ix.iview
Class UndoManager

java.lang.Object
  extended by ix.iview.UndoManager
All Implemented Interfaces:
DataChangeListener, CurrentConstructListener

public class UndoManager
extends java.lang.Object
implements DataChangeListener, CurrentConstructListener

A manager that keeps track of objects' edits for undo/redo purposes. Keeps a current object and its edits. Keeps a list of undos for each object that has been edited. To use an UndoManager, do the following:


Nested Class Summary
protected  class UndoManager.UndoNote
           
 
Field Summary
protected  EditableObject currentObject
           
protected  java.util.ArrayList currentUndos
          A list of slot / previous value pairs for the current object
protected  int undoIndex
           
protected  boolean undoing
           
protected  java.util.HashMap undoObjects
          a map of undos for previously edited objects
 
Constructor Summary
UndoManager(UndoEditing editor)
          Creates an undo manager with the given source of the editing for data lookup and setting.
 
Method Summary
 void addUndoListener(UndoChangeListener listener)
           
 boolean canRedo()
           
 boolean canUndo()
           
 void clearUndos()
           
 void constructChanged(java.awt.Component source, UIObject oldUIO, UIObject newUIO)
          Implement this method to take note of action selections
 void dataChanged(EditableObject object, java.lang.String field, java.lang.Object oldValue, java.lang.Object newValue)
          make sure you only call this if data really has changed!
 void ensureConstructSet(EditableObject uio)
           
protected  void fireUndoChange()
           
 boolean isUndoing()
          Checks if the manager is currently undoing a change
 void noteUndo(EditableObject uio, java.lang.String field, java.lang.Object oldValue, java.lang.Object newValue)
          Notes an undoable change.
 boolean redo()
          Redoes a change that has previously been undone.
 boolean redo(EditableObject uio)
          As above, but for a given object.
 void setConstruct(EditableObject uio)
           
 void test()
           
 boolean undo()
          Undoes an undoable change.
 boolean undo(EditableObject uio)
          As above, but for a given object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentUndos

protected java.util.ArrayList currentUndos
A list of slot / previous value pairs for the current object


currentObject

protected EditableObject currentObject

undoing

protected boolean undoing

undoIndex

protected int undoIndex

undoObjects

protected java.util.HashMap undoObjects
a map of undos for previously edited objects

Constructor Detail

UndoManager

public UndoManager(UndoEditing editor)
Creates an undo manager with the given source of the editing for data lookup and setting.

Method Detail

isUndoing

public boolean isUndoing()
Checks if the manager is currently undoing a change


noteUndo

public void noteUndo(EditableObject uio,
                     java.lang.String field,
                     java.lang.Object oldValue,
                     java.lang.Object newValue)
Notes an undoable change.


undo

public boolean undo()
Undoes an undoable change.


undo

public boolean undo(EditableObject uio)
As above, but for a given object. The manager will swap current object if the given one does not match the current one.


redo

public boolean redo()
Redoes a change that has previously been undone.


redo

public boolean redo(EditableObject uio)
As above, but for a given object. The manager will swap current object if the given one does not match the current one.


clearUndos

public void clearUndos()

ensureConstructSet

public void ensureConstructSet(EditableObject uio)

setConstruct

public void setConstruct(EditableObject uio)

canUndo

public boolean canUndo()

canRedo

public boolean canRedo()

dataChanged

public void dataChanged(EditableObject object,
                        java.lang.String field,
                        java.lang.Object oldValue,
                        java.lang.Object newValue)
make sure you only call this if data really has changed!

Specified by:
dataChanged in interface DataChangeListener

constructChanged

public void constructChanged(java.awt.Component source,
                             UIObject oldUIO,
                             UIObject newUIO)
Description copied from interface: CurrentConstructListener
Implement this method to take note of action selections

Specified by:
constructChanged in interface CurrentConstructListener
Parameters:
source - the component that changed the action

test

public void test()

fireUndoChange

protected void fireUndoChange()

addUndoListener

public void addUndoListener(UndoChangeListener listener)