Package arcommon.ui.other
Class MyUndoManager
- java.lang.Object
-
- javax.swing.undo.AbstractUndoableEdit
-
- javax.swing.undo.CompoundEdit
-
- javax.swing.undo.UndoManager
-
- arcommon.ui.other.MyUndoManager
-
- All Implemented Interfaces:
java.io.Serializable,java.util.EventListener,javax.swing.event.UndoableEditListener,javax.swing.undo.UndoableEdit
public class MyUndoManager extends javax.swing.undo.UndoManager
An UndoManager that can handle the double undo and redo that is created by aJTextComponent.setText(String)call.
The double undo is a remove (all) and a insert (all). These are combined by this UndoManager.
NOTE: ThenextUndoIsDouble()method MUST be MANUALLY called before the call toJTextComponent.setText(String)!
Or the two undos must be executed fast (< 1msec) after each other (andFAST_EDITS_ARE_THE_SAME_EDIT= true).
Fast like selecting text and then start writing. This is with this UndoManager also only one undo / redo.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static booleanFAST_EDITS_ARE_THE_SAME_EDIT
-
Constructor Summary
Constructors Constructor Description MyUndoManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddEdit(javax.swing.undo.UndoableEdit anEdit)static MyUndoManageraddUndoToTextComponent(javax.swing.text.JTextComponent textComponent)voiddiscardAllEdits()voidnextUndoIsDouble()voidredo()java.lang.StringtoString()voidundo()-
Methods inherited from class javax.swing.undo.UndoManager
canRedo, canUndo, canUndoOrRedo, editToBeRedone, editToBeUndone, end, getLimit, getRedoPresentationName, getUndoOrRedoPresentationName, getUndoPresentationName, redoTo, setLimit, trimEdits, trimForLimit, undoableEditHappened, undoOrRedo, undoTo
-
-
-
-
Field Detail
-
FAST_EDITS_ARE_THE_SAME_EDIT
public static final boolean FAST_EDITS_ARE_THE_SAME_EDIT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MyUndoManager
public MyUndoManager()
-
-
Method Detail
-
addUndoToTextComponent
public static MyUndoManager addUndoToTextComponent(javax.swing.text.JTextComponent textComponent)
-
nextUndoIsDouble
public void nextUndoIsDouble()
-
addEdit
public boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
- Specified by:
addEditin interfacejavax.swing.undo.UndoableEdit- Overrides:
addEditin classjavax.swing.undo.UndoManager
-
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
-
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
-
discardAllEdits
public void discardAllEdits()
- Overrides:
discardAllEditsin classjavax.swing.undo.UndoManager
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjavax.swing.undo.UndoManager
-
-