Bug 528329 - Decorations are not refreshed during a manual diagram refresh
Summary: Decorations are not refreshed during a manual diagram refresh
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 5.1.0   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2017-12-08 10:04 EST by Stéphane Thibaudeau CLA
Modified: 2017-12-20 05:55 EST (History)
1 user (show)

See Also:


Attachments
Reproduction sample (19.47 KB, application/zip)
2017-12-20 05:54 EST, Maxime Porhel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stéphane Thibaudeau CLA 2017-12-08 10:04:33 EST
In Sirius documentation we can read :

Decoration display update

The decorations can be manually and automatically refreshed.
- Manually, when the user clicks on the refresh button in the diagram tool bar.
 Automatically, according to semantic changes when:
  - the target semantic element of the DDiagramElement ( DSemanticDecorator_Target feature) is changed, 
  - the semantic elements of the DDiagramElement ( DRepresentationElement_SemanticElements feature) are changed. They are defined with Associated Elements Expression on the mapping. It means that a specifier that defined decorations can not add new “semantic element”, dedicated to decorations, that would be listened to for the automatic refresh. 

My decoration does not match the second case (automatic refresh) but when I do a manual refresh the decoration is not refreshed at all.
Comment 1 Stéphane Thibaudeau CLA 2017-12-11 08:52:19 EST
As seen with Laurent Fasani, I've tried to programmatically refresh the decorations by using :

new DecorationHelper(diagram).updateDecorations(layersToRefresh);

This does not work because :
- I need to run this code inside an EMF Transaction (easily solvable from my side)
- in org.eclipse.sirius.diagram.business.internal.helper.decoration.DecorationHelperInternal.addDecoration(DDiagramElement, DecorationDescription) the following test makes the method return without updating my decoration. Indeed, the decoration is the same object, the precondition still evaluates to True but the image expression will return a different result.

        for (final Decoration decoration : element.getTransientDecorations()) {
            if (EcoreUtil.equals(decorationDescription, decoration.getDescription())) {
                return;
            }
       }
Comment 2 Stéphane Thibaudeau CLA 2017-12-11 08:53:48 EST
As seen with Laurent, we should not have a problem with EMF Transaction as long as we change only transient objects.
Comment 3 Maxime Porhel CLA 2017-12-20 05:54:29 EST
Created attachment 271975 [details]
Reproduction sample

Steps to reproduce : 
 - import the two projects from the attached zip in your runtime
 - open the "new EPackage" diagram
 - activate the "transient layer"
 - a green car decoration (or ...) appears on each right side of the displayed nodes
 - select the abstract EPackage in the Model Explorer
 - change its name to "aaaaaa" (must not contains "abstract")
 - nothing is done on the diagram (auto refresh) : ok the changed element is not a semantic element of the diagram
 - click on the refresh button in the tabbar
 - KO decorations are not update
 - close and reopen the diagram or disable and reenable the "TransientDecoration" layer
 - OK the decorations have been changed to a yellow car