Package com.jidesoft.swing
Class DelayUndoManager
java.lang.Object
javax.swing.undo.AbstractUndoableEdit
javax.swing.undo.CompoundEdit
javax.swing.undo.UndoManager
com.jidesoft.swing.DelayUndoManager
- All Implemented Interfaces:
Serializable,EventListener,UndoableEditListener,UndoableEdit
An undo manager that aggregates UndoableEdits into one CompoundEdit if they are executed very close to each other. By
default, the gap is 500 ms. You can control it by passing in a different number in the constructor.
- See Also:
-
Field Summary
FieldsFields inherited from class javax.swing.undo.CompoundEdit
editsFields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddEdit(UndoableEdit anEdit) voidCalls super.addEdit without caching.booleancanRedo()Override to commit the cache before checking redo status.booleancanUndo()Override to commit the cache before checking undo status.voidCommits the cached edit.voidvoidbooleanChecks if there are pending edits in the DelayUndoManager.voidredo()Override to commit the cache before redo.voidundo()Override to commit the cache before undo.Methods inherited from class javax.swing.undo.UndoManager
canUndoOrRedo, editToBeRedone, editToBeUndone, end, getLimit, getRedoPresentationName, getUndoOrRedoPresentationName, getUndoPresentationName, redoTo, setLimit, toString, trimEdits, trimForLimit, undoableEditHappened, undoOrRedo, undoToMethods inherited from class javax.swing.undo.CompoundEdit
die, getPresentationName, isInProgress, isSignificant, lastEditMethods inherited from class javax.swing.undo.AbstractUndoableEdit
replaceEdit
-
Field Details
-
_timer
-
-
Constructor Details
-
DelayUndoManager
public DelayUndoManager() -
DelayUndoManager
public DelayUndoManager(int delay)
-
-
Method Details
-
isCacheEmpty
public boolean isCacheEmpty()Checks if there are pending edits in the DelayUndoManager.- Returns:
- true if there are pending edits. Otherwise false.
-
commitCache
public void commitCache()Commits the cached edit. -
addEditWithoutCaching
public void addEditWithoutCaching()Calls super.addEdit without caching. -
discardCache
public void discardCache() -
addEdit
- Specified by:
addEditin interfaceUndoableEdit- Overrides:
addEditin classUndoManager
-
canUndo
public boolean canUndo()Override to commit the cache before checking undo status.- Specified by:
canUndoin interfaceUndoableEdit- Overrides:
canUndoin classUndoManager- Returns:
- true if an undo operation would be successful now, false otherwise
-
canRedo
public boolean canRedo()Override to commit the cache before checking redo status.- Specified by:
canRedoin interfaceUndoableEdit- Overrides:
canRedoin classUndoManager- Returns:
- true if an redo operation would be successful now, false otherwise
-
undo
Override to commit the cache before undo.- Specified by:
undoin interfaceUndoableEdit- Overrides:
undoin classUndoManager- Throws:
CannotUndoException
-
redo
Override to commit the cache before redo.- Specified by:
redoin interfaceUndoableEdit- Overrides:
redoin classUndoManager- Throws:
CannotRedoException
-
discardAllEdits
public void discardAllEdits()- Overrides:
discardAllEditsin classUndoManager
-