Package org.eclipse.gef.commands
Class Command
- java.lang.Object
-
- org.eclipse.gef.commands.Command
-
- Direct Known Subclasses:
CompoundCommand,SetPropertyValueCommand,UnexecutableCommand
public abstract class Command extends java.lang.ObjectAn Abstract implementation ofCommand.- Since:
- 2.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanExecute()booleancanRedo()booleancanUndo()Commandchain(Command command)Returns a Command that represents the chaining of a specified Command to this Command.voiddispose()This is called to indicate that theCommandwill not be used again.voidexecute()Executes the Command.java.lang.StringgetDebugLabel()java.lang.StringgetLabel()voidredo()Re-executes the Command.voidsetDebugLabel(java.lang.String label)Sets the debug label for this commandvoidsetLabel(java.lang.String label)Sets the label used to describe this command to the User.voidundo()Undoes the changes performed duringexecute().
-
-
-
Method Detail
-
canRedo
public boolean canRedo()
- Returns:
trueif the command can be redone. This method should only be called afterundo()has been called.- Since:
- 3.10
-
canExecute
public boolean canExecute()
- Returns:
trueif the command can be executed
-
canUndo
public boolean canUndo()
- Returns:
trueif the command can be undone. This method should only be called afterexecute()orredo()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 willexecute()after this command has executed, and it willundo()before this Command is undone.- Parameters:
command-nullor the Command being chained- Returns:
- a Command representing the union
-
dispose
public void dispose()
This is called to indicate that theCommandwill 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 java.lang.String getDebugLabel()
- Returns:
- an untranslated String used for debug purposes only
-
getLabel
public java.lang.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 afterundo()has been called.
-
setDebugLabel
public void setDebugLabel(java.lang.String label)
Sets the debug label for this command- Parameters:
label- a description used for debugging only
-
setLabel
public void setLabel(java.lang.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 duringexecute(). This method should only be called afterexecutehas been called, and only whencanUndo()returnstrue.- See Also:
canUndo()
-
-