MindFusion.Java Package Programmer's Guide
Overview

Interactive actions, carried out by users, and programmatic commands that change the structure of a diagram are recorded in a history queue. While action records are still in that queue, the actions can be undone or redone. The queue has a fixed length - if it gets full, recording a new action makes the oldest one drop from the queue.

Undo is disabled by default. To enable it, call the setUndoEnabled method. To undo or redo an action, call the undo or redo methods of UndoManager.

JDiagram automatically saves the following types of actions for later undo/redo:

Changes of item values are not saved automatically in the history. If your application must be able to undo/redo changes, use the ChangeItemCmd command. ChangeItemCmd allows recording several changes as an atomic undoable action.

In some cases, you might need to create your own types of actions or commands. For example, suppose you need undo/redo for changes made to items' tag objects. However, JDiagram is not able to detect such changes, so it cannot undo them. To enable undo/redo, create a subclass of Command and implement the execute, undo and redo methods.