NotificationService &amp; Updateshttps://www.eclipse.org/forums/index.php/mv/msg/262217/757131/#msg_757131
I have some issues with the notification service.

I have to say that my diagrams only show part of the elements of the model: other elements contribute by decorating shown elements. Let me use an example:

The model class has a list of commands.
There are two types (subclasses) of commands: "Shown" and "Decorator".

Shown are directly shown in the editor, together with their "name" attribute.

Decorator are not shown. They have a reference "using" to a Shown element, which must be decorated.

Doing that is really easy: I only have to implement method ToolBehaviorProvider.getDecorators, inspect the model, and verify if a given function has one or more D element referencing it.

However, the real problem is reacting when the model is changed. In this case, I was not able to use the notification service to update the function being referenced by the newly created Decorator. I think that the problem is in two places: (1) my model is silly (but I'm forced to use it) and (2) the notification service (class DomainModelChangeListener) triggers the updates starting from the notifier of the ResourceSetChangeEvent. This way, when a new Decorator is added, the updates comes from the Model, and I cannot figure out which Decorator is referenced.

How can I solve this? Are there guidelines on how to use Graphiti's service and deal with silly models?]]>Matteo Miraz2011-11-16T16:05:15-00:00Re: NotificationService &amp; Updateshttps://www.eclipse.org/forums/index.php/mv/msg/262217/757133/#msg_757133
you can overwrite the method
calculateRelatedPictogramElements(...)
in the DefaultNotificationService.

Does it work?

Best, Tim]]>Tim Kaiser2011-11-16T16:56:32-00:00Re: NotificationService &amp; Updateshttps://www.eclipse.org/forums/index.php/mv/msg/262217/757136/#msg_757136
no, because when a new Decorator is added, I got a reference to the whole model (and not to the new Decorator).
I could state that all elements are related, but I don't like forcing a global update to detect the changed element...

Any other idea?]]>Matteo Miraz2011-11-16T17:05:03-00:00Re: NotificationService &amp; Updateshttps://www.eclipse.org/forums/index.php/mv/msg/262217/757145/#msg_757145
i expected that the newly created model object would be
reported (and not only the whole model). Did you debug DomainModelChangeListener?

If nothing helps, you could implement your own ResourceSetListener and add it to
the resource set. Then, you have the chance to inspect the ResourceSetChangeEvent/Notifications yourself and you can react accordingly and trigger updates/refreshes.

As you can see, the changedBOs is calculated by considering notification.getNotifier(), that in my case is the model. I think that normally this is not an issue because elements are added by using an Add/CreateFeature.

In the meanwhile, I implemented my own ResourceSetListener, using DomainModelChangeListener as inspiration. I computed the set of changed elements and the dirty pictogramElements (using notificationService.calculateRelatedPictogramElements). However, if I invoke

notificationService.updatePictogramElements(dirtyPes);

the diagram is not updated correctly. Only a

diagramEditor.refresh();

shows the decorators.

What is the difference between the two methods? (I feel I made other errors, and I'd like to understand what's wrong)

The elements I show in the diagram are only composed of a rectangle and a text. For this reason, my update feature only checks if the name is changed, in order to update the text of the rectangle.

Decorators are shown by using graphiti's decorators. These are not recalculated when I issue an update (maybe because my update feature says that everything is up to date). Accordingly, my diagram does not change when I invoke notificationService.updatePictogramElements(dirtyPes).

Conversely, refresh method performs a refresh of the element shown, including their decorators. Since I do have calculated the dirty pictogramElements, I should use the refresh method with a pictogram element as parameter (I did not noticed it), so I can force the refresh only on the dirty elements.

Thank you all for the support! I hope I have nailed it, and that this post might be useful for somebody else!