instrument/JTree API Documentation

org.pvv.bcd.instrument.JTree
Class InfoUndoManager

java.lang.Object
  |
  +--javax.swing.undo.AbstractUndoableEdit
        |
        +--javax.swing.undo.CompoundEdit
              |
              +--javax.swing.undo.UndoManager
                    |
                    +--org.pvv.bcd.instrument.JTree.InfoUndoManager
All Implemented Interfaces:
java.util.EventListener, java.io.Serializable, javax.swing.undo.UndoableEdit, javax.swing.event.UndoableEditListener

public class InfoUndoManager
extends javax.swing.undo.UndoManager

A specialized undo manager that offers many capabilities beyond that of Swing's regular undo manager. Much of this functionality was inspired (some would say stolen) from the excellent book JAVA 2 Developer's Handbook by Phillip Heller and Simon Roberts.

The most immediately interesting feature of this manager is that it fires events whenever something happens to alter the undo status.

It will fire a StateChangedEvent whenever a redo or undo takes place or when edits have been discarded. It will fire an UndoableEditEvent whenever a new undo event is added to it. This can be used to track undo/redo lists in the GUI etc.

The class also offers methods for retrieving lists of undos and redos.

See Also:
Serialized Form

Fields inherited from class javax.swing.undo.CompoundEdit
edits
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Constructor Summary
InfoUndoManager()
           
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
           
 boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
           
 void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
           
 void discardAllEdits()
           
protected  void fireStateChanged(javax.swing.event.ChangeEvent e)
           
 javax.swing.undo.UndoableEdit[] getEdits()
          Retrieves an array of all edits.
 javax.swing.undo.UndoableEdit[] getRedoableEdits()
          Returns a list of all outstanding redoable edits.
 javax.swing.undo.UndoableEdit[] getUndoableEdits()
          Returns a list of all outstanding undoable edits.
 void redo()
           
 void redoTo(javax.swing.undo.UndoableEdit edit)
           
 void removeChangeListener(javax.swing.event.ChangeListener l)
           
 void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
           
 void undo()
           
 void undoableEditHappened(javax.swing.event.UndoableEditEvent ev)
           
 void undoOrRedo()
           
 void undoTo(javax.swing.undo.UndoableEdit edit)
           
 
Methods inherited from class javax.swing.undo.UndoManager
canRedo, canUndo, canUndoOrRedo, editToBeRedone, editToBeUndone, end, getLimit, getRedoPresentationName, getUndoOrRedoPresentationName, getUndoPresentationName, setLimit, toString, trimEdits, trimForLimit
 
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
 

Constructor Detail

InfoUndoManager

public InfoUndoManager()
Method Detail

undo

public void undo()
          throws javax.swing.undo.CannotUndoException
Overrides:
undo in class javax.swing.undo.UndoManager

undoTo

public void undoTo(javax.swing.undo.UndoableEdit edit)
Overrides:
undoTo in class javax.swing.undo.UndoManager

redo

public void redo()
          throws javax.swing.undo.CannotRedoException
Overrides:
redo in class javax.swing.undo.UndoManager

redoTo

public void redoTo(javax.swing.undo.UndoableEdit edit)
Overrides:
redoTo in class javax.swing.undo.UndoManager

undoOrRedo

public void undoOrRedo()
                throws javax.swing.undo.CannotUndoException,
                       javax.swing.undo.CannotRedoException
Overrides:
undoOrRedo in class javax.swing.undo.UndoManager

getEdits

public javax.swing.undo.UndoableEdit[] getEdits()
Retrieves an array of all edits.
Returns:
Array of undoable edits.

discardAllEdits

public void discardAllEdits()
Overrides:
discardAllEdits in class javax.swing.undo.UndoManager

getUndoableEdits

public javax.swing.undo.UndoableEdit[] getUndoableEdits()
Returns a list of all outstanding undoable edits. Useful, for instance, for presentation in a GUI so the user can see what has happened and what can be undone.
Returns:
Array of undoable edits. Will contain only edits that can be undone and that are "significant".

getRedoableEdits

public javax.swing.undo.UndoableEdit[] getRedoableEdits()
Returns a list of all outstanding redoable edits. Useful, for instance, for presentation in a GUI so the user can see what has happened and what can be redone.
Returns:
Array of redoable edits. Will contain only edits that can be redone and that are "significant".

addEdit

public boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
Overrides:
addEdit in class javax.swing.undo.UndoManager

undoableEditHappened

public void undoableEditHappened(javax.swing.event.UndoableEditEvent ev)
Overrides:
undoableEditHappened in class javax.swing.undo.UndoManager

addUndoableEditListener

public void addUndoableEditListener(javax.swing.event.UndoableEditListener l)

removeUndoableEditListener

public void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)

fireStateChanged

protected void fireStateChanged(javax.swing.event.ChangeEvent e)

instrument/JTree API Documentation