public class BasicCommandStack extends java.lang.Object implements CommandStack
Command for more details about the command methods that this implementation uses.| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<Command> |
commandList
The list of commands.
|
protected java.util.Collection<CommandStackListener> |
listeners
The
CommandStackListeners. |
protected Command |
mostRecentCommand
The command most recently executed, undone, or redone.
|
protected int |
saveIndex
The value of
top when saveIsDone() is called. |
protected int |
top
The current position within the list from which the next execute, undo, or redo, will be performed.
|
| Constructor and Description |
|---|
BasicCommandStack()
Creates a new empty instance.
|
| Modifier and Type | Method and Description |
|---|---|
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
CommandStack.redo() is called. |
Command |
getUndoCommand()
Returns the command that will be undone if
CommandStack.undo() is called. |
protected void |
handleError(java.lang.Exception exception)
Handles an exception thrown during command execution by logging it with the plugin.
|
boolean |
isSaveNeeded()
Returns whether the model has changes since
saveIsDone() was call the last. |
protected void |
notifyListeners()
This is called to ensure that
CommandStackListener.commandStackChanged(java.util.EventObject) is called for each listener. |
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 |
saveIsDone()
Called after a save has been successfully performed.
|
void |
undo()
Moves the top of the stack down, undoing what was formerly the top command.
|
protected java.util.List<Command> commandList
protected int top
protected Command mostRecentCommand
protected java.util.Collection<CommandStackListener> listeners
CommandStackListeners.protected int saveIndex
top when saveIsDone() is called.public void execute(Command command)
CommandStackexecute in interface CommandStackcommand - the command to execute.public boolean canUndo()
CommandStackcanUndo in interface CommandStackpublic void undo()
CommandStackundo in interface CommandStackpublic boolean canRedo()
CommandStackcanRedo in interface CommandStackpublic void redo()
CommandStackredo in interface CommandStackpublic void flush()
CommandStackflush in interface CommandStackpublic Command getUndoCommand()
CommandStackCommandStack.undo() is called.getUndoCommand in interface CommandStackCommandStack.undo() is called.public Command getRedoCommand()
CommandStackCommandStack.redo() is called.getRedoCommand in interface CommandStackCommandStack.redo() is called.public Command getMostRecentCommand()
CommandStackgetMostRecentCommand in interface CommandStackpublic void addCommandStackListener(CommandStackListener listener)
CommandStackaddCommandStackListener in interface CommandStacklistener - the listener to add.public void removeCommandStackListener(CommandStackListener listener)
CommandStackremoveCommandStackListener in interface CommandStacklistener - the listener to remove.protected void notifyListeners()
CommandStackListener.commandStackChanged(java.util.EventObject) is called for each listener.protected void handleError(java.lang.Exception exception)
public void saveIsDone()
public boolean isSaveNeeded()
saveIsDone() was call the last.saveIsDone was call the last.Copyright © 2018. Licensed under the Eclipse Public License v1.0. All rights reserved.
Submit a bug or feature