Runtime

## org.eclipse.gmf.runtime.emf.type.core.commands
Class CreateElementCommand

    java.lang.Object
      org.eclipse.core.commands.operations.AbstractOperation
          org.eclipse.emf.workspace.AbstractEMFOperation
              org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand
                  org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand
                      org.eclipse.gmf.runtime.emf.type.core.commands.CreateElementCommand

All Implemented Interfaces:
  IUndoableOperation, ICommand, org.eclipse.gmf.runtime.common.core.internal.command.ICommandWithSettableResult

Direct Known Subclasses:
  CreateRelationshipCommand

    public class CreateElementCommand

extends EditElementCommand

Command to create a new model element.

Constructor Summary
`CreateElementCommand(CreateElementRequest request)` Constructs a new element creation command for the `request`.

Method Summary
`boolean` `canExecute()` Checks that the element to be modified by this command is of the correct kind.
`protected ConfigureRequest` `createConfigureRequest()` Creates the request to configure the new element.
`protected org.eclipse.emf.ecore.EObject` `doDefaultElementCreation()` Subclasses should implement this to override the basic element creation.
`protected CommandResult` `doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)` Implemented by subclasses to perform the model changes.
`protected org.eclipse.emf.ecore.EReference` `getContainmentFeature()` Gets the containment feature for the new element.
`CreateElementRequest` `getCreateRequest()` Gets the create request.
`protected IStatus` `getDefaultElementCreationStatus()` Gets the status of the default element creation.
`protected org.eclipse.emf.ecore.EClass` `getEClassToEdit()` Gets the EClass of the element to be edited.
`protected org.eclipse.emf.ecore.EObject` `getElementToEdit()` Initializes the container of the new element by asking the create to create the container, if necessary.
`protected IElementType` `getElementType()` Gets the element type for the new element.
`org.eclipse.emf.ecore.EObject` `getNewElement()` Gets the new element that was created by this command.
`protected void` `setContainmentFeature(org.eclipse.emf.ecore.EReference containmentFeature)` Sets the containment feature for the new element.
`protected void` `setDefaultElementCreationStatus(IStatus status)` Sets the status of the default element creation.

Methods inherited from class org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand
`getAffectedFiles, getEClass, getRequest, isOK, setEClass, setElementToEdit`

Methods inherited from class org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand
`aggregateStatuses, cleanup, compose, didRedo, didUndo, doExecute, doRedo, doUndo, getAffectedFiles, getCommandResult, getWorkspaceFiles, getWorkspaceFiles, internalSetResult, reduce, setResult`

Methods inherited from class org.eclipse.emf.workspace.AbstractEMFOperation
`canRedo, canSetOptions, canUndo, didCommit, dispose, execute, getChange, getEditingDomain, getOptions, isReuseParentTransaction, redo, setOptions, setReuseParentTransaction, undo`

Methods inherited from class org.eclipse.core.commands.operations.AbstractOperation
`addContext, getContexts, getLabel, hasContext, removeContext, setLabel, toString`

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

Methods inherited from interface org.eclipse.gmf.runtime.common.core.command.ICommand
`setLabel`

Methods inherited from interface org.eclipse.core.commands.operations.IUndoableOperation
`addContext, canRedo, canUndo, dispose, execute, getContexts, getLabel, hasContext, redo, removeContext, undo`

Constructor Detail

### CreateElementCommand

    public CreateElementCommand(CreateElementRequest request)

  Constructs a new element creation command for the `request`.

  Parameters:
    `request` - the element creation request

Method Detail

### doExecuteWithResult

    protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
                                                IAdaptable info)
                                         throws ExecutionException

  Description copied from class: `AbstractTransactionalCommand`
  Implemented by subclasses to perform the model changes. These changes are applied by manipulation of the EMF metamodel's API, not by executing commands on the editing domain's command stack.

  Specified by:
    `doExecuteWithResult` in class `AbstractTransactionalCommand`
  Parameters:
    `monitor` - the progress monitor provided by the operation history
    `info` - the adaptable provided by the operation history
  Returns:
    the result of the execution
  Throws:
    `ExecutionException` - if, for some reason, I fail to complete the operation

### createConfigureRequest

    protected ConfigureRequest createConfigureRequest()

  Creates the request to configure the new element.

  Returns:
    the request

### doDefaultElementCreation

    protected org.eclipse.emf.ecore.EObject doDefaultElementCreation()

  Subclasses should implement this to override the basic element creation.

  Returns:
    the new model element that has been created

### getDefaultElementCreationStatus

    protected IStatus getDefaultElementCreationStatus()

  Gets the status of the default element creation.

  Returns:
    the status
  Since:
    1.2

### setDefaultElementCreationStatus

    protected void setDefaultElementCreationStatus(IStatus status)

  Sets the status of the default element creation.

  Parameters:
    `status` - the new status
  Since:
    1.2

### getElementToEdit

    protected org.eclipse.emf.ecore.EObject getElementToEdit()

  Initializes the container of the new element by asking the create to create the container, if necessary.

  Overrides:
    `getElementToEdit` in class `EditElementCommand`
  Returns:
    the element to be modified

### getEClassToEdit

    protected org.eclipse.emf.ecore.EClass getEClassToEdit()

  Gets the EClass of the element to be edited.

  Overrides:
    `getEClassToEdit` in class `EditElementCommand`
  Returns:
    the EClass

### getContainmentFeature

    protected org.eclipse.emf.ecore.EReference getContainmentFeature()

  Gets the containment feature for the new element.

  Returns:
    the containment feature

### setContainmentFeature

    protected void setContainmentFeature(org.eclipse.emf.ecore.EReference containmentFeature)

  Sets the containment feature for the new element.

  Parameters:
    `containmentFeature` - the containment feature for the new element

### getElementType

    protected IElementType getElementType()

  Gets the element type for the new element.

  Returns:
    the element type

### getCreateRequest

    public CreateElementRequest getCreateRequest()

  Gets the create request.

  Returns:
    the create request

### canExecute

    public boolean canExecute()

  Description copied from class: `EditElementCommand`
  Checks that the element to be modified by this command is of the correct kind.

  Specified by:
    `canExecute` in interface `IUndoableOperation`
  Overrides:
    `canExecute` in class `EditElementCommand`

### getNewElement

    public org.eclipse.emf.ecore.EObject getNewElement()

  Gets the new element that was created by this command. Will be `null` if the command has not been executed.

  Returns:
    the new element

Runtime

Guidelines for using Eclipse APIs.

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