Search code examples
add-inenterprise-architect

What's best practice to track if user has made changes to an Enterprise Architect model in an EA add-in?


Desired behaviour:

Once a user makes a change in the model, my EA add-in is supposed to flag the model as 'dirty'. This allows to conditionally export to another format on closing the file as in if dirty then do export.

A change could be any kind of modification of the appearance or logical structure of the model.

So far, I'm setting a boolean value dirty to true in the EA_OnNotifyContextItemModified event and it seems to work on some simple testing. However, I find the documentation on that event slightly unclear. What is a 'context item' exactly? Is it simply any model element that is selected in the EA GUI?

Are there any better options to notice user changes?


Solution

  • I noticed that simply adding an element, package or diagram to the project tree without dragging it on a diagram or editing it in a diagram view will not cause the EA_OnNotifyContextItemModified event to fire.

    To notify the add-in of an addition of any of the likes to the model, the dirty flag should be updated on EA_OnPreNewElement, EA_OnPreNewPackage and EA_OnPreNewDiagram as well.