public abstract class ChangeCommand extends AbstractCommand
This command uses the Change Model facilities to enable a group of modifications to be executed as one single command. The undo operation reverts all the modifications made when the command was executed
In order to use this class, the org.eclipse.emf.ecore.change plugin has to be available in your Eclipse configuration.
AbstractCommand.NonDirtying| Modifier and Type | Field and Description |
|---|---|
protected ChangeDescription |
changeDescription |
protected ChangeRecorder |
changeRecorder |
protected Notifier |
notifier |
protected java.util.Collection<Notifier> |
notifiers |
description, isExecutable, isPrepared, label| Modifier | Constructor and Description |
|---|---|
protected |
ChangeCommand(ChangeRecorder changeRecorder) |
|
ChangeCommand(ChangeRecorder changeRecorder,
java.util.Collection<Notifier> notifiers) |
|
ChangeCommand(ChangeRecorder changeRecorder,
Notifier notifier) |
|
ChangeCommand(java.util.Collection<Notifier> notifiers) |
|
ChangeCommand(Notifier notifier) |
| Modifier and Type | Method and Description |
|---|---|
protected ChangeRecorder |
createChangeRecorder() |
void |
dispose()
Called to indicate that the command will never be used again.
|
protected void |
disposeChangeRecorder(ChangeRecorder changeRecorder)
Disposes the
ChangeRecorder created by execute(). |
protected abstract void |
doExecute()
Subclasses should override this to perform modifications to resources and objects.
|
void |
execute()
Executes the command.
|
protected ChangeDescription |
getChangeDescription() |
ChangeRecorder |
getChangeRecorder()
Returns the
ChangeRecorder specified in the
constructor if any. |
protected boolean |
prepare()
Called at most once in
AbstractCommand.canExecute() to give the command an opportunity to ready itself for execution. |
void |
redo()
Performs the command activity required to
redo the effect after undoing the effect. |
protected void |
setChangeDescription(ChangeDescription changeDescription) |
void |
undo()
Throws a runtime exception.
|
canExecute, canUndo, chain, getAffectedObjects, getDescription, getLabel, getResult, setDescription, setLabel, toStringprotected ChangeDescription changeDescription
protected Notifier notifier
protected java.util.Collection<Notifier> notifiers
protected ChangeRecorder changeRecorder
protected ChangeCommand(ChangeRecorder changeRecorder)
public ChangeCommand(ChangeRecorder changeRecorder, Notifier notifier)
public ChangeCommand(Notifier notifier)
public ChangeCommand(ChangeRecorder changeRecorder, java.util.Collection<Notifier> notifiers)
public ChangeCommand(java.util.Collection<Notifier> notifiers)
public void dispose()
Commanddispose in interface Commanddispose in class AbstractCommandpublic ChangeRecorder getChangeRecorder()
ChangeRecorder specified in the
constructor if any.ChangeRecorderprotected ChangeRecorder createChangeRecorder()
protected ChangeDescription getChangeDescription()
protected void setChangeDescription(ChangeDescription changeDescription)
protected boolean prepare()
AbstractCommandAbstractCommand.canExecute() to give the command an opportunity to ready itself for execution.
The returned value is stored in AbstractCommand.canExecute().
In other words, you can override this method to initialize
and to yield a cached value for the all subsequent calls to canExecute.prepare in class AbstractCommandpublic void execute()
doExecute().protected abstract void doExecute()
AbortExecutionException
may be thrown to avoid placing the command on the command stack.protected void disposeChangeRecorder(ChangeRecorder changeRecorder)
ChangeRecorder created by execute(). The default
implementation doesn't dispose the change recorder if it was passed in
through one of the constructor methods.changeRecorder - public void undo()
AbstractCommandundo in interface Commandundo in class AbstractCommandpublic void redo()
Commandredo the effect after undoing the effect.
The effect, if any, of calling redo before undo is called is undefined.
Note that if you implement redo to call execute
then any derived class will be restricted by that decision also.