Overview

 
Package  Use  Tree  Deprecated  Index  Help 
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


 

org.eclipse.emf.edit.command
Class AddCommand

java.lang.Object
  extended byorg.eclipse.emf.common.command.AbstractCommand
      extended byorg.eclipse.emf.edit.command.AbstractOverrideableCommand
          extended byorg.eclipse.emf.edit.command.AddCommand

All Implemented Interfaces:
Command, OverrideableCommand


public class AddCommand
extends AbstractOverrideableCommand

The add command logically acts upon an owner object that has a collection-based feature to which other objects can be added. The static create methods delegate command creation to 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 comands in this package, the add command is undoable.

An add command is an OverrideableCommand.


Nested Class Summary
 
Nested classes inherited from class org.eclipse.emf.common.command.AbstractCommand
AbstractCommand.NonDirtying
 
Field Summary
protected  Collection affectedObjects
          This is the value returned by Command.getAffectedObjects().
protected  Collection collection
          This is the collection of objects being added to the owner list.
protected static String DESCRIPTION
          This cachaes the description.
protected static String DESCRIPTION_FOR_LIST
          This cachaes 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 String LABEL
          This caches the label.
protected  EObject owner
          This is the owner object upon which the command will act.
protected  EList ownerList
          This is the list to which the command will add the collection.
 
Fields inherited from class org.eclipse.emf.edit.command.AbstractOverrideableCommand
domain, overrideCommand
 
Fields inherited from class org.eclipse.emf.common.command.AbstractCommand
description, isExecutable, isPrepared, label
 
Constructor Summary
AddCommand(EditingDomain domain, EList list, Collection collection)
          This constructs a primitive command to insert a collection of values into the specified extent.
AddCommand(EditingDomain domain, EList list, Collection collection, int index)
          This constructs a primitive command to insert a collection of values into the specified extent.
AddCommand(EditingDomain domain, EList list, Object value)
          This constructs a primitive command to add a particular value into the specified extent.
AddCommand(EditingDomain domain, EList list, Object value, int index)
          This constructs a primitive command to insert particular value into the specified extent.
AddCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, 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, 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, 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, Object value, int index)
          This constructs a primitive command to insert particular value into the specified many-valued feature of the owner.
 
Method Summary
static Command create(EditingDomain domain, Object owner, Object feature, Collection collection)
          This creates a command to add a collection of values to the specified feature of the owner.
static Command create(EditingDomain domain, Object owner, Object feature, 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, Object owner, Object feature, Object value)
          This creates a command to add a particular value to the specified feature of the owner.
