Eclipse GEF
2.1

org.eclipse.gef.commands
Class Command

java.lang.Object
  |
  +--org.eclipse.gef.commands.Command
Direct Known Subclasses:
CompoundCommand, UnexecutableCommand

public abstract class Command
extends Object

An Abstract implementation of Command.

Since:
2.0

Constructor Summary
Command()
          Constructs a Command with no label.
Command(String label)
          Constructs a Command with the specified label.
 
Method Summary
 boolean canExecute()
           
 boolean canUndo()
           
 Command chain(Command command)
          Returns a Command that represents the chaining of a specified Command to this Command.
 void dispose()
          This is called to indicate that the Command will not be used again.
 void execute()
          executes the Command.
 String getDebugLabel()
           
 String getLabel()
           
 void redo()
          Re-executes the Command.
 void setDebugLabel(String label)
          Sets the debug label for this command
 void setLabel(String label)
          Sets the label used to describe this command to the User.
 void undo()
          Undoes the changes performed during execute().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Command

public Command()
Constructs a Command with no label.


Command

public Command(String label)
Constructs a Command with the specified label.

Parameters:
label - the Command's label
Method Detail

canExecute

public boolean canExecute()
Returns:
true if the command can be executed

canUndo

public boolean canUndo()
Returns:
true if the command can be undone. This method should only be called after execute() or redo() has been called.

chain

public Command chain(Command command)
Returns a Command that represents the chaining of a specified Command to this Command. The Command being chained will execute() after this command has executed, and it will undo() before this Command is undone.

Parameters:
command - null or the Command being chained
Returns:
a Command representing the union

dispose

public void dispose()
This is called to indicate that the Command will not be used again. The Command may be in any state (executed, undone or redone) when dispose is called. The Command should not be referenced in any way after it has been disposed.


execute

public void execute()
executes the Command. This method should not be called if the Command is not executable.


getDebugLabel

public String getDebugLabel()
Returns:
an untranslated String used for debug purposes only

getLabel

public String getLabel()
Returns:
a String used to describe this command to the User

redo

public void redo()
Re-executes the Command. This method should only be called after undo() has been called.


setDebugLabel

public void setDebugLabel(String label)
Sets the debug label for this command

Parameters:
label - a description used for debugging only

setLabel

public void setLabel(String label)
Sets the label used to describe this command to the User.

Parameters:
label - the label

undo

public void undo()
Undoes the changes performed during execute(). This method should only be called after execute has been called, and only when canUndo() returns true.

See Also:
canUndo()

Eclipse GEF
2.1

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.