Package org.eclipse.emf.common.command
Interface CommandStack
- All Known Implementing Classes:
BasicCommandStack
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
Modifier and TypeMethodDescriptionvoidaddCommandStackListener(CommandStackListener listener) Adds a listener to the command stack, which will be notified whenever a command has been processed on the stack.booleancanRedo()Returns whether there are commands past the top of the stack that can be redone.booleancanUndo()Returns whether the top command on the stack can be undone.voidClears any redoable commands not yet redone, adds the command, and then executes the command.voidflush()Disposes all the commands in the stack.Returns the command most recently executed, undone, or redone.Returns the command that will be redone ifredo()is called.Returns the command that will be undone ifundo()is called.voidredo()Moves the top of the stack up, redoing the new top command.voidRemoves a listener from the command stack.voidundo()Moves the top of the stack down, undoing what was formerly the top command.
-
Method Details
-
execute
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 ifundo()is called.- Returns:
- the command that will be undone if
undo()is called.
-
getRedoCommand
Command getRedoCommand()Returns the command that will be redone ifredo()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
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
Removes a listener from the command stack.- Parameters:
listener- the listener to remove.
-