Community
Participate
Working Groups
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.
Created attachment 188088 [details] Patch v1
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.
Created attachment 188097 [details] Patch V2 Patch v2 to address the above issues
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.
Closing. This can be considered verified as Shenxue has submitted the patch and I reviewed the code and behavior before releasing.