|
Eclipse GEF 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.gef.commands.CommandStack
An implementation of a command stack. A command stack manages the executing, undoing,
and redoing of Commands
. Executed commands are pushed onto an undo
stack. Commands that are undone are pushed onto a Redo stack. Whenever a new command is
executed, the Redo stack is flushed.
A CommandStack contains a dirty property. This property can be used to determine
when persisting the Commands' changes is required. The stack is dirty whenever the last
executed or redone command is different than the command that was at the top of the
undo stack when markSaveLocation()
was last called. Upon construction, the
undo stack is empty, and is not dirty.
Field Summary | |
protected List |
listeners
the list of CommandStackListener s |
Constructor Summary | |
CommandStack()
Constructs a command stack. |
Method Summary | |
void |
addCommandStackListener(CommandStackListener listener)
Adds the specified listener. |
boolean |
canRedo()
|
boolean |
canUndo()
|
void |
dispose()
This will dispose() all the commands in both the undo and redo stack. |
void |
execute(Command command)
Executes the specified Command if it is executable. |
void |
flush()
Flushes the entire stack and resets the save location to zero. |
Object[] |
getCommands()
|
Command |
getRedoCommand()
Peeks at the top of the redo stack. |
Command |
getUndoCommand()
Peeks at the top of the undo stack. |
int |
getUndoLimit()
Returns the undo limit. |
boolean |
isDirty()
Returns true if the stack is dirty. |
void |
markSaveLocation()
Marks the last executed or redone Command as the point at which the changes were saved. |
protected void |
notifyListeners()
Sends notification to all CommandStackListener s. |
void |
redo()
Calls redo on the Command at the top of the redo stack, and pushes that Command onto the undo stack. |
void |
removeCommandStackListener(CommandStackListener listener)
Removes the first occurance of the specified listener. |
void |
setUndoLimit(int undoLimit)
Sets the undo limit. |
void |
undo()
Undoes the most recently executed (or redone) Command. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected List listeners
CommandStackListener
s
Constructor Detail |
public CommandStack()
Method Detail |
public void addCommandStackListener(CommandStackListener listener)
listener
- the listenerpublic boolean canRedo()
true
if it is appropriate to call redo()
.public boolean canUndo()
true
if undo()
can be calledpublic void execute(Command command)
command
- the Command to executepublic void dispose()
dispose()
all the commands in both the undo and redo stack. Both
stacks will be empty afterwards.
public void flush()
public Object[] getCommands()
public Command getRedoCommand()
Command
has a label describing it.
null
public Command getUndoCommand()
Command
has a label describing it.
null
public int getUndoLimit()
-1
is used to indicate no limit.
public boolean isDirty()
markSaveLocation()
was last called.
true
if the stack is dirtypublic void markSaveLocation()
isDirty()
will be based on this checkpoint.
protected void notifyListeners()
CommandStackListener
s.
public void redo()
canUndo()
returns true
.
public void removeCommandStackListener(CommandStackListener listener)
listener
- the listenerpublic void setUndoLimit(int undoLimit)
-1
is used to indicate no limit.
undoLimit
- the undo limitpublic void undo()
canUndo()
returns true
.
|
Eclipse GEF 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |