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
edits
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
addEdit
(UndoableEdit anEdit) void
Calls super.addEdit without caching.boolean
canRedo()
Override to commit the cache before checking redo status.boolean
canUndo()
Override to commit the cache before checking undo status.void
Commits the cached edit.void
void
boolean
Checks if there are pending edits in the DelayUndoManager.void
redo()
Override to commit the cache before redo.void
undo()
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, undoTo
Methods inherited from class javax.swing.undo.CompoundEdit
die, getPresentationName, isInProgress, isSignificant, lastEdit
Methods 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:
addEdit
in interfaceUndoableEdit
- Overrides:
addEdit
in classUndoManager
-
canUndo
public boolean canUndo()Override to commit the cache before checking undo status.- Specified by:
canUndo
in interfaceUndoableEdit
- Overrides:
canUndo
in 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:
canRedo
in interfaceUndoableEdit
- Overrides:
canRedo
in classUndoManager
- Returns:
- true if an redo operation would be successful now, false otherwise
-
undo
Override to commit the cache before undo.- Specified by:
undo
in interfaceUndoableEdit
- Overrides:
undo
in classUndoManager
- Throws:
CannotUndoException
-
redo
Override to commit the cache before redo.- Specified by:
redo
in interfaceUndoableEdit
- Overrides:
redo
in classUndoManager
- Throws:
CannotRedoException
-
discardAllEdits
public void discardAllEdits()- Overrides:
discardAllEdits
in classUndoManager
-