Detect edit event via manual interactions vs. programmatical changes


#1

Hi all,

Do you know how to detect the event that a model has been edited via manual interactions (e.g. keyboard, mouse drag leading to any element changed) as opposed to events that the model has been changed programmatically (e.g. calling Modelling.createShape)? My use case is the application screen needs to disable some functions as soon as the user has changed the model interactively, except one button that if being pressed will synchronize the edited model with other data areas.


#2

I implemented a technique to do the above and it works. Basically it listens to the ‘commandStack.changed’ event which is fired after an action is executed, then it reads the command stack and check the current base action. If the base action is not among a list of known actions defined in the application, it means a manual edit action has just been executed. So it needs a little hack: to read the content of the command stack which is not public, this is because I don’t know of any related public interface in bpmn.io to do this.


#3

It seems like you got deep into the modeler core, pretty fast. Kudos for that :heart:.

We’d need to understand the concrete scenario you’d like to support and why in order to be able to judge whether there is a better way to support this use case (or whether there is room for improvement on the toolkit side of things).

Best,
Nico


#4

The application screen attached shows a comparison between a BPMN model and an event log. All differences are listed on the left, each item statement explains the difference. Click on the item will show the corresponding difference highlighted in red in the editor. Click the Apply button will apply the difference to the model, i.e. removing all shapes/connections in grey and turning all reds to normal color. Now, if the user manually edits the model (as opposed to changes via the Apply button), e.g. removing shapes and connections, the difference list and Apply button must be disabled and the Re-compare button will be enabled. Click on the Re-compare button will re-compare the edited model and the log and refresh the difference list.