| Summary: | Paste layout fails and introduce wrong colors on some edges | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Modeling] Sirius | Reporter: | Cedric Brun <cedric.brun> | ||||||||||
| Component: | Diagram | Assignee: | Pierre Guilet <pierre.guilet> | ||||||||||
| Status: | CLOSED FIXED | QA Contact: | Florian Barbin <florian.barbin> | ||||||||||
| Severity: | normal | ||||||||||||
| Priority: | P3 | CC: | florian.barbin, laurent.redor, pierre-charles.david, pierre.guilet | ||||||||||
| Version: | 4.1.0 | Keywords: | triaged | ||||||||||
| Target Milestone: | 4.1.2 | ||||||||||||
| Hardware: | PC | ||||||||||||
| OS: | All | ||||||||||||
| See Also: |
https://git.eclipse.org/r/85496 https://git.eclipse.org/r/85598 https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=5ecd3c3dd5e9844c8ac9bf9bf9e2bcd84f3563e1 https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=8dadc572a41ead59b252e84e97704a285170306f |
||||||||||||
| Whiteboard: | |||||||||||||
| Attachments: |
|
||||||||||||
Created attachment 265379 [details]
diagram before paste
Created attachment 265380 [details]
diagram after paste
Created attachment 265381 [details]
projets to reproduce the problem
(In reply to Cedric Brun from comment #0) > and even worst their colors are wrong and are pink whereas > they should be blue. They are pink in "diagram before paste" so they are always pink in "diagram after paste". It is normal. The paste layout does not paste the style. (In reply to Laurent Redor from comment #4) > (In reply to Cedric Brun from comment #0) > > and even worst their colors are wrong and are pink whereas > > they should be blue. > > They are pink in "diagram before paste" so they are always pink in "diagram > after paste". It is normal. The paste layout does not paste the style. You are right (though I have no clue why...) that might be a separate issue, ignore this comment please. (In reply to Cedric Brun from comment #5) > (In reply to Laurent Redor from comment #4) > > (In reply to Cedric Brun from comment #0) > > > and even worst their colors are wrong and are pink whereas > > > they should be blue. > > > > They are pink in "diagram before paste" so they are always pink in "diagram > > after paste". It is normal. The paste layout does not paste the style. > > You are right (though I have no clue why...) that might be a separate issue, > ignore this comment please. Correction of the correction: it is probably related, I guess the edges are not matched correctly for some reasons, when doing the same scenario but at the end: - create a new diagram for the family - right click, Edit, Paste Style => the edge colors are unexpectedly changed from blue (the father relationship) to pink on the Elias->Paul relationship. The styles goes into "customized mode" though it was not done so in the original diagram . => the expectation was that this edge would stay blue in the first place. The color problem as well as the layout problem comes from the same source that is the construction of the key in org.eclipse.sirius.diagram.ui.tools.internal.format.semantic.AbstractSemanticFormatDataKey. This key is used in the map containing all format for all edges in org.eclipse.sirius.diagram.ui.tools.internal.format.semantic.SiriusFormatDataManagerForSemanticElements.edgeFormatDataMap For all edges the key must be unique but this currently not the case. Indeed, the key is constructed with the following : this.semanticElementURIFragment = EcoreUtil.getURI(semanticElement).fragment(); So if we copy format of a node with two edges, we will keep the format of the second one only. We must modify the key construction to be unique. We cannot be based on the source and target because we can have multiple edges with the same source and target. The key must be constructed with the mapping id, the source and target fragment instead of the target only. (In reply to Pierre Guilet from comment #8) > The key must be constructed with the mapping id, the source and target > fragment instead of the target only. No, it is not possible. The copy/paste must be allowed between two diagrams with the same semantic elements representing by different mapping. So the mapping id can not be used as part of the key. Another solution must be chosen. You might want to add the mapping, source/target information as a "hint" which can be used to pick the most specific one when two possibles set of style/format/layout are candidates to a given paste. In my case the mapping would have been enough to get the expected result. I think this would work quite well for a lot of cases. (In reply to Pierre Guilet from comment #7) > The color problem as well as the layout problem comes from the same source > that is the construction of the key in > org.eclipse.sirius.diagram.ui.tools.internal.format.semantic. > AbstractSemanticFormatDataKey. > > This key is used in the map containing all format for all edges in > org.eclipse.sirius.diagram.ui.tools.internal.format.semantic. > SiriusFormatDataManagerForSemanticElements.edgeFormatDataMap > > For all edges the key must be unique but this currently not the case. > Indeed, the key is constructed with the following : > this.semanticElementURIFragment = > EcoreUtil.getURI(semanticElement).fragment(); > > So if we copy format of a node with two edges, we will keep the format of > the second one only. > > We must modify the key construction to be unique. > We cannot be based on the source and target because we can have multiple > edges with the same source and target. This "limitation" is known for node and more easily understandable. The key used to retrieve layout information is the semantic element. If a semantic element is represented several times in a diagram, only one location/size is stored for all the "graphical representations" of this semantic element (as the key is the same). For "relation based" edge, the semantic element considered as key is the semantic element of the source of the edge. So the problem is exactly the same if there are several "relation based" edges starting from a same element. As explained in previous comment, we can not use the mapping as part of the key (to allow copy/paste bewteen diagram of different kind). But we can even so consider it to avoid this limitation in most common cases. Here is a description of the choosen approach: - If we have only one value stored during the format copy, then we keep the current way to distinguish it. - If we have more than one value to store for the same key during the format copy, we will keep track of additional information to distinguish the different values (and facilite reconciliation during paste). The additional information is the mapping. While pasting format (or style or layout), when trying to retrieve the format information for a representation of a semantic element, we try to find the best match format among those with the following rules: -First the key is used to retreive the associated format information. - If we find only one format, we apply this format - If many formats exist for this key, we use additional information (mapping) to retreive the correct format. If the mapping does not allow to distinguish the correct format, we use the first one (as today). New Gerrit change created: https://git.eclipse.org/r/85496 New Gerrit change created: https://git.eclipse.org/r/85598 Gerrit change https://git.eclipse.org/r/85496 was merged to [master]. Commit: http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=5ecd3c3dd5e9844c8ac9bf9bf9e2bcd84f3563e1 Gerrit change https://git.eclipse.org/r/85598 was merged to [master]. Commit: http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=8dadc572a41ead59b252e84e97704a285170306f Verified on Sirius 4.1.2.201612011000. Available in Sirius 4.1.2 (see https://wiki.eclipse.org/Sirius/4.1.2 for details). |
Created attachment 265378 [details] diagram to copy Steps to reproduce: - install the family metamodel - import the attached projects into your workspace - open "basicfamily.sample" - open the diagram "nice hierarchy" - right click, Edit, Copy Format - open the diagram "unlayouted" - right click, Edit, Paste Layout => some edges don't have the same layout as what they had in "nice-hierarchy" and even worst their colors are wrong and are pink whereas they should be blue.