FileDocCategorySizeDatePackage
ExtendedUndoManager.javaAPI DocExample3158Thu Oct 24 20:14:26 BST 2002None

ExtendedUndoManager

public class ExtendedUndoManager extends UndoManager implements UndoableEditListener

Fields Summary
private ExtendedUndoableEditSupport
support
private Object
source
Constructors Summary
Methods Summary
public synchronized booleanaddEdit(javax.swing.undo.UndoableEdit anEdit)

    boolean b = super.addEdit(anEdit);
    if (b)
      support.postEdit(anEdit); // If the edit was added, notify listeners.
    return b;
  
public synchronized voidaddUndoableEditListener(javax.swing.event.UndoableEditListener l)

    support.addUndoableEditListener(l);
  
public synchronized javax.swing.undo.UndoableEdit[]getEdits()

 // The source of the last edit

  // Return the complete list of edits in an array.
      
    UndoableEdit[] array = new UndoableEdit[edits.size()];
    edits.copyInto(array);
    return array;
  
public synchronized javax.swing.undo.UndoableEdit[]getRedoableEdits()

    int size = edits.size();
    Vector v = new Vector(size);
    for (int i=0; i<size; i++) {
      UndoableEdit u = (UndoableEdit)edits.elementAt(i);
      if (u.canRedo() && u.isSignificant())
        v.addElement(u);
    }
    UndoableEdit[] array = new UndoableEdit[v.size()];
    v.copyInto(array);
    return array;
  
public synchronized javax.swing.undo.UndoableEdit[]getUndoableEdits()

    int size = edits.size();
    Vector v = new Vector(size);
    for (int i=size-1;i>=0;i--) {
      UndoableEdit u = (UndoableEdit)edits.elementAt(i);
      if (u.canUndo() && u.isSignificant())
        v.addElement(u);
    }
    UndoableEdit[] array = new UndoableEdit[v.size()];
    v.copyInto(array);
    return array;
  
public synchronized voidremoveUndoableEditListener(javax.swing.event.UndoableEditListener l)

    support.removeUndoableEditListener(l);
  
public synchronized voidundoableEditHappened(javax.swing.event.UndoableEditEvent ev)

    UndoableEdit ue = ev.getEdit();
    source = ev.getSource();
    addEdit(ue);