org.scopemvc.controller.basic
Class ViewContext

java.lang.Object
  |
  +--org.scopemvc.controller.basic.ViewContext
Direct Known Subclasses:
ServletContext, SwingContext

public abstract class ViewContext
extends java.lang.Object

ViewContext handles show/hide of views, errors and has some concept of the application's context. eg a Swing implementation would show views inside JFrames or JDialogs and show errors using JOptionPanes. A servlet implementation would know about the HTTP response and push views into its stream.

There's a place in here to store properties per context. This is used in the servlet implementation to maintain state over a single request.

Several static methods are used to set the context for an application either on a global basis (eg Swing) or per-thread (eg servlet): see getViewContext() etc.

Version:
$Revision: 1.12 $ $Date: 2002/09/11 19:15:55 $
Author:
Steve Meyfroidt

Constructor Summary
ViewContext()
           
 
Method Summary
 void addProperty(java.lang.String inKey, java.lang.Object inObject)
          Store an arbitrary object under a known key.
 void clearProperties()
          Clear all properties from this context.
static void clearThreadContext()
          Clear the ViewContext for the current thread.
abstract  void exit()
          Exit the application
 java.lang.Object getProperty(java.lang.String inKey)
          Fetch an arbitrary object under a known key.
static ViewContext getViewContext()
          Return the current ViewContext.
abstract  void hideView(View inView)
          Hide the view
 java.lang.Object removeProperty(java.lang.String inKey)
          Fetch and remove an arbitrary object under a known key.
static void setGlobalContext(ViewContext inContext)
          Set the global ViewContext.
static void setThreadContext(ViewContext inContext)
          Set a ViewContext for the current thread.
abstract  void showError(java.lang.String inErrorTitle, java.lang.String inErrorMessage)
          Show an error message.
abstract  void showView(View inView)
          Show the view
abstract  void startProgress()
          Start a progress indicator for long operations.
abstract  void stopProgress()
          Stop the progress indicator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewContext

public ViewContext()
Method Detail

getViewContext

public static ViewContext getViewContext()
Return the current ViewContext. First try the per-thread context and if none, returns the global context. May return null if no context is set.

Returns:
The viewContext value

setGlobalContext

public static void setGlobalContext(ViewContext inContext)
Set the global ViewContext.

Parameters:
inContext - The new globalContext value

setThreadContext

public static void setThreadContext(ViewContext inContext)
Set a ViewContext for the current thread.

Parameters:
inContext - The new threadContext value

clearThreadContext

public static void clearThreadContext()
Clear the ViewContext for the current thread.


getProperty

public java.lang.Object getProperty(java.lang.String inKey)
Fetch an arbitrary object under a known key.

Parameters:
inKey - The property key
Returns:
The property value

showView

public abstract void showView(View inView)
Show the view

Parameters:
inView - The view to show

hideView

public abstract void hideView(View inView)
Hide the view

Parameters:
inView - The view to hide

showError

public abstract void showError(java.lang.String inErrorTitle,
                               java.lang.String inErrorMessage)
Show an error message.

Parameters:
inErrorTitle - The title for the error message
inErrorMessage - The error message

exit

public abstract void exit()
Exit the application


startProgress

public abstract void startProgress()
Start a progress indicator for long operations.


stopProgress

public abstract void stopProgress()
Stop the progress indicator.


addProperty

public void addProperty(java.lang.String inKey,
                        java.lang.Object inObject)
Store an arbitrary object under a known key.

Parameters:
inKey - The element to be added to the Property attribute
inObject - The element to be added to the Property attribute

removeProperty

public java.lang.Object removeProperty(java.lang.String inKey)
Fetch and remove an arbitrary object under a known key.

Parameters:
inKey - The property key
Returns:
The removed value, or null if the key was not defined

clearProperties

public void clearProperties()
Clear all properties from this context.



Copyright © 2000-2002 The Scope Team. All Rights Reserved.