com.tensegrity.generic.command
Interface Command

All Known Subinterfaces:
ChoiceCommand, ToggleCommand
All Known Implementing Classes:
BaseCommand, SetSortModeCommand, ToggleAntialiasCommand, ToggleAutomaticLayoutCommand, ToggleCategoriesCommand, ToggleConnectModeCommand, ToggleExactMatchingCommand, ToggleFullscreenCommand, ToggleLeftColumnCommand, ToggleMergeElementTypesCommand, ToggleRightColumnCommand, ToggleZoomRectangleModeCommand, ViewGridCommand, ViewRulerCommand

public interface Command

By encapsulating a request as an object, commands let you parameterize clients with different requests, queue or log requests, and support undo/redo operations.

The Command interface is one implementation of the well-known GoF pattern just described. Our Command objects are identified, described, executable objects with an enabling state that can be controlled by client code. These characteristics are reflected in the declared methods of the interface. Commands can be attached to both MenuBar and ToolBar items and generally facilitate the extension of custom applications.

All commands have these common characteristics and abilities:

The identifier is used to look up the object in the CommandRegistry and has to be unique. The behavior of a Command is coded in the perform(Object) method of an implementation class. If a description has been set and the Command is used in a ToolBar, this description will be shown as a Tooltip. The perform description describes what the Command is doing during its execution. This string is shown in the StatusBar for a short period of time.

Version:
$Id: Command.java,v 1.23 2005/11/07 13:51:31 KevinCVS Exp $
Author:
Stepan Rutz
See Also:
{@link http://java.sun.com/products/jfc/swingdoc-api-1.0.3/com/sun/java/swing/Action.html>Action}

Method Summary
 java.lang.String getDescription()
          Returns the description of this command.
 java.lang.String getId()
          Retrieves the unique identifier of the command.
 java.lang.String getPerformDescription()
          Returns a textual description of what the command does when it is invoked.
 boolean isEnabled()
          Returns true if this command is enabled.
 void perform(java.lang.Object args)
          This method will specify the functionality the command offers.
 void setEnabled(boolean enabled)
          Specifies whether this command is enabled or not.
 

Method Detail

perform

public void perform(java.lang.Object args)
This method will specify the functionality the command offers. Optionally a parameter can be specified.

Parameters:
args - optional parameter for this command

getId

public java.lang.String getId()
Retrieves the unique identifier of the command.

Returns:
the unique identifier of this command.

getDescription

public java.lang.String getDescription()
Returns the description of this command. A desciption can be used as a tooltip-text, for example.

Returns:
the set description for this command, null otherwise.

getPerformDescription

public java.lang.String getPerformDescription()
Returns a textual description of what the command does when it is invoked. The difference between getDescription() is, that the returned String of this method describes what the Command does when it performs. The String returned by getDescription() describes what the command will do.

For example:
You specify a command that opens a document.

Returns:
a String describing what this command does during performance, or null if it is not set.

isEnabled

public boolean isEnabled()
Returns true if this command is enabled.

Returns:
true if this command is enabled.

setEnabled

public void setEnabled(boolean enabled)
Specifies whether this command is enabled or not.

Parameters:
enabled - specifies whether this command is enabled.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.