|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.emf.common.command.AbstractCommand org.eclipse.emf.common.command.CommandWrapper org.eclipse.emf.edit.command.CreateChildCommand
public class CreateChildCommand
This command wraps an AddCommand
or SetCommand
to
provide the higher-level operation of "creating" an appropriate child
object and adding it to a owner object. In fact, all of the possible
child objects are created by the owner's item provider before this
command is created, and specified in the newChildDescriptor
argument to create()
-- they must be, so that the user
can specify which he actually wishes to create. As a result, this
command essentially just creates and executes the appropriate lower-level
EMF command, and delegates matters of appearance (text, icon, result) to
the appropriate item provider, so that it may be handled correctly for
the given model.
Note that this command makes no assumptions about the relationship
between the owner
, to which the new child will be added, and
the selected object. This allows the command to be reused for sibling
creation. As a result, the selection
be explicitly
specified, so that it can be restored when the command is undone.
Nested Class Summary | |
---|---|
static interface |
CreateChildCommand.Helper
This is the helper interface to which CreateChildCommand
functionality is delegated. |
Nested classes/interfaces inherited from class org.eclipse.emf.common.command.AbstractCommand |
---|
AbstractCommand.NonDirtying |
Field Summary | |
---|---|
protected java.util.Collection<?> |
affectedObjects
This is the value to be returned by getAffectedObjects() . |
protected java.lang.Object |
child
This is the child object to be added. |
protected EditingDomain |
domain
This is the editing domain in which this command operates. |
protected EStructuralFeature |
feature
This is the feature of the owner to which the child will be added. |
protected CreateChildCommand.Helper |
helper
This is the helper object, usually the item provider for owner ,
to which parts of this command's functionality are delegated. |
protected int |
index
This is the index for the new object's position under the feature. |
protected static int |
NO_INDEX
Deprecated. As of EMF 2.0, use CommandParameter.NO_INDEX , whose
value is equal to this, instead. |
protected EObject |
owner
This is the object to which the child will be added. |
protected java.util.Collection<?> |
selection
This is the collection of objects that were selected when this command was created. |
Fields inherited from class org.eclipse.emf.common.command.CommandWrapper |
---|
command |
Fields inherited from class org.eclipse.emf.common.command.AbstractCommand |
---|
description, isExecutable, isPrepared, label |
Constructor Summary | |
---|---|
CreateChildCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
java.lang.Object child,
java.util.Collection<?> selection)
This constructor initializes an instance that adds the specified child object to the feature of the
owner object. |
|
CreateChildCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
java.lang.Object child,
java.util.Collection<?> selection,
CreateChildCommand.Helper helper)
This constructor initializes an instance, as above, but the command delegates functionality to the specified Helper . |
|
CreateChildCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
java.lang.Object child,
int index,
java.util.Collection<?> selection)
This constructor initializes an instance that adds the specified child object to the owner object, at the
specified index of its feature feature, if it
is multi-valued. |
|
CreateChildCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
java.lang.Object child,
int index,
java.util.Collection<?> selection,
CreateChildCommand.Helper helper)
This constructor initializes an instance, as above, but the command delegates functionality to the specified Helper . |
Method Summary | |
---|---|
static Command |
create(EditingDomain domain,
java.lang.Object owner,
java.lang.Object newChildDescriptor,
java.util.Collection<?> selection)
This returns a command created by the editing domain to add the child described by newChildDescriptor to the given
object . |
protected Command |
createCommand()
This creates the wrapped AddCommand or SetCommand that
adds the child object to the model. |
void |
execute()
This executes the wrapped command and sets the affected objects to the collection returned by helper.getCreateChildResult() . |
java.util.Collection<?> |
getAffectedObjects()
This returns the affected objects. |
java.lang.String |
getDescription()
This returns the description by delegating to helper.getCreateChildDescription() . |
java.lang.Object |
getImage()
This returns the icon by delegating to helper.getCreateChildImage() . |
java.util.Collection<?> |
getResult()
This returns the result of this command by delegating to helper.getCreateChildResult() . |
java.lang.String |
getText()
This returns the label by delegating to helper.getCreateChildText() . |
java.lang.String |
getToolTipText()
This returns the tool tip text by delegating to helper.getCreateChildToolTipText() . |
void |
redo()
This redoes the wrapped command and sets the affected objects to the collection returned by helper.getCreateChildResult() . |
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()
This undoes the wrapped command and sets the affected objects to the original selection. |
Methods inherited from class org.eclipse.emf.common.command.CommandWrapper |
---|
canUndo, dispose, getCommand, getLabel, prepare |
Methods inherited from class org.eclipse.emf.common.command.AbstractCommand |
---|
canExecute, chain, setDescription, setLabel |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.eclipse.emf.edit.command.CommandActionDelegate |
---|
canExecute |
Field Detail |
---|
@Deprecated protected static final int NO_INDEX
CommandParameter.NO_INDEX
, whose
value is equal to this, instead.
protected EditingDomain domain
protected EObject owner
protected EStructuralFeature feature
protected java.lang.Object child
protected int index
protected CreateChildCommand.Helper helper
owner
,
to which parts of this command's functionality are delegated.
protected java.util.Collection<?> affectedObjects
getAffectedObjects()
.
The affected objects are different after an execute or redo from after
an undo, so we record them.
protected java.util.Collection<?> selection
Constructor Detail |
---|
public CreateChildCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.lang.Object child, java.util.Collection<?> selection)
child
object to the feature
of the
owner
object. If any of owner
,
feature
, or child
are null
,
createCommand()
will return UnexecutableCommand.INSTANCE
and, hence, AbstractCommand.canExecute()
will return
false
. If non-null, selection
is the
collection of selected objects. An internal default Helper
will provide generic implmentations for the delegated command
methods.
public CreateChildCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.lang.Object child, java.util.Collection<?> selection, CreateChildCommand.Helper helper)
Helper
.
If helper
is null
, the internal default
helper is used.
public CreateChildCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.lang.Object child, int index, java.util.Collection<?> selection)
child
object to the owner
object, at the
specified index
of its feature
feature, if it
is multi-valued. If any of owner
, feature
,
or child
are null
, createCommand()
will return UnexecutableCommand.INSTANCE
and, hence, AbstractCommand.canExecute()
will return
false
. If non-null, selection
is the
collection of selected objects. The internal default helper is used by
the command. If index
is CommandParameter.NO_INDEX
,
this behaves just like the first constructor form.
public CreateChildCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.lang.Object child, int index, java.util.Collection<?> selection, CreateChildCommand.Helper helper)
Helper
.
If helper
is null
, the internal default
helper is used.
Method Detail |
---|
public static Command create(EditingDomain domain, java.lang.Object owner, java.lang.Object newChildDescriptor, java.util.Collection<?> selection)
newChildDescriptor
to the given
object
.
protected Command createCommand()
AddCommand
or SetCommand
that
adds the child object to the model. If the owner, feature, or child
is null
, or if the feature is single-valued and has
already been set to an object, UnexecutableCommand.INSTANCE
will be returned.
createCommand
in class CommandWrapper
public void execute()
helper.getCreateChildResult()
.
execute
in interface Command
execute
in class CommandWrapper
public void undo()
undo
in interface Command
undo
in class CommandWrapper
public void redo()
helper.getCreateChildResult()
.
redo
in interface Command
redo
in class CommandWrapper
public java.util.Collection<?> getAffectedObjects()
getAffectedObjects
in interface Command
getAffectedObjects
in class CommandWrapper
public java.util.Collection<?> getResult()
helper.getCreateChildResult()
.
getResult
in interface Command
getResult
in class CommandWrapper
public java.lang.String getText()
helper.getCreateChildText()
.
getText
in interface CommandActionDelegate
public java.lang.String getDescription()
helper.getCreateChildDescription()
.
getDescription
in interface Command
getDescription
in interface CommandActionDelegate
getDescription
in class CommandWrapper
public java.lang.String getToolTipText()
helper.getCreateChildToolTipText()
.
getToolTipText
in interface CommandActionDelegate
public java.lang.Object getImage()
helper.getCreateChildImage()
.
getImage
in interface CommandActionDelegate
public java.lang.String toString()
field:value
pairs.
toString
in class CommandWrapper
|
Copyright 2001-2006 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |