Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 335642 - [diagram] improve color and line style api
Summary: [diagram] improve color and line style api
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Sapphire (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Shenxue Zhou CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-27 20:02 EST by Konstantin Komissarchik CLA
Modified: 2021-11-19 09:22 EST (History)
0 users

See Also:


Attachments
Patch v1 (21.67 KB, patch)
2011-02-01 16:09 EST, Shenxue Zhou CLA
no flags Details | Diff
Patch V2 (22.24 KB, patch)
2011-02-01 17:25 EST, Shenxue Zhou CLA
konstantin: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Komissarchik CLA 2011-01-27 20:02:33 EST
A recent change added support for setting line style and color on diagram connections. This was done using hints facilities. I am actually trying to phase out the reliance on hints. We loose a lot of expressive power by not treating these settings as explicit properties and the syntax in the sdef file isn't very convenient.

Let's add LineStyle and LineColor properties to IDiagramConnectionDef. 

LineStyle property can use the existing LineStyle enum. You will not need LineStyle.getLineStyle(<string>) method any more. Use @EnumSerialization annotation on enum items to set how enums are to be converted to string form.

LineColor property needs a corresponding Color object. You will need to register a value serialization service since this will be a completely custom value type. There are plenty of examples of how to do this. See basic types like Integer in the modeling plugin. The parseColor function would live in the serializer. The Color class cannot use SWT's RGB class. It should contain the color triplet directly. The rendering layer can construct RGB objects as necessary.

Both LineStyle class and the to-be-created Color class should live in the root sapphire.ui package since they are in principle more generic than diagram feature.
Comment 1 Shenxue Zhou CLA 2011-02-01 16:09:11 EST
Created attachment 188088 [details]
Patch v1
Comment 2 Konstantin Komissarchik CLA 2011-02-01 16:21:41 EST
A few issues...

1. ColorSerializationService needs encode implementation. The default implementation uses toString(), but you haven't implemented toString() on Color either.

2. LineStyle.getLineStyle() static method should be removed. This sort of translation should happen via serialization service. For enums, the serialization service is supplied by the system. You would write something like this... element.service( MyProperty, ValueSerializationService.class ).decode( str )

3. There is a commented-out color hint line in MapEditor.sdef with old syntax. Should this line be removed?

Also, please name your patches "Patch v1", "Patch v2", etc. This makes it simpler to sort out what's going on. A detail description of the content should go in the accompanying comment rather than attachment title.
Comment 3 Shenxue Zhou CLA 2011-02-01 17:25:34 EST
Created attachment 188097 [details]
Patch V2

Patch v2 to address the above issues
Comment 4 Konstantin Komissarchik CLA 2011-02-01 19:55:00 EST
Released patch v2. There was one other problem that I noticed in ColorSerializationService, but I just fixed it up myself. The issue is that the decode method isn't supposed to throw exceptions. It should return null instead. I have also updated javadoc of ValueSerializationService to state as much.
Comment 5 Konstantin Komissarchik CLA 2011-06-09 16:37:50 EDT
Closing. This can be considered verified as Shenxue has submitted the patch and I reviewed the code and behavior before releasing.