Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can...

40
Budapesti Műszaki és Gazdaságtudományi Egyetem Méréstechnika és Információs Rendszerek Tanszék Graphical Concrete Syntax Design for Domain-specific Languages Dániel Varró, Zoltán Ujhelyi Model Driven Software Development Lecture 7

Transcript of Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can...

Page 1: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Budapesti Műszaki és Gazdaságtudományi Egyetem Méréstechnika és Információs Rendszerek Tanszék

Graphical Concrete Syntax Design for Domain-specific Languages

Dániel Varró, Zoltán Ujhelyi Model Driven Software Development

Lecture 7

Page 2: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Structure of DSMs Graphical syntax

Code generation

View

Well-formedness constraints

Behavioural semantics, simulation

Abstract syntax

Textual syntax

Mapping

Code (documentation,

configuration)

2

Page 3: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

DSM aspects

DSM

Abstract syntax

Concrete syntax

Well-formedness constraints

Behavioural (dynamic) semantics

Views, translations,

mappings

3

Page 4: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Concrete Syntax Design

User-managed parts of a modeling language

o Performance

o Robustness

o Usability issues

Creating model editors

o Similar problems at programming languages

o IDE extensions needed

4

Page 5: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Approaches

Textual syntax

o Character-based edit operations

o Abstract syntax: traditional AST

Graphical syntax

o Editing operations: translated to abstract syntax

o Abstract syntax: based on metamodel

Form-based entry

o Less common

o Behaves similar to graphical syntax

5

Page 6: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Advanced features

High level editing support

• Outline view

• Documentation display (e.g. Javadoc)

• Templates/snippets/examples

• Content assist

• Validation, automatic fixes

Project-level integration

• Code generation

• Wizards to create projects/files

• Integration with manually written code in GPL

6

Page 7: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Technology

Eclipse Modeling Tools

o Several related subprojects

o Each supports a single aspect

o Examples of today

Microsoft Visual Studio 2010 Visualization & Modeling SDK

o DSL modeling framework from Microsoft

o Own metamodeling core

o Focuses on graphical modeling

7

Page 8: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Graphical Editors

Page 9: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Graphical Editor Techiques

GEF • Draw2D

EMF • EMF.Edit

GMF Graphiti

Sirius EuGENia

GEF3D Zest

Spray

Page 10: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Graphical Modeling

Model

o Typically graph-based modeling (Edges, Nodes)

o In our case EMF

Idea

o Display and editing as a graph model

10

Page 11: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Example: Petri net editor

11

Tree-based outline view

Page 12: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Example: Social Network editor

12

Graphical outline view

Properties view

Project Explorer

extensions

Page 13: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Implementation

Presentation

o Based on a Canvas

o Using vector-graphic libraries (GEF/Draw2d)

Model manipulation

o EMF Edit model manipulation commands

• Atomic operations: create/modify/remove node/edge

o Transactional modifications

• Undo/redo support

• Replayability

13

Page 14: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Implementation 2.

View models

oModeling for view-specific information

• Coordinates

• Size

• Colors and fonts

• …

o Generic implementation in GMF and Graphiti

o Often stored in external files

• Separation of concerns

• E.g. code generator not interested in view information

14

Page 15: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Technologies 1. - GEF

Graphical Editing Framework (GEF)

o “Low level” editor framework

o Not EMF-specific

Model-View-Controller approach

Generic graph-based editor framework

o Including undo/redo support

o Graphical outlines

Manual coding for every possible element

GEF4 FX – JavaFX-based replacement of the core

15

Page 16: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Technologies 2. – GMF

Graphical Modeling Framework

Based on GEF and EMF

Well-separated view and domain models

o Generic view model

o Synchronization provided by GMF framework

Relatively old technology

oWidely used

o Very complex to start

16

Page 17: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Technologies 2. – GMF

Model-driven development environment o Common model for graphical editors, using

• Figure definition model – Basic symbol definition of the graphical language

• Tooling model – Defining model manipulation commands

• Mapping model – Mapping figures and tools to domain model

o Fully functional editor can be generated • Problematic manual modifications

Or a high-level editor framework oManual coding

17

Page 18: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Technologies 3. - Graphiti

Newer high level graphical editor framework

o Based on EMF and GEF

o But: different approach then GMF

• Simplified programmatic API

• Manual coding

o Idea

• All Graphiti based editors should – Look similar

– Behave similar

18

Page 19: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Technologies 3. - Graphiti

Development methodology

o Coding over a high-level Java framework

