public class MoveCommand extends AbstractOverrideableCommand
EditingDomain.createCommand
,
which may or may not result in the actual creation of an instance of this class.
Like all the low level commands in this package, the move command is undoable.
The implementation of this class is low-level and EMF specific; it allows an object to be moved to a new position within a many-valued feature of an owner, i.e., it is equivalent of the call
((EList)((EObject)owner).eGet((EStructuralFeature)feature)).move(index, object);
It can also be used as an equivalent to the call
((EList)extent).move(index, object);which is how root objects are moved within the contents of a resource. Like all the low-level commands in this package, the move command is undoable.
A move command is an OverrideableCommand
.
AbstractCommand.NonDirtying
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
DESCRIPTION
This caches the description.
|
protected static java.lang.String |
DESCRIPTION_FOR_LIST
This caches the description for a list-based command.
|
protected EStructuralFeature |
feature
This is the feature of the owner object upon the command will act.
|
protected int |
index
This is the position to which the object will be moved.
|
protected static java.lang.String |
LABEL
This caches the label.
|
protected int |
oldIndex
This is the original position to which the object will be moved upon undo.
|
protected EObject |
owner
This is the owner object upon which the command will act.
|
protected EList<java.lang.Object> |
ownerList
This is the list in which the command will move an object.
|
protected java.lang.Object |
value
This is the value being moved within the owner list.
|
domain, overrideCommand
description, isExecutable, isPrepared, label
Constructor and Description |
---|
MoveCommand(EditingDomain domain,
EList<?> list,
int sourceIndex,
int targetIndex)
This constructs a primitive command to move a value at a particular index to another particular index of the specified extent.
|
MoveCommand(EditingDomain domain,
EList<?> list,
java.lang.Object value,
int index)
This constructs a primitive command to move a particular value to a particular index of the specified extent.
|
MoveCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
int sourceIndex,
int targetIndex)
This constructs a primitive command to move a value at a particular index to another particular index
of the specified many-valued feature of the owner.
|
MoveCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
java.lang.Object value,
int index)
This constructs a primitive command to move a particular value to a particular index
of the specified many-valued feature of the owner.
|
Modifier and Type | Method and Description |
---|---|
static Command |
create(EditingDomain domain,
java.lang.Object owner,
java.lang.Object feature,
java.lang.Object value,
int index)
This creates a command to move particular value to a particular index in the specified feature of the owner.
|
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<?> |
doGetResult()
This is overrideable command's implementation of getResult.
|
void |
doRedo()
This is overrideable command's implementation of redo.
|
void |
doUndo()
This is overrideable command's implementation of undo.
|
EStructuralFeature |
getFeature()
This returns the feature of the owner object upon the command will act.
|
int |
getIndex()
This returns the position to which the value will be moved.
|
int |
getOldIndex()
This returns the original position to which the object will be moved upon undo.
|
EObject |
getOwner()
This returns the owner object upon which the command will act.
|
EList<java.lang.Object> |
getOwnerList()
This returns the list in which the command will move an object.
|
java.lang.Object |
getValue()
This returns the value being moved.
|
protected boolean |
prepare()
Called at most once in
AbstractCommand.canExecute() to give the command an opportunity to ready itself for execution. |
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.
|
canExecute, canUndo, dispose, doCanExecute, doCanUndo, doDispose, doGetChildrenToCopy, doGetDescription, doGetLabel, execute, getAffectedObjects, getChildrenToCopy, getDescription, getDomain, getLabel, getOverride, getOwnerList, getResult, redo, setOverride, undo, updateEMap
chain, setDescription, setLabel
protected static final java.lang.String LABEL
protected static final java.lang.String DESCRIPTION
protected static final java.lang.String DESCRIPTION_FOR_LIST
protected EObject owner
EList
.protected EStructuralFeature feature
EList
.protected EList<java.lang.Object> ownerList
protected java.lang.Object value
protected int index
protected int oldIndex
public MoveCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.lang.Object value, int index)
public MoveCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, int sourceIndex, int targetIndex)
public MoveCommand(EditingDomain domain, EList<?> list, java.lang.Object value, int index)
public MoveCommand(EditingDomain domain, EList<?> list, int sourceIndex, int targetIndex)
public static Command create(EditingDomain domain, java.lang.Object owner, java.lang.Object feature, java.lang.Object value, int index)
public EObject getOwner()
EList
.public EStructuralFeature getFeature()
EList
.public EList<java.lang.Object> getOwnerList()
public java.lang.Object getValue()
public int getIndex()
public int getOldIndex()
protected boolean prepare()
AbstractCommand
AbstractCommand.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 AbstractCommand
public void doExecute()
OverrideableCommand
doExecute
in interface OverrideableCommand
doExecute
in class AbstractOverrideableCommand
public void doUndo()
OverrideableCommand
doUndo
in interface OverrideableCommand
doUndo
in class AbstractOverrideableCommand
public void doRedo()
OverrideableCommand
doRedo
in interface OverrideableCommand
doRedo
in class AbstractOverrideableCommand
public java.util.Collection<?> doGetResult()
OverrideableCommand
doGetResult
in interface OverrideableCommand
doGetResult
in class AbstractOverrideableCommand
public java.util.Collection<?> doGetAffectedObjects()
OverrideableCommand
doGetAffectedObjects
in interface OverrideableCommand
doGetAffectedObjects
in class AbstractOverrideableCommand
public java.lang.String toString()
toString
in class AbstractOverrideableCommand