Bug 281506 - Copy Appearance Properties Error
Summary: Copy Appearance Properties Error
Status: RESOLVED FIXED
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: 2.2   Edit
Hardware: PC Windows XP
: P3 normal
Target Milestone: 2.2.1   Edit
Assignee: Alex Boyko CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2009-06-25 10:22 EDT by Thomas Beyer CLA
Modified: 2010-07-19 12:29 EDT (History)
2 users (show)

See Also:


Attachments
Patch (897 bytes, patch)
2009-06-25 10:23 EDT, Thomas Beyer CLA
no flags Details | Diff
Patch (1.14 KB, patch)
2009-06-26 02:58 EDT, Thomas Beyer CLA
ahunter.eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Beyer CLA 2009-06-25 10:22:50 EDT
Build ID: 20090619-0625

Steps To Reproduce:
1. Create a new Ecore-Diagram
2. Create 2 EClass-Objects
3. Change the background-color of EClass-Object A
4. Select both EClass-Objects and trigger Copy Appearance Properties
5. Error

More information:
After some investigation it seems, that in org.eclipse.gmf.runtime.diagram.core.util.ViewRefactorHelper#copyViewStyle(View oldView, View newView, Style oldStyle, List excludeStyles)
the error occurs.
Since the default value for GradientStyle is null, it tries copy null, if the node A has no gradient set yet, which then causes the error.

Attached path simply adds a check, if the old value is null.
However this is just a quick fix, because it does not override a gradient of object a, if gradient of object b is not set yet.

Therefor the default-value of FillStyleImpl#GRADIENT_EDEFAULT should be reconsidered.
Comment 1 Thomas Beyer CLA 2009-06-25 10:23:25 EDT
Created attachment 140099 [details]
Patch
Comment 2 Alex Boyko CLA 2009-06-25 23:35:24 EDT
I'd suggest to check if the feature value isSet() then set it if it is instead of a null check.
Comment 3 Thomas Beyer CLA 2009-06-26 02:58:13 EDT
Created attachment 140189 [details]
Patch
Comment 4 Thomas Beyer CLA 2009-06-26 02:59:39 EDT
I think both approaches don't cover all use cases.

Let's say there are 2 elements with a FillStyle.

Element A has the GradientStyle set, element B has not.
Now I would select element B first and then element A, and invoke copy appearance properties. So the styles of B should get copied into A.

The null-check resp. check if the feature is set would always avoid the resetting of the GradientStyle of element A.

Attached patch above should take this idea into consideration and use appropriate EMF-methods instead of null-checks.
Comment 5 Alex Boyko CLA 2009-06-26 11:32:04 EDT
Yes, we do need to unset the feature on a new style if it is unset on the old one. Good catch.
Comment 6 Alex Boyko CLA 2009-07-03 13:19:37 EDT
Committed Thomas's patch to HEAD and Maintenance streams for 2.2.1
Comment 7 Eclipse Webmaster CLA 2010-07-19 12:29:00 EDT
[GMF Restructure] Bug 319140 : product GMF and component
Runtime Diagram was the original product and component for this bug