spray code generation 2012

29
A quick wa y of creating Graphiti Marko Boger HTWG Konstanz Karsten Thoms - Itemis Jos Warmer - Independant Fabio Filipelli, Markus Gerhart, Michael Bauer, Ste ff en Kollosche HTWG Kons tanz CodeGeneration 2012 - Marko Boger 1

Upload: rahul

Post on 13-Apr-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 1/29

A quick way of creating Graphiti

Marko Boger – HTWG Konstanz

Karsten Thoms - temis

!os Warmer - n"epen"ant

#a$io #i%ipe%%i& Markus Gerhart&

Michae% Bauer& 'teffen Ko%%osche – HTWG Konstanz

(o"eGeneration )*+) - Marko Boger +

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 2/29

• 'pray is an open source pro,ect

 – 'tarte" at the (o"eGen )*++ – By !os Warmer& Karten Thoms an" Marko Boger

 – Hoste" athttp..co"e/goog%e/com.a.ec%ipse%a$s/org.p.spray.

• 0ur goa% is to make the "e1e%opement of graphica% 2"itors as simp%e as a te3tua% e"itorwith too%s %ike 4te3t

• #irst Target 5%atform is 2c%ipse with Graphiti an"2M#

• 6ersion */7/* re%ease" in March )*+)

(o"eGeneration )*+) - Marko Boger )

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 3/29

Graphiti• Framework approach

• Easy to understand (relatively...)• Hides complexity of GEF, Draw2D

• Only few core concepts

•Everything is a Feature

 –  Add, Update, Move, Delete, ...

• Providers

 – Diagram Type Provider,Tool Provider, Image Provider,...

(o"eGeneration )*+) - Marko Boger 8

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 4/29

Graphiti• Much code, often repetitive

implementation

• Per mapped meta class

• at least AddFeature, CreateFeature, UpdateFeature

• Remove, Delete, Move, Layout, DrillDown, ...

• Registration in FeatureProvider

• Configure palette in ToolBehaviourProvider

• Repeat this e.g. for10 meta classes...

(o"eGeneration )*+) - Marko Boger 7

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 5/29

Shape DSLSpray (Core) DSL

"iagram

c%ass

shape

connection

Model-Driven Generation

Eclipse Plugin for Graphical Editor

- A quick way of creating Graphiti

Style DSL

sty%e c%ass

Metamodel

ava!ML (Plugin) Properties (Plugin)

(o"eGeneration )*+) - Marko Boger 9

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 6/29

'pray :';

<(o"eGeneration )*+) - Marko Boger

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 7/29

'pray :';

=(o"eGeneration )*+) - Marko Boger

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 8/29

:efining 'hapes

8

The Shape

(o"eGeneration )*+) - Marko Boger >

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 9/29

:efining 'hapes - with Graphiti

(o"eGeneration )*+) - Marko Boger ?

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 10/29

:efining 'hapes - with 'pray• 'pray pro1i"es a simp%e :'; to "efine 'hapes

 – #rom primiti1e neste" shapes with properties

(o"eGeneration )*+) - Marko Boger +*

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 11/29

'hapes create" with this 'hape :';

(o"eGeneration )*+) - Marko Boger ++

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 12/29

'ty%es• 'ty%e :';

 – (o%or

 – #ont

 – ;ine

• nherita$%e

• @eferra$%e for 'hapes

(o"eGeneration )*+) - Marko Boger +)

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 13/29

The 'ty%es

:';

• n%ine

• 23terna%

• Mi3e"

(o"eGeneration )*+) - Marko Boger +8

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 14/29

6arious 'ty%es• 'ty%es can $e reuse"

• 'ty%es can $e inherite" – n"i1i"ua% attri$utes can $e

o1erri""en

• The who%e "iagram can ha1e a"efau%t sty%e

 – uick%y changes the entire %ook

an" fee% to a (• Gra"ients an" sha"ows in

preparation

(o"eGeneration )*+) - Marko Boger +7

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 15/29

(onnections are 'hapes

(o"eGeneration )*+) - Marko Boger +9

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 16/29

Anchor• An Anchor is the

connection point

of a connectionto a shape

• ts position is aproperty of the

shape• There are 7

options –  (enter "efau%tC

 –  (orners –  #i3e"

 –  @e%ati1e

(o"eGeneration )*+) - Marko Boger +<

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 17/29

23ten"ing the (o"e• The co"e is generate" in a way to a%%ow

manua% e3tension – Generate goo" co"e for most situations

 – 5rogram e3tensions for rare e3ceptiona% cases

 – 23ten"e"C Generation Gap 5attern

 – 23tensi$i%ity of generator using :epen"ency

n,ection GuiceC

(o"eGeneration )*+) - Marko Boger +=

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 18/29

0ur To"o-;ist• (%ipping

• @esize• cons

• (opy-5aste

• 0ut%ine

• Dn"er%ine

• @api" Button• (onte3t menu

• 'ha"ows an" G%ows

• Gra"ients• 5roperty 2"itor

• Te3t-'upport

• (ompartments

• Mo"e% 1a%i"ation

• Mo"e% $rowser

(o"eGeneration )*+) - Marko Boger +>

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 19/29

#uture 5%ans• (omp%e3 :iagrams B5ME& DM;& 5etriEet

• 21o%1e :';s

• 'e1era% Bui%" targets

 – 'wing – We$

• :ata$ase support

• Mu%ti-Dser support

(o"eGeneration )*+) - Marko Boger +?

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 20/29

;W( 5iping an" nstrumentation• Graphica% 2"itor

 – 'imp%e Metamo"e% in 2M#

 – 'pray coreC :';

 – 'hapes

(o"eGeneration )*+) - Marko Boger )*

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 21/29

The Metamo"e%• 2M# metamo"e%

 – (an $e create" withany 2M# comp%iant

too%

• 2c%ipse tree e"itor

• 5osei"on for :';s

(o"eGeneration )*+) - Marko Boger )+

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 22/29

The 'pray coreC :';

(o"eGeneration )*+) - Marko Boger ))

class LWCLocationNoLine alias Noline :

shape LWC_Location_NoLine {

shapeName = name.substring(0,name.indexOf(";"))

valueName = name.substring(name.indexOf(";")+1, name.length)

behavior {

create into modelElements palette "Locations" askFor name;

diagram LWC for LWCodelElement

class LWC!esselori#ontal alias ori#ontal :

shape LWC_!essel_ori#ontal {

shapeName = name

behavior {

create into modelElements palette "!essels" askFor name;

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 23/29

The 'pray coreC :'; (onnectionsC

(o"eGeneration )*+) - Marko Boger )8

class LWC$ipe :

connection LWC_$ipe%& {

from fromElement;

to toElement;

behavior {

create into modelElements palette "Connections";

class LWC'o(rceE)ha(st'tart :

connection LWC_'o(rce_E)ha(st %& {

from fromElement;

to toElement;

behavior {

create into modelElements palette "Connections";

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 24/29

The 'hape :';

(o"eGeneration )*+) - Marko Boger )7

shape LWC_!essel_ori#ontal % *ava+lang+'tring shapeName & {

ro(nded,rectangle {

position%)-./0-.&

si#e%1idth-2./height-34.&c(rve%1idth-5./height-5.&

te)t {

si#e%1idth-2./height-4.&

position%)-6/0-5.&

val(e-shapeName

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 25/29

(o"eGeneration )*+) - Marko Boger )9

shape LWC_eatE)changer %*ava+lang+'tring shapeName& {

ellipse {

position%)-./0-4.&

si#e%1idth-2./height-2.&

pol0line {

point%)-7./0-8.&

point%)-6./0-8.&

point%)-5./0-5.&

point%)-6./0-6.&

point%)-7./0-6.&

te)t {position%)-./0-.&

si#e%1idth-3../height-4.&

val(e-shapeName

anchor {position%)-./0-5.&

position%)-7./0-6.&

position%)-7./0-8.&

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 26/29

(o"eGeneration )*+) - Marko Boger )<

shape LWC_eatE)changer %*ava+lang+'tring shapeName& {

ro(nded,rectangle {

position%)-./0-4.&

si#e%1idth-2./height-7.&c(rve%1idth-5./ height-5.&

pol0line {

point%)-7./0-7.&

point%)-6./0-7.&

point%)-5./0-8.&

point%)-6./0-5.&

point%)-7./0-5.&

te)t {

position%)-./0-.&

si#e%1idth-3../height-4.&

val(e-shapeName

anchor {

position%)-./0-5.&

position%)-./0-7.&

position%)-7./0-5.&

position%)-7./0-7.&

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 27/29

The (ha%%enge

(o"eGeneration )*+) - Marko Boger )=

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 28/29

0ur 5roposa% at this timeC

(o"eGeneration )*+) - Marko Boger )>

7/27/2019 Spray Code Generation 2012

http://slidepdf.com/reader/full/spray-code-generation-2012 29/29

(osts• Metamo"e% )? %ines

• 'pray coreC :'; +89 %ines• 'hape :'; 8*8 %ines

• 'ty%e * %ines

• Tota% 7=< %ines

 – F hours or "ays

• Generate" (o"e )7* #i%es& +)/*** %ines

 – F weeks or months

(o"eGeneration )*+) - Marko Boger )?