Package org.eclipse.gef.commands
Class CompoundCommand
java.lang.Object
org.eclipse.gef.commands.Command
org.eclipse.gef.commands.CompoundCommand
- Direct Known Subclasses:
- ForwardUndoCompoundCommand
An aggregation of multiple 
Commands. A
 CompoundCommand is executable if all of its contained Commands
 are executable, and it has at least one contained Command. The same is true
 for undo. When undo is called, the contained Commands are undone in the
 reverse order in which they were executed.
 An empty CompoundCommand is not executable.
 A CompoundCommand can be unwrapped. Unwrapping returns the
 simplest equivalent form of the CompoundCommand. So, if a CompoundCommand
 contains just one Command, that Command is returned.
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs an empty CompoundCommandCompoundCommand(String label) Constructs an empty CompoundCommand with the specified label.
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdds the specified command if it is notnull.booleanbooleancanRedo()booleancanUndo()voiddispose()Disposes all contained Commands.voidexecute()Execute the command.For a compound command this means executing all of the commands that it contains.Object[]This is useful when implementingITreeContentProvider.getChildren(Object)to display the Command's nested structure.getLabel()booleanisEmpty()voidredo()Re-executes the Command.intsize()voidundo()Undoes the changes performed duringexecute().unwrap()Returns the simplest form of this Command that is equivalent.Methods inherited from class org.eclipse.gef.commands.Commandchain, getDebugLabel, setDebugLabel, setLabel
- 
Constructor Details- 
CompoundCommandpublic CompoundCommand()Constructs an empty CompoundCommand- Since:
- 2.0
 
- 
CompoundCommandConstructs an empty CompoundCommand with the specified label.- Parameters:
- label- the label for the Command
 
 
- 
- 
Method Details- 
addAdds the specified command if it is notnull.- Parameters:
- command-- nullor a Command
 
- 
canRedopublic boolean canRedo()
- 
canExecutepublic boolean canExecute()- Overrides:
- canExecutein class- Command
- Returns:
- trueif the command can be executed
- See Also:
 
- 
canUndopublic boolean canUndo()
- 
disposepublic void dispose()Disposes all contained Commands.
- 
executepublic void execute()Execute the command.For a compound command this means executing all of the commands that it contains.
- 
getChildrenThis is useful when implementingITreeContentProvider.getChildren(Object)to display the Command's nested structure.- Returns:
- returns the Commands as an array of Objects.
 
- 
getCommands- Returns:
- the List of contained Commands
 
- 
getLabel
- 
isEmptypublic boolean isEmpty()- Returns:
- trueif the CompoundCommand is empty
 
- 
redopublic void redo()Description copied from class:CommandRe-executes the Command. This method should only be called afterundo()has been called.
- 
sizepublic int size()- Returns:
- the number of contained Commands
 
- 
undopublic void undo()Description copied from class:CommandUndoes the changes performed duringexecute(). This method should only be called afterexecutehas been called, and only whencanUndo()returnstrue.
- 
unwrapReturns the simplest form of this Command that is equivalent. This is useful for removing unnecessary nesting of Commands.- Returns:
- the simplest form of this Command that is equivalent
 
 
-