org.esa.beam.framework.ui.command
Class DefaultCommandManager

java.lang.Object
  extended by org.esa.beam.framework.ui.command.DefaultCommandManager
All Implemented Interfaces:
CommandManager

public class DefaultCommandManager
extends Object
implements CommandManager

The DefaultCommandManager provides a default implementation for the CommandManager interface.

It also provides a simple mechanism to configure Command items with the key/value pairs stored in a resource bundle.

Version:
$Revision$ $Date$
Author:
Sabine Embacher, Norman Fomferra
See Also:
Command, ResourceBundle

Constructor Summary
DefaultCommandManager()
           
 
Method Summary
 void addCommand(Command command)
          Adds a new command to this command manager.
 CommandGroup createCommandGroup(String commandGroupID, CommandStateListener listener)
          Creates a new command group command for the given unique command ID an the given command state listener.
 ExecCommand createExecCommand(String commandID, CommandListener listener)
          Creates a new executable command for the given unique command ID and the given command listener.
 ToolCommand createToolCommand(String commandID, CommandStateListener listener, com.bc.ceres.swing.figure.Interactor tool)
          Creates a new tool command for the given unique command ID an the given tool.
 Command getCommand(String commandID)
          Gets the command associated with the given command-COMMAND_ID or null if a command with the given command-ID has not been registered (so far).
 Command getCommandAt(int index)
          Returns the element at the specified position in this DefaultCommandManager.
 CommandGroup getCommandGroup(String commandID)
          Gets the command group associated with the given command-ID or null if an command group with the given command-ID has not been registered.
 ExecCommand getExecCommand(String commandID)
          Gets the command associated with the given command-ID or null if an command with the given command-ID has not been registered.
 int getNumCommands()
          Returns the number of commands in this DefaultCommandManager.
 ToolCommand getToolCommand(String commandID)
          Gets the tool command associated with the given command-ID or null if a tool command with the given command-ID has not been registered.
 void removeCommand(Command command)
          Removes an existing command from this command manager.
 void updateComponentTreeUI()
          Updates the component tree of all commands since the Java look-and-feel has changed.
 void updateState()
          Calls the updateState method of all registered commands.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultCommandManager

public DefaultCommandManager()
Method Detail

createExecCommand

public ExecCommand createExecCommand(String commandID,
                                     CommandListener listener)
Creates a new executable command for the given unique command ID and the given command listener. Finally the created command is added to internal list of registered commands.

Specified by:
createExecCommand in interface CommandManager
Parameters:
commandID - a unique command ID
listener - the command listener which executes the command and updates its state
Returns:
a new executable command
See Also:
createToolCommand(java.lang.String, org.esa.beam.framework.ui.command.CommandStateListener, com.bc.ceres.swing.figure.Interactor), createCommandGroup(java.lang.String, org.esa.beam.framework.ui.command.CommandStateListener), addCommand(Command)

createToolCommand

public ToolCommand createToolCommand(String commandID,
                                     CommandStateListener listener,
                                     com.bc.ceres.swing.figure.Interactor tool)
Creates a new tool command for the given unique command ID an the given tool. Finally the created command is added to internal list of registered commands.

Specified by:
createToolCommand in interface CommandManager
Parameters:
commandID - a unique command ID
listener - the command state listener used to update the tool command's state
tool - the tool which executes the command and updates its state
Returns:
a new tool command
See Also:
createExecCommand(java.lang.String, org.esa.beam.framework.ui.command.CommandListener), createCommandGroup(java.lang.String, org.esa.beam.framework.ui.command.CommandStateListener), addCommand(Command)

createCommandGroup

public CommandGroup createCommandGroup(String commandGroupID,
                                       CommandStateListener listener)
Creates a new command group command for the given unique command ID an the given command state listener. Finally the created command group is added to internal list of registered commands.

Specified by:
createCommandGroup in interface CommandManager
Parameters:
commandGroupID - a unique command group ID
listener - the command state listener used to update the command group state
Returns:
a new command group
See Also:
createExecCommand(java.lang.String, org.esa.beam.framework.ui.command.CommandListener), createToolCommand(java.lang.String, org.esa.beam.framework.ui.command.CommandStateListener, com.bc.ceres.swing.figure.Interactor), addCommand(Command)

getNumCommands

public int getNumCommands()
Returns the number of commands in this DefaultCommandManager. If this manager contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE :-)

Specified by:
getNumCommands in interface CommandManager
Returns:
the number of commands in this DefaultCommandManager.

getCommandAt

public Command getCommandAt(int index)
Returns the element at the specified position in this DefaultCommandManager.

Specified by:
getCommandAt in interface CommandManager
Parameters:
index - index of command to return.
Returns:
the Command at the specified position in this DefaultCommandManager.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= getNumCommands()).

getCommand

public Command getCommand(String commandID)
Gets the command associated with the given command-COMMAND_ID or null if a command with the given command-ID has not been registered (so far).

Specified by:
getCommand in interface CommandManager

getExecCommand

public ExecCommand getExecCommand(String commandID)
Gets the command associated with the given command-ID or null if an command with the given command-ID has not been registered.

Specified by:
getExecCommand in interface CommandManager

getToolCommand

public ToolCommand getToolCommand(String commandID)
Gets the tool command associated with the given command-ID or null if a tool command with the given command-ID has not been registered.

Specified by:
getToolCommand in interface CommandManager

getCommandGroup

public CommandGroup getCommandGroup(String commandID)
Gets the command group associated with the given command-ID or null if an command group with the given command-ID has not been registered.

Specified by:
getCommandGroup in interface CommandManager

updateState

public void updateState()
Calls the updateState method of all registered commands.

Specified by:
updateState in interface CommandManager

updateComponentTreeUI

public void updateComponentTreeUI()
Updates the component tree of all commands since the Java look-and-feel has changed.

Specified by:
updateComponentTreeUI in interface CommandManager

addCommand

public void addCommand(Command command)
Adds a new command to this command manager.

Specified by:
addCommand in interface CommandManager
Parameters:
command - the command to be added
Throws:
IllegalArgumentException - if the command ID property of the command has not been set, or if an command with the same command ID has alreay been registered

removeCommand

public void removeCommand(Command command)
Removes an existing command from this command manager.

Specified by:
removeCommand in interface CommandManager
Parameters:
command - the command to be removed


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.