• Much simpler then GMF

• Repetitive code needed

Spray project

o Textual modeling environment for graphical editors

o Generates code over the Graphiti framework

19

Page 20: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Technologies 4. - Sirius

20

New modeling project

o Since 2013 on eclipse.org

o Previously Obeo Designer – commercial tool

How stable is it?

o Old projects are to be migrated

o Version history

• 0.9: 2013-12-10

• 1.0: 2014-06-25 (Kepler release train)

• 2.0: 2014-10-24, (Luna release train)

• 3.0: 2015-06-25, planned (Mars release train)

Page 21: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Sirius Viewpoints

Base concept:

o Every diagram is a view of the model

o With a defined syntax

• Graphical

• Table/Tree syntax

• Xtext-based textual syntax

Viewpoint definition

o Viewpoint specification model

Page 22: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Viewpoint Specification Model

Viewpoint

Feature Provider registration

Mappings

Creation tools

Page 23: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Node & Edge Mapping

Domain class

Filter settings

Edge class

Source features

Target features

Page 24: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Feature Selection

Interpreted expressions o Special interpreters

• var: accessing specification model variables

• feature: accessing EMF model features

• service: accessing service methods

o Acceleo • Acceleo expressions

– Basic operations

– Comparison with single ‘=‘ symbols

• Syntax: [theExpression/]

o Raw OCL • Not recommended, Acceleo provides superset features

o Custom interpreter

Page 25: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Node & Edge Tool

Tool parameter variables

Model creation sequence

Different variables

More complex creation steps

Page 26: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Interpreted Modeler Development Viewpoint

specification

View model using the interpreted

specification

Page 27: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Technology Comparison GEF GMF Graphiti Sirius

Model Arbitrary EMF EMF EMF

Non graph-based presentation

Manageable Large amount of customization needed

Not supported Tree, Table

Code size Large, repetitive code

Mostly modeling, some coding

Smaller amount, but repetitive code

Negligible

Development workflow

Only coding Modeling and coding

Coding Modeling

27

Page 28: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Advanced issues

Cumbersome editing

o E.g., reorganization to insert a node to the middle

Handling large models

o 20+ nodes on a diagram:

• Logical structure, readability possible

• But needs human support

o 100-1000+ nodes on a diagram

• Technological limitations

• Usability limitations

28

Page 29: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Example: Layouting

29

Page 30: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Example: Layouting

30

Page 31: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Layouting Support for Graphical Editors

Computation of the position of nodes

o Possible to do automatically

o For a given metamodel

• No unified visual requirements possible

• We have to decide what is important to show

31

Minimum amount of

edge crossings

Minimum edge length

Page 32: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Layouting Support for Graphical Editors

GraphViz - http://graphviz.org

o Layouting project with high quality layout algorithm

o Hard to integrate into Eclipse applications

Zest - http://wiki.eclipse.org/index.php/Zest

o Graph widgets for SWT applications

o Easily integratable into Eclipse applications

o Not the best layout algorithms

KIELER - http://rtsys.informatik.uni-kiel.de/trac/kieler/

o Eclipse based tools

o Built-in support for GMF layouting

32

Page 33: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Textual or graphical?

Page 34: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Comparison

Textual Languages Graphical Languages

Quick and simple editing More cumbersome editing

References described as string identifiers

References displayed visually

Inconsistent models during editing

Models always syntactically correct

Automatic formatting Automatic layouting

Content assist Tool list to add nodes/edges

Displaying validation errors, offering quick fixes

Both are supported with EMF-based technologies 34

Page 35: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

35

Editing

State

Modified state

Edit

Graphical editors • Insert model element • Remove model element • Insert reference • Remove reference • Modify attribute

Textual Editors: • Insert character(s) • Delete character(s) • Replace character(s)

Page 36: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Question: textual or graphical?

No clear choice

Rules of thumb

o Behaviour description is usually simpler in textual

o For structural information graphical is often better

For simple languages

o Form-based editing might also be an alternative

36

Page 37: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Xtext and GMF on the same instance model

37

Page 39: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Concrete Syntax Design

Conclusion

Page 40: Graphical Concrete Syntax Design for Domain-specific · PDF fileoFully functional editor can be generated ... •Xtext-based textual syntax Viewpoint definition oViewpoint specification

Concrete Syntax Design

Multiple approaches

o Textual and/or graphical syntaxes

o Combinable

Large amount of development work needed

o Directly used by users

o Usability issues

Not everything is coded in an editor

o Editor + corresponding views form the interface

40