public class AddCommand extends AbstractOverrideableCommand
EditingDomain.createCommand
,
which may or may not result in the actual creation of an instance of this class.
The implementation of this class is low-level and EMF specific; it allows one or more objects to be added to a many-valued feature of an owner, i.e., it is equivalent of the call
((EList)((EObject)owner).eGet((EStructuralFeature)feature)).addAll(index, (Collection)collection);
It can also be used as an equivalent to the call
((EList)extent).addAll(index, (Collection)collection);which is how root objects are added into the contents of a resource. Like all the low-level commands in this package, the add command is undoable.
An add command is an OverrideableCommand
.
AbstractCommand.NonDirtying
Modifier and Type | Field and Description |
---|---|
protected java.util.Collection<?> |
affectedObjects
This is the value returned by
Command.getAffectedObjects() . |
protected java.util.Collection<?> |
collection
This is the collection of objects being added to the owner list.
|
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 addition.
|
protected EStructuralFeature |
feature
This is the feature of the owner object upon the command will act.
|
protected int |
index
This is the position at which the objects will be inserted.
|
protected static java.lang.String |
LABEL
This caches the label.
|
protected EObject |
owner
This is the owner object upon which the command will act.
|
protected EList<java.lang.Object> |
ownerList
This is the list to which the command will add the collection.
|
domain, overrideCommand
description, isExecutable, isPrepared, label
Constructor and Description |
---|
AddCommand(EditingDomain domain,
EList<?> list,
java.util.Collection<?> collection)
This constructs a primitive command to insert a collection of values into the specified extent.
|
AddCommand(EditingDomain domain,
EList<?> list,
java.util.Collection<?> collection,
int index)
This constructs a primitive command to insert a collection of values into the specified extent.
|
AddCommand(EditingDomain domain,
EList<?> list,
java.lang.Object value)
This constructs a primitive command to add a particular value into the specified extent.
|
AddCommand(EditingDomain domain,
EList<?> list,
java.lang.Object value,
int index)
This constructs a primitive command to insert particular value into the specified extent.
|
AddCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
java.util.Collection<?> collection)
This constructs a primitive command to add a collection of values to the specified many-valued feature of the owner.
|
AddCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
java.util.Collection<?> collection,
int index)
This constructs a primitive command to insert a collection of values into the specified many-valued feature of the owner.
|
AddCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
java.lang.Object value)
This constructs a primitive command to add a particular value to the specified many-valued feature of the owner.
|
AddCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
java.lang.Object value,
int index)
This constructs a primitive command to insert particular value into 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.util.Collection<?> collection)
This creates a command to add a collection of values to the specified feature of the owner.
|
static Command |
create(EditingDomain domain,
java.lang.Object owner,
java.lang.Object feature,
java.util.Collection<?> collection,
int index)
This creates a command to insert a collection of values at a particular index in the specified feature of the owner.
|
static Command |
create(EditingDomain domain,
java.lang.Object owner,
java.lang.Object feature,
java.lang.Object value)
This creates a command to add a particular value to the specified feature of the owner.
|
static Command |
create(EditingDomain domain,
java.lang.Object owner,
java.lang.Object feature,
java.lang.Object value,
int index)
This creates a command to insert particular value at 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.
|
java.util.Collection<?> |
getCollection()
This returns the collection of objects being added.
|
EStructuralFeature |
getFeature()
This returns the feature of the owner object upon the command will act.
|
int |
getIndex()
This returns the position at which the objects will be added.
|
EObject |
getOwner()
This returns the owner object upon which the command will act.
|
EList<?> |
getOwnerList()
This returns the list to which the command will add.
|
protected boolean |
isUserElement(EStructuralFeature entryFeature) |
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.util.Collection<?> collection
protected int index
protected java.util.Collection<?> affectedObjects
Command.getAffectedObjects()
.
The affected objects are different after an execute than after an undo, so we record it.public AddCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.lang.Object value)
public AddCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.lang.Object value, int index)
public AddCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.util.Collection<?> collection)
public AddCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.util.Collection<?> collection, int index)
public AddCommand(EditingDomain domain, EList<?> list, java.lang.Object value)
public AddCommand(EditingDomain domain, EList<?> list, java.lang.Object value, int index)
public AddCommand(EditingDomain domain, EList<?> list, java.util.Collection<?> collection)
public AddCommand(EditingDomain domain, EList<?> list, java.util.Collection<?> collection, int index)
public static Command create(EditingDomain domain, java.lang.Object owner, java.lang.Object feature, java.lang.Object value)
public static Command create(EditingDomain domain, java.lang.Object owner, java.lang.Object feature, java.lang.Object value, int index)
public static Command create(EditingDomain domain, java.lang.Object owner, java.lang.Object feature, java.util.Collection<?> collection)
public static Command create(EditingDomain domain, java.lang.Object owner, java.lang.Object feature, java.util.Collection<?> collection, int index)
public EObject getOwner()
EList
.public EStructuralFeature getFeature()
EList
.public EList<?> getOwnerList()
public java.util.Collection<?> getCollection()
public int getIndex()
protected boolean isUserElement(EStructuralFeature entryFeature)
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