|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dsto.dfc.util.BasicPropertyEventSource dsto.dfc.swing.undo.MonitoredUndoManager
public class MonitoredUndoManager
Provides the same functions as the Swing UndoManager, plus provides functionality to skip non-undoable edits in the middle of the history list. Note that the non-undoable edit and subsequent edits are removed if they are skipped because they are rendered invalid.
Field Summary | |
---|---|
static int |
DEFAULT_LIMIT
The default limit placed on the number of undo's. |
protected EditListModel |
edits
The list of edits. |
protected int |
indexOfNextAdd
The index at which to place the next edit added to the manager. |
protected int |
limit
The maximum number of edits stored in the undo list. |
static UndoableEdit |
NULL_EDIT
Null object pattern - the cursors will point to valid edits or NULL_EDIT. |
UndoableEdit |
redoCursor
The next edit to be redone in the edit list. |
UndoableEdit |
undoCursor
The last edit which can be undone in the edit list. |
protected Object |
undoRedoSemaphore
Thread lock. |
Constructor Summary | |
---|---|
MonitoredUndoManager()
|
Method Summary | |
---|---|
void |
addEdit(UndoableEdit edit)
Add an edit to list at position of undoCursor, and advance cursor. |
void |
broadcastEditEventsTo(UndoableEditListener newEditEventRecorder)
By invoking this method, the editEventRecorder will 'hear' every UndoableEdit that the MonitoredUndoManager
'hears'. |
boolean |
canRedo()
True if the manager can execute a redo operation. |
boolean |
canUndo()
True if the manager can execute an undo operation. |
boolean |
containsAllEdits(List someEdits)
Returns true if all edits in someEdits are known to the MonitoredUndoManager and false otherwise. |
boolean |
containsEdit(UndoableEdit edit)
Returns true if edit is known to the MonitoredUndoManager . |
void |
discardAllEdits()
Removes all edits from the undo stack and calls UndoableEdit.die() for each edit. |
protected void |
dropEdit(int index)
Drops the edit at index and handles moving of the cursors. |
void |
dropEdit(UndoableEdit unwantedEdit)
Drops the unwantedEdit and handles the moving of cursors. |
void |
dropEdits(Collection unwantedEdits)
Drops the collection of unwantedEdits and handles updating of cursors. |
protected void |
dropEdits(int start,
int end)
Drop all edits between two indices. |
void |
dropFirstEdit()
Drops the first edit in the edit list and handles the moving of cursors. |
protected boolean |
editQueueIsFull()
Internal test to determine if edits is full and edits need to be
dropped before more can be added. |
int |
getEditCount()
The number of edits on the undo stack. |
UndoableEdit |
getEditOrNullEdit(int i)
Get an edit for a given index into the undo stack. |
EditListModel |
getEdits()
Returns the list of edits maintained by the MonitoredUndoManager . |
int |
getLimit()
The maximum number of edits that will be kept on the stack. |
static MonitoredUndoManager |
getOrCreateUndoManager(Component c)
Get or create a monitored undomanager for the window containing a given component. |
String |
getPresentationName()
Get the name of the next edit to be undone using its getPresentationName () method. |
UndoableEdit |
getRedoCursor()
Returns the next edit in line to be redone. |
String |
getRedoPresentationName()
Get the human readable name for the next edit that will be redone by redo (). |
UndoableEdit |
getUndoCursor()
Returns the undo cursor which points to the last edit not undone. |
String |
getUndoPresentationName()
Get the human readable name for the next edit that will be undone by undo() . |
protected void |
handleMoveEdits(int insertionIndex,
List droppedEdits)
For drop'n'drag support of edits. |
protected void |
handleSkipUndoRamifications()
Drops all edits beyond the undo cursor when an undo is skipped. |
int |
indexOfEdit(UndoableEdit edit)
Returns the index of edit if it's known, and -1 if it isn't. |
int |
indexOfRedoCursor()
Returns the index of the redo cursor. |
int |
indexOfUndoCursor()
Returns the index of the undo cursor. |
boolean |
inRedoList(UndoableEdit edit)
Returns true if edit is in the redo list and false otherwise. |
boolean |
insertEdit(int index,
UndoableEdit newEdit)
Insert newEdit at index. |
void |
insertEdits(int index,
Collection newEdits)
Inserts the edits in newEdits at index. |
boolean |
inUndoList(UndoableEdit edit)
Returns true if edit is in the undo list and false otherwise. |
int |
lastIndex()
Returns the index of the last edit in the list. |
boolean |
missingFromRedoList(UndoableEdit edit)
Returns true if edit is not in the redo list. |
boolean |
missingFromUndoList(UndoableEdit edit)
Returns true if edit is not in the undo list. |
protected void |
moveCursorsBackward()
Moves the cursors one step backwards. |
protected void |
moveCursorsForward()
Moves the cursors one step forward. |
void |
redo()
Redo the next available redoable edit. |
boolean |
redoCursorIsNull()
Returns true if the redo cursor is the NULL_EDIT . |
void |
redoTo(UndoableEdit endEdit)
Redo the edits up to and including endEdit. |
void |
setLimit(int newLimit)
Sets the maximum number of edits kept on the stack. |
protected void |
setRedoCursor(UndoableEdit newCursor)
|
protected void |
setUndoCursor(UndoableEdit newCursor)
Sets the current cursor to newEdit which has not been undone. |
void |
skipRedo()
Skip the current redoable edit at move the cursors forward one step. |
void |
skipUndo()
Skips a non-undoable edit, moving the undo cursor to the previous edit and removing the non-undoable edit and the invalid edits after it. |
void |
stopBroadcastingEditEvents()
Deregisters the currently registered editEventRecorder. |
void |
undo()
Undoes the edit at the undo cursor and shifts the cursor backwards one step. |
void |
undoableEditHappened(UndoableEditEvent e)
UndoableEditListener interface implementation. |
boolean |
undoCursorIsNull()
Returns true if the undo cursor is the NULL_EDIT . |
void |
undoTo(UndoableEdit endEdit)
Undoes the edits up to and including endEdit. |
Methods inherited from class dsto.dfc.util.BasicPropertyEventSource |
---|
addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeSource, removePropertyChangeListener, setPropertyChangeSource |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_LIMIT
public static final UndoableEdit NULL_EDIT
protected int limit
protected EditListModel edits
protected int indexOfNextAdd
public UndoableEdit undoCursor
public UndoableEdit redoCursor
protected Object undoRedoSemaphore
Constructor Detail |
---|
public MonitoredUndoManager()
Method Detail |
---|
public static MonitoredUndoManager getOrCreateUndoManager(Component c)
public int getLimit()
public void setLimit(int newLimit)
newLimit
- The new maximum edit limit.public EditListModel getEdits()
MonitoredUndoManager
.
public void discardAllEdits()
UndoableEdit.die()
for each edit.
public boolean canUndo()
public boolean canRedo()
public String getUndoPresentationName()
undo()
.
canUndo()
public String getRedoPresentationName()
canRedo()
public String getPresentationName()
public UndoableEdit getEditOrNullEdit(int i)
i
- The index of the edit.
getEditCount()
public int getEditCount()
protected void setUndoCursor(UndoableEdit newCursor)
newEdit
which has not been undone.
public UndoableEdit getUndoCursor()
protected void setRedoCursor(UndoableEdit newCursor)
public UndoableEdit getRedoCursor()
public boolean containsEdit(UndoableEdit edit)
MonitoredUndoManager
.
public boolean containsAllEdits(List someEdits)
MonitoredUndoManager
and false otherwise.
public int lastIndex()
protected boolean editQueueIsFull()
edits
is full and edits need to be
dropped before more can be added.
public void addEdit(UndoableEdit edit)
edit
- The edit to be added to the stack.public boolean insertEdit(int index, UndoableEdit newEdit)
public void insertEdits(int index, Collection newEdits)
protected void moveCursorsForward()
protected void moveCursorsBackward()
public void redo() throws CannotRedoException
CannotRedoException
- if there are no redoable edits.public void redoTo(UndoableEdit endEdit) throws CannotRedoException
CannotRedoException
public void undo() throws CannotUndoException
CannotUndoException
public void undoTo(UndoableEdit endEdit) throws CannotUndoException
CannotUndoException
public void skipUndo()
protected void handleSkipUndoRamifications()
public void skipRedo()
public boolean inUndoList(UndoableEdit edit)
public boolean missingFromUndoList(UndoableEdit edit)
public boolean inRedoList(UndoableEdit edit)
public boolean missingFromRedoList(UndoableEdit edit)
public int indexOfEdit(UndoableEdit edit)
public int indexOfUndoCursor()
public int indexOfRedoCursor()
public void undoableEditHappened(UndoableEditEvent e)
addEdit(javax.swing.undo.UndoableEdit)
to
add the edit to the stack.
undoableEditHappened
in interface UndoableEditListener
public void dropFirstEdit()
protected void dropEdit(int index)
protected void dropEdits(int start, int end)
start
- The first index.end
- The second index. start <= end or this method does nothing.public void dropEdit(UndoableEdit unwantedEdit)
public void dropEdits(Collection unwantedEdits)
public void broadcastEditEventsTo(UndoableEditListener newEditEventRecorder)
UndoableEdit
that the MonitoredUndoManager
'hears'. Only one editEventRecorder can be registered with the MonitoredUndoManager
at any one time.
public void stopBroadcastingEditEvents()
public boolean undoCursorIsNull()
NULL_EDIT
.
public boolean redoCursorIsNull()
NULL_EDIT
.
protected void handleMoveEdits(int insertionIndex, List droppedEdits)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |