public class TextUndoManager
extends UndoManager
To use this, simply drop this as an UndoableEditListener into your document, and then create actions to call undo/redo as needed (checking can undo/redo first, of course).
| Constructor and description |
|---|
TextUndoManager()Creates a new instance of TextUndoManager. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
addPropertyChangeListener(PropertyChangeListener pcl)Registers a listener for undo/redo state changes. |
|
public void |
die()Sends die to each subedit,
in the reverse of the order that they were added. |
|
public void |
discardAllEdits()Empties the undo manager sending each edit a die message
in the process.
|
|
protected void |
firePropertyChangeEvent(String name, boolean oldValue, boolean newValue)Fires an undo-state property change event. |
|
public boolean |
hasChanged()Indicates whether the document differs from the last reset point. |
|
public void |
redo()Redoes the appropriate edits. If end has been
invoked this calls through to the superclass. Otherwise
this invokes redo on all edits between the
index of the next edit and the next significant edit, updating
the index of the next edit appropriately.
|
|
protected void |
redoTo(UndoableEdit edit)Redoes all changes from the index of the next edit to edit, updating the index of the next edit appropriately.
|
|
public void |
removePropertyChangeListener(PropertyChangeListener pcl)Removes a listener for undo/redo state changes. |
|
public void |
reset()Marks the current undo position as the unmodified state. |
|
public void |
setRecording(boolean recording)Toggle recording of undoable edits. |
|
protected void |
trimEdits(int from, int to)Removes edits in the specified range. All edits in the given range (inclusive, and in reverse order) will have die invoked on them and are removed from
the list of edits. This has no effect if
from > to.
|
|
public void |
undo()Undoes the appropriate edits. If end has been
invoked this calls through to the superclass, otherwise
this invokes undo on all edits between the
index of the next edit and the last significant edit, updating
the index of the next edit appropriately.
|
|
public void |
undoableEditHappened(UndoableEditEvent uee)An UndoableEditListener method. This invokes
addEdit with e.getEdit().
|
| Methods inherited from class | Name |
|---|---|
class UndoManager |
addEdit, canRedo, canUndo, canUndoOrRedo, die, discardAllEdits, end, equals, getClass, getLimit, getPresentationName, getRedoPresentationName, getUndoOrRedoPresentationName, getUndoPresentationName, hashCode, isInProgress, isSignificant, notify, notifyAll, redo, replaceEdit, setLimit, toString, undo, undoOrRedo, undoableEditHappened, wait, wait, wait |
Registers a listener for undo/redo state changes.
pcl - the listener to add Sends die to each subedit,
in the reverse of the order that they were added.
Empties the undo manager sending each edit a die message
in the process.
Fires an undo-state property change event.
name - the property nameoldValue - the previous valuenewValue - the new valueIndicates whether the document differs from the last reset point.
true if undo history contains unreset edits Redoes the appropriate edits. If end has been
invoked this calls through to the superclass. Otherwise
this invokes redo on all edits between the
index of the next edit and the next significant edit, updating
the index of the next edit appropriately.
CannotRedoException or there are no edits
to be redone Redoes all changes from the index of the next edit to
edit, updating the index of the next edit appropriately.
CannotRedoExceptionedit - the edit to be redo toRemoves a listener for undo/redo state changes.
pcl - the listener to removeMarks the current undo position as the unmodified state.
Toggle recording of undoable edits. Used to suppress capture of programmatic style changes (e.g. a theme switch re-parsing the document) that shouldn't be reachable via user-initiated Undo.
Removes edits in the specified range.
All edits in the given range (inclusive, and in reverse order)
will have die invoked on them and are removed from
the list of edits. This has no effect if
from > to.
from - the minimum index to removeto - the maximum index to remove Undoes the appropriate edits. If end has been
invoked this calls through to the superclass, otherwise
this invokes undo on all edits between the
index of the next edit and the last significant edit, updating
the index of the next edit appropriately.
CannotUndoException or there are no edits
to be undone An UndoableEditListener method. This invokes
addEdit with e.getEdit().
e - the UndoableEditEvent the
UndoableEditEvent will be added fromCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.