Holds the event names and associated listeners in an array. The array contains the event name followed by the respective listener for each registered listener.
Specifies if events can be fired. Default is true.
Optional source for events. Default is null.
Array that contains the steps of the command history.
Index of the element to be added next.
Maximum command history size. 0 means unlimited history. Default is 100.
Binds the specified function to the given event name. If no event name is given, then the listener is registered for all events.
The parameters of the listener are the sender and an EventObject.
Dispatches the given event to the listeners which are registered for the event. The sender argument is optional. The current execution scope ("this") is used for the listener invocation (see Utils#bind).
Example:
fireEvent(new mxEventObject("eventName", key1, val1, .., keyN, valN))
EventObject that represents the event.
Optional sender to be passed to the listener. Default value is
the return value of
Method to be called to add new undoable edits to the
UndoManager
Implements a command history. When changing the graph model, an mxUndoableChange object is created at the start of the transaction (when model.beginUpdate is called). All atomic changes are then added to this object until the last model.endUpdate call, at which point the mxUndoableEdit is dispatched in an event, and added to the history inside UndoManager. This is done by an event listener in Editor.installUndoHandler.
Each atomic change of the model is represented by an object (eg. mxRootChange, mxChildChange, mxTerminalChange etc) which contains the complete undo information. The UndoManager also listens to the mxGraphView and stores it's changes to the current root as insignificant undoable changes, so that drilling (step into, step up) is undone.
This means when you execute an atomic change on the model, then change the current root on the view and click undo, the change of the root will be undone together with the change of the model so that the display represents the state at which the model was changed. However, these changes are not transmitted for sharing as they do not represent a state change.
Example
When adding an undo manager to a graph, make sure to add it to the model and the view as well to maintain a consistent display across multiple undo/redo steps.
The code creates a function that informs the undoManager of an undoable edit and binds it to the undo event of mxGraphModel and mxGraphView using EventSource.addListener.
Event: mxEvent.CLEAR
Fires after clear was invoked. This event has no properties.
Event: mxEvent.UNDO
Fires afer a significant edit was undone in undo. The
edit
property contains the mxUndoableEdit that was undone.Event: mxEvent.REDO
Fires afer a significant edit was redone in redo. The
edit
property contains the mxUndoableEdit that was redone.Event: mxEvent.ADD
Fires after an undoable edit was added to the history. The
edit
property contains the mxUndoableEdit that was added.