As described in the documentation, setting the isAutoUpdateAtRuntime() in the feature provider to true will automatically update open diagrams. However, it does this only when the diagram is already dirty.
I need to update the diagram on domain model changes, even when the diagram is not dirty. This check is done in DomainModelChangeListener.
Looking further I tried to change the field "domainModelListener" in the DiagramEditor (actually in my own sibclass of it) to point to my own subclass of DomainModelChangeListener. However, the field is private, so I cannot possibly change it.
Is it possible to add the option to Graphiti to auto-update even when the editor is not dirty ?
Michael Wenz Messages: 1714 Registered: July 2009 Location: Walldorf, Germany
We didn't implement that mode because we thought that would be confusing for
the user; at some point in time while he works in another editor the diagram
gets dirty. But if you have a use case for that, others might have well.
For now you might implement your own DomainModelChangeListener that does the
same things as the standard ones but omits the check for the dirty editor.
You can do this by overriding both registerBOListener and
unregisterBOListener in DiagramEditorInternal.
In general it would make sense to add an additional mode to the editor,
something like isAutoUpdateAtRuntimeAllEditors. Would you open a bugzilla
for that request? Maybe you have also a better name for that method...
My use case is an editor where I automatically do the layout. I do not even store the diagram, it is generated whenever the users opens a model element. If the user drops anything from the palette, it is first added to the model repsoitory and then auto layout again.
I have sub-classed the DiagramEditor and redefined the method isDirty() to always return false to stop the editor from trying to save (as it isn't stored anyway). I have now also redefined registerBOListener and
I got the same problem. I created my own DomainModelChangeListener, where I modified the resourceSetChanged(..) and run(...) to omit the dirty check. Furthermore I override registerBOListener() and unregisterBOListener in my own DiagramEditor. But now I'm stuck as I can't set domainModelListener to my own DomainModelChangeListener. How do I replace the original one there?
My use case is btw. that I want to have a CustomFeature which applies several modifications to the DomainModel, followed by an auto layout of the drawing.