Package org.fife.ui.rtextarea
Class RUndoManager
- java.lang.Object
-
- javax.swing.undo.AbstractUndoableEdit
-
- javax.swing.undo.CompoundEdit
-
- javax.swing.undo.UndoManager
-
- org.fife.ui.rtextarea.RUndoManager
-
- All Implemented Interfaces:
java.io.Serializable,java.util.EventListener,javax.swing.event.UndoableEditListener,javax.swing.undo.UndoableEdit
public class RUndoManager extends javax.swing.undo.UndoManagerThis class manages undos/redos for a particular editor pane. It groups all undos that occur one character position apart together, to avoid Java's horrible "one character at a time" undo behavior. It also recognizes "replace" actions (i.e., text is selected, then the user types), and treats it as a single action, instead of a remove/insert action pair.- Version:
- 1.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classRUndoManager.RCompoundEditThe edit used byRUndoManager.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringcantRedoTextprivate java.lang.StringcantUndoTextprivate RUndoManager.RCompoundEditcompoundEditprivate intinternalAtomicEditDepthprivate intlastOffsetprivate static java.lang.StringMSGprivate RTextAreatextArea
-
Constructor Summary
Constructors Constructor Description RUndoManager(RTextArea textArea)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeginInternalAtomicEdit()Begins an "atomic" edit.voidendInternalAtomicEdit()Ends an "atomic" edit.java.lang.StringgetCantRedoText()Returns the localized "Can't Redo" string.java.lang.StringgetCantUndoText()Returns the localized "Can't Undo" string.voidredo()private RUndoManager.RCompoundEditstartCompoundEdit(javax.swing.undo.UndoableEdit edit)voidundo()voidundoableEditHappened(javax.swing.event.UndoableEditEvent e)voidupdateActions()Ensures that undo/redo actions are enabled appropriately and have descriptive text at all times.-
Methods inherited from class javax.swing.undo.UndoManager
addEdit, canRedo, canUndo, canUndoOrRedo, discardAllEdits, editToBeRedone, editToBeUndone, end, getLimit, getRedoPresentationName, getUndoOrRedoPresentationName, getUndoPresentationName, redoTo, setLimit, toString, trimEdits, trimForLimit, undoOrRedo, undoTo
-
-
-
-
Field Detail
-
compoundEdit
private RUndoManager.RCompoundEdit compoundEdit
-
textArea
private RTextArea textArea
-
lastOffset
private int lastOffset
-
cantUndoText
private java.lang.String cantUndoText
-
cantRedoText
private java.lang.String cantRedoText
-
internalAtomicEditDepth
private int internalAtomicEditDepth
-
MSG
private static final java.lang.String MSG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RUndoManager
public RUndoManager(RTextArea textArea)
Constructor.- Parameters:
textArea- The parent text area.
-
-
Method Detail
-
beginInternalAtomicEdit
public void beginInternalAtomicEdit()
Begins an "atomic" edit. This method is called when RTextArea KNOWS that some edits should be compound automatically, such as when the user is typing in overwrite mode (the deletion of the current char + insertion of the new one) or the playing back of a macro.- See Also:
endInternalAtomicEdit()
-
endInternalAtomicEdit
public void endInternalAtomicEdit()
Ends an "atomic" edit.- See Also:
beginInternalAtomicEdit()
-
getCantRedoText
public java.lang.String getCantRedoText()
Returns the localized "Can't Redo" string.- Returns:
- The localized "Can't Redo" string.
- See Also:
getCantUndoText()
-
getCantUndoText
public java.lang.String getCantUndoText()
Returns the localized "Can't Undo" string.- Returns:
- The localized "Can't Undo" string.
- See Also:
getCantRedoText()
-
redo
public void redo()
- Specified by:
redoin interfacejavax.swing.undo.UndoableEdit- Overrides:
redoin classjavax.swing.undo.UndoManager
-
startCompoundEdit
private RUndoManager.RCompoundEdit startCompoundEdit(javax.swing.undo.UndoableEdit edit)
-
undo
public void undo()
- Specified by:
undoin interfacejavax.swing.undo.UndoableEdit- Overrides:
undoin classjavax.swing.undo.UndoManager
-
undoableEditHappened
public void undoableEditHappened(javax.swing.event.UndoableEditEvent e)
- Specified by:
undoableEditHappenedin interfacejavax.swing.event.UndoableEditListener- Overrides:
undoableEditHappenedin classjavax.swing.undo.UndoManager
-
updateActions
public void updateActions()
Ensures that undo/redo actions are enabled appropriately and have descriptive text at all times.
-
-