de.cau.cs.kieler.core.model.util
Class PossiblyEmptyCompoundCommand
java.lang.Object
org.eclipse.emf.common.command.AbstractCommand
org.eclipse.emf.common.command.CompoundCommand
de.cau.cs.kieler.core.model.util.PossiblyEmptyCompoundCommand
- All Implemented Interfaces:
- Command
public class PossiblyEmptyCompoundCommand
- extends CompoundCommand
A CompoundCommand that may be empty. Even when the list of commands stored
within is empty, the prepare() method will return true and hence the command
is marked as executable. Can be used to create an empty executable command.
- Rating

Method Summary |
protected boolean |
prepare()
Returns whether all the commands can execute so that
AbstractCommand.isExecutable can be cached. |
Command |
unwrap()
Return one of three commands: If the command list is empty, return null;
if there is exactly one command in the list, return that command;
otherwise return this PossiblyEmptyCompoundCommand. |
Command |
unwrapAll()
Flatten all PossiblyEmptyCompoundCommands recursively. |
Methods inherited from class org.eclipse.emf.common.command.CompoundCommand |
append, appendAndExecute, appendIfCanExecute, canUndo, dispose, execute, getAffectedObjects, getCommandList, getDescription, getLabel, getMergedAffectedObjectsCollection, getMergedResultCollection, getResult, getResultIndex, isEmpty, redo, toString, undo |
PossiblyEmptyCompoundCommand
public PossiblyEmptyCompoundCommand()
prepare
protected boolean prepare()
- Returns whether all the commands can execute so that
AbstractCommand.isExecutable
can be cached. An empty command list causes
true
to be returned.
- Overrides:
prepare
in class CompoundCommand
- Returns:
- whether all the commands can execute.
unwrap
public Command unwrap()
- Return one of three commands: If the command list is empty, return null;
if there is exactly one command in the list, return that command;
otherwise return this PossiblyEmptyCompoundCommand. Can be used to remove
unnecessary hierarchy levels of commands.
- Overrides:
unwrap
in class CompoundCommand
- Returns:
- the resulting Command, maybe null
unwrapAll
public Command unwrapAll()
- Flatten all PossiblyEmptyCompoundCommands recursively. Go recursively
through all PossiblEmptyCompoundCommand children and unwrap them all. If
a result is still a PossiblyEmptyCompoundCommand, all of its children are
moved one level up and the compound command gets removed.
- Returns:
- Either a flat PossiblyEmptyCompoundCommand or one single other
Command or maybe null.