org.eclipse.gmt.umlx.editor.command
Class CompoundCommand

java.lang.Object
  extended by org.eclipse.gef.commands.Command
      extended by org.eclipse.gmt.umlx.editor.command.AbstractCommand
          extended by org.eclipse.gmt.umlx.editor.command.CompoundCommand
All Implemented Interfaces:
IAbstractCommand
Direct Known Subclasses:
CompoundModelStateCommand, ForwardUndoCompoundCommand

public class CompoundCommand
extends AbstractCommand

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.


Method Summary
 void add(IAbstractCommand command)
          Adds the specified command if it is not null.
 void addSelectedObjects(java.util.Collection<java.lang.Object> selectedObjects, boolean isDone)
           
 boolean canExecute()
           
 boolean canUndo()
           
static IAbstractCommand compound(java.lang.String label, IAbstractCommand baseCommand, IAbstractCommand extraCommand)
          Return a possibly compound command that comprises the base possibly compound command followed by the extra command.
 void diagnoseCannotExecute(boolean isUndo)
           
 void dispose()
           
 void doPrepare(IAbstractCommand rootCommand)
          Prepare to execute the command.
 void doRedo()
          (re)-execute the command.
 void doUndo()
          un-execute the command.
 java.util.List<IAbstractCommand> getCommands()
           
 java.lang.String getLabel()
           
 java.lang.String toString()
           
 
Methods inherited from class org.eclipse.gmt.umlx.editor.command.AbstractCommand
couldNotUnlock, execute, getCommand, prepare, prepare, redo, requestModification, undo
 
Methods inherited from class org.eclipse.gef.commands.Command
chain, getDebugLabel, setDebugLabel, setLabel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

compound

public static IAbstractCommand compound(java.lang.String label,
                                        IAbstractCommand baseCommand,
                                        IAbstractCommand extraCommand)
Return a possibly compound command that comprises the base possibly compound command followed by the extra command.

Parameters:
label - for any constructed CompoundCommand
baseCommand -
extraCommand -
Returns:
the compounded command

add

public void add(IAbstractCommand command)
Adds the specified command if it is not null.

Parameters:
command - null or a Command

addSelectedObjects

public void addSelectedObjects(java.util.Collection<java.lang.Object> selectedObjects,
                               boolean isDone)
Specified by:
addSelectedObjects in interface IAbstractCommand
Overrides:
addSelectedObjects in class AbstractCommand

canExecute

public boolean canExecute()
Specified by:
canExecute in interface IAbstractCommand
Overrides:
canExecute in class AbstractCommand

canUndo

public boolean canUndo()
Specified by:
canUndo in interface IAbstractCommand
Overrides:
canUndo in class AbstractCommand

diagnoseCannotExecute

public void diagnoseCannotExecute(boolean isUndo)
                           throws AbstractFailureException
Specified by:
diagnoseCannotExecute in interface IAbstractCommand
Overrides:
diagnoseCannotExecute in class AbstractCommand
Throws:
AbstractFailureException

dispose

public void dispose()
Specified by:
dispose in interface IAbstractCommand
Overrides:
dispose in class AbstractCommand

doPrepare

public void doPrepare(IAbstractCommand rootCommand)
Description copied from class: AbstractCommand
Prepare to execute the command. Derived implementations should requestModification permission for each affected object, and possibly appendToPrefixChain for any commands that need executing first.

Parameters:
rootCommand - command gathering mofication permissions etc

doRedo

public void doRedo()
Description copied from class: AbstractCommand
(re)-execute the command.


doUndo

public void doUndo()
Description copied from class: AbstractCommand
un-execute the command.


getCommands

public java.util.List<IAbstractCommand> getCommands()
Returns:
the List of contained Commands

getLabel

public java.lang.String getLabel()
Specified by:
getLabel in interface IAbstractCommand
Overrides:
getLabel in class org.eclipse.gef.commands.Command

toString

public java.lang.String toString()
Overrides:
toString in class AbstractCommand
Returns:
the number of contained Commands