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.UndoManagerAn 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 booleanaddEdit(javax.swing.undo.UndoableEdit anEdit)voidaddEditWithoutCaching()Calls super.addEdit without caching.booleancanRedo()Override to commit the cache before checking redo status.booleancanUndo()Override to commit the cache before checking undo status.voidcommitCache()Commits the cached edit.voiddiscardAllEdits()voiddiscardCache()booleanisCacheEmpty()Checks 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, 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:
addEditin interfacejavax.swing.undo.UndoableEdit- Overrides:
addEditin classjavax.swing.undo.UndoManager
-
canUndo
public boolean canUndo()
Override to commit the cache before checking undo status.- Specified by:
canUndoin interfacejavax.swing.undo.UndoableEdit- Overrides:
canUndoin 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:
canRedoin interfacejavax.swing.undo.UndoableEdit- Overrides:
canRedoin classjavax.swing.undo.UndoManager- Returns:
- true if an redo operation would be successful now, false otherwise
-
undo
public void undo() throws javax.swing.undo.CannotUndoExceptionOverride to commit the cache before undo.- Specified by:
undoin interfacejavax.swing.undo.UndoableEdit- Overrides:
undoin classjavax.swing.undo.UndoManager- Throws:
javax.swing.undo.CannotUndoException
-
redo
public void redo() throws javax.swing.undo.CannotRedoExceptionOverride to commit the cache before redo.- Specified by:
redoin interfacejavax.swing.undo.UndoableEdit- Overrides:
redoin classjavax.swing.undo.UndoManager- Throws:
javax.swing.undo.CannotRedoException
-
discardAllEdits
public void discardAllEdits()
- Overrides:
discardAllEditsin classjavax.swing.undo.UndoManager
-
-