archimatetool/archi-scripting-plugin

Feature request: event handlers for jArchi

gxpcluster opened this issue · 2 comments

How hard is it to add event handlers to Archi and jArchi? It would be great to have such a feature at least for basic events: changing the concept on the diagram, opening the model, closing the model, changing the diagram...
As far as I understand it, this could be done as follows:

  1. Archi checks if the jArchi plugin is installed
  2. When an event occurs, Archi checks if there are handlers for that event in some jArchi script and executes the handler.
  3. When creating the plugin, the developer must register the event handler so that Archi stores it and knows about it and which script it is in.

Thanks!

Archi already has an event handler - the Eclipse Modelling Framework (EMF) eCore framework. Every model change sends an event that is handled by the UI or another handler. This can be used in Archi plug-ins...if the plug-in is well-behaved and properly places any changes to the model on the Undo/Redo stack.

jArchi is a wrapper around Archi's commands and implements things so that it is well behaved and creates proper Undo/Redo command stack events. If this was exposed to downstream scripts the resulting behaviour would be unpredictable.

So, the short answer is, I won't be implementing this in jArchi because of the reasons above and, even if it were possible, would take a lot of time and effort. But thanks for the idea!

Thank you @Phillipus.
I have situations where it would be very convenient to have a script triggered by certain user actions. For example, when a user adds a new concept to a diagram or changes an existing concept, I need to record in a text file what happened - the ID of the added or changed concept. So far, I haven't figured out how to do this without running the script manually. Unfortunately, I'm not good at Java to write a separate plugin.
Thanks for explaining how events work in Archi.