org.eclipse.emf.common.command
Interface CommandStack

All Known Implementing Classes:
BasicCommandStack, PersistentCommandStack

public interface CommandStack

A simple and obvious interface for an undoable stack of commands with a listener. See Command for more details about the command methods that this implementation uses and CommandStackListener for details about the listener.


Method Summary
 void addCommandStackListener(CommandStackListener listener)
          Adds a listener to the command stack, which will be notified whenever a command has been processed on the stack.
 boolean canRedo()
          Returns whether there are commands past the top of the stack that can be redone.
 boolean canUndo()
          Returns whether the top command on the stack can be undone.
 void execute(Command command)
          Clears any redoable commands not yet redone, adds the command, and then executes the command.
 void flush()
          Disposes all the commands in the stack.
 Command getMostRecentCommand()
          Returns the command most recently executed, undone, or redone.
 Command getRedoCommand()
          Returns the command that will be redone if redo() is called.
 Command getUndoCommand()
          Returns the command that will be undone if undo() is called.
 void redo()
          Moves the top of the stack up, redoing the new top command.
 void removeCommandStackListener(CommandStackListener listener)
          Removes a listener from the command stack.
 void undo()
          Moves the top of the stack down, undoing what was formerly the top command.
 

Method Detail

execute

void execute(Command command)
Clears any redoable commands not yet redone, adds the command, and then executes the command.

Parameters:
command - the command to execute.

canUndo

boolean canUndo()
Returns whether the top command on the stack can be undone.

Returns:
whether the top command on the stack can be undone.

undo

void undo()
Moves the top of the stack down, undoing what was formerly the top command.


canRedo

boolean canRedo()
Returns whether there are commands past the top of the stack that can be redone.

Returns:
whether there are commands past the top of the stack that can be redone.

getUndoCommand

Command getUndoCommand()
Returns the command that will be undone if undo() is called.

Returns:
the command that will be undone if undo() is called.

getRedoCommand

Command getRedoCommand()
Returns the command that will be redone if redo() is called.

Returns:
the command that will be redone if redo() is called.

getMostRecentCommand

Command getMostRecentCommand()
Returns the command most recently executed, undone, or redone.

Returns:
the command most recently executed, undone, or redone.

redo

void redo()
Moves the top of the stack up, redoing the new top command.


flush

void flush()
Disposes all the commands in the stack.


addCommandStackListener

void addCommandStackListener(CommandStackListener listener)
Adds a listener to the command stack, which will be notified whenever a command has been processed on the stack.

Parameters:
listener - the listener to add.

removeCommandStackListener

void removeCommandStackListener(CommandStackListener listener)
Removes a listener from the command stack.

Parameters:
listener - the listener to remove.

Copyright 2001-2012 IBM Corporation and others.
All Rights Reserved.