com.yospace.yae.pm
Class Panelet

java.lang.Object
  |
  +--com.yospace.yae.pm.Panelet
All Implemented Interfaces:
ActionListener

public class Panelet
extends java.lang.Object
implements ActionListener

Panelet holds model information such as state and name, and also holds a reference to the Panelet's view. By using getPaneletContext(), requests can be made to the Panelet management system for state changes etc.


Field Summary
static int STATE_COMPACT
          The constant to define the compact state for a Panelet.
static int STATE_MAXIMIZED
          The constant to define the maximized state for a Panelet.
static int STATE_MINIMIZED
          The constant to define the minimized state for a Panelet.
static int STATE_UNDEFINED
          The constant to define the undefined state for a Panelet.
 
Constructor Summary
Panelet()
          Sets the current and old states to be STATE_UNDEFINED.
 
Method Summary
 void actionPerformed(YogiComponent source)
          Listens for state change button presses such as when a Panelet display's minimize button is pressed.
 void destroy()
          Empty template method for permanently freeing up resources when the Panelet management system decides to kill this Panelet.
 java.lang.String getName()
          Accessor method for the Panelet's current name.
 int getOldState()
          Accessor method for the Panelet's old state.
 PaneletContext getPaneletContext()
          Accessor method for the Panelet's Context object.
 YogiPaneletDisplay getPaneletDisplay()
          Accessor method for the Panelet Display.
 YogiPaneletDisplay getPaneletDisplay(int state)
          Accessor method for the Panelet Display registered for the given state.
 java.lang.String getPaneletInfo()
          Accessor method for the Panelet's info String.
 int getState()
          Accessor method for the Panelet's current state.
 java.lang.String getStringResource(java.lang.String name)
          Gets the string resource for the given name.
static java.lang.String getStringResource(YogiComponent source, java.lang.String resourceId)
          Where a reference to the Panelet is not available, this method can be used.
 java.util.Hashtable getStringResources()
          Gets the Hashtable of string resources associated with this Panelet.
 YogiComponent getTopLevelComponent(java.lang.String id)
          Gets a top level component from the those generated by the UI builder.
 java.lang.String[] getTopLevelComponentIds()
          Gets the ids of all of the top level components (which do not include YogiPaneletDisplays here).
 void init(java.lang.String name, java.util.Hashtable topLevelObjects)
          Initialises a Panelet.
protected  void modifyState(int newState)
          Change the current state value for this Panelet.
 void notifyDestroyed()
          Called by application code to signify to the Panelet Manager that this Panelet should be removed.
 void pause()
          Empty template method for freeing up resources when the Panelet management system goes to sleep.
 void setName(java.lang.String name)
          Setter method for the Panelet's name.
static void setPaneletManager(PaneletManager pm, YogiRootWindow key)
          Initialises Panelets to all have the given Panelet manager.
 void setState(int newState)
          Sets the current state of the Panelet.
 void setStringResources(java.util.Hashtable stringResources)
          Sets the Hashtable of string resources associated with this Panelet.
 void start()
          Empty template method, called after creation of a Panelet just as it is about to be displayed.
 java.lang.String toString()
          Returns a String of the form "["Panelet name" - "state]".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATE_UNDEFINED

public static final int STATE_UNDEFINED
The constant to define the undefined state for a Panelet.

STATE_MINIMIZED

public static final int STATE_MINIMIZED
The constant to define the minimized state for a Panelet.

STATE_COMPACT

public static final int STATE_COMPACT
The constant to define the compact state for a Panelet.

STATE_MAXIMIZED

public static final int STATE_MAXIMIZED
The constant to define the maximized state for a Panelet.
Constructor Detail

Panelet

public Panelet()
Sets the current and old states to be STATE_UNDEFINED.
Method Detail

init

public void init(java.lang.String name,
                 java.util.Hashtable topLevelObjects)
Initialises a Panelet. Called once the UI has been built, so that the list of top level components and panelet displays can be generated before start is called.
Parameters:
name - the name of the Panelet (the name that is used in the panelet config file).
topLevelObjects - the top level components built from the Panelet XML.

setPaneletManager

public static void setPaneletManager(PaneletManager pm,
                                     YogiRootWindow key)
Initialises Panelets to all have the given Panelet manager. Note that this is only possible if the key Object (a YogiRootWindow) is non-null.
Parameters:
pm - the PaneletManager to use.
key - the YogiRootWindow key.

