Package jahuwaldt.swing.undo
Class ExtendedUndoManager
- java.lang.Object
-
- javax.swing.undo.AbstractUndoableEdit
-
- javax.swing.undo.CompoundEdit
-
- javax.swing.undo.UndoManager
-
- jahuwaldt.swing.undo.ExtendedUndoManager
-
- All Implemented Interfaces:
java.io.Serializable,java.util.EventListener,javax.swing.event.UndoableEditListener,javax.swing.undo.UndoableEdit
public class ExtendedUndoManager extends javax.swing.undo.UndoManager implements javax.swing.event.UndoableEditListener
An extension of UndoManager that provides two additional features: (1) The ability to add & remove listeners and (2) the ability to gain more extensive access to the edits being managed. See: O'Reilly's Java Swing (1st edition).Modified by: Joseph A. Huwaldt, Date: February 22, 2025
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ExtendedUndoManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddEdit(javax.swing.undo.UndoableEdit anEdit)Add an edit and notify our listeners.voidaddUndoableEditListener(javax.swing.event.UndoableEditListener l)Add a listener to be notified each time an edit is added to this manager.javax.swing.undo.UndoableEditeditToBeRedone()Returns the the next significant edit to be redone if redo is called.javax.swing.undo.UndoableEditeditToBeUndone()Returns the the next significant edit to be undone if undo is called.javax.swing.undo.UndoableEdit[]getEdits()Return the complete list of edits in an array.javax.swing.undo.UndoableEdit[]getRedoableEdits()Return all currently significant redoable edits.javax.swing.undo.UndoableEdit[]getUndoableEdits()Return all currently significant undoable edits.voidremoveUndoableEditListener(javax.swing.event.UndoableEditListener l)Remove a listener from this manager.voidundoableEditHappened(javax.swing.event.UndoableEditEvent ev)When an edit is sent to us, call addEdit() to notify any of our listeners.-
Methods inherited from class javax.swing.undo.UndoManager
canRedo, canUndo, canUndoOrRedo, discardAllEdits, end, getLimit, getRedoPresentationName, getUndoOrRedoPresentationName, getUndoPresentationName, redo, setLimit, toString, undo, undoOrRedo
-
-
-
-
Constructor Detail
-
ExtendedUndoManager
public ExtendedUndoManager()
-
-
Method Detail
-
editToBeUndone
public javax.swing.undo.UndoableEdit editToBeUndone()
Returns the the next significant edit to be undone if undo is called. May return null.
-
editToBeRedone
public javax.swing.undo.UndoableEdit editToBeRedone()
Returns the the next significant edit to be redone if redo is called. May return null.
-
getEdits
public javax.swing.undo.UndoableEdit[] getEdits()
Return the complete list of edits in an array.- Returns:
- The complete list of edits in an array.
-
getUndoableEdits
public javax.swing.undo.UndoableEdit[] getUndoableEdits()
Return all currently significant undoable edits. The first edit is the next one to be undone.- Returns:
- All currently significant undoable edits.
-
getRedoableEdits
public javax.swing.undo.UndoableEdit[] getRedoableEdits()
Return all currently significant redoable edits. The first edit is the next one to be redone.- Returns:
- All currently significant redoable edits.
-
addEdit
public boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
Add an edit and notify our listeners.- Specified by:
addEditin interfacejavax.swing.undo.UndoableEdit- Overrides:
addEditin classjavax.swing.undo.UndoManager- Parameters:
anEdit- An edit and notify our listeners.
-
undoableEditHappened
public void undoableEditHappened(javax.swing.event.UndoableEditEvent ev)
When an edit is sent to us, call addEdit() to notify any of our listeners.- Specified by:
undoableEditHappenedin interfacejavax.swing.event.UndoableEditListener- Overrides:
undoableEditHappenedin classjavax.swing.undo.UndoManager
-
addUndoableEditListener
public void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
Add a listener to be notified each time an edit is added to this manager. This makes it easy to update undo/redo menus as edits are added.- Parameters:
l- The listener to be notified each time an edit is added to this manager.
-
removeUndoableEditListener
public void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
Remove a listener from this manager.- Parameters:
l- The listener to be notified each time an edit is added to this manager.
-
-