|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.nwoods.jgo.AbstractUndoableEdit
com.nwoods.jgo.CompoundEdit
com.nwoods.jgo.UndoManager
com.nwoods.jgo.JGoUndoManager
This class is an extension of UndoManager that also keeps track of JGoDocumentEvents and produces JGoDocumentChangedEdits that get added to CompoundEdits that this undo manager manages.
JGoDocumentChangedEdit
,
JGoDocument
,
JGoDocumentEvent
,
Serialized FormNested Class Summary | |
class |
JGoUndoManager.JGoCompoundEdit
This CompoundEdit keeps track of the presentation name for this group of JGoDocumentChangedEdits that form a transaction. |
Field Summary | |
java.lang.String[] |
myViewEditPresentationNames
An array of user-visible JGoView action presentation names. |
Fields inherited from class com.nwoods.jgo.CompoundEdit |
edits |
Constructor Summary | |
JGoUndoManager()
Construct a JGoUndoManager. |
Method Summary | |
void |
discardAllEdits()
This override of UndoManager.discardAllEdits makes sure any ongoing changes are thrown away first. |
void |
documentChanged(JGoDocumentEvent e)
Implement the JGoDocumentListener interface. |
void |
endTransaction(boolean commit)
Call this method after making a set of changes to a document. |
void |
endTransaction(java.lang.String pname)
Call this method after making a set of changes to a document. |
java.util.Vector |
getAllEdits()
Return the vector of all CompoundEdits being managed by this UndoManager. |
JGoUndoManager.JGoCompoundEdit |
getCurrentEdit()
Return the current CompoundEdit, if any. |
java.util.Vector |
getCurrentEditVector()
Return the edits vector of JGoDocumentChangedEdits in the current CompoundEdit. |
int |
getTransactionLevel()
Return the number of nested transactions currently in progress. |
java.lang.String |
getViewEditPresentationName(int act)
Return a name for each of the different kinds of actions that the default JGoView provides, suitable for an UndoableEdit's presentation name. |
boolean |
isRedoing()
This predicate returns true when we are performing an redo. |
boolean |
isUndoing()
This predicate returns true when we are performing an undo. |
void |
redo()
This override of UndoManager.redo makes sure any ongoing changes are thrown away and then calls super.redo such that isRedoing() is true so that any changes that happen because of the undo operation are ignored by this document listener. |
void |
setCurrentEdit(JGoUndoManager.JGoCompoundEdit e)
Set the current CompoundEdit. |
boolean |
skipEvent(JGoDocumentEvent e)
This predicate is called by the default document listener implementation to decide whether the event is worth recording for the purposes of undo and redo. |
void |
startTransaction()
Call this method before making a set of changes to a document. |
void |
undo()
This override of UndoManager.undo makes sure any ongoing changes are bundled up into a transaction and then calls super.undo such that isUndoing() is true so that any changes that happen because of the undo operation are ignored by this document listener. |
Methods inherited from class com.nwoods.jgo.UndoManager |
addEdit, canRedo, canUndo, editToBeRedone, editToBeUndone, end, getLimit, getRedoPresentationName, getUndoPresentationName, redoTo, setLimit, trimEdits, trimForLimit, undoTo |
Methods inherited from class com.nwoods.jgo.CompoundEdit |
die, getPresentationName, isInProgress, lastEdit |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public java.lang.String[] myViewEditPresentationNames
Constructor Detail |
public JGoUndoManager()
Method Detail |
public void undo() throws CannotUndoException
undo
in interface UndoableEdit
undo
in class UndoManager
CannotUndoException
public void redo() throws CannotRedoException
redo
in interface UndoableEdit
redo
in class UndoManager
CannotRedoException
public void discardAllEdits()
discardAllEdits
in class UndoManager
public void documentChanged(JGoDocumentEvent e)
This method must be a no-op if isUndoing() or isRedoing() is true, because we must ignore any notifications from actually performing an undo or redo.
documentChanged
in interface JGoDocumentListener
e
- is a document event describing the changepublic boolean skipEvent(JGoDocumentEvent e)
e
- an event produced by the document
public int getTransactionLevel()
This should be zero between transactions. Calling startTransaction() will increment this value. Calling endTransaction will decrement this value, but not below zero. When the value is greater than zero, canUndo() and canRedo() should be false.
public void startTransaction()
By default this method does nothing except keep track of nested transactions, because the default implementation assumes all detected changes to the document should be bundled into the current CompoundEdit until a call to endTransaction.
public void endTransaction(boolean commit)
Normally one calls endTransaction(true) to indicate that we're done with a logical set of changes. Call this method with a false value to abort the ongoing changes--this will throw away the current CompoundEdit.
Note that calling endTransaction(false) does not actually undo any or all of the changes that have happened since the last call to startTransaction. Instead, only the record of those changes will be thrown away. This behavior is reasonable for the normal case because JGoView has to restore the "before" state even if no undo/redo functionality is present.
The default implementation permits calling endTransaction without a preceding call to startTransaction. In effect each endTransaction implicitly starts a new transaction after committing any ongoing JGoDocumentChangedEdits.
However, calling startTransaction without calling endTransaction may cause some surprising behavior when using undo and redo. You should be careful to make sure endTransaction is called after every logical user action for each call to startTransaction.
commit
- if true, ends the current CompoundEdit and adds it to
this UndoManager; if false, throws away any current CompoundEditpublic void endTransaction(java.lang.String pname)
Unlike endTransaction(boolean), this method assumes the transaction is being committed, and furthermore gives it a presentation name.
pname
- the presentation name for the current CompoundEdit being endedpublic java.util.Vector getAllEdits()
public java.util.Vector getCurrentEditVector()
public JGoUndoManager.JGoCompoundEdit getCurrentEdit()
public void setCurrentEdit(JGoUndoManager.JGoCompoundEdit e)
public boolean isUndoing()
public boolean isRedoing()
public java.lang.String getViewEditPresentationName(int act)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |