stella.jview
Class JLaunchBox

java.lang.Object
  extended by util.PropertyContainer
      extended by util.rmi.RmiPropertyContainer
          extended by util.rmi.AbstractRmiListener
              extended by stella.jview.JLaunchBox
All Implemented Interfaces:
ActionListener, Cloneable, Remote, EventListener, Displayable, RmiAcknowledgeListener, RmiDoneListener, RmiErrorListener, ExitCleaning, Initializable, PropertyBearing, RmiEventListener, RmiListener, RmiPropertyBearing

public class JLaunchBox
extends AbstractRmiListener
implements RmiAcknowledgeListener, RmiDoneListener, RmiErrorListener, Initializable, Displayable, ActionListener

The generic class to allow GUI-driven command-sending. This class can be used to directly send commands to a single command server. The receiving edge (the command server) must be up and running, otherwise construction will fail.

Note that this class uses the CommandLaunching rmi-command casting ability, regardless wether the underlying launcher is a true rmi-implementation or a socket-based workaround. Additionally, to allow proper functionality of this class as a done, acknowledge, and error listener, it depends on rmi-based event delivery. In the rmi-regime this is directly achieved by registering to the remote command servers. In the socket world this again requires binding to the command launching instance.

On startup this class uses its properties to establish the following thing:

It then brings up a window with all JDisplayableCommand components layed out in grid-bag fashion. Pressing the appropriate OK button assigned to the JDisplayableCommands sends the command to the command server.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyContainer
PropertyContainer.URLResource
 
Field Summary
private static int DEFCOLUMN
          The default number of display columns (1).
private static boolean DEFLOGFLAG
          The default syslog-to-status behaviour.
static String KEY_ACKNOWLEDGE
          The key to the rmi-acknowledge caster to bind to, resolvable URL.
static String KEY_COLUMN
          The key denoting the number of colums to display.
static String KEY_COMMAND
          The key to the command launcher, properties file.
static String KEY_DONE
          The key to the rmi-done caster to bind to, resolvable URL.
static String KEY_ERROR
          The key to the rmi-error caster to bind to, resolvable URL.
static String KEY_FILE
          The key to a file containing a (long) list of all jcommands.
static String KEY_LIST
          The key to the jcommand list.
static String KEY_LOGFLAG
          If true, syslog messages are also passed to the status field.
static String KEY_TITLE
          The key to this launch box title.
private  CommandLaunching launch
          The command launcher.
private  JStatusPanel status
          The status panel.
private  List<JDisplayableCommand> valid
          The list of displayable commands.
 
Fields inherited from class util.rmi.AbstractRmiListener
KEY_ALIVE, KEY_EXPORTPORT, KEY_INIT, KEY_LISTENERNAME, KEY_RETRY, KEY_RETRYSLEEP, KEY_SHUTDOWNDELAY
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR, KEY_NOINITONCREATE, KEY_RESOURCEBUNDLES
 
Fields inherited from interface util.PropertyBearing
CONFIG, KEY_CLASS, KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
JLaunchBox(Map prop)
          Constructs a new launch box.
 
Method Summary
 void actionPerformed(ActionEvent ae)
          Catches the action events from the JDisplayableCommands.
protected  boolean deregisterAtCaster(RmiCaster rmicast, Class service)
          Deregisters at the specified caster if the caster is either an RmiDoneCaster or an RmiAcknowledgeCaster
protected  List getDisplayableCommands()
          Returns the hosted list of displayable commands.
 Icon getIcon()
          Might return an icon, if one was stated in the properties
protected  JPanel getJDisplayablePanel()
          Does the layout for all JDisplayableCommand in the control box.
protected  CommandLaunching getLauncher()
          Returns my command launching instance.
protected  Map<String,String> getLauncherProperties()
          Returns the launcher properties from a file.
 Component getRepresentation()
          Returns a panel where the status panel and the jdisplayables are combined.
protected  JStatusPanel getStatus()
          Returns the status panel for delivering messages to it.
 void init()
          Initialize first the list of command before adding the action listeners to the buttons.
protected  void launchCommand(CommandEvent cmd)
          Launches a specified command through the command caster associated with this launch box.
static void main(String[] arg)
          Launches a command conrtol box.
protected  boolean registerAtCaster(RmiCaster rmicast, Class service)
          Binds to an caster.
 void rmiErrorOccured(ErrorEvent ee)
          The receiving edge of the error listener.
 void rmiGotAcknowledge(AcknowledgeEvent ae)
          The receiving edge of the acknowledge listener.
 void rmiGotDone(DoneEvent de)
          The receiving edge of the done listener.
 void setAllEnabled(boolean isactive)
          Enables or disables all command sending.
 
Methods inherited from class util.rmi.AbstractRmiListener
allBound, blockBinding, blockBinding, disconnect, exit, getIP, getListenerName, isConnected, listenerName, releaseBinding, releaseBinding, rescanned, startBinding, startBinding
 
Methods inherited from class util.rmi.RmiPropertyContainer
containsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemoteProperty
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, clone, createFrom, createFrom, createFrom, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getLocalClassLoader, getLocalized, getLocalized, getLocalizedString, getLocalizedString, getProperties, getPropertiesToKey, getPropertiesToKey, getProperty, getResource, getResourceAsStream, getResourceFromKey, getResources, has, isNew, keyCreate, keyCreate, parseObject, reload, reload, removeProperty, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.rmi.RmiEventListener
getListenerName
 
Methods inherited from interface util.rmi.RmiListener
disconnect, isConnected
 

Field Detail

KEY_COMMAND

public static final String KEY_COMMAND
The key to the command launcher, properties file.

See Also:
Constant Field Values

KEY_ACKNOWLEDGE

public static final String KEY_ACKNOWLEDGE
The key to the rmi-acknowledge caster to bind to, resolvable URL.

See Also:
Constant Field Values

KEY_DONE

public static final String KEY_DONE
The key to the rmi-done caster to bind to, resolvable URL.

See Also:
Constant Field Values

KEY_ERROR

public static final String KEY_ERROR
The key to the rmi-error caster to bind to, resolvable URL.

See Also:
Constant Field Values

KEY_LIST

public static final String KEY_LIST
The key to the jcommand list.

See Also:
Constant Field Values

KEY_FILE

public static final String KEY_FILE
The key to a file containing a (long) list of all jcommands.

See Also:
Constant Field Values

KEY_COLUMN

public static final String KEY_COLUMN
The key denoting the number of colums to display.

See Also:
Constant Field Values

KEY_TITLE

public static final String KEY_TITLE
The key to this launch box title. Should be related to the server.

See Also:
Constant Field Values

KEY_LOGFLAG

public static final String KEY_LOGFLAG
If true, syslog messages are also passed to the status field.

See Also:
Constant Field Values

DEFCOLUMN

private static final int DEFCOLUMN
The default number of display columns (1).

See Also:
Constant Field Values

DEFLOGFLAG

private static final boolean DEFLOGFLAG
The default syslog-to-status behaviour.

See Also:
Constant Field Values

launch

private CommandLaunching launch
The command launcher.


valid

private List<JDisplayableCommand> valid
The list of displayable commands.


status

private JStatusPanel status
The status panel.

Constructor Detail

JLaunchBox

public JLaunchBox(Map prop)
           throws RemoteException
Constructs a new launch box. If the command launcher specified cannot be constructed for any reason the VM exits. Additionally, the properties are scanned for the KEY_ACKNOWLEDGE, KEY_DONE, and KEY_ERROR.

Throws:
RemoteException
Method Detail

init

public void init()
Initialize first the list of command before adding the action listeners to the buttons. Binds the rmi-acknowledge, done and error casters to this launch box. Additionally, registers an action listener to all launch buttons in this box. Whenever a launch button is pressed its appropriate index is searched and the jcommand associated to the button is querried for the full command. This command event is then passed to the command launcher.

