de.sciss.app
Class UndoManager
java.lang.Object
javax.swing.undo.AbstractUndoableEdit
javax.swing.undo.CompoundEdit
javax.swing.undo.UndoManager
de.sciss.app.UndoManager
- All Implemented Interfaces:
- java.io.Serializable, java.util.EventListener, javax.swing.event.UndoableEditListener, javax.swing.undo.UndoableEdit
public class UndoManager
- extends javax.swing.undo.UndoManager
An subclass of Swing's UndoManager that
provides Actions to attach to menu items
in a standard edit menu. Besides it informs the main
application's document handler about the document being
modified, thus allowing the application to update the
window's title bar and display confirmation dialogs when
an unsaved session is about to be discarded.
- Version:
- 0.18, 02-Oct-07
- Author:
- Hanns Holger Rutz
- See Also:
- Serialized Form
|
Field Summary |
protected java.lang.String |
redoText
|
protected java.lang.String |
undoText
|
| Fields inherited from class javax.swing.undo.CompoundEdit |
edits |
| Fields inherited from class javax.swing.undo.AbstractUndoableEdit |
RedoName, UndoName |
|
Method Summary |
boolean |
addEdit(javax.swing.undo.UndoableEdit anEdit)
Add a new edit to the undo history. |
protected javax.swing.AbstractAction |
createRedoAction()
|
protected javax.swing.AbstractAction |
createUndoAction()
|
void |
discardAllEdits()
Purge the undo history and
update the undo / redo actions enabled / disabled state. |
protected javax.swing.undo.UndoableEdit |
editToBeRedone()
|
protected javax.swing.undo.UndoableEdit |
editToBeUndone()
|
javax.swing.Action |
getDebugDumpAction()
Get an Action object that will dump the
current undo history to the console. |
Document |
getDocument()
|
protected java.util.List |
getEdits()
|
javax.swing.Action |
getRedoAction()
Get an Action object that will redo the
next step in the undo history. |
javax.swing.Action |
getUndoAction()
Get an Action object that will undo the
last step in the undo history. |
void |
redo()
|
void |
undo()
|
| Methods inherited from class javax.swing.undo.UndoManager |
canRedo, canUndo, canUndoOrRedo, 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 |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
undoText
protected final java.lang.String undoText
redoText
protected final java.lang.String redoText
UndoManager
public UndoManager(Document doc)
- Instantiate a new UndoManager.
- Parameters:
doc - the document whose edits are monitored
createUndoAction
protected javax.swing.AbstractAction createUndoAction()
createRedoAction
protected javax.swing.AbstractAction createRedoAction()
getUndoAction
public javax.swing.Action getUndoAction()
- Get an Action object that will undo the
last step in the undo history.
- Returns:
Action suitable for attaching to a JMenuItem.
getRedoAction
public javax.swing.Action getRedoAction()
- Get an Action object that will redo the
next step in the undo history.
- Returns:
Action suitable for attaching to a JMenuItem.
getDebugDumpAction
public javax.swing.Action getDebugDumpAction()
- Get an Action object that will dump the
current undo history to the console.
- Returns:
Action suitable for attaching to a JMenuItem.
addEdit
public boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
- Add a new edit to the undo history.
This behaves just like the normal
UndoManager, i.e. it tries to replace
the previous edit if possible. When
the edits
isSignificant()
method returns true, the main application
is informed about this edit by calling
the setModified method.
Also the undo and redo action's enabled
/ disabled states are updated.
Insignificant edits are saved in a pending
compound edit that gets added with the
next significant edit to allow redos as
long as possible.
- Specified by:
addEdit in interface javax.swing.undo.UndoableEdit- Overrides:
addEdit in class javax.swing.undo.UndoManager
- See Also:
Document.setDirty( boolean ),
UndoableEdit.isSignificant(),
Action.setEnabled( boolean )
redo
public void redo()
throws javax.swing.undo.CannotRedoException
- Specified by:
redo in interface javax.swing.undo.UndoableEdit- Overrides:
redo in class javax.swing.undo.UndoManager
- Throws:
javax.swing.undo.CannotRedoException
undo
public void undo()
throws javax.swing.undo.CannotUndoException
- Specified by:
undo in interface javax.swing.undo.UndoableEdit- Overrides:
undo in class javax.swing.undo.UndoManager
- Throws:
javax.swing.undo.CannotUndoException
discardAllEdits
public void discardAllEdits()
- Purge the undo history and
update the undo / redo actions enabled / disabled state.
- Overrides:
discardAllEdits in class javax.swing.undo.UndoManager
- See Also:
Document.setDirty( boolean )
editToBeRedone
protected javax.swing.undo.UndoableEdit editToBeRedone()
- Overrides:
editToBeRedone in class javax.swing.undo.UndoManager
editToBeUndone
protected javax.swing.undo.UndoableEdit editToBeUndone()
- Overrides:
editToBeUndone in class javax.swing.undo.UndoManager
getDocument
public Document getDocument()
getEdits
protected java.util.List getEdits()