|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.undo.AbstractUndoableEdit
javax.swing.undo.CompoundEdit
javax.swing.undo.UndoManager
edu.rice.cs.drjava.model.definitions.CompoundUndoManager
public class CompoundUndoManager
Extended UndoManager with increased functionality. Can handle aggregating multiple edits into one for the purposes of undoing and redoing. It exposes editToBeUndone and editToBeRedone (under new names); they are protected methods in UndoManager. The public methods that involve composite state are synchronized, so this manager can be accessed outside of the event thread. The internal data structures _compoundEdits and _keys are not thread safe but they only accessed only by synchronized methods. The synchronization scheme (locking on this) follows UndoManager.
| Field Summary | |
|---|---|
private LinkedList<CompoundEdit> |
_compoundEdits
The compound edits we are storing. |
private LinkedList<Integer> |
_keys
The keys for the CompoundEdits we are storing. |
private int |
_nextKey
The next key to use for nested CompoundEdits. |
private GlobalEventNotifier |
_notifier
Keeps track of the listeners to this undo manager. |
private UndoableEdit |
_savePoint
The last edit that was performed before the last save. |
private static int |
counter
|
private int |
id
|
(package private) static Log |
LOG
|
| Fields inherited from class javax.swing.undo.CompoundEdit |
|---|
edits |
| Fields inherited from class javax.swing.undo.AbstractUndoableEdit |
|---|
RedoName, UndoName |
| Constructor Summary | |
|---|---|
CompoundUndoManager(GlobalEventNotifier notifier)
Standard constructor. |
|
| Method Summary | |
|---|---|
boolean |
_compoundEditInProgress()
Returns whether or not a compound edit is in progress. |
private void |
_notifyUndoHappened()
Helper method to notify the view that an undoable edit has occured. |
boolean |
addEdit(UndoableEdit e)
Adds an edit. |
boolean |
canUndo()
Returns true when a compound edit is in progress, or when there are valid stored undoable edits |
void |
documentSaved()
Informs this undo manager that the document has been saved. |
private void |
endCompoundEdit()
Ends the compoundEdit in progress if any. |
void |
endCompoundEdit(int key)
Ends a compound edit. |
void |
endLastCompoundEdit()
Ends the last compound edit that was created. |
CompoundEdit |
getLastCompoundEdit()
Gets the last Compound Edit entered into the list. |
UndoableEdit |
getNextRedo()
Gets the next redo. |
UndoableEdit |
getNextUndo()
Gets the next undo. |
String |
getUndoPresentationName()
Returns the presentation name for this undo, or delegates to super if none is available |
boolean |
isModified()
Determines if the document is in the same undo state as it was when it was last saved. |
void |
redo()
Overrides redo so that any compound edit in progress is ended before the redo is performed. |
int |
startCompoundEdit()
Starts a compound edit. |
String |
toString()
|
void |
undo()
Undoes the last undoable edit, or compound edit created by the user. |
| Methods inherited from class javax.swing.undo.UndoManager |
|---|
canRedo, canUndoOrRedo, discardAllEdits, editToBeRedone, editToBeUndone, end, getLimit, getRedoPresentationName, getUndoOrRedoPresentationName, redoTo, setLimit, trimEdits, trimForLimit, undoableEditHappened, undoOrRedo, undoTo |
| Methods inherited from class javax.swing.undo.CompoundEdit |
|---|
die, getPresentationName, isInProgress, isSignificant, lastEdit |
| Methods inherited from class javax.swing.undo.AbstractUndoableEdit |
|---|
replaceEdit |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
static Log LOG
private static volatile int counter
private final int id
private final LinkedList<CompoundEdit> _compoundEdits
private final LinkedList<Integer> _keys
private volatile int _nextKey
private volatile UndoableEdit _savePoint
private final GlobalEventNotifier _notifier
| Constructor Detail |
|---|
public CompoundUndoManager(GlobalEventNotifier notifier)
| Method Detail |
|---|
public int startCompoundEdit()
public void endLastCompoundEdit()
public void endCompoundEdit(int key)
key - the key that was returned by startCompoundEdit()public CompoundEdit getLastCompoundEdit()
public UndoableEdit getNextUndo()
public UndoableEdit getNextRedo()
public boolean addEdit(UndoableEdit e)
addEdit in interface UndoableEditaddEdit in class UndoManagere - the edit to be added
public boolean _compoundEditInProgress()
public boolean canUndo()
canUndo in interface UndoableEditcanUndo in class UndoManagerpublic String getUndoPresentationName()
getUndoPresentationName in interface UndoableEditgetUndoPresentationName in class UndoManagerpublic void undo()
undo in interface UndoableEditundo in class UndoManagerpublic void redo()
redo in interface UndoableEditredo in class UndoManagerprivate void _notifyUndoHappened()
private void endCompoundEdit()
public void documentSaved()
public boolean isModified()
public String toString()
toString in class UndoManager
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||