Runtime

## org.eclipse.gmf.runtime.emf.type.core.edithelper
Class AbstractEditHelper

    java.lang.Object
      org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper

All Implemented Interfaces:
  IEditHelper

    public abstract class AbstractEditHelper

extends java.lang.Object
implements IEditHelper

Abstract edit helper implementation. Implements the default edit command algorithm, which returns a composite command containing the following:

1. 'before' commands from matching element types and specializations
2. 'instead' command from this edit helper
3. 'after' commands from matching element types and specializations

The before and after commands are obtained by consulting the edit helper advice that is bound to the edit helper context in the edit request. Edit helper advice can be inherited from supertypes.

Clients should subclass this class when creating new edit helpers.

Constructor Summary
`AbstractEditHelper()`

Method Summary
`protected boolean` `approveRequest(IEditCommandRequest request)` Approves the edit gesture described in the `request`.
`boolean` `canEdit(IEditCommandRequest req)` Checks that I can get an executable edit command.
`protected void` `configureRequest(IEditCommandRequest request)` Approves the edit gesture described in the `request`.
`protected ICompositeCommand` `createCommand(IEditCommandRequest req)` Creates a new composite command.
`protected ICommand` `getBasicDestroyElementCommand(DestroyElementRequest req)` Gets the command to destroy a single child of an element of my kind, and only it.
`protected ICommand` `getConfigureCommand(ConfigureRequest req)` Gets the command to configure a new element of my kind.
`java.util.List` `getContainedValues(org.eclipse.emf.ecore.EObject eContainer, org.eclipse.emf.ecore.EReference feature)` Gets the values that can be contained in the `feature` of `eContainer`.
`protected ICommand` `getCreateCommand(CreateElementRequest req)` Gets the command to create a new element in an element of my kind.
`protected ICommand` `getCreateRelationshipCommand(CreateRelationshipRequest req)` Gets the command to create a new relationship in an element of my kind.
`protected org.eclipse.emf.ecore.EReference` `getDefaultContainmentFeature(org.eclipse.emf.ecore.EClass eClass)` Gets the default feature to contain the `eClass`.
`protected java.util.Map` `getDefaultContainmentFeatures()`
`protected ICommand` `getDestroyDependentsCommand(DestroyDependentsRequest req)` Gets the command to destroy dependents of an element of my kind.
`protected ICommand` `getDestroyElementCommand(DestroyElementRequest req)` Gets the command to destroy a child of an element of my kind.
`protected ICommand` `getDestroyElementWithDependentsCommand(DestroyElementRequest req)` Gets the command to destroy a single child of an element of my kind along with its dependents (not related by containment).
`protected ICommand` `getDestroyReferenceCommand(DestroyReferenceRequest req)` Gets the command to remove a reference from an element of my kind.
`protected ICommand` `getDuplicateCommand(DuplicateElementsRequest req)` Gets the command to duplicate a child in an element of my kind.
`ICommand` `getEditCommand(IEditCommandRequest req)` Builds and returns the edit command, which is a composite command containing the following: 'before' commands from matching element type specializations 'instead' command from this edit helper 'after' commands from matching element type specializations Verifies that the edit request is approved before constructing the edit command.
`protected ICommand` `getEditContextCommand(GetEditContextRequest req)` Gets the command to create or return the edit context element for the creation of a new element of my kind (e.g., when creating a relationship, the relationship may be owned by the source or target, or some ancestor of one or the other, or both).
`protected IEditHelperAdvice[]` `getEditHelperAdvice(IEditCommandRequest req)` Gets the array of edit helper advice for this request.
`protected ICommand` `getInsteadCommand(IEditCommandRequest req)` Gets my command to do the work described in `req`.
`protected ICommand` `getMoveCommand(MoveRequest req)` Gets the command to move an element into an element of my kind.
`protected ICommand` `getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req)` Gets the command to change the source or target of a reference in an element of my kind.
`protected ICommand` `getReorientRelationshipCommand(ReorientRelationshipRequest req)` Gets the command to change the source or target of a relationship in an element of my kind.
`protected ICommand` `getSetCommand(SetRequest req)` Gets the command to set a value of an element of my kind.
`void` `initializeDefaultFeature(CreateElementRequest req)` Sets the default feature in `req`, if there is no containment feature already in the request.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AbstractEditHelper

    public AbstractEditHelper()

Method Detail

### canEdit

    public boolean canEdit(IEditCommandRequest req)

  Checks that I can get an executable edit command.

  Subclasses should override if they have a different way to decide whether or not the edit is allowed.

  Specified by:
    `canEdit` in interface `IEditHelper`
  Parameters:
    `req` - the edit request
  Returns:
    `true` if the requested edit can be performed, `false` otherwise.

### getEditCommand

    public ICommand getEditCommand(IEditCommandRequest req)

  Builds and returns the edit command, which is a composite command containing the following:
  1. 'before' commands from matching element type specializations
  2. 'instead' command from this edit helper
  3. 'after' commands from matching element type specializations

  Verifies that the edit request is approved before constructing the edit command.

  Specified by:
    `getEditCommand` in interface `IEditHelper`
  Parameters:
    `req` - the edit request
  Returns:
    the edit command, or `null` if none could be found

### configureRequest

    protected void configureRequest(IEditCommandRequest request)

  Approves the edit gesture described in the `request`. This method will be consulted before the edit request is approved.

  The default implementation does nothing. Subclasses should override if they wish to change the request parameters.

  Parameters:
    `request` - the edit request

### approveRequest

    protected boolean approveRequest(IEditCommandRequest request)

  Approves the edit gesture described in the `request`. This method will be consulted before the edit command is constructed.

  The default implementation returns `true`. Subclasses should override if they wish to provide a different answer.

  Parameters:
    `req` - the edit request
  Returns:
    `true` if the edit request is approved, `false` otherwise. No edit command will be constructed if the request is not approved.

### getEditHelperAdvice

    protected IEditHelperAdvice[] getEditHelperAdvice(IEditCommandRequest req)

  Gets the array of edit helper advice for this request.

  Parameters:
    `req` - the edit request
  Returns:
    the edit helper advice, or `null` if there is none

### createCommand

    protected ICompositeCommand createCommand(IEditCommandRequest req)

  Creates a new composite command.

  Subclasses may override to provide their own kind of composite command.

  Parameters:
    `req` - the edit request
  Returns:
    a new composite command

### getInsteadCommand

    protected ICommand getInsteadCommand(IEditCommandRequest req)

  Gets my command to do the work described in `req`.

  Delegates to the more specific methods in this class to actually get the command. Subclasses should override these more specific methods.

  Parameters:
    `req` - the edit request
  Returns:
    the command to do the requested work, or `null` if I don't support the requested work.

### getContainedValues

    public java.util.List getContainedValues(org.eclipse.emf.ecore.EObject eContainer,
                                             org.eclipse.emf.ecore.EReference feature)

  Description copied from interface: `IEditHelper`
  Gets the values that can be contained in the `feature` of `eContainer`. Such values may be element types that could be owned by the `eContainer`, or actual model element instances that can be referenced by the feature.

  Specified by:
    `getContainedValues` in interface `IEditHelper`
  Parameters:
    `eContainer` - the container object
    `feature` - the feature of the container object
  Returns:
    the possible values that can be contained in the feature

### getConfigureCommand

    protected ICommand getConfigureCommand(ConfigureRequest req)

  Gets the command to configure a new element of my kind. By default, returns `null`. Subclasses may override to provide their command.

  Parameters:
    `req` - the configure request
  Returns:
    the configure command

### getCreateRelationshipCommand

    protected ICommand getCreateRelationshipCommand(CreateRelationshipRequest req)

  Gets the command to create a new relationship in an element of my kind.

  Returns the `IdentityCommand` if the request does not have a source or a target. This ensures that the create relationship gesture is enabled until the request can be completely specified.

  Subclasses may override to provide their own command.

  Parameters:
    `req` - the create relationship request
  Returns:
    the create relationship command

### getCreateCommand

    protected ICommand getCreateCommand(CreateElementRequest req)

  Gets the command to create a new element in an element of my kind. Subclasses may override to provide their command.

  Parameters:
    `req` - the create request
  Returns:
    the create command

### initializeDefaultFeature

    public void initializeDefaultFeature(CreateElementRequest req)

  Sets the default feature in `req`, if there is no containment feature already in the request.

  Parameters:
    `req` - the create request

