In some particular circumstances, model events are sent by Modelio to modules that have registered themselves to receive these events.

For model changes, a ModelChangeEvent event is sent when a top-level transaction is committed. The ModelChangeEvent event contains a structured and optimized list of changes that have been applied to the model. By processing these changes, a Module is able to perform any processing it requires.

The structured list of changes contained in a ModelChangeEvent distinguishes between:

  • Created elements

  • Deleted elements

  • Updated elements

  • Moved elements

These lists are optimized by Modelio in order to reduce the amount of data to be processed by the module. For example, no update is reported for a deleted element.

Created elements

A created element is an element that has been added to the model during the transaction.

Optimizations

  • In the case of the creation of a parent and its children, only the parent creation is reported

  • A created element will not appear in either the updated elements list or the moved elements list

  • If an element is created and deleted by the transaction, no creation (and no deletion) is reported

Deleted elements

A deleted element is an element that has been removed from the model during the transaction.

Optimizations

  • In the case of the deletion of a parent and its children, only the parent deletion is reported

  • A deleted element will not appear in either the updated elements list or the moved elements list

  • If an element is created and deleted by the transaction, no deletion (and no creation) is reported

Updated elements

An updated element is an element which is not a created or deleted element and which has been modified by the transaction without being moved. The reordering of the child elements owned by a parent element makes this parent element appear in the updated elements list.

Optimizations

  • No matter how many changes have been made to an element, it is reported once in the updated list

Moved elements

An element E is considered as a moved element if its "parent" has changed. "Parent" here must be understood as the value of E.getCompositionOwner() .

Optimizations

  • Whatever the number of parent changes that have occurred during the transaction, only one report will be available in the moved elements list. The reported move will contain the initial (before the transaction) and last known (at the end of the transaction) parent.

Event handling or listening

Modelio provides two levels of notification :

  1. handler : handlers are triggered before listener and event handlers are allowed to modify the model

  2. listener : listeners are triggered last and their code can’t modify the model. Listeners are notified of modification events done by handlers.