public abstract class AbstractOverrideableCommand extends AbstractCommand implements OverrideableCommand
OverrideableCommand.
Subclasses of AbstractOverrideableCommand should provide implementations of the doXxx methods
(e.g., doExecute) from OverrideableCommand instead of the base command methods (e.g.,
execute), which have final implementations here.AbstractCommand.NonDirtying| Modifier and Type | Field and Description |
|---|---|
protected EditingDomain |
domain
This is the editing domain in which this command operates.
|
protected Command |
overrideCommand
This is the command that overrides this command.
|
description, isExecutable, isPrepared, label| Modifier | Constructor and Description |
|---|---|
protected |
AbstractOverrideableCommand(EditingDomain domain)
This constructs an instance in this editing domain.
|
protected |
AbstractOverrideableCommand(EditingDomain domain,
java.lang.String label)
This constructs an instance with the given label and in this editing domain.
|
protected |
AbstractOverrideableCommand(EditingDomain domain,
java.lang.String label,
java.lang.String description)
This constructs an instance with the given label and description, in this editing domain.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canExecute()
Calls
AbstractCommand.prepare(),
caches the result in AbstractCommand.isExecutable,
and sets AbstractCommand.isPrepared to true;
from then on, it will yield the value of isExecutable. |
boolean |
canUndo()
Returns
true because most command should be undoable. |
void |
dispose()
Called to indicate that the command will never be used again.
|
boolean |
doCanExecute()
This is overrideable command's implementation of canExecute.
|
boolean |
doCanUndo()
This is overrideable command's implementation of canUndo.
|
void |
doDispose()
This is overrideable command's implementation of dispose.
|
abstract void |
doExecute()
This is overrideable command's implementation of execute.
|
java.util.Collection<?> |
doGetAffectedObjects()
This is overrideable command's implementation of getAffectedObjects.
|
java.util.Collection<?> |
doGetChildrenToCopy() |
java.lang.String |
doGetDescription()
This is overrideable command's implementation of getDescription.
|
java.lang.String |
doGetLabel()
This is overrideable command's implementation of getLabel.
|
java.util.Collection<?> |
doGetResult()
This is overrideable command's implementation of getResult.
|
abstract void |
doRedo()
This is overrideable command's implementation of redo.
|
abstract void |
doUndo()
This is overrideable command's implementation of undo.
|
void |
execute()
Performs the command activity required for the effect.
|
java.util.Collection<?> |
getAffectedObjects()
Returns an empty list.
|
java.util.Collection<?> |
getChildrenToCopy() |
java.lang.String |
getDescription()
Returns a string suitable to help describe the effect of this command.
|
EditingDomain |
getDomain()
This returns the editing domain that contains this.
|
java.lang.String |
getLabel()
Returns a string suitable to represent the label that identifies this command.
|
Command |
getOverride()
This returns the command that overrides this command.
|
static EList<java.lang.Object> |
getOwnerList(EObject owner,
EStructuralFeature feature) |
java.util.Collection<?> |
getResult()
Returns an empty list.
|
void |
redo()
Performs the command activity required to
redo the effect after undoing the effect. |
void |
setOverride(Command overrideCommand)
This sets the command that overrides this command.
|
java.lang.String |
toString()
This gives an abbreviated name using this object's own class' name, without package qualification,
followed by a space separated list of field:value pairs.
|
void |
undo()
Throws a runtime exception.
|
protected void |
updateEMap(EObject owner,
EStructuralFeature feature)
If the owner and the feature aren't null,
the feature is the key of a map entry class,
and the owner is contained in a EMap,
then the map is updated to properly reflect the change to the key's hash code.
|
chain, prepare, setDescription, setLabelprotected EditingDomain domain
protected Command overrideCommand
protected AbstractOverrideableCommand(EditingDomain domain)
protected AbstractOverrideableCommand(EditingDomain domain, java.lang.String label)
protected AbstractOverrideableCommand(EditingDomain domain, java.lang.String label, java.lang.String description)
public EditingDomain getDomain()
public Command getOverride()
getOverride in interface OverrideableCommandpublic void setOverride(Command overrideCommand)
setOverride in interface OverrideableCommandpublic final boolean canExecute()
AbstractCommandAbstractCommand.prepare(),
caches the result in AbstractCommand.isExecutable,
and sets AbstractCommand.isPrepared to true;
from then on, it will yield the value of isExecutable.canExecute in interface CommandcanExecute in class AbstractCommandpublic boolean doCanExecute()
OverrideableCommanddoCanExecute in interface OverrideableCommandpublic final void execute()
Commandexecute when canExecute returns false,
or when canExecute hasn't been called, is undefined.public abstract void doExecute()
OverrideableCommanddoExecute in interface OverrideableCommandpublic final boolean canUndo()
AbstractCommandtrue because most command should be undoable.canUndo in interface CommandcanUndo in class AbstractCommandtrue.public boolean doCanUndo()
OverrideableCommanddoCanUndo in interface OverrideableCommandpublic final void undo()
AbstractCommandundo in interface Commandundo in class AbstractCommandpublic abstract void doUndo()
OverrideableCommanddoUndo in interface OverrideableCommandpublic final 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.public abstract void doRedo()
OverrideableCommanddoRedo in interface OverrideableCommandpublic final java.util.Collection<?> getResult()
AbstractCommandgetResult in interface CommandgetResult in class AbstractCommandpublic java.util.Collection<?> doGetResult()
OverrideableCommanddoGetResult in interface OverrideableCommandpublic final java.util.Collection<?> getAffectedObjects()
AbstractCommandgetAffectedObjects in interface CommandgetAffectedObjects in class AbstractCommandpublic java.util.Collection<?> doGetAffectedObjects()
OverrideableCommanddoGetAffectedObjects in interface OverrideableCommandpublic final java.lang.String getLabel()
CommandgetLabel in interface CommandgetLabel in class AbstractCommandpublic java.lang.String doGetLabel()
OverrideableCommanddoGetLabel in interface OverrideableCommandpublic final java.lang.String getDescription()
CommandgetDescription in interface CommandgetDescription in class AbstractCommandpublic java.lang.String doGetDescription()
OverrideableCommanddoGetDescription in interface OverrideableCommandpublic final void dispose()
Commanddispose in interface Commanddispose in class AbstractCommandpublic void doDispose()
OverrideableCommanddoDispose in interface OverrideableCommandpublic final java.util.Collection<?> getChildrenToCopy()
public java.util.Collection<?> doGetChildrenToCopy()
public static EList<java.lang.Object> getOwnerList(EObject owner, EStructuralFeature feature)
protected void updateEMap(EObject owner, EStructuralFeature feature)
owner - the owner of the feature.feature - the feature that's been updated.public java.lang.String toString()
toString in class AbstractCommand