public class DefaultCommandStack extends Object implements ICommandStack
ICommand,
ICommandStackListener| Constructor and Description |
|---|
DefaultCommandStack()
Creates a new command stack with a default size (number of undoable
commands).
|
DefaultCommandStack(int size)
Creates a new command stack.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCommandStackListener(ICommandStackListener l)
Adds a listener to the command stack.
|
void |
clear()
Clears the command stack, which means that the list of executed and
undone commands will be cleared and no further commands can be undone or
redone.
|
void |
execute(ICommand cmd,
IProgressMonitor monitor)
Executes the given command.
|
protected void |
fireCommandStackChanged(CommandStackEvent event)
Used internally to inform stack listeners about executed, undone or
redone commands.
|
ICommandStackListener[] |
getCommandStackListeners()
Returns all command stack listeners.
|
List<ICommand> |
getExecutedCommands()
Returns a copy of the list of executed commands.
|
ICommand |
getRedoableCommand()
Returns the command, which would be redone if the application called the
redo operation on the stack.
|
int |
getSize()
Returns the stack size as defined via the constructor or default stack
size value.
|
ICommand |
getUndoableCommand()
Returns the command, which would be undone if the application called the
undo operation on the stack.
|
List<ICommand> |
getUndoneCommands()
Returns a copy of the list of undone commands.
|
boolean |
isRedoable()
Determines whether the command stack currently supports the redo
operation.
|
boolean |
isUndoable()
Determines whether the command stack currently supports the undo
operation.
|
void |
redo(IProgressMonitor monitor)
If it is redoable then the last undone command can be redone by calling
this method.
|
void |
removeCommandStackListener(ICommandStackListener l)
Removes a listener from the command stack.
|
void |
undo(IProgressMonitor monitor)
If it is undoable then the last executed command can be undone by calling
this method.
|
public DefaultCommandStack(int size)
size - the maximum stack size and number of undoable commandspublic DefaultCommandStack()
public int getSize()
public void execute(ICommand cmd, IProgressMonitor monitor)
execute in interface ICommandStackcmd - the command to executemonitor - a monitor to report the command's progress toCommandStackEventpublic void undo(IProgressMonitor monitor)
undo in interface ICommandStackmonitor - a monitor for reporting progress of the undo operationICommandStack.undo(IProgressMonitor),
CommandStackEventpublic void redo(IProgressMonitor monitor)
redo in interface ICommandStackmonitor - a monitor for reporting the progress of the redo operationICommandStack.redo(IProgressMonitor),
CommandStackEventpublic void clear()
clear in interface ICommandStackICommandStack.clear()public boolean isUndoable()
isUndoable in interface ICommandStackICommandStack.isUndoable()public boolean isRedoable()
isRedoable in interface ICommandStackICommandStack.isRedoable()public void addCommandStackListener(ICommandStackListener l)
addCommandStackListener in interface ICommandStackl - the listener to addICommandStack.addCommandStackListener(ICommandStackListener)public void removeCommandStackListener(ICommandStackListener l)
removeCommandStackListener in interface ICommandStackl - the listener to removeICommandStack.removeCommandStackListener(ICommandStackListener)public ICommandStackListener[] getCommandStackListeners()
protected void fireCommandStackChanged(CommandStackEvent event)
event - the event to send to the listenerspublic ICommand getUndoableCommand()
getUndoableCommand in interface ICommandStackICommandStack.getUndoableCommand()public ICommand getRedoableCommand()
getRedoableCommand in interface ICommandStackICommandStack.getRedoableCommand()public List<ICommand> getExecutedCommands()
Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.