|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjimm.datavision.gui.cmd.CommandHistory
public class CommandHistory
A command history holds comands and manages undo and redo behavior. To
use a new command for the first time, pass it to perform.
You can then call undo and redo to walk the
command history chain.
| Field Summary | |
|---|---|
protected int |
baselineIndex
If the command index is different than the baseline index then something has changed, and isChanged will return true. |
protected int |
commandIndex
|
protected java.util.ArrayList |
commands
|
protected javax.swing.JMenuItem |
redoMenuItem
|
protected javax.swing.JMenuItem |
undoMenuItem
|
| Constructor Summary | |
|---|---|
CommandHistory()
|
|
CommandHistory(javax.swing.JMenuItem undoMenuItem,
javax.swing.JMenuItem redoMenuItem)
|
|
| Method Summary | |
|---|---|
void |
add(Command command)
Add a command to the history list without performing it. |
boolean |
canRedo()
Answers the question, "Is there anything to redo?" |
boolean |
canUndo()
Answers the question, "Is there anything to undo?" |
java.lang.String |
getCommandName(int index)
Return the name of the command at index. |
java.lang.String |
getRedoName()
Return the name of the command that would be redone were one to call redo(). |
java.lang.String |
getUndoName()
Return the name of the command that would be undone were one to call undo(). |
boolean |
isChanged()
Answers the question, "Has anything changed?" |
void |
perform(Command command)
Perform a command and add it to the history list. |
void |
redo()
Redo the command under the the history cursor. |
void |
setBaseline()
Resets the baseline index. |
void |
setMenuItems(javax.swing.JMenuItem undoMenuItem,
javax.swing.JMenuItem redoMenuItem)
|
void |
undo()
Undo the command at the history cursor. |
protected void |
updateMenu()
|
protected void |
updateMenuItem(javax.swing.JMenuItem item,
java.lang.String verb,
java.lang.String cmdName,
boolean canDo)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.util.ArrayList commands
protected int commandIndex
protected int baselineIndex
isChanged will return true.
protected javax.swing.JMenuItem undoMenuItem
protected javax.swing.JMenuItem redoMenuItem
| Constructor Detail |
|---|
public CommandHistory()
public CommandHistory(javax.swing.JMenuItem undoMenuItem,
javax.swing.JMenuItem redoMenuItem)
| Method Detail |
|---|
public void setMenuItems(javax.swing.JMenuItem undoMenuItem,
javax.swing.JMenuItem redoMenuItem)
public boolean canUndo()
public boolean canRedo()
public void setBaseline()
isChanged returns
false only when the baseline index is equal to the
current command index.
public boolean isChanged()
public void add(Command command)
command - the command to addpublic void perform(Command command)
command - the command to performpublic void undo()
public void redo()
public java.lang.String getUndoName()
null if there is no such command.
public java.lang.String getRedoName()
null if there is no such command.
public java.lang.String getCommandName(int index)
null
if there is no such command.
protected void updateMenu()
protected void updateMenuItem(javax.swing.JMenuItem item,
java.lang.String verb,
java.lang.String cmdName,
boolean canDo)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||