Table of Contents
Undo/Redo is supported by the Tensegrity API for each instance of a VisualGraphView. After
an invocation of method VisualGraphView.enableUndoRedo(),
automatic undo/redo recording is enabled for the particular instance. From
then on, the methods undo() and redo() can be invoked to perform the desired
operations. Invoking each method multiple times will advance one more step
backwards and forwards respectively in the internally managed undo/redo
history. If no further undo or redo operations are possible, the methods
will return silently without performing any operations.
For enabling and disabling buttons in the user interface, it is necessary to
determine if there are any undo or redo records available. The methods
undoPossible and redoPossible
return boolean values that indicate whether there are any further undo or
redo records left in the internally managed undo/redo history.
Changes that are made interactively (mouse events the view area, operation
invocations like cut(), copy(), paste() or deleteSelection)
are automatically grouped and can be subsequently undone by simply invoking
the undo() or redo() method.
If an instance of VisualGraphView is changed internally by invoking a series of
methods on that instance or its nested objects, the user has to manually
provide information on how to group the operations so that they can be undone
or redone in meaningful ways.
In order to group operations, one should group them in between an opening
call to the VisualGraphView method journalPreAction()
and a closing call to method journalPostAction().
Please make absolutely sure that these two calls are paired. It would be
fatal if the call journalPostAction() would be missing.
Using Java's try/finally construct is the perfect way to keep these paired
invocations stable.
© 2004, 2005 Tensegrity Software GmbH