Package 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.UndoManagerAn subclass of Swing'sUndoManagerthat providesActionsto 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.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classUndoManager.ActionRedoprotected classUndoManager.ActionUndo
-
Constructor Summary
Constructors Constructor Description UndoManager(Document doc)Instantiate a new UndoManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddEdit(javax.swing.undo.UndoableEdit anEdit)Add a new edit to the undo history.protected javax.swing.AbstractActioncreateRedoAction()protected javax.swing.AbstractActioncreateUndoAction()voiddiscardAllEdits()Purge the undo history and update the undo / redo actions enabled / disabled state.protected javax.swing.undo.UndoableEditeditToBeRedone()protected javax.swing.undo.UndoableEditeditToBeUndone()javax.swing.ActiongetDebugDumpAction()Get an Action object that will dump the current undo history to the console.DocumentgetDocument()protected java.util.ListgetEdits()javax.swing.ActiongetRedoAction()Get an Action object that will redo the next step in the undo history.javax.swing.ActiongetUndoAction()Get an Action object that will undo the last step in the undo history.voidredo()voidundo()-
Methods inherited from class javax.swing.undo.UndoManager
canRedo, canUndo, canUndoOrRedo, end, getLimit, getRedoPresentationName, getUndoOrRedoPresentationName, getUndoPresentationName, redoTo, setLimit, toString, trimEdits, trimForLimit, undoableEditHappened, undoOrRedo, undoTo
-
-
-
-
Constructor Detail
-
UndoManager
public UndoManager(Document doc)
Instantiate a new UndoManager.- Parameters:
doc- the document whose edits are monitored
-
-
Method Detail
-
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:
Actionsuitable for attaching to aJMenuItem.
-
getRedoAction
public javax.swing.Action getRedoAction()
Get an Action object that will redo the next step in the undo history.- Returns:
Actionsuitable for attaching to aJMenuItem.
-
getDebugDumpAction
public javax.swing.Action getDebugDumpAction()
Get an Action object that will dump the current undo history to the console.- Returns:
Actionsuitable for attaching to aJMenuItem.
-
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 editsisSignificant()method returns true, the main application is informed about this edit by calling thesetModifiedmethod. 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:
addEditin interfacejavax.swing.undo.UndoableEdit- Overrides:
addEditin classjavax.swing.undo.UndoManager- See Also:
Document.setDirty( boolean ),UndoableEdit.isSignificant(),Action.setEnabled( boolean )
-
redo
public void redo() throws javax.swing.undo.CannotRedoException- Specified by:
redoin interfacejavax.swing.undo.UndoableEdit- Overrides:
redoin classjavax.swing.undo.UndoManager- Throws:
javax.swing.undo.CannotRedoException
-
undo
public void undo() throws javax.swing.undo.CannotUndoException- Specified by:
undoin interfacejavax.swing.undo.UndoableEdit- Overrides:
undoin classjavax.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:
discardAllEditsin classjavax.swing.undo.UndoManager- See Also:
Document.setDirty( boolean )
-
editToBeRedone
protected javax.swing.undo.UndoableEdit editToBeRedone()
- Overrides:
editToBeRedonein classjavax.swing.undo.UndoManager
-
editToBeUndone
protected javax.swing.undo.UndoableEdit editToBeUndone()
- Overrides:
editToBeUndonein classjavax.swing.undo.UndoManager
-
getDocument
public Document getDocument()
-
getEdits
protected java.util.List getEdits()
-
-