The ChangedEvent class constructor produces an empty ChangedEvent object.
Gets or sets the nature of change that occurred. The default is ChangedEvent.Property. Other values are ChangedEvent.Insert, ChangedEvent.Remove, and ChangedEvent.Transaction.
This read-only property is true when this ChangedEvent is of type ChangedEvent.Transaction and represents the end of a transactional change. It is implemented as:
return (this.change === ChangedEvent.Transaction &&
(this.propertyName === "CommittedTransaction" ||
this.propertyName === "FinishedUndo" ||
this.propertyName === "FinishedRedo"));
Gets or sets the Model or TreeModel or GraphLinksModel that was modified. When this property is non-null, the diagram property will be null. However this property and the diagram property may both be null simultaneously, when no particular model or diagram applies.
Gets or sets the name of the model change, reflecting a change to model data in addition to a change to the model itself.
The default is an empty string, which indicates that this is just a regular change to some object's state, probably its property. For a list of possible model change names, see the documentation for ChangedEvent. The names are compared in a case-sensitive manner.
Gets or sets an optional value associated with the new value. Most properties do not require any parameter to describe the change. This is typically a value that helps distinguish the new value, such as an index into an array. It is null if it is not used. The default is null.
Gets or sets the next or current value that the property has. The default is null.
Gets or sets the Object that was modified. The default is null.
For ChangedEvent.Transaction changes, this may be the Transaction.
Gets or sets an optional value associated with the old value. Most properties do not require any parameter to describe the change. This is typically a value that helps distinguish the old value, such as an index into an array. It is null if it is not used. The default is null.
Gets or sets the previous or old value that the property had. The default is null.
Gets or sets the name of the property change. The default is an empty string, which is not a valid property name. This property can be useful even when the type of change is not ChangedEvent.Property, because it can help identify the collection in the object that was modified (for ChangedEvent.Insert or ChangedEvent.Remove) or the stage of the current transaction (for ChangedEvent.Transaction).
This predicate returns true if you can call redo().
True if ready for redo() to be called.
This predicate returns true if you can call undo().
True if ready for undo() to be called.
Forget any object references that this ChangedEvent may have.
Make a copy of this ChangedEvent. ChangedEvents are copied when the UndoManager adds to a Transaction.
This is a convenient method to get the right parameter value, depending on the value of undo, when implementing a state change as part of an undo or a redo.
If true, returns the oldParam, otherwise returns the newParam.
Either the oldParam or the newParam.
This is a convenient method to get the right value, depending on the value of undo, when implementing a state change as part of an undo or a redo.
If true, returns the oldValue, otherwise returns the newValue.
Either the oldValue or the newValue.
Re-perform this object change after an undo(). canRedo() must be true for this method to have any effect.
Reverse the effects of this object change. canUndo() must be true for this method to have any effect.
For inserting into collections, and used as the value for ChangedEvent.change. The modified object is given by ChangedEvent.object. Use the optional ChangedEvent.propertyName to distinguish between different collections on the object. Use the ChangedEvent.newValue property to indicate the value that was inserted. Use the optional ChangedEvent.newParam property to indicate where or how, such as an array index or dictionary key.
For simple property changes, and used as the value for ChangedEvent.change. The name of the property is given by ChangedEvent.propertyName. The modified object is given by ChangedEvent.object. Use the ChangedEvent.oldValue and ChangedEvent.newValue properties for the previous and next property values.
For model changes, the ChangedEvent.modelChange may be non-empty, indicating a structural change to the model.
For removing from collections, and used as the value for ChangedEvent.change. The modified object is given by ChangedEvent.object. Use the optional ChangedEvent.propertyName to distinguish between different collections on the object. Use the ChangedEvent.oldValue property to indicate the value that was removed. Use the optional ChangedEvent.oldParam property to indicate where or how, such as an array index or dictionary key.
For informational events, such as transactions and undo/redo operations, and used as the value for ChangedEvent.change. The ChangedEvent.object refers to the Transaction affected, if any. The ChangedEvent.propertyName distinguishes the different transaction or undo or redo stages. The ChangedEvent.oldValue may provide the transaction name, if available, as given to UndoManager.commitTransaction.
A ChangedEvent represents a change to an object, typically a GraphObject, but also for model data, a Model, or a Diagram. The most common case is for remembering the name of a property and the before-and-after values for that property.
You can listen for changed events on the model using Model.addChangedListener or Diagram.addModelChangedListener, and on the Diagram using Diagram.addChangedListener.
There are four kinds of changes, represented by enumerated values: ChangedEvent.Property (the most common), ChangedEvent.Insert and ChangedEvent.Remove (to represent inserting or removing objects from collections), and ChangedEvent.Transaction (to notify about beginning or ending transactions or undo or redo).
The most common kind of ChangedEvent is a Property change. The name of the property is given by propertyName. The modified object is given by object. Use the oldValue and newValue properties for the before and after property values.
For an Insert ChangedEvent, the modified collection (often an Array) is a property value on the object. The propertyName helps distinguish between different collections on the object. Use the newValue property to indicate the value that was inserted. Use the newParam property to indicate where or how, such as an array index or dictionary key.
For a Remove ChangedEvent, the modified collection is a property value on the object. The propertyName helps distinguish between different collections on the object. Use the oldValue property to indicate the value that was removed. Use the oldParam property to indicate where or how, such as an array index or dictionary key.
Transaction ChangedEvents are generated by the UndoManager. The propertyName names the nature of the ChangedEvent. For the very first transaction, the property name is "StartingFirstTransaction". This ChangedEvent precedes a ChangedEvent whose property name is "StartedTransaction", which occurs for every top-level transaction.
When ending a transaction, there is first a ChangedEvent whose name is "ComittingTransaction". This is followed by one with either "CommittedTransaction" or "RolledBackTransaction", depending on how the transaction is ending. The oldValue provides the transaction name and the object is the Transaction being finished. (Note that the Transaction value may be null if no Transaction is available at that time, perhaps because there were no changes made during the transaction.) That Transaction can be scanned to look for ChangedEvents that you may wish to record in a database, all within a single database transaction.
There are also Transaction ChangedEvents corresponding to "StartingUndo", "FinishedUndo", "StartingRedo", and "FinishedRedo". The object property provides the Transaction that is about-to-be or just-was undone or redone.
Non-Transaction ChangedEvents are remembered by the UndoManager, if UndoManager.isEnabled, and held in the UndoManager.history as Transactions which hold lists of ChangedEvents. That is why ChangedEvent implements undo and redo of the change that it remembers.
When the ChangedEvent represents a change to a Model, the value of model is non-null and the value of diagram is meaningless. If the change is a structural change to the model, the value of modelChange indicates the kind of change. Currently defined model changed event names include:
The value of ChangedEvent.propertyName indicates the actual name of the property that was modified. ChangedEvent.modelChange is a non-empty string only when there is a known structural change to the model, not just the setting of some property on some object.
When the ChangedEvent represents a change to a Diagram or a GraphObject within a diagram, the value of diagram is non-null and the values of model and modelChange are meaningless.
Please note that ChangedEvents can be raised for many different causes. You may not be interested in changes to temporary objects -- in that case ignore the ChangedEvent when Model.skipsUndoManager or Diagram.skipsUndoManager is true.