proyecto.undo
Class CompoundUndoManager

java.lang.Object
  extended by javax.swing.undo.AbstractUndoableEdit
      extended by javax.swing.undo.CompoundEdit
          extended by javax.swing.undo.UndoManager
              extended by proyecto.undo.CompoundUndoManager
All Implemented Interfaces:
Serializable, EventListener, DocumentListener, UndoableEditListener, UndoableEdit

public class CompoundUndoManager
extends UndoManager
implements UndoableEditListener, DocumentListener

CompoundUndoManager.

Existe un problema cuando se rehace y se deshace acciones en nuestro editor, ello viene debido a que el UndoManager de java considera una acción el pintado de la palabra. Por eso se necesita adaptar dicha clase para el funcionamiento correcto del deshacer y rehacer (undo y redo).

This class will merge individual edits into a single larger edit. That is, characters entered sequentially will be grouped together and undone as a group. Any attribute changes will be considered as part of the group and will therefore be undone when the group is undone.

See Also:
CompoundEdit, UndoManager, Serialized Form

Nested Class Summary
(package private)  class CompoundUndoManager.MyCompoundEdit
          The Class MyCompoundEdit.
 
Field Summary
 CompoundEdit compoundEdit
          The compound edit.
 
Fields inherited from class javax.swing.undo.CompoundEdit
edits
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Constructor Summary
CompoundUndoManager(JTextComponent editor)
          Constructor compound undo manager.
 
Method Summary
 void changedUpdate(DocumentEvent e)
           
 void insertUpdate(DocumentEvent e)
          Implement DocumentListener Updates to the Document as a result of Undo/Redo will cause the Caret to be repositioned
static void main(String[] args)
          Método main.
 void redo()
          Add a DocumentLister before the redo is done so we can position
 void removeUpdate(DocumentEvent e)
           
 void undo()
          Add a DocumentLister before the undo is done so we can position the Caret correctly as each edit is undone.
 void undoableEditHappened(UndoableEditEvent e)
          Whenever an UndoableEdit happens the edit will either be absorbed by the current compound edit or a new compound edit will be started
 
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
 
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
 

Field Detail

compoundEdit

public CompoundEdit compoundEdit
The compound edit.

Constructor Detail

CompoundUndoManager

public CompoundUndoManager(JTextComponent editor)
Constructor compound undo manager. Creado : Parras, 05-oct-2009

Parameters:
editor - the editor
Method Detail

undo

public void undo()
Add a DocumentLister before the undo is done so we can position the Caret correctly as each edit is undone.

Specified by:
undo in interface UndoableEdit
Overrides:
undo in class UndoManager
See Also:
UndoManager.undo()

redo

public void redo()
Add a DocumentLister before the redo is done so we can position

Specified by:
redo in interface UndoableEdit
Overrides:
redo in class UndoManager
See Also:
UndoManager.redo()

undoableEditHappened

public void undoableEditHappened(UndoableEditEvent e)
Whenever an UndoableEdit happens the edit will either be absorbed by the current compound edit or a new compound edit will be started

Specified by:
undoableEditHappened in interface UndoableEditListener
Overrides:
undoableEditHappened in class UndoManager
See Also:
UndoManager.undoableEditHappened(javax.swing.event.UndoableEditEvent)

insertUpdate

public void insertUpdate(DocumentEvent e)
Implement DocumentListener Updates to the Document as a result of Undo/Redo will cause the Caret to be repositioned

Specified by:
insertUpdate in interface DocumentListener
See Also:
DocumentListener.insertUpdate(javax.swing.event.DocumentEvent)

removeUpdate

public void removeUpdate(DocumentEvent e)
Specified by:
removeUpdate in interface DocumentListener

changedUpdate

public void changedUpdate(DocumentEvent e)
Specified by:
changedUpdate in interface DocumentListener

main

public static void main(String[] args)
Método main.

Parameters:
args - the arguments Creado : Parras, 05-oct-2009