harmonic.mz.manager
Class UndoManager

java.lang.Object
  |
  +--harmonic.mz.manager.UndoManager

public class UndoManager
extends java.lang.Object

The manager of the undo/redo system.

The undo/redo system is based on keeping an object that holds the old state of an object that is about to be changed. Before changing the state, create the appropriate type of undo node, and add to the UndoManager. The undo node is cappable of restoring the old state if it is actavated. When the undo node is actavated, it creates another undo node that has the current state of the object (before the undo is done), and puts this in the redo list. Thus the same type of undo node is used for both undo and redo.


Method Summary
 void addActionHistoryListener(ActionHistoryListener l)
          Registers a listener to changes in the undo history
 void addUndo(UndoRecord ur)
          Add an undo to the undo stack.
 void addUndo(UndoRecord ur, UndoGroup group)
          Add an undo record to the given undo group
 UndoMark addUndoMark()
          Create a mark in undo history.
 void clearUndoBlock()
          Clears the current undo block, so that addUndo() will add the node directly to the undo history.
 java.util.Vector getRedoProphacy()
          Returns list of UndoRecords that will make redos.
 int getRedoProphacySize()
          Return number of items on redo stack
 java.util.Vector getUndoHistory()
          Returns list of UndoRecords that will make undos.
 int getUndoHistorySize()
          Return number of items on undo stack
 void notifyListeners()
          Notifies listeners
 void purgeUndo()
          Purge the undo stack.
 void redo()
          Execute the redo at the end of the redo list, and add add the corresponding undo back onto the undo list
 void removeActionHistoryListener(ActionHistoryListener l)
          Un-Registers a listener to changes in the undo history
 void setUndoBlock()
          This creates an undo group and sets an internal variable that will make addUndo() add the given undo reference to the undo group.
 void setUndoBlock(java.lang.String name)
           
 void undo()
          Execute the undo record at the top of the undo stack, and create a redo record and add to redo list.
 void undoToMark(UndoMark mark)
          Undo everything added after the undo mark was added.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addActionHistoryListener

public void addActionHistoryListener(ActionHistoryListener l)
Registers a listener to changes in the undo history


removeActionHistoryListener

public void removeActionHistoryListener(ActionHistoryListener l)
Un-Registers a listener to changes in the undo history


notifyListeners

public void notifyListeners()
Notifies listeners


purgeUndo

public void purgeUndo()
Purge the undo stack.


setUndoBlock

public void setUndoBlock()
This creates an undo group and sets an internal variable that will make addUndo() add the given undo reference to the undo group. In this way a set of related changes may be stored under one undo group, even if the changers are only calling addUndo() with no known undo group.


setUndoBlock

public void setUndoBlock(java.lang.String name)

clearUndoBlock

public void clearUndoBlock()
Clears the current undo block, so that addUndo() will add the node directly to the undo history.


addUndoMark

public UndoMark addUndoMark()
Create a mark in undo history. Marks created for this purpose (internal use marks) should not appear in users list.


undoToMark

public void undoToMark(UndoMark mark)
Undo everything added after the undo mark was added.


getRedoProphacy

public java.util.Vector getRedoProphacy()
Returns list of UndoRecords that will make redos.


getUndoHistory

public java.util.Vector getUndoHistory()
Returns list of UndoRecords that will make undos.


getUndoHistorySize

public int getUndoHistorySize()
Return number of items on undo stack


getRedoProphacySize

public int getRedoProphacySize()
Return number of items on redo stack


addUndo

public void addUndo(UndoRecord ur,
                    UndoGroup group)
Add an undo record to the given undo group


addUndo

public void addUndo(UndoRecord ur)
Add an undo to the undo stack. If setUndoBlock() has been used to establish an undo scope, the undo record will be added the block, else it will be added directly to undo stack.


undo

public void undo()
Execute the undo record at the top of the undo stack, and create a redo record and add to redo list. If the undo record is a group, all contained undos are executed.


redo

public void redo()
Execute the redo at the end of the redo list, and add add the corresponding undo back onto the undo list