Runtime

## org.eclipse.gmf.runtime.diagram.ui.parts
Class DiagramCommandStack

    java.lang.Object
      org.eclipse.gef.commands.CommandStack
          org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack

public class DiagramCommandStack
extends CommandStack

GEF command stack that delegates to an `IOperationHistory`.

Field Summary

Fields inherited from class org.eclipse.gef.commands.CommandStack
`listeners, POST_EXECUTE, POST_REDO, POST_UNDO, PRE_EXECUTE, PRE_REDO, PRE_UNDO`

Constructor Summary
`DiagramCommandStack(IDiagramEditDomain editDomain)` Initializes me with my diagram edit domain and undo context.

Method Summary
`void` `addCommandStackListener(CommandStackListener listener)` Adds a listener to this CommandStack.
`boolean` `canRedo()` Returns `true` if there is a Command to redo.
`boolean` `canUndo()` Returns `true` if the last Command executed can be undone.
`void` `dispose()`
`void` `execute(Command command)` Executes the given Command if it can execute.
`void` `execute(Command command, IProgressMonitor progressMonitor)` Executes the given Command if it can execute.
`protected void` `execute(ICommand command)` exectus a the supplied command
`protected void` `execute(ICommand command, IProgressMonitor progressMonitor)` executes the supplied command
`protected IDiagramEditDomain` `getDiagramEditDomain()` Returns the editDomain.
`static ICommand` `getICommand(Command command)` Converts a GEF `Command` into a GMF `ICommand`
`static ICommand` `getICommand(ICommand command)` Removes redundancies from `command` by stripping out layers of command wrappers used to accomodate the use of GEF commands on an `IOperationHistory` and `ICommand`s on the GEF `CommandStack`.
`Command` `getMostRecentCommand()` Returns the most recently executed command.
`protected IOperationHistory` `getOperationHistory()` Gets my operation history delegate.
`Command` `getRedoCommand()` getRedoCommand Returns the command at the top of the redo stack.
`static java.util.Collection` `getReturnValues(Command c)` Gets the return values of the given executed command
`static java.util.Collection` `getReturnValues(CommandProxy cmd)` gets the return the values for the supplied command.
`static java.util.Collection` `getReturnValues(ICommand cmd)` gets the return the values for the supplied command.
`static java.util.Collection` `getReturnValues(ICommandProxy cmd)` gets the return the values for the supplied command.
`Command` `getUndoCommand()` getUndoCommand() Returns the next command to be undone.
`IUndoContext` `getUndoContext()` Gets my undo context.
`void` `redo()` Executes the last undone Command.
`void` `removeCommandStackListener(CommandStackListener listener)` Removes the given CommandStackListener.
`void` `setOperationHistory(IOperationHistory operationHistory)` Sets my operation history delegate.
`void` `setUndoContext(IUndoContext undoContext)` Sets my undo context.
`void` `undo()` Undoes the last executed Command.

Methods inherited from class org.eclipse.gef.commands.CommandStack
`addCommandStackEventListener, flush, getCommands, getUndoLimit, isDirty, markSaveLocation, notifyListeners, notifyListeners, removeCommandStackEventListener, setUndoLimit`

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

Constructor Detail

### DiagramCommandStack

    public DiagramCommandStack(IDiagramEditDomain editDomain)

  Initializes me with my diagram edit domain and undo context.

Parameters:
  `editDomain` - the editing domain assoicated with this stack

Method Detail

### addCommandStackListener

    public void addCommandStackListener(CommandStackListener listener)

  Adds a listener to this CommandStack.

  Parameters:
    `listener` - The Object listening to this CommandStack.

### canRedo

    public boolean canRedo()

  Returns `true` if there is a Command to redo.

  Returns:
    `true` if there is a Command to redo.

### canUndo

    public boolean canUndo()

  Returns `true` if the last Command executed can be undone.

  Returns:
    `true` if the last Command executed can be undone.

### execute

    public void execute(Command command)

  Executes the given Command if it can execute.

  Parameters:
    `command` - The Command to execute.

### execute

    public void execute(Command command,
                        IProgressMonitor progressMonitor)

  Executes the given Command if it can execute.

  Parameters:
    `command` - The Command to execute.
    `progressMonitor` -

### execute

    protected void execute(ICommand command)

  exectus a the supplied command

  Parameters:
    `command` - the command to execute

### execute

    protected void execute(ICommand command,
                           IProgressMonitor progressMonitor)

  executes the supplied command

  Parameters:
    `command` - the command to exectue
    `progressMonitor` -

### getICommand

    public static ICommand getICommand(Command command)

  Converts a GEF `Command` into a GMF `ICommand`

  Parameters:
    `command` - the GEF command
  Returns:
    the GMF command

### getICommand

    public static ICommand getICommand(ICommand command)

  Removes redundancies from `command` by stripping out layers of command wrappers used to accomodate the use of GEF commands on an `IOperationHistory` and `ICommand`s on the GEF `CommandStack`.

  Parameters:
    `command` - the command to be processed
  Returns:
    a command representing the simplified form of the input command. May be a new command.

### getMostRecentCommand

    public Command getMostRecentCommand()

  Returns the most recently executed command.

  Returns:
    The most recently executed command.

### getRedoCommand

    public Command getRedoCommand()

  getRedoCommand Returns the command at the top of the redo stack.

  See Also:
    `CommandStack.getRedoCommand()`

### getUndoCommand

    public Command getUndoCommand()

  getUndoCommand() Returns the next command to be undone.

  See Also:
    `CommandStack.getUndoCommand()`

### redo

    public void redo()

  Executes the last undone Command.

### removeCommandStackListener

    public void removeCommandStackListener(CommandStackListener listener)

  Removes the given CommandStackListener.

  Parameters:
    `listener` - The object to be removed from the list of listeners.

### undo

    public void undo()

  Undoes the last executed Command.

### getDiagramEditDomain

    protected IDiagramEditDomain getDiagramEditDomain()

  Returns the editDomain.

  Returns:
    IDiagramEditDomain

### getOperationHistory

    protected IOperationHistory getOperationHistory()

  Gets my operation history delegate.

  Returns:
    my operation history delegate

### setOperationHistory

    public void setOperationHistory(IOperationHistory operationHistory)

  Sets my operation history delegate.

  Parameters:
    `operationHistory` - my operation history delegate

### getReturnValues

    public static java.util.Collection getReturnValues(Command c)

  Gets the return values of the given executed command

  Parameters:
    `c` - The command
  Returns:
    A collection of values returned by the given command

### getReturnValues

    public static java.util.Collection getReturnValues(ICommandProxy cmd)

  gets the return the values for the supplied command.

  Parameters:
    `cmd` - command to use
  Returns:
    a collection of return values

### getReturnValues

    public static java.util.Collection getReturnValues(CommandProxy cmd)

  gets the return the values for the supplied command.

  Parameters:
    `cmd` - command to use
  Returns:
    a collection of return values

### getReturnValues

    public static java.util.Collection getReturnValues(ICommand cmd)

  gets the return the values for the supplied command.

  Parameters:
    `cmd` - command to use
  Returns:
    a collection of return values

### getUndoContext

    public IUndoContext getUndoContext()

  Gets my undo context. I add my context to all commands executed through me.

  Returns:
    my undo context

### setUndoContext

    public void setUndoContext(IUndoContext undoContext)

  Sets my undo context.

  Parameters:
    `undoContext` - my undo context

### dispose

    public void dispose()

Runtime

Guidelines for using Eclipse APIs.

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