cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a validator once per change

norberts
Champ in-the-making
Champ in-the-making
Hey,

so I wrote my own validator and since the extension point is deactivated right now I call it in the doSave method ActivitiDiagramEditor for testing purposes. However I want to call it now whenever a change occurs in the diagram of the editor. So every time the user moves/adds/deletes elements and the editor get's dirty, I want to call it.
I looked at the isDirty method but that is called by various eclipse and graphiti classes something like 5 times per change and that would be a pretty inefficient position.
I hoped also on the refresh method, but that is called not at all. Same for the updateDirtyState method of the DiagramEditor.

Any suggestions where I can call my validator once so it is  executed on every change in the diagram?

Also, is it possible to distinguish between the two options "just moved something" and "added or deleted something"? Since the graph doesn't change when the user just moves an element.

Thanks for your help.
1 REPLY 1

norberts
Champ in-the-making
Champ in-the-making
Alright, so I'm looking into the DomainModelChangeListener that is registered on the Editor. It is called on every change, which is nice. But I noticed that the BPMN model of Activiti is not updated when the user uses the undo and redo logic. Is that supposed to be like that? 'Cause I think this affects all validators and marshallers that are getting the diagram and work on the flow elements.

Just tested if the export/save to xml is affected by it and it is. If you delete an element, return it via an undo and then save the diagram, that element is not included.

My workaround for that is that I disabled the undo and redo commands of Graphiti by overwriting the initializeActionRegistry method in the ActivitiDiagramEditor to do nothing. Copy, paste, delete via DEL and multiple selection still works with that.