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:
java.io.Serializable
,java.util.EventListener
,javax.swing.event.UndoableEditListener
,javax.swing.undo.UndoableEdit
public class DelayUndoManager extends javax.swing.undo.UndoManager
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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.swing.Timer
_timer
-
Constructor Summary
Constructors Constructor Description DelayUndoManager()
DelayUndoManager(int delay)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addEdit(javax.swing.undo.UndoableEdit anEdit)
void
addEditWithoutCaching()
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
commitCache()
Commits the cached edit.void
discardAllEdits()
void
discardCache()
boolean
isCacheEmpty()
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
-
-
-
-
Method Detail
-
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
public boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
- Specified by:
addEdit
in interfacejavax.swing.undo.UndoableEdit
- Overrides:
addEdit
in classjavax.swing.undo.UndoManager
-
canUndo
public boolean canUndo()
Override to commit the cache before checking undo status.- Specified by:
canUndo
in interfacejavax.swing.undo.UndoableEdit
- Overrides:
canUndo
in classjavax.swing.undo.UndoManager
- 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 interfacejavax.swing.undo.UndoableEdit
- Overrides:
canRedo
in classjavax.swing.undo.UndoManager
- Returns:
- true if an redo operation would be successful now, false otherwise
-
undo
public void undo() throws javax.swing.undo.CannotUndoException
Override to commit the cache before undo.- Specified by:
undo
in interfacejavax.swing.undo.UndoableEdit
- Overrides:
undo
in classjavax.swing.undo.UndoManager
- Throws:
javax.swing.undo.CannotUndoException
-
redo
public void redo() throws javax.swing.undo.CannotRedoException
Override to commit the cache before redo.- Specified by:
redo
in interfacejavax.swing.undo.UndoableEdit
- Overrides:
redo
in classjavax.swing.undo.UndoManager
- Throws:
javax.swing.undo.CannotRedoException
-
discardAllEdits
public void discardAllEdits()
- Overrides:
discardAllEdits
in classjavax.swing.undo.UndoManager
-
-