com.ideanest.swing
Class ActiveUndoManager

java.lang.Object
  |
  +--com.ideanest.swing.ActiveUndoManager
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.UndoableEditListener

public class ActiveUndoManager
extends java.lang.Object
implements javax.swing.event.UndoableEditListener

An undo manager that manages a limited list of undo edits.


Constructor Summary
ActiveUndoManager()
           
ActiveUndoManager(int limit)
           
 
Method Summary
 void addEdit(javax.swing.undo.UndoableEdit edit)
          Add an edit to the manager.
 void clear()
           
 ActiveList getEdits()
          Return the list of all edits currently buffered by this undo manager.
 int getLimit()
          Return the maximum size of the edit list, including both significant and insignificant edits.
 ActiveList getRedoableEdits()
          Return the list of significant redoable edits.
 int getSplitIndex()
          Return the index where the next edit to be added would be stored in the edits list.
 ActiveList getUndoableEdits()
          Return the list of significant undoable edits.
 void redo()
          Redo up to and including the first significant event in the buffer.
 void redoTo(javax.swing.undo.UndoableEdit edit)
          Redo up to and including the given edit.
 void setLimit(int limit)
          Set the maximum size of the edit list, including both significant and insignificant edits.
 void undo()
          Undo up to and including the first significant event in the buffer.
 void undoableEditHappened(javax.swing.event.UndoableEditEvent ev)
           
 void undoTo(javax.swing.undo.UndoableEdit edit)
          Undo up to and including the given edit.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActiveUndoManager

public ActiveUndoManager()

ActiveUndoManager

public ActiveUndoManager(int limit)
Method Detail

addEdit

public void addEdit(javax.swing.undo.UndoableEdit edit)
Add an edit to the manager. If adding this edit would exceed the maximum number of edits, remove the oldest edit and kill it.

Throws:
java.lang.IllegalStateException - if an undo or redo operation is currently in progress

clear

public void clear()

getEdits

public ActiveList getEdits()
Return the list of all edits currently buffered by this undo manager. The list includes both significant and insignificant edits.

Returns:
the list of all edits

getLimit

public int getLimit()
Return the maximum size of the edit list, including both significant and insignificant edits.

Returns:
the maximum number of edits buffered

getRedoableEdits

public ActiveList getRedoableEdits()
Return the list of significant redoable edits.

Returns:
the list of significant redoable edits

getSplitIndex

public int getSplitIndex()
Return the index where the next edit to be added would be stored in the edits list. This indicates the first redoable edit, or the end of the list if there are no redoable edits.

Returns:
the split index into the edits list

getUndoableEdits

public ActiveList getUndoableEdits()
Return the list of significant undoable edits.

Returns:
the list of significant undoable edits

redo

public void redo()
Redo up to and including the first significant event in the buffer. If there are no significant events, redo all (insignificant) events available.

Throws:
javax.swing.undo.CannotRedoException - if there are no events to redo at all

redoTo

public void redoTo(javax.swing.undo.UndoableEdit edit)
Redo up to and including the given edit.

Parameters:
edit - the edit up to which to redo
Throws:
java.util.NoSuchElementException - if the given edit is not in the buffer or is after the split index

setLimit

public void setLimit(int limit)
Set the maximum size of the edit list, including both significant and insignificant edits.


undo

public void undo()
Undo up to and including the first significant event in the buffer. If there are no significant events, undo all (insignificant) events.

Throws:
javax.swing.undo.CannotUndoException - if there are no events to undo at all

undoableEditHappened

public void undoableEditHappened(javax.swing.event.UndoableEditEvent ev)
Specified by:
undoableEditHappened in interface javax.swing.event.UndoableEditListener

undoTo

public void undoTo(javax.swing.undo.UndoableEdit edit)
Undo up to and including the given edit.

Parameters:
edit - the edit up to which to undo
Throws:
java.util.NoSuchElementException - if the given edit is not in the buffer or is after the split index