SPT Core API

com.sptci.echo
Class Application

java.lang.Object
  extended by nextapp.echo.app.ApplicationInstance
      extended by com.sptci.echo.Application
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
JDOApplication

public class Application
extends ApplicationInstance

A base class that extends ApplicationInstance and can serve as the base class for the application specific global application instance.

© Copyright 2006 Sans Pareil Technologies, Inc.

Version:
$Id: Application.java 4853 2009-08-10 21:10:14Z rakesh $
Author:
Rakesh Vidyadharan 2006-11-23
See Also:
Serialized Form

Field Summary
protected  String contentPane
          The fully qualified name of the ContentPane class that will be set as the content of window.
protected  String dataDirectory
          The root directory under which persistent state is stored.
protected static Logger logger
          The logger to use to log errors/messages to.
static int MINIMUM_INTERVAL
          The minimum interval at which tasks will be enqueued.
protected  int pollingInterval
          The polling interval as which any tasks in updateTasks will be executed.
protected  Principal principal
          The object that represents the name of the currently authenticated user.
protected  Map<String,Object> properties
          A map to store arbitrary properties in the application session scope.
protected static Map<String,TimeZone> TIME_ZONES
          A map that is used to store the time offsets from UTC and their corresponding time zone short names.
protected  TimeZone timeZone
          The time zone for the client browser.
protected  User user
          The value object that represents the user currently logged on to the application.
protected  Window window
          The Window instance that will be controlled by this application.
 
Fields inherited from class nextapp.echo.app.ApplicationInstance
FOCUSED_COMPONENT_CHANGED_PROPERTY, ID_STRING, LOCALE_CHANGED_PROPERTY, MODAL_COMPONENTS_CHANGED_PROPERTY, STYLE_SHEET_CHANGED_PROPERTY, WINDOWS_CHANGED_PROPERTY
 
Constructor Summary
Application()
          Default constructor.
 
Method Summary
 void addPane(FloatingPane pane)
          Add the specified FloatingPane to the ContentPane of window with an appropriate z-index.
protected  void addTask(Controller.Updater updater, Runnable runnable)
          Add the specified updater task to the task queue.
static Application getApplication()
          Convenience method to return the active application as a properly typed object.
 ContentPane getContentPane()
          Convenience method that returns the ContentPane for window.
 String getDataDirectory()
          Returns dataDirectory.
 Locale[] getLocales()
          Return the Locales specified by the client browser for the current session.
static Logger getLogger()
          Return the logger used by the application.
static String getOffset(int offset)
          Parse the specified offset from UTC in milliseconds and return it in HHmm format.
static View getParentView(Component component)
          Return the view component that is the parent of the specified component.
 Principal getPrincipal()
          Returns principal.
 Object getProperty(String key)
          Fetches the property associated with the key from the application session scope.
 TimeZone getTimeZone()
          Return the timezone of the client browser.
 User getUser()
          Returns user.
 Window getWindow()
          Returns window.
protected  int getZIndex()
          Get the z-index value to use for the next FloatingPane component to be added.
 boolean hasQueuedTasks()
          Over-ridden to enqueue each task in updateTasks.
 Window init()
          The mandatory initialisation method.
 void processFatalException(String message, Throwable t)
          A global handler for exceptions encountered while updating the display.
 void processFatalException(Throwable t)
          A global handler for exceptions encountered while updating the display.
 void removePane(FloatingPane pane)
          Remove the specified FloatingPane from the ContentPane of window.
protected  void removeTask(Controller.Updater updater)
          Remove the specified updater task from the task queue.
 void setContentPane(String contentPane)
          Sets the values of contentPane to the fully qualified name of the ContentPane class.
 void setDataDirectory(String dataDirectory)
          Set dataDirectory.
 void setPrincipal(Principal principal)
          Set principal.
 void setProperty(String key, Object value)
          Add a new property to the application session scope.
 void setUser(User user)
          Set user.
protected  void updatePollingInterval()
          Update pollingInterval to the maximum value in the intervals for all the tasks that are queued.
 
Methods inherited from class nextapp.echo.app.ApplicationInstance
activate, addPropertyChangeListener, createTaskQueue, dispose, doInit, doValidation, enqueueCommand, enqueueTask, firePropertyChange, generateId, generateSystemId, getActive, getComponentByRenderId, getContextProperty, getDefaultWindow, getFocusedComponent, getLayoutDirection, getLocale, getModalContextRoot, getStyle, getStyleSheet, getUpdateManager, hasTaskQueues, passivate, processInput, processQueuedTasks, removePropertyChangeListener, removeTaskQueue, setActive, setContextProperty, setFocusedComponent, setLocale, setStyleSheet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final Logger logger
The logger to use to log errors/messages to.


MINIMUM_INTERVAL

public static final int MINIMUM_INTERVAL
The minimum interval at which tasks will be enqueued.

See Also:
Constant Field Values

TIME_ZONES

protected static final Map<String,TimeZone> TIME_ZONES
A map that is used to store the time offsets from UTC and their corresponding time zone short names.


pollingInterval

protected int pollingInterval
The polling interval as which any tasks in updateTasks will be executed.


