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 ICommandStack
cmd
- the command to executemonitor
- a monitor to report the command's progress toCommandStackEvent
public void undo(IProgressMonitor monitor)
undo
in interface ICommandStack
monitor
- a monitor for reporting progress of the undo operationICommandStack.undo(IProgressMonitor)
,
CommandStackEvent
public void redo(IProgressMonitor monitor)
redo
in interface ICommandStack
monitor
- a monitor for reporting the progress of the redo operationICommandStack.redo(IProgressMonitor)
,
CommandStackEvent
public void clear()
clear
in interface ICommandStack
ICommandStack.clear()
public boolean isUndoable()
isUndoable
in interface ICommandStack
ICommandStack.isUndoable()
public boolean isRedoable()
isRedoable
in interface ICommandStack
ICommandStack.isRedoable()
public void addCommandStackListener(ICommandStackListener l)
addCommandStackListener
in interface ICommandStack
l
- the listener to addICommandStack.addCommandStackListener(ICommandStackListener)
public void removeCommandStackListener(ICommandStackListener l)
removeCommandStackListener
in interface ICommandStack
l
- 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 ICommandStack
ICommandStack.getUndoableCommand()
public ICommand getRedoableCommand()
getRedoableCommand
in interface ICommandStack
ICommandStack.getRedoableCommand()
public List<ICommand> getExecutedCommands()
Copyright © 2006–2016 Dirk Lemmermann Software & Consulting. All rights reserved.