Undo Package Implementation Design and Details

Introduction

The undo manager attaches to the structure of the program in several places. The GraphDispatcher contains the undo manager, and the Graph and PropMan classes also have a link to it. Each GraphDispatcher (and its graph) has an undo manager associated with it.

UndoPack object model:

Functionality

Documentation of the specific methods and classes associated with the undo manager can be found in the package documentation. The manager supports unlimited undo (no protection is provided for memory overflow) and unlimited redo while undoing. That is, you can undo any number of actions, then redo them immediately. If you undo something, then do something else, the redo information is lost. There is also a primitive provision for debugging user-written filters. Normally the execution of a filter would be considered a single action and would be completely undone. The filter can place delimiters on the stack of undo/redo information that will halt the undo process midway, allowing the user to step through the filter.

Debugging Filters

By calling GraphDispatcher.beginminiUndo() at various points in your filter, you can place debugging delimiters on the undo stack. Unfortunately, since the type of the paramter to the filter action method is a GraphInterface, you must cast the parameter as a GraphDispatcher before calling this method.

Calls to beginMiniUndo() will not affect the normal execution of the filter, and the normal undo and redo operations will ignore them. The only operations that will recognize the mini delimiters are the miniUndo and miniRedo, which will undo/redo until they encounter a mini delimiter. Using these tools, you can set "breakpoints" within your filter, then execute the filter, undo it, and start miniRedoing to step forward through the execution of your filter.

Implementation

The UndoObject class is the fundamental undoable object. From this class is inherited a subclass for each undoable action. These objects are stored in a stack.