static Command create(EditingDomain domain, Object owner, Object feature, 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.
 Collection doGetAffectedObjects()
          This is overrideable command's implementation of getAffectedObjects.
 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.
 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 prepare()
          Called at most once in AbstractOverrideableCommand.canExecute() to give the command an opportunity to ready itself for execution.
 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.
 
Methods inherited from class org.eclipse.emf.edit.command.AbstractOverrideableCommand
canExecute, canUndo, dispose, doCanExecute, doCanUndo, doDispose, doGetChildrenToCopy, doGetDescription, doGetLabel, execute, getAffectedObjects, getChildrenToCopy, getDescription, getDomain, getLabel, getOverride, getOwnerList, getResult, redo, setOverride, undo
 
Methods inherited from class org.eclipse.emf.common.command.AbstractCommand
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.common.command.Command
chain
 

 

Field Detail

 

 

LABEL

protected static final String LABEL

This caches the label.


 

 

DESCRIPTION

protected static final String DESCRIPTION

This cachaes the description.


 

 

DESCRIPTION_FOR_LIST

protected static final String DESCRIPTION_FOR_LIST

This cachaes the description for a list-based addition.


 

 

owner

protected EObject owner

This is the owner object upon which the command will act. It could be null in the case that we are dealing with an EList.


 

 

feature

protected EStructuralFeature feature

This is the feature of the owner object upon the command will act. It could be null, in the case that we are dealing with an EList.


 

 

ownerList

protected EList ownerList

This is the list to which the command will add the collection.


 

 

collection

protected Collection collection

This is the collection of objects being added to the owner list.


 

 

index

protected int index

This is the position at which the objects will be inserted.


 

 

affectedObjects

protected Collection affectedObjects

This is the value returned by Command.getAffectedObjects(). The affected objects are different after an execute than after an undo, so we record it.

Constructor Detail

 

 

AddCommand

public AddCommand(EditingDomain domain,
                  EObject owner,
                  EStructuralFeature feature,
                  Object value)

This constructs a primitive command to add a particular value to the specified many-valued feature of the owner.


 

 

AddCommand

public AddCommand(EditingDomain domain,
                  EObject owner,
                  EStructuralFeature feature,
                  Object value,
                  int index)

This constructs a primitive command to insert particular value into the specified many-valued feature of the owner.


 

 

AddCommand

public AddCommand(EditingDomain domain,
                  EObject owner,
                  EStructuralFeature feature,
                  Collection collection)

This constructs a primitive command to add a collection of values to the specified many-valued feature of the owner.


 

 

AddCommand

public AddCommand(EditingDomain domain,
                  EObject owner,
                  EStructuralFeature feature,
                  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

public AddCommand(EditingDomain domain,
                  EList list,
                  Object value)

This constructs a primitive command to add a particular value into the specified extent.


 

 

AddCommand

public AddCommand(EditingDomain domain,
                  EList list,
                  Object value,
                  int index)

This constructs a primitive command to insert particular value into the specified extent.


 

 

AddCommand

public AddCommand(EditingDomain domain,
                  EList list,
                  Collection collection)

This constructs a primitive command to insert a collection of values into the specified extent.


 

 

AddCommand

public AddCommand(EditingDomain domain,
                  EList list,
                  Collection collection,
                  int index)

This constructs a primitive command to insert a collection of values into the specified extent.

Method Detail

 

 

create

public static Command create(EditingDomain domain,
                             Object owner,
                             Object feature,
                             Object value)

This creates a command to add a particular value to the specified feature of the owner. The feature will often be null because the domain will deduce it.


 

 

create

public static Command create(EditingDomain domain,
                             Object owner,
                             Object feature,
                             Object value,
                             int index)

This creates a command to insert particular value at a particular index in the specified feature of the owner. The feature will often be null because the domain will deduce it.


 

 

create

public static Command create(EditingDomain domain,
                             Object owner,
                             Object feature,
                             Collection collection)

This creates a command to add a collection of values to the specified feature of the owner. The feature will often be null because the domain will deduce it.


 

 

create

public static Command create(EditingDomain domain,
                             Object owner,
                             Object feature,
                             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. The feature will often be null because the domain will deduce it.


 

 

getOwner

public EObject getOwner()

This returns the owner object upon which the command will act. It could be null in the case that we are dealing with an EList.


 

 

getFeature

public EStructuralFeature getFeature()

This returns the feature of the owner object upon the command will act. It could be null, in the case that we are dealing with an EList.


 

 

getOwnerList

public EList getOwnerList()

This returns the list to which the command will add.


 

 

getCollection

public Collection getCollection()

This returns the collection of objects being added.


 

 

getIndex

public int getIndex()

This returns the position at which the objects will be added.


 

 

prepare

protected boolean prepare()

Description copied from class: AbstractCommand
Called at most once in 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.

Overrides:
prepare in class AbstractCommand

Returns:
whether the command is executable.


 

 

doExecute

public void doExecute()

Description copied from interface: OverrideableCommand
This is overrideable command's implementation of execute.

Specified by:
doExecute in interface OverrideableCommand
Specified by:
doExecute in class AbstractOverrideableCommand


 

 

doUndo

public void doUndo()

Description copied from interface: OverrideableCommand
This is overrideable command's implementation of undo.

Specified by:
doUndo in interface OverrideableCommand
Specified by:
doUndo in class AbstractOverrideableCommand


 

 

doRedo

public void doRedo()

Description copied from interface: OverrideableCommand
This is overrideable command's implementation of redo.

Specified by:
doRedo in interface OverrideableCommand
Specified by:
doRedo in class AbstractOverrideableCommand


 

 

doGetResult

public Collection doGetResult()

Description copied from interface: OverrideableCommand
This is overrideable command's implementation of getResult.

Specified by:
doGetResult in interface OverrideableCommand
Overrides:
doGetResult in class AbstractOverrideableCommand


 

 

doGetAffectedObjects

public Collection doGetAffectedObjects()

Description copied from interface: OverrideableCommand
This is overrideable command's implementation of getAffectedObjects.

Specified by:
doGetAffectedObjects in interface OverrideableCommand
Overrides:
doGetAffectedObjects in class AbstractOverrideableCommand


 

 

toString

public 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.

Overrides:
toString in class AbstractOverrideableCommand


 

Overview

 
Package  Use  Tree  Deprecated  Index  Help 
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