Runtime

## org.eclipse.gmf.runtime.common.core.command
Interface ICommand

All Superinterfaces:
  IUndoableOperation

All Known Subinterfaces:
  ICompositeCommand

All Known Implementing Classes:
  AbstractCommand, AbstractTransactionalCommand, AddCommand, CompositeCommand, CompositeTransactionalCommand, ConfigureElementCommand, ConfigureRelationshipCommand, CreateDiagramCommand, CreateElementCommand, CreateRelationshipCommand, DeferredSetValueCommand, DeleteCommand, DestroyElementCommand, DestroyReferenceCommand, DuplicateEObjectsCommand, EditElementCommand, GetEditContextCommand, IdentityCommand, MoveElementsCommand, OneTimeCommand, RemoveBookmarkCommand, RepositionEObjectCommand, RestoreDefaultPropertyValueCommand, SetConnectionAnchorsCommand, SetConnectionEndsCommand, SetModelPropertyValueCommand, SetPropertyCommand, SetValueCommand, UnexecutableCommand

    public interface ICommand

extends IUndoableOperation

A self-composing undoable operation that has a `CommandResult` and a list of affected `IFile`s.

Executing, undoing or redoing a command can have a result which clients can obtain by using the `getCommandResult()` method. For example, executing a command that create a new entity may wish to make the new entity accessible to clients through the `getCommandResult()` method.

The command provides a list of `IFile`s that are expected to be modified when the it is executed, undone or redone. An `IOperationApprover` is registered with the `OperationHistoryFactory.getOperationHistory()` to validate the modification to these resources.

If an error occurs, or the progress monitor is canceled during execute, undo or redo, the command should make every effort to roll back the changes it has made up to that point.

Method Summary
`ICommand` `compose(IUndoableOperation operation)` Returns a new command object that represents a composition of this command with the specified `command` parameter.
`java.util.List` `getAffectedFiles()` Returns the list of `IFile`s that are expected to be modified by this command.
`CommandResult` `getCommandResult()` Retrieves the result of executing, undoing, or redoing this command, depending on which of these operations was last performed.
`ICommand` `reduce()` Returns the simplest form of this command that is equivalent.
`void` `setLabel(java.lang.String label)` Since not all commands have names, reduce() should propogate label from an upper command that may be thrown away to the resultant reduced command.

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

Method Detail

### getCommandResult

    CommandResult getCommandResult()

  Retrieves the result of executing, undoing, or redoing this command, depending on which of these operations was last performed. This value can be `null` if the operation has no meaningful result.

  The value of this result is undefined if the command has not yet been executed, undone or redone.

  Returns:
    The result of executing, undoing or redoing this command.

### getAffectedFiles

    java.util.List getAffectedFiles()

  Returns the list of `IFile`s that are expected to be modified by this command.

  Returns:
    the list of `IFile`s that will be modified

### compose

    ICommand compose(IUndoableOperation operation)

  Returns a new command object that represents a composition of this command with the specified `command` parameter.

  Parameters:
    `operation` - The operation that is to be composed with this command.
  Returns:
    A command that represents a composition of this command with the specified command.

### reduce

    ICommand reduce()

  Returns the simplest form of this command that is equivalent. Use this method to remove unnecessary nesting of commands.

  Returns:
    the simplest form of this command that is equivalent

### setLabel

    void setLabel(java.lang.String label)

  Since not all commands have names, reduce() should propogate label from an upper command that may be thrown away to the resultant reduced command. The method is needed to assign the label to a nameless command, because `IUndoableOperation` is missing this method.

  Parameters:
    `label` - command's new label

Runtime

Guidelines for using Eclipse APIs.

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