### getDefaultContainmentFeature

    protected org.eclipse.emf.ecore.EReference getDefaultContainmentFeature(org.eclipse.emf.ecore.EClass eClass)

  Gets the default feature to contain the `eClass`.

  Returns `null` by default. Subclasses should override to provide the default feature, if there is one.

  Parameters:
    `eClass` - the EClass
  Returns:
    the default feature

### getDefaultContainmentFeatures

    protected java.util.Map getDefaultContainmentFeatures()

### getSetCommand

    protected ICommand getSetCommand(SetRequest req)

  Gets the command to set a value of an element of my kind. By default, returns `null`. Subclasses may override to provide their command.

  Parameters:
    `req` - the set request
  Returns:
    the set command

### getEditContextCommand

    protected ICommand getEditContextCommand(GetEditContextRequest req)

  Gets the command to create or return the edit context element for the creation of a new element of my kind (e.g., when creating a relationship, the relationship may be owned by the source or target, or some ancestor of one or the other, or both). By default, returns a command that returns a `null` edit context. Subclasses may override to provide their command.

  Parameters:
    `req` - the get edit context request
  Returns:
    the get edit context command

### getBasicDestroyElementCommand

    protected ICommand getBasicDestroyElementCommand(DestroyElementRequest req)

  Gets the command to destroy a single child of an element of my kind, and only it. By default, returns a `DestroyElementCommand`. Subclasses may override to provide their own command.

  Parameters:
    `req` - the destroy request
  Returns:
    a command that destroys only the element specified as the request's element to destroy

### getDestroyElementWithDependentsCommand

    protected ICommand getDestroyElementWithDependentsCommand(DestroyElementRequest req)

  Gets the command to destroy a single child of an element of my kind along with its dependents (not related by containment). By default, returns a composite that destroys the elements and zero or more dependents.

  Parameters:
    `req` - the destroy request
  Returns:
    a command that destroys the element specified as the request's element to destroy and its non-containment dependents

### getDestroyElementCommand

    protected ICommand getDestroyElementCommand(DestroyElementRequest req)

  Gets the command to destroy a child of an element of my kind. By default, returns a composite command that destroys the element specified by the request and all of its contents.

  Parameters:
    `req` - the destroy request
  Returns:
    a command that destroys the element specified as the request's `element to destroy` along with its contents and other dependents

### getDestroyDependentsCommand

    protected ICommand getDestroyDependentsCommand(DestroyDependentsRequest req)

  Gets the command to destroy dependents of an element of my kind. By default, returns `null`. Subclasses may override to provide a command.

  Parameters:
    `req` - the destroy dependents request
  Returns:
    a command to destroy dependents, or `null`

### getDestroyReferenceCommand

    protected ICommand getDestroyReferenceCommand(DestroyReferenceRequest req)

  Gets the command to remove a reference from an element of my kind. By default, returns `null`. Subclasses may override to provide their command.

  Parameters:
    `req` - the destroy reference request
  Returns:
    the destroy reference command

### getDuplicateCommand

    protected ICommand getDuplicateCommand(DuplicateElementsRequest req)

  Gets the command to duplicate a child in an element of my kind. By default, returns `null`. Subclasses may override to provide their command.

  Parameters:
    `req` - the duplicate request
  Returns:
    the duplicate command

### getMoveCommand

    protected ICommand getMoveCommand(MoveRequest req)

  Gets the command to move an element into an element of my kind. By default, returns `null`. Subclasses may override to provide their command.

  Parameters:
    `req` - the move request
  Returns:
    the move command

### getReorientReferenceRelationshipCommand

    protected ICommand getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req)

  Gets the command to change the source or target of a reference in an element of my kind. By default, returns `null`. Subclasses may override to provide their command.

  Parameters:
    `req` - the reorient reference request
  Returns:
    the reorient reference command

### getReorientRelationshipCommand

    protected ICommand getReorientRelationshipCommand(ReorientRelationshipRequest req)

  Gets the command to change the source or target of a relationship in an element of my kind. By default, returns `null`. Subclasses may override to provide their command.

  Parameters:
    `req` - the reorient relationship request
  Returns:
    the reorient relationship command

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.