Runtime

## org.eclipse.gmf.runtime.diagram.ui.commands
Class CreateCommand

    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.diagram.ui.commands.CreateCommand

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

public class CreateCommand
extends AbstractTransactionalCommand

A view creation command that creates a `View`. After execution, the command result is a singleton list containing an `IAdatable` object that adapts to `View`. Before execution, after undo or after redo, the returned `IAdaptable` adapts to nothing (will return `null` when adapted to `View`)

Field Summary
`protected View` `containerView` The container view
`protected CreateViewRequest.ViewDescriptor` `viewDescriptor` the view descriptor

Constructor Summary
`CreateCommand(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, CreateViewRequest.ViewDescriptor viewDescriptor, View containerView)` Creates a new CreateCommand

Method Summary
`boolean` `canExecute()`
`protected CommandResult` `doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)` Implemented by subclasses to perform the model changes.
`java.util.List` `getAffectedFiles()` Returns the `IFile`s for resources that may be modified when the operation is executed, undone or redone.
`protected View` `getContainerView()` give access to the view, where that will contain the created view
`protected CreateViewRequest.ViewDescriptor` `getViewDescriptor()` Return the cached view descriprot.
`boolean` `isPersisted()` returns true if the view that will be created will be a transient view, transient views will not dirty the model and will never get serialized in the saved file

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

Methods inherited from class org.eclipse.emf.workspace.AbstractEMFOperation
`canRedo, canUndo, didCommit, dispose, execute, getChange, getEditingDomain, getOptions, redo, 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.core.commands.operations.IUndoableOperation
`addContext, canRedo, canUndo, dispose, execute, getContexts, getLabel, hasContext, redo, removeContext, undo`

Field Detail

### viewDescriptor

    protected final CreateViewRequest.ViewDescriptor viewDescriptor

  the view descriptor

### containerView

    protected final View containerView

  The container view

Constructor Detail

### CreateCommand

    public CreateCommand(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
                         CreateViewRequest.ViewDescriptor viewDescriptor,
                         View containerView)

  Creates a new CreateCommand

Parameters:
  `editingDomain` - the editing domain through which model changes are made
  `viewDescriptor` - the view descriptor associated with this command
  `containerView` - the view that will containe the new view

Method Detail

### getViewDescriptor

    protected CreateViewRequest.ViewDescriptor getViewDescriptor()

  Return the cached view descriprot.

  Returns:
    view descriprot

### getContainerView

    protected View getContainerView()

  give access to the view, where that will contain the created view

  Returns:
    the conatiner view

### 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

### canExecute

    public boolean canExecute()

### isPersisted

    public boolean isPersisted()

  returns true if the view that will be created will be a transient view, transient views will not dirty the model and will never get serialized in the saved file

  Returns:
    true if persisted false if transient

### getAffectedFiles

    public java.util.List getAffectedFiles()

  Description copied from class: `AbstractTransactionalCommand`
  Returns the `IFile`s for resources that may be modified when the operation is executed, undone or redone.

  Specified by:
    `getAffectedFiles` in interface `ICommand`
  Overrides:
    `getAffectedFiles` in class `AbstractTransactionalCommand`

Runtime

Guidelines for using Eclipse APIs.

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