timeZone

protected TimeZone timeZone
The time zone for the client browser.


window

protected Window window
The Window instance that will be controlled by this application.


contentPane

protected String contentPane
The fully qualified name of the ContentPane class that will be set as the content of window.


dataDirectory

protected String dataDirectory
The root directory under which persistent state is stored.


user

protected User user
The value object that represents the user currently logged on to the application.


principal

protected transient Principal principal
The object that represents the name of the currently authenticated user. This is available for container managed authentication.


properties

protected final transient Map<String,Object> properties
A map to store arbitrary properties in the application session scope. This should make it unnecessary to sub-class this instance for most applications.

Constructor Detail

Application

public Application()
Default constructor. Sets the UpdateManager for this application.

Method Detail

getApplication

public static Application getApplication()
Convenience method to return the active application as a properly typed object.

Returns:
The currently active Application instance.

init

public Window init()
The mandatory initialisation method. Initialises window and returns it.

Specified by:
init in class ApplicationInstance
Returns:
Window The properly initialised window.
See Also:
ApplicationInstance.setStyleSheet(nextapp.echo.app.StyleSheet), Window.setContent(nextapp.echo.app.ContentPane)

processFatalException

public void processFatalException(Throwable t)
A global handler for exceptions encountered while updating the display.

Parameters:
t - The fatal exception

processFatalException

public void processFatalException(String message,
                                  Throwable t)
A global handler for exceptions encountered while updating the display.

Parameters:
message - The message to display regarding the error condition.
t - The fatal exception

getWindow

public Window getWindow()
Returns window.

Returns:
Window The value/reference of/to window.

addPane

public void addPane(FloatingPane pane)
Add the specified FloatingPane to the ContentPane of window with an appropriate z-index.

Parameters:
pane - The window pane that is to be added.
See Also:
getZIndex()

removePane

public void removePane(FloatingPane pane)
Remove the specified FloatingPane from the ContentPane of window.

Parameters:
pane - The pane window pane that is to be removed.

getZIndex

protected int getZIndex()
Get the z-index value to use for the next FloatingPane component to be added.

Returns:
The next higher z-index value to use.

addTask

protected void addTask(Controller.Updater updater,
                       Runnable runnable)
Add the specified updater task to the task queue.

Parameters:
updater - The updater task to run.
runnable - The runnable instance to queue the task.

removeTask

protected void removeTask(Controller.Updater updater)
Remove the specified updater task from the task queue.

Parameters:
updater - The task that is to be removed from the queue.

updatePollingInterval

protected void updatePollingInterval()
Update pollingInterval to the maximum value in the intervals for all the tasks that are queued.


hasQueuedTasks

public boolean hasQueuedTasks()
Over-ridden to enqueue each task in updateTasks.

Overrides:
hasQueuedTasks in class ApplicationInstance
Returns:
Return true if there are queued tasks.

getLocales

public Locale[] getLocales()
Return the Locales specified by the client browser for the current session. The getLocale method inherited from ApplicationInstance returns only the locale of the server.

Returns:
The locales specified by the client browser.

getTimeZone

public TimeZone getTimeZone()
Return the timezone of the client browser. Initialises timeZone lazily.

Returns:
The timezone of the client browser.

getOffset

public static String getOffset(int offset)
Parse the specified offset from UTC in milliseconds and return it in HHmm format. This is used to lookup TimeZone instances.

Parameters:
offset - The offset from UTC in milliseconds.
Returns:
The string representation in proper format.

getParentView

public static View getParentView(Component component)
Return the view component that is the parent of the specified component.

Parameters:
component - The component whose parent view is to be returned.
Returns:
The parent view or null if no parent that is an instance of view exists.

setProperty

public void setProperty(String key,
                        Object value)
Add a new property to the application session scope.

Parameters:
key - The key used to identify the property.
value - The value of the property.

getProperty

public Object getProperty(String key)
Fetches the property associated with the key from the application session scope.

Parameters:
key - The key assigned to the property.
Returns:
The value assigned to the property. Returns null if no value has been assigned to the specified key.

getContentPane

public ContentPane getContentPane()
Convenience method that returns the ContentPane for window.

Returns:
The fully qualified name of the content pane.
See Also:
Window.getContent()

setContentPane

public void setContentPane(String contentPane)
Sets the values of contentPane to the fully qualified name of the ContentPane class.

Parameters:
contentPane - The value to set.

getDataDirectory

public String getDataDirectory()
Returns dataDirectory.

Returns:
The value/reference of/to dataDirectory.

setDataDirectory

public void setDataDirectory(String dataDirectory)
Set dataDirectory.

Parameters:
dataDirectory - The value to set.

getUser

public User getUser()
Returns user.

Returns:
The value/reference of/to user.

setUser

public void setUser(User user)
Set user.

Parameters:
user - The value to set.

getPrincipal

public Principal getPrincipal()
Returns principal.

Returns:
The value/reference of/to principal.

setPrincipal

public void setPrincipal(Principal principal)
Set principal.

Parameters:
principal - The value to set.

getLogger

public static Logger getLogger()
Return the logger used by the application.

Returns:
Returns logger.

SPT Core API