T
- the object type of the nested commandspublic abstract class AbstractCompoundCommand<T extends ICommand> extends AbstractCommand
ICommand
interface.ICommand
,
Serialized FormConstructor and Description |
---|
AbstractCompoundCommand(String name)
Creates a new compound command with the given name.
|
Modifier and Type | Method and Description |
---|---|
void |
addCommand(T cmd)
Adds a command to the compound command.
|
void |
executeCommand(IProgressMonitor monitor)
Executes the compound command by iterating over the list of added
commands and calling their execute method.
|
T |
getCommand(int index)
Returns the nested command for the given index.
|
int |
getCommandCount()
Returns the number of commands added to the compound command.
|
boolean |
isRedoable()
Returns true if the compund command can be redone.
|
boolean |
isUndoable()
Returns true if the compound command can be undone.
|
void |
redoCommand(IProgressMonitor monitor)
Redos the command by calling the execute method of the command.
|
boolean |
removeCommand(T cmd)
Removes a command from the compound command.
|
void |
setCommands(T[] cmd)
Adds the given commands to the compound command and removed all
previously added commands.
|
void |
undoCommand(IProgressMonitor monitor)
Undos the compound command by iterating over the list of added commands
(in reverse order: last added command gets undone first) and calling
their undo method.
|
getName, isRelevant, setName
public AbstractCompoundCommand(String name)
name
- the name of the commandpublic void addCommand(T cmd)
cmd
- the added commandpublic boolean removeCommand(T cmd)
cmd
- the removed commandpublic int getCommandCount()
public T getCommand(int index)
index
- the index of the nested commandpublic void setCommands(T[] cmd)
cmd
- the commands to be executed by the compound commandpublic void executeCommand(IProgressMonitor monitor) throws CommandException
monitor
- a monitor for reporting the progress of the command executionCommandException
- if anything during the execution of the command has gone
wrongundoCommand(IProgressMonitor)
,
redoCommand(IProgressMonitor)
public void undoCommand(IProgressMonitor monitor) throws CommandException
monitor
- a monitor for reporting the progress of the command executionCommandException
- if anything during the execution of the command has gone
wrongexecuteCommand(IProgressMonitor)
,
redoCommand(IProgressMonitor)
public void redoCommand(IProgressMonitor monitor) throws CommandException
redoCommand
in interface ICommand
redoCommand
in class AbstractCommand
monitor
- a monitor for reporting the progress of the command executionCommandException
- if anything during the execution of the command has gone
wrongexecuteCommand(IProgressMonitor)
,
undoCommand(IProgressMonitor)
public boolean isUndoable()
isUndoable
in interface ICommand
isUndoable
in class AbstractCommand
isRedoable()
public boolean isRedoable()
isRedoable
in interface ICommand
isRedoable
in class AbstractCommand
isUndoable()
Copyright © 2006–2016 Dirk Lemmermann Software & Consulting. All rights reserved.