Specified by:
init in interface Initializable
Overrides:
init in class PropertyContainer

getLauncherProperties

protected Map<String,String> getLauncherProperties()
Returns the launcher properties from a file.


setAllEnabled

public void setAllEnabled(boolean isactive)
Enables or disables all command sending. Does this by enabling/ disabling all JDisplayableCommands.


rmiGotAcknowledge

public void rmiGotAcknowledge(AcknowledgeEvent ae)
                       throws RemoteException
The receiving edge of the acknowledge listener. Passes the acknowledge message received to the status field.

Specified by:
rmiGotAcknowledge in interface RmiAcknowledgeListener
Throws:
RemoteException

rmiGotDone

public void rmiGotDone(DoneEvent de)
                throws RemoteException
The receiving edge of the done listener. Passes the done message received to the status field.

Specified by:
rmiGotDone in interface RmiDoneListener
Throws:
RemoteException

rmiErrorOccured

public void rmiErrorOccured(ErrorEvent ee)
                     throws RemoteException
The receiving edge of the error listener. Passes the error/status message received to the status field's error channel.

Specified by:
rmiErrorOccured in interface RmiErrorListener
Throws:
RemoteException

getIcon

public Icon getIcon()
Might return an icon, if one was stated in the properties

Specified by:
getIcon in interface Displayable

getRepresentation

public Component getRepresentation()
Returns a panel where the status panel and the jdisplayables are combined.

Specified by:
getRepresentation in interface Displayable

actionPerformed

public void actionPerformed(ActionEvent ae)
Catches the action events from the JDisplayableCommands. The action event command string is used for identifying the issuing JDisplayableCommand. If successful, the JDisplayableCommand.getCommand() is invoked and the returned command event is sent to the command launcher.

Specified by:
actionPerformed in interface ActionListener

registerAtCaster

protected boolean registerAtCaster(RmiCaster rmicast,
                                   Class service)
Binds to an caster. If the argumental RmiCaster is an instance of RmiDoneCaster this done listener registers to it via the RmiDoneCaster.addRmiDoneListener(stella.rmi.RmiDoneListener) method. If the argumental RmiCaster is an instance of RmiAcknowledgeCaster this acknowledge listener registers to it via the RmiAcknowledgeCaster.addRmiAcknowledgeListener(stella.rmi.RmiAcknowledgeListener) method.

If the argument is neither of these two types the method returns silently.

Specified by:
registerAtCaster in class AbstractRmiListener
Returns:
True, if this listener can register at the specified caster
See Also:
deregisterAtCaster(util.rmi.RmiCaster, java.lang.Class)

deregisterAtCaster

protected boolean deregisterAtCaster(RmiCaster rmicast,
                                     Class service)
Deregisters at the specified caster if the caster is either an RmiDoneCaster or an RmiAcknowledgeCaster

Specified by:
deregisterAtCaster in class AbstractRmiListener
Returns:
True, if this listener can deregister at the specified caster
See Also:
registerAtCaster(util.rmi.RmiCaster, java.lang.Class)

getJDisplayablePanel

protected JPanel getJDisplayablePanel()
Does the layout for all JDisplayableCommand in the control box. The returned panel has a grid-bag layout with a number of columns equal to KEY_COLUMN.


getStatus

protected JStatusPanel getStatus()
Returns the status panel for delivering messages to it.


getDisplayableCommands

protected List getDisplayableCommands()
Returns the hosted list of displayable commands.


getLauncher

protected CommandLaunching getLauncher()
Returns my command launching instance.


launchCommand

protected void launchCommand(CommandEvent cmd)
Launches a specified command through the command caster associated with this launch box. If the castre is not ready or doesn't handle the command specified, an error message is passed to the status field.


main

public static void main(String[] arg)
Launches a command conrtol box. The available commands are found in the properties file handed over with the first argument. Other key ingredients are the key to the command launching instance and the rmi-binding names to the error, acknowledge, and done casters that should be served by this control box.