NextApp Echo
1.1.4

nextapp.echo
Class EchoInstance

java.lang.Object
  extended bynextapp.echo.EchoInstance
All Implemented Interfaces:
java.io.Serializable

public abstract class EchoInstance
extends java.lang.Object
implements java.io.Serializable

A single user-instance of an Echo application.

See Also:
Serialized Form

Field Summary
private static java.lang.ThreadLocal activeInstance
          Holds a thread local reference to the active EchoInstance for easy retrieval.
private  java.util.Map attributes
          An mutable map of application attributes.
static Color DEFAULT_BACKGROUND
          The default background color (white)
static Font DEFAULT_FONT
          The default font (10 point sans-serif)
static Color DEFAULT_FOREGROUND
          The default foreground color (black)
static int DEFAULT_WINDOW_HEIGHT
          The default window height (100 pixels).
static int DEFAULT_WINDOW_WIDTH
          The default window width (100 pixels).
static java.lang.String FOCUSED_COMPONENT_CHANGED_PROPERTY
           
private  java.lang.ref.WeakReference focusedComponent
          The presently focused component.
static java.lang.String ID_STRING
          The name and version of the Echo API in use.
private  java.util.Locale locale
          The default locale of the application.
static java.lang.String LOCALE_CHANGED_PROPERTY
           
private  java.beans.PropertyChangeSupport propertyChangeSupport
          Fires property change events for the instance object.
private  java.util.Set windows
          The set of all windows registered with the application.
static java.lang.String WINDOWS_CHANGED_PROPERTY
           
 
Constructor Summary
EchoInstance()
          Creates a new instance of this Echo application.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Adds a property change listener to this instance.
 void addWindow(Window w)
          Adds a new window to the application, causing it to then be displayed.
 void doExit()
          Invoked by the application container when the application instance is to be destroyed.
 Window doInit()
          Invoked by the application container to initialize the application.
 void doValidation()
          Validates all components in all windows registered with the application.
private  void doValidation(Component c)
          Validates a single component and then recursively validates its children.
 void exit()
          Notifies the application that it has reached the end of its life, and should clean up any resources if required.
 java.lang.Object getAttribute(java.lang.String key)
          Returns the value of an attribute.
static EchoInstance getEchoInstance()
          Returns a reference to the EchoInstance that is relevant to the current thread.
 Component getFocusedComponent()
          Returns the presently focused component, if known.
 java.util.Locale getLocale()
          Returns the application instance's default locale.
 Window[] getWindows()
          Returns an array of all windows registered with the application instance.
protected abstract  Window init()
          Invoked to initialize the application, returning the primary window.
 void markActive(boolean active)
          Marks this EchoInstance as active or inactive for the current thread.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Removes a property change listener from this instance.
 void removeWindow(Window w)
          Removes a window from the application, causing it to then be closed.
 void setAttribute(java.lang.String key, java.lang.Object value)
          Sets an attribute value.
 void setFocusedComponent(Component newValue)
          Sets the presently focused component.
 void setLocale(java.util.Locale newValue)
          Sets the application instance's default locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activeInstance

private static final java.lang.ThreadLocal activeInstance
Holds a thread local reference to the active EchoInstance for easy retrieval.


DEFAULT_BACKGROUND

public static final Color DEFAULT_BACKGROUND
The default background color (white)


DEFAULT_FONT

public static final Font DEFAULT_FONT
The default font (10 point sans-serif)


DEFAULT_FOREGROUND

public static final Color DEFAULT_FOREGROUND
The default foreground color (black)


DEFAULT_WINDOW_HEIGHT

public static final int DEFAULT_WINDOW_HEIGHT
The default window height (100 pixels).

See Also:
Constant Field Values

DEFAULT_WINDOW_WIDTH

public static final int DEFAULT_WINDOW_WIDTH
The default window width (100 pixels).

See Also:
Constant Field Values

ID_STRING

public static final java.lang.String ID_STRING
The name and version of the Echo API in use.

