|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.vectomatic.client.rep.command.CommandHistory
public class CommandHistory
Class to represent an undo/redo stack of commands with a fixed depth. The oldest command is automatically removed when the stack capacity is exhausted.
Constructor Summary | |
---|---|
CommandHistory(int capacity)
Constructor |
Method Summary | |
---|---|
void |
addCommand(ICommand command)
Adds a new command to the stack |
void |
addCommandHistoryListener(ICommandHistoryListener listener)
|
boolean |
canRedo()
Returns true if the command stack contains a command which can be redone false otherwise. |
boolean |
canUndo()
Returns true if the command stack contains a command which can be undone false otherwise. |
void |
fireCommandHistoryChange()
|
int |
getCapacity()
Returns the stack capacity |
ICommand[] |
getCommands()
Gets all the commands currently in the stack |
int |
getCurrentCommand()
Returns the index of the current command in the array returned by getCommands(). |
ICommand |
getRedoCommand()
Returns the command which will be redone if undo is invoked |
ICommand |
getUndoCommand()
Returns the command which will be undone if undo is invoked |
boolean |
needsSaving()
|
void |
purge()
Clears the stack |
void |
redo()
Redoes the previously undone command |
void |
removeCommandHistoryListener(ICommandHistoryListener listener)
|
void |
setCapacity(int capacity)
Specifies a new capacity for the stack If the new capacity is smaller than the previous one, a proportional window of commands around the current command will be kept. |
void |
setSavePoint()
|
void |
undo()
Undoes the current command |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CommandHistory(int capacity)
capacity
- The depth of the undo stackMethod Detail |
---|
public boolean canUndo()
public boolean canRedo()
public void undo()
public void redo()
public void addCommand(ICommand command)
command
- the command to addpublic ICommand getUndoCommand()
public ICommand getRedoCommand()
public ICommand[] getCommands()
public int getCurrentCommand()
public void purge()
public void setCapacity(int capacity)
capacity
- public int getCapacity()
public void addCommandHistoryListener(ICommandHistoryListener listener)
public void removeCommandHistoryListener(ICommandHistoryListener listener)
public void fireCommandHistoryChange()
public void setSavePoint()
public boolean needsSaving()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |