com.sdm.quasar.client.core.commands
Class RunnableCommandManager

java.lang.Object
  extended bycom.sdm.quasar.client.core.commands.RunnableCommandManager
All Implemented Interfaces:
CommandManager
Direct Known Subclasses:
GenericCommandManager

public class RunnableCommandManager
extends java.lang.Object
implements CommandManager

A CommandManager using Runnables for its Commands. The enablement state of the Command must be provided by the user of this class.

Version:
1.0
Author:
Thomas Wolf

Constructor Summary
RunnableCommandManager()
          Creates a new RunnableCommandManager.
 
Method Summary
 Command getCommand(java.lang.String commandId)
          Get a Command from the CommandManager
 boolean hasCommand(java.lang.String commandId)
          Checks, if the CommandManager provides a command with a given id
 void registerCommand(java.lang.String commandId, java.lang.Runnable runnable, BooleanState enabledBooleanState)
          Registers a new command with the given id and parameters to this RunnableCommandManager.
 void setEnabledBooleanState(java.lang.String commandId, BooleanState enabledBooleanState)
          Sets the enabled BooleanState for the command with the given id.
 void unregisterCommand(java.lang.String commandId)
          Unregisters a previously registered command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RunnableCommandManager

public RunnableCommandManager()
Creates a new RunnableCommandManager.

Method Detail

registerCommand

public void registerCommand(java.lang.String commandId,
                            java.lang.Runnable runnable,
                            BooleanState enabledBooleanState)
Registers a new command with the given id and parameters to this RunnableCommandManager.

Parameters:
commandId - the command id for the command (not null)
runnable - the Runnable beeing executed (not null)
enabledBooleanState - an enabled state (may be null; this means the command is always enabled)
Throws:
java.lang.IllegalArgumentException - if command id or method is null or if the given method cannot be executed on the given target object

unregisterCommand

public void unregisterCommand(java.lang.String commandId)
Unregisters a previously registered command.

Parameters:
commandId - the command id of the command to unregister

setEnabledBooleanState

public void setEnabledBooleanState(java.lang.String commandId,
                                   BooleanState enabledBooleanState)
Sets the enabled BooleanState for the command with the given id.

Parameters:
commandId - the command id (not null)
enabledBooleanState - the new enabled state (not null)
See Also:
Command.getEnabledBooleanState()

hasCommand

public boolean hasCommand(java.lang.String commandId)
Description copied from interface: CommandManager
Checks, if the CommandManager provides a command with a given id

Specified by:
hasCommand in interface CommandManager
Parameters:
commandId - the id of a command
Returns:
true, if the CommandManager provides a command with given id
See Also:
CommandManager.hasCommand(java.lang.String)

getCommand

public Command getCommand(java.lang.String commandId)
Description copied from interface: CommandManager
Get a Command from the CommandManager

Specified by:
getCommand in interface CommandManager
Parameters:
commandId - the id of a command
Returns:
the command with the given id,
See Also:
CommandManager.getCommand(java.lang.String)