See Also:
Constant Field Values

FOCUSED_COMPONENT_CHANGED_PROPERTY

public static final java.lang.String FOCUSED_COMPONENT_CHANGED_PROPERTY
See Also:
Constant Field Values

LOCALE_CHANGED_PROPERTY

public static final java.lang.String LOCALE_CHANGED_PROPERTY
See Also:
Constant Field Values

WINDOWS_CHANGED_PROPERTY

public static final java.lang.String WINDOWS_CHANGED_PROPERTY
See Also:
Constant Field Values

attributes

private java.util.Map attributes
An mutable map of application attributes.


windows

private java.util.Set windows
The set of all windows registered with the application.


propertyChangeSupport

private java.beans.PropertyChangeSupport propertyChangeSupport
Fires property change events for the instance object.


locale

private java.util.Locale locale
The default locale of the application.


focusedComponent

private java.lang.ref.WeakReference focusedComponent
The presently focused component.

Constructor Detail

EchoInstance

public EchoInstance()
Creates a new instance of this Echo application.

Method Detail

getEchoInstance

public static final EchoInstance getEchoInstance()
Returns a reference to the EchoInstance that is relevant to the current thread.

Returns:
The relevant EchoInstance.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a property change listener to this instance.

Parameters:
l - The listener to be added.

addWindow

public void addWindow(Window w)
Adds a new window to the application, causing it to then be displayed. If the window is already registered with the application (i.e. it was previously added and not removed), then this method has no effects.

Parameters:
w - A new window to be added to the application and displayed.

doExit

public final void doExit()
Invoked by the application container when the application instance is to be destroyed.


doInit

public final Window doInit()
Invoked by the application container to initialize the application. Returns the first window of the application.

Returns:
The first window of the application.

doValidation

public final void doValidation()
Validates all components in all windows registered with the application.


doValidation

private void doValidation(Component c)
Validates a single component and then recursively validates its children.

Parameters:
c - The component to be validated.

exit

public void exit()
Notifies the application that it has reached the end of its life, and should clean up any resources if required. This method should be overridden by applications that require end-of-life resource clean-up.


getAttribute

public java.lang.Object getAttribute(java.lang.String key)
Returns the value of an attribute.

Parameters:
key - The key (name) of the attribute.
Returns:
Object The value of the attribute represented by the provided key.

getFocusedComponent

public Component getFocusedComponent()
Returns the presently focused component, if known.

Returns:
The presently focused component, if known.

getLocale

public java.util.Locale getLocale()
Returns the application instance's default locale.

Returns:
The application instance's default locale.

getWindows

public Window[] getWindows()
Returns an array of all windows registered with the application instance.

Returns:
An array of all windows registered with the application instance.

init

protected abstract Window init()
Invoked to initialize the application, returning the primary window. The returned window must be visible.

Returns:
The primary window of the application.

markActive

public void markActive(boolean active)
Marks this EchoInstance as active or inactive for the current thread.

Parameters:
active - True if the EchoInstance should be marked active for the current thread, false if it should be marked inactive.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a property change listener from this instance.

Parameters:
l - The listener to be removed.

removeWindow

public void removeWindow(Window w)
Removes a window from the application, causing it to then be closed. If the window is not registered with the application (e.g. if it was disposed earlier or never added), then this method has no effects.

Parameters:
w - A window that was previously added to the application that now should be removed and closed.

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object value)
Sets an attribute value. Your application should rarely (if ever) call this method. Attributes should NOT be used to hold application data.

Parameters:
key - The key (name) of the attribute.
value - The new value of the attribute.

setFocusedComponent

public void setFocusedComponent(Component newValue)
Sets the presently focused component.

Parameters:
newValue - The component to be focused.

setLocale

public void setLocale(java.util.Locale newValue)
Sets the application instance's default locale. The locale will be automatically set based on information from the client during initialization if the application has not yet set it.

Parameters:
newValue - The new default locale.

NextApp Echo
1.1.4