| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.eclipse.emf.common.command.AbstractCommand
org.eclipse.emf.common.command.CommandWrapper
org.eclipse.emf.edit.command.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 inherited from class org.eclipse.emf.common.command.AbstractCommand |
| AbstractCommand.NonDirtying |
| Field Summary | |
| protected Collection | affectedObjects
This is the value to be returned by getAffectedObjects(). |
| protected Object | child
This is the child object to be added. |
| protected EditingDomain | domain
This is the editing doman 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 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,
Object child,
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,
Object child,
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,
Object child,
int index,
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,
Object child,
int index,
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,
Object owner,
Object newChildDescriptor,
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(). |
| Collection | getAffectedObjects()
This returns the affected objects. |
| String | getDescription()
This returns the description by delegating to helper.getCreateChildDescription(). |
| Object | getImage()
This returns the icon by delegating to helper.getCreateChildImage(). |
| Collection | getResult()
This returns the result of this command by delegating to helper.getCreateChildResult(). |
| String | getText()
This returns the label by delegating to helper.getCreateChildText(). |
| 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(). |
| 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 |
protected static final int NO_INDEX
protected EditingDomain domain
protected EObject owner
protected EStructuralFeature feature
protected Object child
protected int index
protected CreateChildCommand.Helper helper
protected Collection affectedObjects
protected Collection selection
| Constructor Detail |
public CreateChildCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
Object child,
Collection selection)
public CreateChildCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
Object child,
Collection selection,
CreateChildCommand.Helper helper)
public CreateChildCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
Object child,
int index,
Collection selection)
public CreateChildCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
Object child,
int index,
Collection selection,
CreateChildCommand.Helper helper)
| Method Detail |
public static Command create(EditingDomain domain,
Object owner,
Object newChildDescriptor,
Collection selection)
protected Command createCommand()
public void execute()
public void undo()
public void redo()
public Collection getAffectedObjects()
public Collection getResult()
public String getText()
public String getDescription()
public String getToolTipText()
public Object getImage()
public String toString()
|
Copyright 2001-2004 IBM Corporation and others. All Rights Reserved. | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||