public class CompoundCommand extends Command
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 and Description |
|---|
CompoundCommand()
Constructs an empty CompoundCommand
|
CompoundCommand(java.lang.String label)
Constructs an empty CompoundCommand with the specified label.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Command command)
Adds the specified command if it is not
null. |
boolean |
canExecute() |
boolean |
canRedo() |
boolean |
canUndo() |
void |
dispose()
Disposes all contained Commands.
|
void |
execute()
Execute the command.For a compound command this means executing all of
the commands that it contains.
|
java.lang.Object[] |
getChildren()
This is useful when implementing
ITreeContentProvider.getChildren(Object)
to display the Command's nested structure. |
java.util.List |
getCommands() |
java.lang.String |
getLabel() |
boolean |
isEmpty() |
void |
redo()
Re-executes the Command.
|
int |
size() |
void |
undo()
Undoes the changes performed during
execute(). |
Command |
unwrap()
Returns the simplest form of this Command that is equivalent.
|
chain, getDebugLabel, setDebugLabel, setLabelpublic CompoundCommand()
public CompoundCommand(java.lang.String label)
label - the label for the Commandpublic void add(Command command)
null.command - null or a Commandpublic boolean canRedo()
canRedo in class Commandtrue if the command can be redone. This method
should only be called after undo() has been called.Command.canRedo()public boolean canExecute()
canExecute in class Commandtrue if the command can be executedCommand.canExecute()public boolean canUndo()
canUndo in class Commandtrue if the command can be undone. This method
should only be called after execute() or
redo() has been called.Command.canUndo()public void dispose()
dispose in class CommandCommand.dispose()public void execute()
public java.lang.Object[] getChildren()
ITreeContentProvider.getChildren(Object)
to display the Command's nested structure.public java.util.List getCommands()
public java.lang.String getLabel()
getLabel in class CommandCommand.getLabel()public boolean isEmpty()
true if the CompoundCommand is emptypublic void redo()
Commandundo() has been called.redo in class CommandCommand.redo()public int size()
public void undo()
Commandexecute(). This method
should only be called after execute has been called, and
only when canUndo() returns true.undo in class CommandCommand.undo()public Command unwrap()
Copyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.