getPaneletDisplay

public YogiPaneletDisplay getPaneletDisplay()
Accessor method for the Panelet Display.
Returns:
the current Panelet Display.

getPaneletDisplay

public YogiPaneletDisplay getPaneletDisplay(int state)
Accessor method for the Panelet Display registered for the given state.
Parameters:
state - the Panelet state to get the Panelet Display for.
Returns:
the relevant panelet display, or null if one has not bee registered.

setState

public void setState(int newState)
Sets the current state of the Panelet. Delegates this to the Panelet Manager so that it is the Panelet Manager's responsibility to decide whether such a state change should be allowed.
Parameters:
newState - the state to change into, if allowed.

modifyState

protected void modifyState(int newState)
Change the current state value for this Panelet. This method is called by the Panelet Manager when it has decided that a requested state change is allowed.
Parameters:
newState - the new state of the Panelet.

getState

public int getState()
Accessor method for the Panelet's current state.
Returns:
the current state of the Panelet.

getOldState

public int getOldState()
Accessor method for the Panelet's old state.
Returns:
the previous state of the Panelet. STATE_UNDEFINED is used where there was no previous state.

setName

public void setName(java.lang.String name)
Setter method for the Panelet's name.
Parameters:
name - the name to use.

getName

public java.lang.String getName()
Accessor method for the Panelet's current name.
Returns:
the current name, or the String "(no name)" if the name is currently null.

getPaneletContext

public PaneletContext getPaneletContext()
Accessor method for the Panelet's Context object.
Returns:
the Panelet's Context object.
Throws:
java.lang.IllegalArgumentException - currently always thrown as this method has yet to be implemented.

start

public void start()
           throws java.lang.Exception
Empty template method, called after creation of a Panelet just as it is about to be displayed. This method will also be called after a pause(), so should be used to start/restart any resources that were freed up on pause.


pause

public void pause()
Empty template method for freeing up resources when the Panelet management system goes to sleep. These resources should be grabbed again on start().

destroy

public void destroy()
Empty template method for permanently freeing up resources when the Panelet management system decides to kill this Panelet.

notifyDestroyed

public void notifyDestroyed()
Called by application code to signify to the Panelet Manager that this Panelet should be removed.
Throws:
IllegalStateException - if this Panelet has no Panelet Manager.

getPaneletInfo

public java.lang.String getPaneletInfo()
Accessor method for the Panelet's info String. Does the same as a call to toString().
Returns:
a String holding the Panelet name and the Panelet's state.

toString

public java.lang.String toString()
Returns a String of the form "["Panelet name" - "state]".
Overrides:
toString in class java.lang.Object
Returns:
a String holding the Panelet name and the Panelet's state.

getTopLevelComponent

public YogiComponent getTopLevelComponent(java.lang.String id)
Gets a top level component from the those generated by the UI builder.
Parameters:
id - the id of the top level component to be fetched.

getTopLevelComponentIds

public java.lang.String[] getTopLevelComponentIds()
Gets the ids of all of the top level components (which do not include YogiPaneletDisplays here).
Returns:
all the ids from the object store.

setStringResources

public void setStringResources(java.util.Hashtable stringResources)
Sets the Hashtable of string resources associated with this Panelet.
Parameters:
stringResources - the string resources Hashtable.

getStringResource

public java.lang.String getStringResource(java.lang.String name)
Gets the string resource for the given name.
Parameters:
name - the string resource id to get.
Returns:
the relevant String resource.

getStringResource

public static java.lang.String getStringResource(YogiComponent source,
                                                 java.lang.String resourceId)
Where a reference to the Panelet is not available, this method can be used. For the given source component, it will try to identify the associated Panelet and then get the requested String resource from that Panelet.
Parameters:
source - the component associated with the relevant Panelet.
resourceId - the resource String to fetch.
Returns:
the String resource found.

getStringResources

public java.util.Hashtable getStringResources()
Gets the Hashtable of string resources associated with this Panelet.
Returns:
the String resources.

actionPerformed

public void actionPerformed(YogiComponent source)
Listens for state change button presses such as when a Panelet display's minimize button is pressed.
Specified by:
actionPerformed in interface ActionListener
Parameters:
source - the source button.

Copyright 2002 Yospace Holdings Ltd. All Rights Reserved.