Spraying The Natural Way of Creating Graphiti Jos Warmer, Independent Karsten Thoms,
©SAP AG All rights reserved. / Page 2 EclipseCon Europe 2011, Ludwigsburg Graphiti Approach No code generation but: Uses a runtime engine Programmed using a Java API Easy (relatively) to understand code
©SAP AG All rights reserved. / Page 3 EclipseCon Europe 2011, Ludwigsburg But … Programming the editor in Java is much (often simple but repetitive) work. E.g. for one shape for one metaclass: At least five feature classes: AddFeature, CreateFeature, DeleteFeature, LayoutFeature, UpdateFeature Features all need to be configured in the FeatureProvider Need to configure palette in the ToolBehaviourProvider Need to configure used images in ImageProvider Repeat this for e.g. ten metaclasses ……….
©SAP AG All rights reserved. / Page 4 EclipseCon Europe 2011, Ludwigsburg The Spray Graphiti Generator Started a research project Got a government grant Became useful before being finished Project for Visual Insurance Product Modeling language Spray had to be adapted to the PMW project Became partly generic, partly project specific Resulting Editors are used by non IT users in production Works well (at least for PMW )
©SAP AG All rights reserved. / Page 5 EclipseCon Europe 2011, Ludwigsburg The Spray Graphiti Generator Spray has become open source in July At: Version 0.1 was the generalized version used for PMW EPL License Current status Spray is in startup phase Much work done on infrastructure Plans … growing Spray by adding more features as we go ….. … getting more users and more feedback …..
©SAP AG All rights reserved. / Page 6 EclipseCon Europe 2011, Ludwigsburg The Spray DSL class BusinessClass icon “class.gif": container ( fill = dark_green ) [ text ( ) { " > " + name}; line (color = black width = 2); reference properties attribute dataType; line (color = RGB(255,138,141)); text ( ) "::" + description; ] references [ superclass : connection(); ] behavior[ create palette "Shapes" ; doWithBusinessClass "Do It With“ ; ] Define visualization for metaclass BusinessClass Contents of the container References to properties of metaclass References of businessclass shown as connections Behaviour for Product shape Will be in palette to create in named compartment Icon shown in palette List of referred objects Custom behavior
©SAP AG All rights reserved. / Page 7 EclipseCon Europe 2011, Ludwigsburg The Spray DSL class Association icon “association.gif“ : connection (width = 2) [ from source to target fromText text() source.name toText text() targetMultiplicity.name ] Define visualization for metaclass Association Shown as a connection (line) Source and target are references in class Association Text to show at the “’from’ and ‘to’ to” side, also options for middle of connection
©SAP AG All rights reserved. / Page 8 EclipseCon Europe 2011, Ludwigsburg Spray Generator Using textual model to define graphical editor Xtext 2, Xtend 2, Xbase Mixing generated and handwritten code by design Uses Generation Gap pattern Allows full access to Graphiti API Managed by simply moving a generated file from “src-gen” to “src” folder Generation of code from Spray DSL remains possible in full project life-cycle.
©SAP AG All rights reserved. / Page 9 EclipseCon Europe 2011, Ludwigsburg Spray Vision Making developing graphical DSL’s as easy as it is to develop textual DSL’s with e.g. Xtext.
©SAP AG All rights reserved. / Page 10 EclipseCon Europe 2011, Ludwigsburg Demo Karsten will show a short demo by creating a simple Graphiti editor from scratch