Eindhoven University of Technology

MASTER

Integration of Xtext and GMF editors in

Dudojevic, E.

Award date: 2014

Link to publication

Disclaimer This document contains a student thesis (bachelor's or master's), as authored by a student at Eindhoven University of Technology. Student theses are made available in the TU/e repository upon obtaining the required degree. The grade received is not published on the document as presented in the repository. The required complexity or quality of research of student theses may vary by program, and the required minimum study period may vary in duration.

General rights Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights.

• Users may download and print one copy of any publication from the public portal for the purpose of private study or research. • You may not further distribute the material or use it for any profit-making activity or commercial gain Technical University Eindhoven

Master Thesis

Integration of

Xtext and GMF editors in Eclipse

Supervisors: Author: prof. dr. Mark van den Brand Edin Dudojevi´c dr. ir. Arjan Mooij

Software Engineering and Technology Department of Computer Science

June 2014 Abstract

Modern Integrated Development Environments (IDEs) provide interactive textual ed- itors and often also offer graphical editors for additional visualization. Eclipse is a platform for developing IDEs, frameworks and other plug-in based applications. The Eclipse Modeling Framework (EMF) is one such framework that enables us to build textual, graphical and other editors on a structured data model. Multiple EMF based frameworks have been developed that offer textual and graphical model editors. How- ever, these frameworks often only operate in isolation, and at best provide a partial integrated solution. Furthermore, textual frameworks can be used mainly to operate on full models. The main problem is that as models tend to get large a user quickly loses overview, which raises the question on how we can isolate certain parts of a model, edit these parts and do this from multiple active editors.

In this work we investigate specifically the EMF based frameworks Xtext and GMF, used respectively for developing textual and graphical editors. For both frameworks we propose several approaches on how to apply and orchestrate partial model editing with an overall synchronization of multiple editors. We provide the relevant integration code and demonstrate the proposed solutions with a couple of implementations. Acknowledgements

First of all, I would like to to thank my supervisors Mark van den Brand and Arjan Mooij, which devoted a large amount of time to steer this project into the right direction. Their feedback and insightful criticisms have been very helpful and aided the succesful completion of this project. Big thanks also goes to Luo Yaping (Luna) for her overall help and useful discussions at times I faced challenging problems.

Finally, a special thanks goes to my beloved fiance Ajka, but also my mother Emina and my brother Ermin who all supported me throughout my entire study, and especially during this project.

iii This thesis is dedicated to my father, NedˇzadDudojevi´c. . .

iv Contents

Abstract ii

Acknowledgements iii

Contents v

List of Figures ix

Contents xi

Abbreviations xiii

1 Introduction1 1.1 Context...... 1 1.2 Project background...... 1 1.3 Problem domain...... 2 1.3.1 Problem overview and goal restrictions...... 2 1.3.2 Problem statement...... 5 1.4 Summary and approach...... 5

2 Integration requirements7 2.1 POOSL language...... 7 2.1.1 POOSL Definition...... 7 2.1.2 Relation to SHESim...... 8 2.2 POOSL use cases...... 9 2.2.1 Creating instantiations and editing existing cluster classes..... 10 2.2.2 Instantiating clusters...... 11 2.2.3 Renaming a process class and its ports...... 13 2.2.4 Error propagation...... 14 2.3 Integration requirements...... 15 2.4 Conclusions...... 16

3 State of the art 17 3.1 Survey of EMF-based technologies...... 17 3.1.1 The Eclipse Project...... 17 3.1.2 Eclipse Modeling Framework (EMF)...... 18

v Contents vi

3.1.3 Textual modeling frameworks...... 19 3.1.4 Graphical modeling frameworks...... 20 3.1.5 Evaluation...... 23 3.2 Existing integration...... 24 3.2.1 Propagation of changes...... 25 3.2.2 GMF model referencing...... 26 3.2.3 Summary and evaluation...... 28 3.3 Conclusions...... 29

4 Towards partial model editors 31 4.1 Introduction...... 31 4.2 Partial model Xtext editors...... 32 4.2.1 The highlight range approach...... 32 4.2.1.1 Synchronization of regular changes...... 33 4.2.1.2 Eclipse editor operations...... 36 4.2.1.3 Renaming elements...... 36 4.2.1.4 Sub-grammar restrictions...... 37 4.2.1.5 Evaluation of advantages and disadvantages...... 38 4.2.2 Dedicated partial model Xtext editors...... 40 4.3 GMF partial editors...... 41 4.4 Embedded partial editors...... 41 4.4.1 Possible combinations of embedded editors...... 41 4.4.2 Viewing and editing textual partial models as labels...... 42 4.4.3 Viewing and editing labels with syntax highlighting...... 45 4.5 Evaluation...... 46 4.6 Conclusion...... 46

5 Architectural patterns 47 5.1 Introduction...... 47 5.2 Navigational structures...... 48 5.3 Multi-editor architectures...... 50 5.4 Conclusions...... 54

6 Implementation 55 6.1 Introduction...... 55 6.2 Greetings...... 56 6.2.1 Generating implementation code...... 56 6.2.2 Customization...... 56 6.2.3 Result...... 57 6.3 State machines...... 57 6.3.1 Generating implementation code...... 57 6.3.2 Customization...... 58 6.3.3 Result...... 59 6.4 Web application...... 59 6.4.1 Generating implementation code and customization...... 60 6.4.2 Result...... 60 6.5 POOSL...... 61 Contents vii

6.5.1 Generating implementation code...... 61 6.5.2 Result...... 61 6.6 Evaluation...... 63

7 Related work 65 7.1 Related technologies...... 65 7.1.1 Sirius...... 65 7.1.2 Meta Programming System (MPS)...... 66 7.1.3 Yakindu Statechart Tools...... 66 7.1.4 BPEL Designer...... 68 7.2 Related research...... 68

8 Conclusions 73 8.1 Results...... 73 8.2 Further discussion on co-evolution...... 74 8.3 Future work...... 75

A Xtext grammars and model definitions 77 A.1 Greetings Xtext grammar...... 77 A.2 Statemachines Xtext grammar...... 77 A.3 Web application Ecore definition...... 78 A.4 POOSL high-level meta-model...... 80

B Integration code 81 B.1 Activator.java...... 81 B.2 EditPolicyProvider.java...... 82 B.3 OpenEditPolicy.java...... 83 B.4 XtextNewTabEditor.java...... 84 B.5 plugin.xml extension point...... 87

C Tutorials 89 C.1 Creating an Xtext editor...... 89 C.2 Creating a GMF editor...... 90 C.3 Integrating YST plugins...... 92

Bibliography 95

List of Figures

1.1 An example Eclipse instance using multiple editors...... 3

2.1 SHESim interface, showing a high-level overview of a network layer model8 2.2 SHESim: Class editing window for DataLinkSender3 ...... 9 2.3 SHESim: Instantiation parameter editing window for DataLinkSender3 .9 2.4 Selecting the process definition SomeProcessClass from the property view 10 2.5 Connecting the ports with channel c ...... 10 2.6 Choosing the class definition of a process from the right-click menu.... 10 2.7 Showing the class definition in a textual editor...... 11 2.8 Showing the instantiation parameters in a textual editor...... 11 2.9 Adding extra port q ...... 11 2.10 Creating a new cluster cluster1 ...... 12 2.11 The textual representation of cluster1 ...... 12 2.12 Adding and connecting cluster ports s and r ...... 12 2.13 Connecting the two processes to previously created cluster...... 13 2.14 Renaming a process class and its ports...... 14 2.15 Defining a custom process class in the textual editor...... 14 2.16 Synchronization of graphical editor by using an incomplete textual model 15

3.1 The relationship between EditPart, model element and graphical repre- sentation...... 21 3.2 The relationship between GEF, GMF and EMF...... 21 3.3 Simplified GMF workflow...... 22 3.4 GMF synchronization with the standard outline and properties view... 24 3.5 Default Xtext-GMF synchronization overview...... 25 3.6 Greetings example file...... 27

4.1 An example with applying the highlight range functions...... 33 4.2 Highlight range showing entire line where the offset range is located... 39 4.3 Editing a label in GMF...... 42 4.4 An example use of GMF compartments...... 43 4.5 Editing a label in GMF...... 43 4.6 Editing a label in GMF...... 45

5.1 Using the Open-declaration functionality with the highlight-range method 49 5.2 Conceptual architecture for the default Xtext-GMF integration...... 50 5.3 GMF diagram defined for the full model, and the Xtext editor defined for a sub-tree...... 52

ix List of Figures x

5.4 Multi-editor architecture using a full model Xtext editor and a sub- diagram GMF editor...... 53 5.5 Multi-editor architecture using one Xtext editor for full model and two different GMF editors...... 53

6.1 Greetings example: the full textual model...... 57 6.2 Greetings example: a partial textual model element...... 57 6.3 Statemachines example diagram...... 59 6.4 Web application example: meta-model definition...... 60 6.5 Web application example: instantiated subdiagrams...... 61 6.6 POOSL example: GMF editor for the system element, showing its high- level instances...... 62 6.7 POOSL example: Opening up a GMF sub-diagram from a cluster class element...... 62 6.8 POOSL example: Showing instance parameters in Xtext...... 63 6.9 POOSL example: Showing a cluster class definition in Xtext...... 63 6.10 POOSL example: Showing system and its instances...... 63

7.1 Projectional editors in MPS where effectively textual editors are embed- ded in other textual parts...... 67 7.2 Yakindu wrapper example integrated with a state transition system... 67 7.3 Xtext integration in BPEL Designer...... 69 7.4 Embedding textual editors into graphical host editors using the approach of Scheidgen...... 70

A.1 High-level meta-model of POOSL...... 80

C.1 GMF Dashboard...... 90 C.2 Workflow for the creation of a GMF editor...... 91 C.3 Yakindu wrapper example integrated with a state transition system... 92 C.4 Yakindu wrapper example integrated with a state transition system... 94 Listings

3.1 Greetings example diagram file: XMI content...... 26 3.2 Greetings example diagram file: using indexes...... 27 4.1 Applying the highlight range functions...... 32 4.2 Determining the offset and length of a model element...... 33 4.3 PartialParser example...... 38 6.1 Statemachines: example file...... 59 A.1 Xtext grammar: Greetings...... 77 A.2 Xtext grammar: Statemachines...... 77 A.3 Web application ecore file...... 78 B.1 Activator.java...... 81 B.2 EditPolicyProvider.java...... 82 B.3 OpenEditPolicy.java...... 83 B.4 XtextNewTabEditor.java...... 84 B.5 plugin.xml extension point...... 87

xi

Abbreviations

API Application Programming Interface AST Abstract Syntax Tree DSL Domain Specific Language EMF Eclipse Modeling Framework ESI Embedded Systems Innovation (by TNO) GEF Graphical Editing Framework GMF Graphical Modeling Framework IDE Integrated Development Environment MPS Meta Programming System MVC Model View Controller POOSL Parallel Object-Oriented Specification Language SLCO Simple Language of Communicating Objects UI User Interface URI Uniform Resource Identifier XMI XML Metadata Interchange XML eXtensible Markup Language YST Yakindu Statechart Tools

xiii

Chapter 1

Introduction

1.1 Context

Domain-Specific Languages (DSLs) receive attention as the possible next abstraction step in programming that bring software development closer to the domain requirements. Modern implementation technologies like the Eclipse Modeling Framework (EMF) seem to boost the industrial interest in DSLs. There are several tools based on EMF for developing textual editors and graphical editors. Although EMF acts as a common base to such editors, the proper way to integrate them is not so clear.

1.2 Project background

The origins of this project lie in the work of Zlatka Manevska who created a User Interaction Layer (UIL) for POOSL [1], which is a system-level description language that is used at Embedded Systems Innovation (ESI), a group of TNO in Eindhoven, for modeling complex systems. The UIL is meant to replace SHESim, which is a combination of textual and graphical editors used for specification of POOSL models.

The main problem with SHESim is that it is outdated and poses several limitations such as the lack of interactivity and many other usability issues. Manevska developed a sophisticated textual editor for POOSL, but also provided a graphical editor prototype, both based on EMF. Based on an evaluation of existing technologies Xtext and GMF 1 Chapter 1. Introduction 2 were chosen for the development of respectively a textual and graphical editor. However, due to several difficulties, the integration of textual and graphical editing turned out to be far from trivial and was therefore left as an open issue. This served as a basis for the formulation of this research project, which in contrast to Manevska’s project, however, focuses on the integration problem in general within the range of Eclipse and EMF based textual and graphical frameworks.

1.3 Problem domain

In this section we analyse the problem of integrating editors by discussing various aspects that play an important role. Based on this discussion we formulate the problem and establish several research questions that will be answered at the end of this thesis.

1.3.1 Problem overview and goal restrictions

Integration can be defined in a very broad way: the act of combining or adding parts to make a unified whole. From the perspective of models in modern IDEs, we look at combining different kinds of representations of such a model that we consequently want to view or edit. The Eclipse platform is a perfect example that allows the use of multiple windows with various editors and many more functionalities as one would expect from a mature IDE. In Figure 1.1 we see such an Eclipse instance where multiple editors ares used, indicated with red. The objects indicated with a green color are different representations of the same model element that is shown over multiple editors, and saved within one file. Changes to an object in one editor is in most cases directly reflected in other editors.

To make this possible we require a tight integration between these editors, where we need to consider a couple of important aspects. From the user perspective we can think of the following characteristics:

• Partial views: The advantage of considering only a part of the model is mainly because of modularity: we only focus on the relevant part that we want to view and/or edit. Especially in case of big models which are often not useful to view at once, we would rather split them up in partial views from which we can navigate Chapter 1. Introduction 3

Figure 1.1: An example Eclipse instance using multiple editors

further through the rest of the model. In hierarchical models, for example, a navigation through layered views could be realized where each view contains a certain level of abstraction with information that is considered relevant at that point. Note furthermore that the use of partial model views also applies to small models in case we for example edit certain properties of a model element. In any case we want to restrict the information we see as the user.

• Multiple types of editors: A user should be able to use multiple types of editors: textual, graphical, tree editors, etc.

• Multiple editors at the same time: Modern IDEs usually allow the user to use multiple views and/or editors at the same time.

Based on the above characteristics the following issues arise:

• Representation/Serialization: There are different kinds of representations to choose which in general are either textual or graphical, but the representations can also be of some other form like tree-views such as the outline in Eclipse. Moreover, Chapter 1. Introduction 4

certain parts of our model are best represented textually, such as complex expres- sions, while others can be represented both textually and graphically. We can serialize our model to a certain format but in case of multiple representations we may have additional information. For example, graphical editors can have position information that, if adaptable by the user, typically needs to be saved. Textual editors, on the other hand, should be able to save textual layout information or comments. Furthermore, should we save this textual and/or graphical information to one or multiple files?

• Synchronization: Having multiple editors raises several important questions if we look at how we update and propagate information between them:

Time of serialization: When do we save our model after changes are made? Is this done in real-time or only when a user explicitly saves the model?

Synchronization: How do changes affect the model that is (partially) displayed in several editors? For example, one typically wants to always have an option to save a model, even if it contains errors. Synchronization therefore might not always be possible, or, if still performed, can lead to unexpected behavior.

• Navigation: When using multiple editors we can also think about the way we navigate between these editors. This especially plays a role when partial views are considered. With respect to this we can ask the following questions. What possibilities for navigation can we use in this case? What influence does the use of different kinds of editors have on this navigational structure?

These questions provide a rough sketch of some of the possible problems that one might encounter. When dealing with existing technologies that need to be integrated it is necessary to analyze all the constraints and possibilities that each tool entails, which in turn can easily add up to the previously discussed complexities. This makes the problem very broad, which in the scope of this project, requires us to narrow the focus of this research. We will therefore restrict ourselves to the Eclipse ecosphere, and more specifically, on EMF based frameworks within Eclipse. Furthermore, we primarily look at integrations between textual and graphical editors. Chapter 1. Introduction 5

1.3.2 Problem statement

Based on the previous discussions we can formulate the problem statement as follows: We want to be able to edit a model using multiple (partial) editors, both textually and graphically (or some other representation form), while keeping everything synchronized, independent of the modeling language being used. In addition, we also want to be able to navigate between these editors, where applicable.

Regarding the above problem statement, there are furthermore a couple of important questions that need to be answered:

• Which EMF-based frameworks can and should be used?

• How can this integration of editors be done in a systematic and generic way?

1.4 Summary and approach

In the previous sections we have discussed various aspects of integration in general and formulated the problem statement. Based on these integration aspects which encompass multiple problems including the creation of partial model editors and synchronization between them, it is clear that this is not a trivial problem, which was exactly one of the conclusions of Manevska in [1]. Moreover, there is also no single solution since integration strongly depends on the users specific needs (which will be discussed in the following chapters). Since the topic of integrating editors in general is too broad for this project, the scope was narrowed by explicitly choosing for Eclipse, and more specifically, EMF.

To solve this problem we will use the following approach. We first establish the integra- tion requirements based on a few uses cases for an existing modeling language (discussed in the next chapter). We will use the POOSL language, which fits in line with previous work by Zlatka Manevska [1]. In the next step we investigate existing technology and discuss whether it can be used to solve our problem. For the provided solution we will set as goal to provide an effective solution that is both practical and easy to apply. After proposing a solution we will show that these integrations can indeed be accomplished by implementing a couple of representative use cases. Chapter 1. Introduction 6

The outline of this thesis is as follows:

• Chapter2: In this chapter we discuss a couple of representative use cases and establish the integration requirements.

• Chapter3: In this chapter we discuss related technologies, select the most ap- plicable tools, and discuss existing integrations based on this selection.

• Chapter4: This chapter describes a couple of approach on constructing partial- model editors.

• Chapter5: This chapter describes the integration patters when multiple editors are used in a larger context.

• Chapter6: In this chapter we present a few implementations to confirm our findings.

• Chapter7: In this chapter related work is discussed.

• Chapter8: In this final chapter we reflect on the overall results and draw the necessary conclusions. Chapter 2

Integration requirements

In this chapter we show a few relevant use cases for the POOSL language. Based on these use cases we finally formulate the integration requirements. The SLCO language has also been investigated but will be omitted in this chapter since it is very similar to POOSL.

2.1 POOSL language

2.1.1 POOSL Definition

POOSL (Parallel Object-Oriented Specification Language) is a system-level modeling lan- guage that has been used at ESI (Embedded Systems Innovation by TNO) for modeling complex systems. It is part of the system-level design method SHE (Software/Hardware Engineering) and was formally defined in [2]. POOSL models can be executed with the simulation tool SHESim [3].

POOSL consists of three conceptual layers [4]: an architecture, a process and a data layer. The architecture layer describes reactive systems which can often be decomposed into several communicating subsystems, which may also be decomposable. The modeling elements of the architecture layer are:

• Processes: represent subsystems that are considered as single entities

7 Chapter 2. Integration requirements 8

• Clusters: denote a group composed of processes and clusters, by which they introduce hierarchy to the models

• Channels: symbolize the communication paths between processes and clusters

The process layer describes the behavior of processes, their communication interface and their message interface. Processes are instantiations of their process classes. A process consists of ports that are possibly connected to channels through which messages can travel. The data layer contains data classes that describe what variables and methods its instances have.

A high-level meta-model of POOSL with the most important elements for our use cases is given in Appendix A.4.

2.1.2 Relation to SHESim

It is important to note that we will loosely adhere to the navigational structure of SHESim [5]. The interface of SHESim with an example model of network layers is shown in Figure 2.1.

Figure 2.1: SHESim interface, showing a high-level overview of a network layer model

The SHESim concepts that we want to use in our use cases are mainly editing classes and instantiation parameters in separate windows. So if we want for instance to edit the class of DataLinkSender3 then we instantiate a new window from the right click menu as shown in Figure 2.2. Chapter 2. Integration requirements 9

Figure 2.2: SHESim: Class editing window for DataLinkSender3

In this window we can add/remove/edit instance variables, instantiation parameters, in- stance methods, port interfaces and message interfaces. Editing of instantiation param- eters is performed in a separate window. The instance parameters of DataLinkSender3 are edited in a separate window, as shown in Figure 2.3.

Figure 2.3: SHESim: Instantiation parameter editing window for DataLinkSender3

2.2 POOSL use cases

In this section we discuss a few relevant use cases for POOSL, based on SHESim. Note that the illustrations are used mainly as conceptual visualizations. Chapter 2. Integration requirements 10

2.2.1 Creating instantiations and editing existing cluster classes

We start by creating an empty diagram. The next thing we want to do is add two instances, process1 and process2 which should both be instantiations of some process class (we assume the process class is already defined).

We do this by placing the instantia- Properties tion elements on our diagram and se- Name process1 Class definition SomeProcessClass lecting for each the same process defini- tion SomeProcessClass (from the prop- Figure 2.4: Selecting the process definition erty view for example - see also Fig- SomeProcessClass from the property view ure 2.4).

We also want these processes to communicate with each other, so we connect their ports p and q by adding channel c. Figure 2.5 shows a high-level view of our system:

process1 : SomeProcessClass process2 : SomeProcessClass

c : Channel p : Port p : Port

System

Figure 2.5: Connecting the ports with channel c

Next we want to view and edit the process process1 : SomeProcessClass class SomeProcessClass. We do this by Right-click menu .. p : Port right clicking on the process1 figure and Instantiation parameters left clicking on the class definition option Class definition

.. from the drop down menu (Figure 2.6). The class definition is shown in a textual Choosing the class definition of a Figure 2.6: editor (Figure 2.7). process from the right-click menu

Similarly, we want to show the instantia- tion parameters. However, in this example the instance does not use any, so only the textual representation of the instance is shown without parameters (Figure 2.8). Chapter 2. Integration requirements 11

1 process class 2 ProcessClassY 3 instance variables 4 a : Integer; 5 port interface 6 p 7 message interface process1 : ProcessClassY 8 p1!easy; class 9 p2!normal; definition 10 p3!hard; 11 initial method call 12 someMethod()() 13 instance methods 14 someMethod()() 15 sel 16 in!easy; 17 or 18 in!normal; 19 or 20 in!hard; 21 les; 22 someMethod()().

Figure 2.7: Showing the class definition in a textual editor

1 instance process1 : SomeProcessClass ()

Figure 2.8: Showing the instantiation parameters in a textual editor

We now want to add one extra port to our process class, let’s say port q, by using the textual editor. The changes are saved (preserving textual layout (and possibly comments)) and we return to the previous high-level overview of our system. We directly see that the changes have been propagated since our port q is now also available in our graphical editor (Figure 2.9).

process1 : SomeProcessClass process2 : SomeProcessClass c : Channel p : Port p : Port

q : Port q : Port

System

Figure 2.9: Adding extra port q

2.2.2 Instantiating clusters

Based on the two processes and the process class changes from the previous use case, we continue by adding a cluster that will contain some internal processes that we want to hide from our high level view. We give our cluster the name cluster1 (Figure 2.10).

The textual representation of our cluster is shown in Figure 2.11. Chapter 2. Integration requirements 12

process1 : SomeProcessClass process2 : SomeProcessClass c : Channel p : Port p : Port

q : Port q : Port

cluster1 : SomeClusterClass

System

Figure 2.10: Creating a new cluster cluster1

1 instance cluster1 : SomeClusterClass ()

Figure 2.11: The textual representation of cluster1

In our new cluster we want to define some ports which we can connect to a channel between our defined processes. We do this by adding the cluster ports s and r. We also add two processes cp1 and cp2. We define the internal cluster structure as depicted in Figure 2.12.

cp1 : BClass r : Port s : Port rcp1 : Channel cp1s : Channel cp1r : Port cp1s : Port

cp1out : Port cp1in : Port

cp1cp2 : Channel cp2cp1 : Channel

cp2in : Port cp2out : Port

cp2 : SClass

SomeClusterClass

Figure 2.12: Adding and connecting cluster ports s and r Chapter 2. Integration requirements 13

We save the model and return to our high-level overview.

The final thing we want to do is to connect the processes process1 and process2 to our newly created cluster. We do this by defining two new channels qr and qs that connect ports q (process1) and r, and q (process2) and s. The result is shown in Figure 2.13. Any position information of the graphical objects is preserved.

process1 : SomeProcessClass process2 : SomeProcessClass c : Channel p : Port p : Port

q : Port q : Port

qr : Channel qs : Channel

r : Port s : Port

cluster1 : SomeClusterClass

Figure 2.13: Connecting the two processes to previously created cluster

2.2.3 Renaming a process class and its ports

In this use case we want to rename the class definition from the example in Figure 2.5 by using a textual editor. We show the system with a graphical editor, as displayed in the same figure, and now want to change the name of the process class definition within a textual editor. Since both instances use the same process class SomeProcessClass, we can use either instance to instantiate the editor. Within the textual editor we change SomeProcessClass into ProcessClassX. In addition, we also want to change the name of the port from currently p into x. After changing the names we save the changes and return to our graphical model overview. The changes have been propagated to the graphical view automatically (Figure 2.14). Chapter 2. Integration requirements 14

process1 : ProcessClassX process2 : ProcessClassX

c : Channel x : Port x : Port

System

Figure 2.14: Renaming a process class and its ports

2.2.4 Error propagation

We continue with the example from previous section. We now want to create a custom class for the second process instance process2. We open up the textual editor and empty the content. The process class for the second instance should now have the name ProcessClassY instead. However, at the moment we do not know what the rest of the process should look like but still want to save our incomplete process. The textual model is shown in Figure 2.15. Since we call the methode someMethodY which we have not defined later on, the editor (correctly) shows an error on line 16. We save the textual model and return to our graphical view of the system.

1 process class 2 ProcessClassY 3 4 instance variables 5 b : Integer; 6 7 port interface 8 y 9 10 message interface 11 y1!easy; 12 y2!normal; 13 y3!hard; 14 15 initial method call 16 x someMethodY()()

Figure 2.15: Defining a custom process class in the textual editor

The incomplete textual model still gets synchronized with the graphical view. We can see the result in Figure 2.16. We see that the name of the process is now shown as ProcessClassY, and the port name as y. However, since the channel connection is not defined correctly, it is not shown in our graphical model. Chapter 2. Integration requirements 15

process1 : ProcessClassX process2 : ProcessClassY

x : Port y : Port

System

Figure 2.16: Synchronization of graphical editor by using an incomplete textual model

2.3 Integration requirements

Based on the previous use cases we can formulate the following global integration re- quirements:1

IR0 It should be possible to instantiate editors both graphically and textually, where applicable.

IR1 It should be possible to switch between multiple editors (textual or graphical) that are active at the same time.

IR2 It should be possible to only show parts of a model, either textually or graphically.

IR3 It should be possible to show multiple parts of a model (textually and/or graphi- cally) at the same time.

IR4 The editors should provide a proper navigation structure:

[IR4.1] from graphical to textual

[IR4.2] from graphical to graphical

[IR4.3] from textual to graphical

[IR4.4] from textual to textual

IR5 Textual (including any comments, tabs, newlines etc.) and graphical layout is saved for a model.

IR6 Changes are propagated to other editors/views.

IR7 It should be possible to edit parts of a model in separate editors.

1Some of the requirements are not directly covered by the use cases, but are rather implicitly derived. Chapter 2. Integration requirements 16

We can directly relate these requirements to the integration aspects from Chapter1:

• Partial views: IR2, IR3

• Multiple types of editors: IR0, IR3

• Multiple editors at the same time: IR1, IR3, IR7

• Representation/Serialization: IR5

• Synchronization: IR6

• Navigation: IR4

2.4 Conclusions

In this chapter we have used a few use cases for the POOSL language in order to establish integration and related functional requirements. From the use cases we can relate to the integration aspects that we discussed in the previous chapter. We use partial views to show parts of a model and use different kinds of representations to do so. We navigate our models hierarchically by opening sub-diagrams for clusters while having both textual and graphical representations for our model elements. By using sub- diagrams and textual instantiations of parts of a model, we also use multiple editors. For the latter we of course require that changes are propagated correctly.

Based on these observations we derived general integration requirements. However, it is necessary to investigate existing technology and what constraints they enforce. In the next chapter we will evaluate multiple existing frameworks and choose the most applicable in terms of our stated requirements. Based on these results we will mainly try to answer the posed research question “Which EMF-based frameworks can and should be used?”. Chapter 3

State of the art

In the previous chapter we established the most relevant integration requirements by using a few POOSL use cases. The purpose of this chapter is to give a brief survey of existing technology and choose a set of related tools that best suits our needs with respect to our stated integrations requirements. Next, a thorough analysis of the selected tools is performed which will serve as a basis for establishing a solution to the problem in the next chapter.

3.1 Survey of EMF-based technologies

In this section we will briefly look at the existing technologies that are directly related to our stated problem, and more specifically, technologies based on EMF. We will start with the relevant concepts of Eclipse and EMF, followed by a breakdown of the available textual and graphical frameworks.1

3.1.1 The Eclipse Project

The Eclipse project supports the development of a platform, or framework, for the im- plementation of integrated development environments (IDEs) and other applications [6]. Eclipse is divided into several components, among which is the Plug-in Development En- vironment (PDE) that provides views and editors to facilitate the creation of plug-ins

1At the time of this writing, the Eclipse Kepler version has been used.

17 Chapter 3. State of the art 18 for Eclipse. Views present information about the object that is selected in another view or editor and typically reflect any changes immediately. The most important and related views in Eclipse are the standard Outline and the Property view.

Within our context we are mainly interested in the basic functionality provided by Eclipse for dealing with our models by using multiple editors. From that perspective, integrated tools in Eclipse work with ordinary files and folders, but use a higher level API (Application Programming Interface) that is based on resources, projects and a workspace. In this context, the most relevant concept is the Resource which is the Eclipse representation of a file. A resource contains change listeners, markers (such as error messages) and a history for previous content. Change listeners can be registered to receive resource change notifications (also called resource deltas) and used for syn- chronization on changes. Markers and history are less relevant for synchronization. A collection of resources which can contain cross references is called a ResourceSet.

3.1.2 Eclipse Modeling Framework (EMF)

The Eclipse Modeling Framework (EMF) is a framework and code generation facility for building tools and other applications based on a structured data model [6][7]. From a model specification described in XMI, EMF provides tools and runtime support to produce a set of Java classes for the model, along with a set of adapter classes that enable viewing and command-based editing of the model, and a basic editor.

To get a better understanding how we can use EMF to describe our models, we need to look at its core concept which is Ecore - a model for describing models, also called a meta- model. Using EMF and such a meta-model definition, we can create model instances which are by default serialized as Ecore XMI (XML Metadata Interchange) files. We will see later on that such a file can be used as a central point of integration. Furthermore, EMF provides us with the possibility to automatically generate implementation code, which is directly used by higher-level frameworks that use EMF as their basis. This is done by a so called generator model that describes the translation of the content into executable code. We can also directly customize this code to meet our specific needs. For a detailed description of EMF see also [6]. Chapter 3. State of the art 19

3.1.3 Textual modeling frameworks

Xtext Xtext is an EMF-based framework for developing textual DSLs and it can be used to edit textual representations of models [8].2 The initial version of Xtext was part of the openArchitectureWare framework [9], which now, after a rewrite, became part of the Textual Modeling Framework (TMF) in Eclipse.

Xtext offers many useful functionalities such as syntax coloring, code-completion, outline- view, source-code navigation, hovers, etc. The runtime components (parser, lexer, linker, validation, etc.) are integrated with EMF which gives us the possibility to use Xtext with other EMF-based frameworks. Moreover, Xtext uses EMF models as in-memory representations of any parsed text files. We call such an in-memory object an Abstract Syntax Tree (AST) or simply model [? ].

After defining a DSL grammar, we can automatically generate an editor. Furthermore, Xtext automatically creates an EMF generator model and runs it, which in turn gen- erates the EMF implementation code. Xtext also automatically generates an Ecore meta-model that corresponds to our previously defined Xtext grammar.

EMFText EMFText is a framework that lets you define textual DSLs by using a predefined Ecore meta-model.3 It provides provides a syntax specification language from which textual editors and components to load and store model instances can be generated [10]. It offers, just like Xtext, advanced features such as code completion, customizable syntax, etc.

Other textual modeling frameworks There exist also other, EMF-based textual modeling frameworks such as TEF (Textual Editing Framework)4 [11], TCS (Textual Concrete Syntax) [12] and MontiCore5 [13].

An extensive survey on language workbenches has been made by Erdweg et al. in [14], where additional textual frameworks are discussed such as Rascal and Spoofax. However, these frameworks are not based on EMF. Since this work has not been intended to 2http://www.xtext.org/ 3http://www.emftext.org/ 4http://tef.berlios.de 5http://www.monticore.org/ Chapter 3. State of the art 20 provide an extensive investigation of all the frameworks, these other frameworks are omitted and serve here only for the sake of completeness.

3.1.4 Graphical modeling frameworks

GEF The Graphical Editing Framework (GEF) is a framework that provides technology to create rich graphical editors and views for the Eclipse Workbench UI [15]. GEF is built on top of the following components:

• Draw2D (org.eclipse.draw2d) A layout and rendering toolkit for displaying graphics on an SWT Canvas [16].

• GEF MVC framework (org.eclipse.gef) A model-view-controller framework that fosters the implementation of SWT-based tree and Draw2d-based graphical editors for the Eclipse Workbench UI. [17].

• Zest (org.eclipse.zest) The Eclipse visualization toolkit [18]. Zest is based on the Standard Widget Toolit (SWT) [19].

GEF uses so called EditParts which are basically the building blocks for GEF viewers. They serve as a link between the application’s model and the visual representation. This is illustrated in Figure 3.1. However, GEF uses quite low level functions for drawing and is best used by providing drawing functionality for any higher level framework. Furthermore, the components of GEF do not provide any connection with the EMF editor which was exactly one of the main requirements.

GMF The Graphical Modeling Framework (GMF) is a framework within the Eclipse plat- form that provides a generative component and runtime infrastructure for developing graphical based editors based on EMF and GEF. Currently, it is part of the Graphical Modeling Project (GMP) as three separate components: GMF Tooling, GMF Runtime and GMF Notation. With GMF Tooling we can create and edit models, but also a gen- erator for producing implementation code that uses GMF Runtime for the core functions of the graphical editor. GMF Notation provides a standard EMF notational meta-model Chapter 3. State of the art 21

GraphicalViewer

Model EditParts Figures

x

Figure 3.1: The relationship between EditPart, model element and graphical repre- sentation that takes care of persisting diagram information separately of the domain model. The dependencies of GEF, GMF and EMF are illustrated in Figure 3.2.

GMF Editor

uses

GMF Runtime uses uses

EMF uses GEF

uses uses

Eclipse Platform

Figure 3.2: The relationship between GEF, GMF and EMF

Developers that use GMF to create graphical editors typically follow the workflow as shown in Figure 3.3.

We can summarize the steps as follows. After creating a domain model (.ecore) we can derive the following files:

• Graphical definition model: a .gmfgraph file where we define our concrete graph- ical syntax. Chapter 3. State of the art 22

.gmfgraph

Graphical Definition Model .ecore .gmfmap .gmfgen

Domain Mapping Generator generate Basic Model Model Model GMF-editor

Tooling Definition Model

.gmftool

Figure 3.3: Simplified GMF workflow.

• Tooling definition model: a .gmftool file where we define the tools that will be available for creating graphical elements.

By combining our domain model and the above two definition models we can generate a so called mapping model (.gmfmap) that essentially maps elements from our domain model to our graphical notation definition. Once we have created a mapping model we can create a generator model (.gmfgen) by which we are able to automatically generate implementation code that we can customize to our needs.

On top of GMF, there exist (at least) three higher-level frameworks:

• EuGENia is a framework used on top of GMF that raises the level of abstraction in generating GMF editors, based on an annotated Ecore model [20].

• Kaybele is very similar to EuGENia and is also a higher-level framework that provides the possibility for annotations and automatically generate GMF code.6

• GenGMF is another high-level framework that also aims at simplifying the in- cremental development of GMF editors [21].7

These higher-level frameworks can greatly decrease the development time and complexity of simple GMF editors. Although it can significantly increase the level of production, it should not be the point of investigation (in terms of our integration problem) since the core functionality that we will be focusing on resides in GMF.

6The project seems abandoned with its last contribution dating to 2010. 7The project has been abandoned and the Eclipse project proposal has been withdrawn. Chapter 3. State of the art 23

Graphiti Graphiti is a framework for developing graphical editors for models based on EMF [22] and is analogous to GMF. However, it currently still resides in the so called “Incubation Phase”, that is, it is still not a fully functioning product. Furthermore, in the work of Refsdal it is stated that edit policies, requests and commands are “invisible” to the user in Graphiti [23]. Another important fact is that Graphiti, unlike GMF, does not generate any implementation code. This raises questions regarding the practical difficulties with integration and whether this is achievable. With this in mind and without further investigation it is assumed that any integrations are at least more difficult to achieve than is the case with GMF. For the sake of completeness it is worth mentioning that a higher-level framework for Graphiti exists called Spray [24], which is somehow analogous to EuGENia and Kaybele.

3.1.5 Evaluation

Just as Xtext, EMFText uses EMF for defining the abstract syntax and is considered very similar [25]. Although EMFText can probably also be used as an Xtext alternative, in this project the choice was made to use only Xtext, for several reasons. The most important one is that POOSL is used as a use case, but also because there was already an Xtext grammar available for POOSL [1]. Furthermore, the Xtext community seems significantly larger and there seem to be more examples and documentation available. Last but not least, the author was already familiar with Xtext.

For constructing a graphical editor we considered several frameworks. GEF is considered quite low level and does not provide any linkage to EMF. The higher-level frameworks GMF and Graphiti do provide this linkage to EMF, but as we discussed Graphiti had major drawbacks in comparison with GMF: it does not generate implementation code and it is not published as a major version. This results in GMF as the clear choice. Other even higher-level framework exist on top of GMF (and Graphiti), but these are considered irrelevant since they mainly facilitate automation of generating implementa- tion code. Chapter 3. State of the art 24

3.2 Existing integration

We already mentioned that Eclipse provides two relevant views which are integrated into the workbench: the standard Outline and the Property view.8 EMF, Xtext and GMF are directly integrated with these default Eclipse views. In case of GMF, for example, when viewing our model definitions we see the tree structure of our model displayed in the Outline view where we can also make certain changes. Other information such as selection of nodes in the Outline view is also propagated to the other view(s) (Figure 3.4).

Figure 3.4: GMF synchronization with the standard outline and properties view.

Besides the synchronization between default Eclipse components and Xtext/GMF there already exists an out of the box synchronization between Xtext and GMF on full models.9 The typical way of achieving this is to start off with an Xtext grammar, generate the Xtext artifacts, and then use the obtained Ecore model in the GMF workflow to generate a GMF editor (discussed in Section 3.1.4).

A simplified overview of the existing integration is depicted in Figure 3.5. The Xtext and GMF views (on top) are textual and graphical representations of our model, re- spectively. Each such editor uses a ResourceSet that in turn contains a Resource that reflects an in-memory model of our physical file. Xtext uses an XtextResource, which is an extension of the default Resource class. GMF, on the other hand, which needs to deal with both position information of the graphical elements and with the abstract

8These views are sometimes also editors when we get the option to make changes. 9http://www.eclipse.org/Xtext/documentation/2.6.0/Xtext%20Documentation.pdf, Section: “13.4. Integration with GMF Editors”. Chapter 3. State of the art 25 model elements, uses two resources: an XtextResource and a DiagramResource. The XtextResource contains our AST, and the DiagramResource contains the graphical ele- ments and a reference to XtextResource elements. The XtextResource corresponding to Xtext and the other one to GMF are two strictly separate Resources, where the content is considered equal only after performing synchronization. Xtext GMF

ResourceSet ResourceSet

XtextResource XtextResource DiagramResource refers to

save/load save/load save/load

Xtext file GMF File

Figure 3.5: Default Xtext-GMF synchronization overview.

3.2.1 Propagation of changes

Any changes, either in our Xtext or GMF editor, are propagated to other active editors and views. So when we for example change our model by using our Xtext editor and save the changes, the XtextResource of GMF gets updated but also the content in the GMF editor. It is important to note that in this case we preserve layout information of other graphical objects that already existed and were displayed in our GMF editor. This is possible because GMF is able to perform a merge in a relatively straightforward way where it compares the previous and current state of our model. However, because of the integration of GMF with Xtext it is still possible to lose layout information. We will discuss this issue and the way GMF references domain model elements in more detail in Section 3.2.2.

Changes are propagated to other editors and views only when they are saved. Another option would be to perform this in real-time, so that changes in one editor are directly visible in other active editors. However, real-time synchronization adds much more complexity to the problem and would therefore easily fall outside the scope of this Chapter 3. State of the art 26 project. Furthermore, van Rest et al. have already investigated this issue and proposed an approach in [26] (discussed in Chapter5). Because of the stated reasons it was chosen explicitly not to handle this issue of real-time synchronization.

3.2.2 GMF model referencing

In the previous section we have seen how existing synchronization between Xtext and GMF is realized. In the current approach (as depicted previously in Figure 3.5) Xtext and GMF both have their own XtextResource. Although it is possible to share this resource between Xtext and GMF so that changes on our domain model are reflected directly, it is duplicated in this way for a good reason: on each change Xtext parses the text and rebuilds the AST which means that a subtree (or even the entire tree depending on the specific change) gets removed and again inserted after parsing. If we would use the same XtextResource for Xtext and GMF, removing and adding nodes from our AST during reparsing by Xtext would result in GMF also removing graphical nodes and inserting it back into view. However, removing nodes from GMF would also mean that layout information gets lost, which in most cases gives unwanted behavior but it also does not fulfill our integration requirement where we explicitly state that any layout information should be preserved.

However, this preservation of layout information is not foolproof. The problem lies in the way the diagram file references our textual model. Moreover, when we decide to use both Xtext and GMF, we by default use one file in which the textual representation of our model is stored. The GMF diagram file contains only layout information and maps graphical objects to their corresponding domain model elements stored in the textual file. Referencing is done by using so called URI fragments. In case of multiple elements of the same type, indexes are used to identify them. This gives problems in case the order of some elements is switched. We will illustrate this with a small example. Let us assume that we have already generated our Xtext and GMF editor (by following the steps as described in Appendix C.1 and C.2, respectively). We create a file default.mydsl containing three greetings objects and instantiate a diagram file default.mydsl diagram as shown in Figure 3.6.

The contents of the diagram file are shown in Listing 3.1. Chapter 3. State of the art 27

Figure 3.6: Greetings example file

Listing 3.1: Greetings example diagram file: XMI content

1 § ¤

2

3

4

5

¦ ¥ On this first instantiation the generated diagram file does not include position informa- tion and assumes default positions that are to be determined by GMF when the file is opened. In our case line 4 references the entire model (the Model model element) by using href="default.mydsl#/". However, when we choose a specific position for our objects the layout information is added and then instead of referencing the whole model we reference each object separately, which in our case are the Greeting model elements. Indexes are then used as shown in Listing 3.2.

Listing 3.2: Greetings example diagram file: using indexes

1 §.. ¤

2 ..

3 ..

4 ..

¦ ¥ Chapter 3. State of the art 28

So if we swap lines 1 and 2 in our textual file (Figure 3.6) and save it, our diagram file will still point to the earlier specified index which now essentially is another object. This results in having the two elements switched graphically, while strictly speaking the graphical model should not have changed at all.

Even though this “issue” can give some unwanted behavior we will accept the current situation and that our requirement of preserving layout information (at least to some extent) is met. Since this is core GMF functionality, and we explicitly avoid making changes to the source code of the chosen frameworks to avoid further complications, we will not dive deeper into the problem and how it can possibly be solved.

3.2.3 Summary and evaluation

In this section we have discussed the existing integration between Xtext and GMF, which can be established when following a certain development workflow. Namely, we start off with an Xtext grammar from which we generate Xtext artifacts, and consequently generate a GMF editor that is automatically adapted such that the editors are synchro- nized on changes when they are saved. This directly fulfills the following integration requirements which we established in the previous chapter (Section 2.3):

• IR0: It should be possible to instantiate editors both graphically and textually, where applicable. We can instantiate an Xtext and GMF editor, for respectively textual and graphical editing

• IR1: It should be possible to switch between multiple editors (textual or graphical) that are active at the same time. We can switch between an Xtext and GMF editor.

• IR2: It should be possible to only show parts of a model, either textually or graphically. Showing parts of a model is only possible with GMF.

• IR3: It should be possible to show multiple parts of a model (textually and/or graphically) at the same time. Chapter 3. State of the art 29

We can show the full model in Xtext and a graphical representation of the model in GMF at the same time.

• IR5: Textual (including any comments, tabs, newlines etc.) and graph- ical layout is saved for a model. Textual and graphical layout is saved.

• IR6: Changes are propagated to other editors/views. Changes between the Xtext and GMF editor are propagated when these are saved.

• IR7: It should be possible to edit parts of a model in separate editors. Editing parts of a model is essentially only possible with a defined GMF editor.

Although this out of the box integration solves a significant portion our stated prob- lem, it has also some drawbacks. After observing the above evaluation of integration requirements we can see that not all requirements are met. Moreover, integration re- quirements IR2 and IR7 are only partially satisfied since this only applies to GMF, while IR4 (Editors should provide a proper navigation structure) is not satisfied at all. Finally, a minor disadvantage of this integration is the fact that because of the GMF referencing mechanism we can possibly get unwanted behavior because elements cannot always be correctly identified. Because of its low impact on our situation, however, we will leave this referencing problem as is.

3.3 Conclusions

After a short survey we have chosen Xtext and GMF as our respectively textual and graphical EMF based frameworks. Further investigation of the two showed that a basic and out-of-the-box integration exists which provides full model synchronization that can be achieved relatively easy. This gives a good basis, but does not solve our stated problem completely: we still need a solution for creating partial model editors. This is currently only possible with graphical models in GMF, but not with textual models in Xtext. In the next chapter we will see a couple of solutions on how to establish such editors.

Chapter 4

Towards partial model editors

In this chapter we discuss a few possible approaches for partial model editing. For each approach we discuss the advantages, disadvantages and their applicability.

4.1 Introduction

The advantage of considering only a part of the model is mainly because of modularity: we only focus on the relevant part that we want to view and/or edit. This usually results in higher productivity since we maintain a clear overview, which becomes even more apparent as the size of the model increases. Working on specific parts of a model has also the advantage of being able to apply different tools to different parts of the model. The default properties editor in Eclipse is a perfect example of such a partial model editor.

In the following sections we discuss several approaches for establishing partial model editors. For Xtext we have identified the highlight range approach and the dedicated editor approach and how they can be used to achieve our goal. In this context the highlight range approach is the most promising one as it offers the most flexibility and is completely generic. In case of GMF we can simply use dedicated partial model editors which we can create by using the default functionality of GMF and GEF. Each of these approaches encompasses several integration aspects such as scoping and model synchronization that need to be considered carefully. We will discuss several approaches to deal with these issues.

31 Chapter 4. Towards partial model editors 32

Another group of partial model editors that are considered important are embedded partial editors where we do not necessarily have full functionality. We discuss in Sec- tion 4.4 several possible embeddings, but we have chosen to highlight mainly embedded textual editors in GMF. We furthermore discuss the limits of GMF and how the existing functionality can be extended to show and edit parts of the model contained within labels.

4.2 Partial model Xtext editors

In this section we discuss two possible approaches to achieve partial Xtext editors:

• The highlight range approach: We apply basically a view on a full textual model and effectively restrict the editing area.

• Dedicated editor approach: We create a dedicated Xtext editor for each mod- eling element (and its children).

4.2.1 The highlight range approach

Any Xtext editor in a workbench window uses the XtextEditor class as defined in org.eclipse.xtext.ui.editor.XtextEditor. After instantiating the Xtext editor on some input file we will see the full contents of the file displayed directly in the editor. To show a part of the file we can basically use two built-in functions that allow us to apply a view within the text area of the editor. In general, we can do this as shown in Listing 4.1.

Listing 4.1: Applying the highlight range functions

1 §editor = page.openEditor(editorInput, editorID); ¤

2 editor.showHighlightRangeOnly( t r u e );

3 editor.setHighlightRange(offset, numberOfCharacters, t r u e );

¦ ¥ In the first line we instantiate an Xtext editor in a new tab within the active page of the current workbench window where we assume a valid input (editorInput - corresponding to a file). We then apply the showHighlightRangeOnly function that, as the name suggests, enables us to highlight a range within the current editor. To specify what range Chapter 4. Towards partial model editors 33 exactly, we use the setHighlightRange function where we select the exact starting offset of the text and its length (and a third parameter which determines whether the cursor should be moved to the start of the highlighted range). This approach with an example model is depicted in Figure 4.1.

(a) The Xtext editor on an example (b) The Xtext editor after applying the Greetings model when instantiated. highlight range functions.

Figure 4.1: An example with applying the highlight range functions

In this example we have applied the highlight range on the region of the second object in our model, corresponding to the textual representation Hello Mark!. This narrows the view so that we only see the editor containing the specified element. To determine the right offset we access the composite nodes from the parse tree created by Xtext as shown in Listing 4.2, where semanticElement is the in-memory model element.

Listing 4.2: Determining the offset and length of a model element

1 §ICompositeNode xtextNode = NodeModelUtils.getNode(semanticElement); ¤

2 offset = xtextNode.getOffset();

3 length = xtextNode.getLength();

¦ ¥

4.2.1.1 Synchronization of regular changes

Determining the offset and applying the highlight range on our partial model editor is the first step, but it also requires to update the document accordingly when changes are made within the partial model editor (or any other active editor for that matter). To solve this we need to setup a listener that continuously updates the offset of the model element. However, since Xtext reparses (a part of) the tree we cannot guarantee that our referenced compositional node is available after changes. So we essentially have lost important information about our node and we need to somehow identify our node again to be able to determine the offset and update the view. We can use one of the following strategies by which we can overcome this problem: Chapter 4. Towards partial model editors 34

• Identification by URI fragments Recall from the previous chapter how GMF references model elements from the notational model. In the same way we can use URI fragments to identify our model element.

• Identification by “parent” editor When we instantiate the partial text editor, we will do this probably from another editor that is either Xtext or GMF.1 This “parent” editor can hold additional information by which we can identify which modeling element has been changed.

• Identification by unique model element A possible third approach is to use a unique textual identifier such as names of objects, if applicable.

The identification by URI fragments approach is straightforward to apply. However, just like the GMF referencing problem it can give problems in case the order of the elements is changed. This problem occurs when elements are swapped in our textual model. So take for instance two active textual editors and assume they are active as shown in Figure 4.1. In this example the editor from Figure 4.1(b) is instantiated from the other editor. If we merely change the text Hello Mark!, the corresponding subtree will get reparsed and the Resource updated. If the modeling element is not deleted completely, the order of the element with respect to other hello modeling elements has not been changed and we can therefore use the same URI fragment to identify the corresponding modeling element. We can consequently use the index from the URI fragment and determine its offset to update the partial model editor. However, swapping lines 2 and 3 from the first editor invalidates our previously hold index since we then refer to a different model element.

The identification by parent editor approach assumes that we instantiate the partial Xtext editor from another editor and that this parent editor has a separate in-memory Resource of our model. Note that the listener should be aware of the node for which the partial editor has been initialized. After changes in our partial model editor, Xtext reparses at most the entire subtree contained within that partial view and so we know for sure that only that region is affected.2 In case of a parent Xtext editor we can

1This is strictly not necessary, since we could also instantiate a partial model editor without having another parent editor active. However, for the sake of illustrating this approach we will assume that there does exist a parent editor. 2The core function responsible for reparsing the dirty text region is defined in: org.eclipse.xtext.resource.XtextResource.update(..) Chapter 4. Towards partial model editors 35 consider basically two approaches. The first approach is to apply the highlight range method on the “parent” Xtext editor, by which we only narrow the view and thereby effectively solve the problem of identification. In the second approach, we create a separate editor instance based on the same XtextResource as the parent editor and then apply the highlight range view on the corresponding modeling element. By using the same XtextResource the changes are propagated automatically between editors. However, since changes can affect the offset of the modeling element that is shown in the partial model editor, we need to determine the offset on each change which we can do by using a separate XtextResource. Since at most the entire subtree shown within the partial model editor is affected, we can use the XtextResource of the parent editor to identify the sub-tree that has been changed and thereby construct the new compositional node. By using this second approach, we can use multiple Xtext editors and synchronize changes between partial model editors (provided that they are instantiated from another parent Xtext editor). In case the parent is a GMF editor, we know that the notational element corresponding to the partial editor content is stored in a DiagramResource (as long as its corresponding node exists in the model). Our listener can access this graphical node and identify the corresponding model element by which we can determine the offset and length to update the partial model editor view.

The identification by unique model element approach assumes that our meta-model de- fines a unique identifier such as unique element names. This is the least generic approach since in most models we do have duplicate elements which would make it unusable. More- over, if we consider our use cases from Chapter2 then we see that certain elements do have some unique identifier while others do not. So this would mean that the approach would indeed only work in certain cases. A remedy could be to define a unique identifier for our modeling elements. If our models are serialized as XMI files this could be an option, but in our case we have chosen to serialize our models as Xtext model files so that we are able to preserve layout information.

Regardless of the choice for any of the above approaches, deleting the entire content contained in a partial model editor results in empty content. Moreover, when we delete a subtree from an editor of which the content is contained in its entirety in some other partial editor then that editor would essentially become empty since the corresponding Chapter 4. Towards partial model editors 36 node does not exist anymore. In this case we can simply force the partial model editor to close.

4.2.1.2 Eclipse editor operations

Apart from the above regular changes to our model, there are special operations in Eclipse available that need to be considered separately. For instance, the Open Declara- tion operation3 opens and highlights the declaration of a selected element. So, if we, for example, use a string type for some variable and decide to open up the declaration, it will give the definition of that type, if available. After calling this operation our highlight range becomes invalid since we have now jumped to another part of our model, which results in showing the entire view again with the focus on the corresponding declaration part.

To solve this we need to update our view accordingly and determine the offset and length of the corresponding model element that is selected. A better alternative would be to open a new editor to avoid any inconsistencies. Note however that this and other possible operations have not been investigated and are here covered only for the sake of completeness. However, at least the following operations have been identified that can affect our specified range, or even be limited by its use:

• Find references:4 Finds the references to the selected object. From these found references, we can select an item and jump directly to its definition.

• Quick outline:5 Gives a structural outline of the model in which we can select an element and jump to it. This operation does not invalidate our range, but instead only works for local elements (within the partial editor). Hence, selecting elements that lie outside the local scope will not work.

4.2.1.3 Renaming elements

Being able to rename an element that possibly occurs at multiple places in a model is encompassed by the requirement that changes should be propagated accordingly. In case

3Available in the right click menu. In Windows we can also use the F3 key. 4Ctrl+Shift+G on Windows. 5Ctrl+O on Windows. Chapter 4. Towards partial model editors 37 of the example from Figure 4.1, the hello element’s name is contained within the scope of the partial editor and so changing the name manually will maintain the correctness of our model (as long as the name itself is valid). However, in larger DSLs such as POOSL we can reference model elements from multiple places in our model. For example, assume that our partial model editor contains a process class Timer:

1 § process c l a s s Timer (timeoutTime: Real) ¤

2 ..

¦ ¥ We furthermore use an instance of this Timer type, defined in our system:

1 § instance timer:Timer(timeoutTime := 240.0) ¤

¦ ¥ If we change the name of the Timer process class in our partial editor to some other non- existing process class name, then the instance will reference an invalid process class. This means that we cannot simply change the identifiers of objects in such a partial model editor, if we want to keep the references consistent as well. Instead, renaming model elements can be performed by using the refactoring operation Rename.6 This operation allows us to rename a specific model element in the entire model. So effectively all references are renamed and our model remains consistent. Fortunately, this renaming feature is part of the Eclipse functionality and therefore works out-of-the-box.

4.2.1.4 Sub-grammar restrictions

The highlight range approach restricts our view on the model visually and retains all other model information to our disposal so that required functionality such as global scoping is still possible. However, with this approach we also preserve all the grammar information that can be used in our partial model editor, while this might not always be desirable.

Let us take again the example from Figure 4.1. In the right editor we have instantiated the second element Hello Mark!. However, in this editor we are not restricted to only changing that part of text. In addition, we could add another Hello element in the partial model editor directly after the initial Hello Mark! statement. From a conceptual point of view a partial model editor that operates on a part of a model should also, strictly

6Available in the right click menu. In Windows we can also use the shortcut key combination Alt+Shift+R. Chapter 4. Towards partial model editors 38 speaking, be restricted to the sub-grammar that corresponds to the part being edited. In our example with the additional inserted statement we would be “outside” our partial model grammar.

To solve this issue we can use the PartialParser function that is defined in Xtext.7 Moreover, this function is used by Xtext internally as a partial parsing strategy to only update the minimal region of the model, based on the specific location of the performed changes. The following snippet of code essentially captures its use (Listing 4.3):

Listing 4.3: PartialParser example

1 § ParserRule parserRule = (ParserRule) node.getGrammarElement(); ¤

2 partialParser = PartialParser. c l a s s .newInstance();

3 partialParser.assignRootRule(xtextResource, parserRule);

4 Reader reader = new StringReader(node.getText());

5 IParseResult partialParseResult = partialParser.parse(parserRule, reader );

¦ ¥ It first needs an assignment of a so called root grammar rule by which the text will be parsed. In our case this is the rule corresponding to the modeling element contained in the partial model editor. For each model element we can get its corresponding grammar rule, assign this rule and parse some piece of text (which makes this approach completely generic). After the region has been parsed we can use the parse result and in case of errors attach an error marker to our editor.

If necessary, we can use this approach to restrict our partial model editor to the cor- responding sub-grammar and inform the user if he uses concepts that lie outside this sub-grammar. Note that we add this as an additional check on top of the existing check(s) of the model. Since this sub-grammar check is a subset of the total gram- mar check, we know implicitly that the total grammar check will always pass if the sub-grammar check passes (assuming no other changes have been).

4.2.1.5 Evaluation of advantages and disadvantages

The advantages of the highlight range approach are clear:

7org.eclipse.xtext.ui.codetemplates.ui.projectedEditing.PartialParser. Chapter 4. Towards partial model editors 39

• Single Xtext editor Instantiating partial model editors on the same model does not require dedicated Xtext editors to be created. So we can just use the existing editor and apply the highlight range. Furthermore, it is also completely generic since we can instantiate such a partial model on any defined model element.

• Global scoping We have a global scope out of the box since the model is actually read in its entirety and we only apply a view on the model.

• Straightforward The approach is relatively easy to implement and does not require much code.

The drawback of this approach is that certain operations such as finding the declaration of a model element probably each need to be considered separately. Another disadvan- tage is that we show entire lines of text that cover the range of our modeling element. This gives problems when (parts of) other elements are also contained on the same line. This is illsturated in Figure 4.2 (based on the Statemachine example defined by the Xtext grammer from Appendix A.2). The instantiated partial model editor shows the textual representation of the expression corresponding to the transition from which the editor is instantiated. However, we do not only see the expression but the entire transition definition that contains this expression since they are located on the same line within the file.

Figure 4.2: Highlight range showing entire line where the offset range is located, which in this case is “12+3+4”

To solve the latter problem we can enforce a suitable structure by changing our Xtext grammar. Another approach is to add new lines before and after the textual represen- tation of our element (in this case before and after the expression ”12+3+4”), by which Chapter 4. Towards partial model editors 40 we isolate the textual part we want to see. The latter approach is more generic than the former, but it suffers from the fact that when these new lines are added, the editor is marked as being in a dirty state, which should actually not be the case.

4.2.2 Dedicated partial model Xtext editors

In the previous approach we have seen that by applying the highlight range approach we can achieve partial model editing. Another possible approach is to create dedicated Xtext editors for each modeling element that we want to edit separately. For instance, if we take the Statemachine example (Appendix A.2) we would generate one editor for the entire model, and then possibly one editor for editing states, one for transitions and one for expressions.

There are however multiple drawbacks of this approach:

• Not generic For each element we need to define and generate a separate editor. In case of multiple layers of navigation, we would also need to integrate each such layer separately.

• No global scope There is no global scope by default. Referencing elements residing outside the partial model will therefore not be possible. This also has consequences for the validation in case global scope is required.

• Requires a custom model-linking strategy Since a dedicated Xtext editor needs a physical file as input, we would also need to think about how we store these sub-models, but also how we identify them. This separation of a model into sub-models stored in separate files means that the model will get fragmented, which might not always be desirable.

Although this approach seems less useful than the highlight range approach (or even completely unusable), it turns out that there exist some architectures where this is still applicable. We will discuss this in the next chapter. Chapter 4. Towards partial model editors 41

4.3 GMF partial editors

For graphical representations of parts of a model we can simply create dedicated GMF editors for all the modeling elements that we want to display, which essentially can be considered as partial model editors. Since we have to define a GMF editor for each different part of a model, this is obviously less generic in comparison with for example the Xtext highlight range approach. However, because the number of dedicated graphical editors is usually limited to a manageable amount, this lack of genericity for GMF editors is not considered a key issue. Moreover, even with complex models it would often suffice to have a few such dedicated graphical editors for a model, each representing a separate layer of a model.

We will see in Chapter6 that even for a mature DSL such as POOSL, it suffices to have at most a few GMF editors to capture the core concepts since most of the information is compacted in a textual form. In more customized scenarios each layer would also have its own graphical syntax of the elements available at that level, and hence requires a custom GMF editor. In addition, we can also have multiple graphical representations of the same model element (and its children), while again in contrast with Xtext you are confined to the single textual representation.

4.4 Embedded partial editors

In the previous sections we have discussed how we can create partial model editors in Xtext and GMF. They are used as instances to show either a purely textual or graphical representation of a part of our model. However, we can also think about editors that combine both into one single editor. We will call these editors integrated within another editor embedded partial editors.

4.4.1 Possible combinations of embedded editors

Aside from the kinds of embedded editors itself, it is important to also think about the “host” editor, that is, the editor in which the embedded editor will reside. If we only consider textual and graphical combinations of editors, we get the following possibilities: Chapter 4. Towards partial model editors 42

1. Textual host editor; textual embedded editor.

2. Textual host editor; graphical embedded editor.

3. Graphical host editor; textual embedded editor.

4. Graphical host editor; graphical embedded editor.

Embedding textual editors in other textual editors might seem a bit unusual, but the Meta Programming System (MPS), for example, does embed textual representations of a model within a textual model.8 We will discuss more about MPS in Chapter7.

Since our focus is primarily on Xtext and GMF, we can consider Xtext as our host editor. However, in Xtext there is (currently) no easy way to embed other editors (either textual or graphical) and therefore it has been omitted. In GMF, on the other hand, besides purely graphical elements we have (by default) also pieces of textual information embedded such as for example the name of some object which we can edit directly (see Figure 4.3). We will discuss this in more detail in Section 4.4.2.

Figure 4.3: Editing a label in GMF

Embedding dedicated graphical editors in GMF has also been omitted because of its complex nature. Instead, we can use the so called GMF compartments. This is illustrated in Figure 4.4. For more information on how to achieve this see the GMF documentation online.9

The last option, embedding textual editors within a host GMF editor, is considered to be the most relevant combination. We will discuss this in more detail in the next sections.

4.4.2 Viewing and editing textual partial models as labels

The instantiated embedded editor from Figure 4.3 is a so called cell editor, which is implemented by the DirectEditManager class and provided by GEF.10 This mixing of 8Note that these editors, which are also called projectional editors, do not require a grammar or parser since they use the so called language composition mechanism [27]. 9http://wiki.eclipse.org/Graphical_Modeling_Framework/Tutorial/Part_2#Compartments 10package org.eclipse.gef.tools Chapter 4. Towards partial model editors 43

Figure 4.4: An example use of GMF compartments textual and graphical representations in GMF, however, is by default very limited. The first thing to note is that the generated GMF code confines us to simple labels. From a meta-model point of view, these are specifically attribute types such as EString. This is a major limitation since there exist cases where we would like to represent more than simply a name.

Let us illustrate this with an example. Take for instance a simple state machine as described by the Xtext grammar in Appendix A.2. It consists of states and transitions between states. We represent states as circular objects and the transitions as links between states. A basic GMF editor with only labels and transitions can be created in a straightforward manner (assuming that an Xtext editor is already available). The result is illustrated in Figure 4.5.

Figure 4.5: Editing a label in GMF

A transition contains furthermore a simple expression that we want to show as labels on these transitions. The problem is that the defined expression is not an attribute but a subtree within our abstract model. We could solve this by altering our meta-model and define these expressions as attributes of our transition of the type EString. During the creation of the editor we would be able to select this attribute and display it as a label. Chapter 4. Towards partial model editors 44

Although it solves our problem it has two major disadvantages. The first is that we need to change our meta-model in order to do this, which as we discussed in earlier chapters should ideally be avoided to maintain meta-model dependence. Another problem also directly related to the meta-model is that we now loose syntax checks and scoping on our expressions. As a result we could use any value and therefore input invalid expressions. We could restrict this by defining separate syntax check, but this might not be desirable. We can think of a restriction where the meta-model cannot be changed or simply the need to perform other operations where the structure of this part is required.

So we want to keep our meta-model as is and display subtrees of our model as labels within GMF. To solve this we proceed as follows. We first need to locate the relevant EditPart. In our case this is the editpart TransitionEditPart.java which corresponds to our transition modeling element. We want to add a label and as its value the textual expression of the expression model element containing it. Within the TransitionFigure class we add the following private variable that will contain the label of our transition:

1 § p r i v a t e WrappingLabel fFigureTransitionNameFigure; ¤

¦ ¥ We furthermore adapt the getFigureTransitionNameFigure function as follows:

1 § p u b l i c WrappingLabel getFigureTransitionNameFigure() { ¤

2 fFigureTransitionNameFigure = new WrappingLabel();

3 TransitionEditPart editPart = getEditpart();

4 EObject semanticElement = editPart.resolveSemanticElement();

5 EObject subSemanticElement = semanticElement.eContents().get(0);

6 ICompositeNode xtextNode = NodeModelUtils.getNode(subSemanticElement );

7 String s = xtextNode.getText();

8 fFigureTransitionNameFigure.setText(xtextNode.getText());

9 t h i s .add(fFigureTransitionNameFigure);

10 r e t u r n fFigureTransitionNameFigure;

11 }

¦ ¥ In this function we essentially resolve the semantic element and get the textual repre- sentation of the expression (in our model a child of the transition). The result of this change is shown in Figure 4.6.

Hence, we can now display subtrees as values in labels. To enable editing of these values we need to make sure that the editpart responsible for instantiating the DirectEditManager Chapter 4. Towards partial model editors 45

Figure 4.6: Editing a label in GMF is also created by GMF. We can do this by customizing our mapping and generator mod- els, or manually creating a class for handling these cases.

4.4.3 Viewing and editing labels with syntax highlighting

When we apply the previous approach of inserting a textual representation of a subtree of our model as a label in GMF, it is possible that such a value contains keywords that are usually marked with a certain color in Xtext. The default cell editor poses a limitation in this context since there is no syntax highlighting present. To make this possible it would be necessary to extend the default cell editor class in such a way that it includes the necessary parser functionality from the generated Xtext editor.

Such an extended class has already been developed as part of the Yakindu Statechart Tools (YST) [28] (the tool itself is described in more detail in Chapter7), which is based on Eclipse. Since YST is based on Eclipse and made open source, it is possible to down- load and use the source code in order to create our custom cell editor.11 To accomplish this we need to create a custom Xtext editor for editing state names and adapt the EditPart corresponding to the label we want to edit where we replace the default cell editor with the custom wrapper provided by the YST plugins (see Appendix C.3 for a detailed description of the necessary steps).

The major drawback is its lack of genericity since we have to define such an Xtext editor for each type of label where we want to use this. Another drawback is the dependence on the plug-ins as provided by the YST developers since it gives no guarantees on how the project and the tool itself will evolve. For example, the plug-ins might get incompatible with the newest versions of Eclipse or any of the used frameworks, but the project might also even be discontinued.

Aside from the syntax highlighting within the cell editor itself, we could also think about syntax highlighting when the labels are printed in a GMF editor. However, this

11http://svn.codespot.com/a/eclipselabs.org/yakindu/BASE/ Chapter 4. Towards partial model editors 46 was considered to be outside the scope of this research and was therefore not investigated in further detail.

4.5 Evaluation

We have discussed how to create partial model textual and graphical editors. In case of GMF, we can use its existing functionality and simply create dedicated editors for a part of a model. In case of Xtext, on the other hand, we offered two options: either also create dedicated editors, or otherwise, apply the highlight range approach. We argued that dedicated Xtext editors for parts of a model are less favorable mainly because of their lack of genericity, but also because it implies that we loose global scope and that the model might get fragmented. The highlight range approach, on the other hand, is completely generic since we basically only narrow the view to the modeling element in question. Besides the minor issues with showing content per line and special operations, we need to take care of synchronization by updating our highlight range, for which several approaches have been proposed.

The suggested approaches for partial textual editors satisfy our previously partially fulfilled requirements IR2 and IR7 where we state that it should be possible to show and edit parts of a model at the same time, either textually or graphically. Integration IR4 (providing a proper navigation structure) is partially fulfilled since we can use the highlight range approach to cover the text-to-text navigational structure.

4.6 Conclusion

In this chapter the partial model editors are discussed mainly in isolation in the context of the partial model editing problem. We have briefly touched the notion of a host editor from which the partial model editors could be instantiated in the highlight range approach. Although these approaches can be used to build partial model editors for single editor use, we are much more interested in more mature scenarios where we look at the entire architecture and how all these editors are interconnected. In the next chapter we will discuss these architectural patterns and the way we can navigate through these different editors. Chapter 5

Architectural patterns

In the previous chapter we have seen how we can create partial model editors for textual and graphical editors. When these approaches are combined in more mature scenarios we can identify certain patterns that significantly can affect their applicability. In this chapter we discuss the key aspects of navigation between these editors, their interlinking structure and the overall synchronization.

5.1 Introduction

We discussed in Chapter3 existing integrations where Xtext and GMF are interlinked by default. In this setting synchronization is performed after changes have been saved while using a single textual file for storing our domain model. However, when integrating multiple editors we do not necessarily have to follow this approach. We argued that there is a need to use partial model editors instead of editors that consider a full model, which particularly applies to textual based editors. When using multiple editors we need to think of how these will be interlinked in case we want to instantiate an editor from another. A key issue in this setting is to create a proper synchronization between these interlinked (partial) model editors. This problem can be summarized by the following questions:

1. How do we interlink multiple editors, with respect to each other so that we can enable a consistent navigational structure?

47 Chapter 5. Architectural patterns 48

2. How do we synchronize these interlinked editors and keep the model(s) consistent?

First we approach the problem of interlinking editors from the perspective of inter-editor navigation (Section 5.2). Moreover, we present the possible navigational structures, what their characteristics are and discuss briefly how such a navigation can be applied. Next, we discuss a few possible multi-editor architectures (Section 5.3), where we base our solutions and discussions on the chosen tools Xtext and GMF, while also keeping in mind their respective restrictions. We also discuss this in relation to the methods for using partial model editors from the previous chapter, where we show their applicability in different scenarios, and their advantages and disadvantages.

5.2 Navigational structures

In this section we discuss the inter-editor navigation between textual and graphical representations, which we will base on Xtext and GMF. More precisely, we discuss how other editors can be instantiated, using the same, or a different representation. Other possibilities are navigations from structured views such as the outline and other views, but this is considered outside the scope of this project and will therefore be omitted.

The Xtext-to-Xtext navigation structure encompasses instantiations of textual editors from other textual editors. We confine ourselves to partial model editors using the highlight range method, as this is considered the most relevant in this case.

In the previous chapter we have briefly discussed the special operations in Eclipse and how we can for instance use the Open declaration operation to jump to the definition of the selected object. This is a perfect example since it shows the navigational aspect that we want to acquire in a text-to-text scenario. In this case we assume that we navigate within an Xtext editor where the highlight range method has already been applied, showing only the textual representation of one modeling element (and its children). This is illustrated in Figure 5.1.

We have already discussed (in the previous chapter) that this gives problems since the range becomes invalid. To solve this we provide the approach of determining the offset of the corresponding declaration part. By using a custom listener we can monitor for these changes. Chapter 5. Architectural patterns 49

Textual Model

______Partial-model editor ______Open declaration ______Partial-model editor ______

Figure 5.1: Applying the highlight-range method on a different element when using the Open-declaration functionality. The bottom partial-model editor represents the source editor where an element type is used, defined earlier in our textual model. The upper partial-model editor shows the definition of the used type.

In case of cross-document references the principle remains the same, except that we probably need to instantiate a new editor or use the same instance with a newly con- structed editor input. As mentioned earlier, this is considered to be outside the scope and is therefore left for further work.

Navigating from an Xtext editor to a GMF editor is another navigational structure to consider. Recall from the previous chapter that for graphical partial model editors we use the approach of generating dedicated GMF editors for each modeling element (and its possible subcomponents) that we want to display graphically. This GMF instantiation is typically useful when we want to show a graphical representation of the current textual representation that is shown.

We can establish this structure by for example defining an action which can be called from the context menu in Eclipse.1 We furthermore need to define a custom handler that will be called when executing this action from the menu.

Navigation from GMF to Xtext is conceptually the same as the Xtext-to-GMF case: we instantiate a dedicated editor using a different kind of representation. However, we will see in Section 5.3 that this navigation structure touches multiple integration aspects on a deeper level.

1The context menu can be used by right clicking on an element. Chapter 5. Architectural patterns 50

In the last case we have the GMF to GMF navigation. Just as with the Xtext-to-GMF combination we again use dedicated GMF editors as our target.2

To achieve this we can use the built-in GMF functionality Open Diagram Behavior that allows us to easily integrate two or more GMF editors (based on the same model), which greatly simplifies the overall integration complexity. This key functionality is defined in the generator model. We define this action for the source editor, where we we will point to our target editor by using a so called EDITOR ID. A detailed example that shows how this is done exactly is discussed in Section 6.4.3

5.3 Multi-editor architectures

Recall from Chapter3 that we discussed the existing integration with Xtext and GMF. We can conceptualize the overal architecture as shown in Figure 5.2. The figure describes a typical scenario where we define a high-level GMF editor and an Xtext editor for the full model.

Xtext load/save GMF .diagram

@URI synchronization on save load/save .xtext

Figure 5.2: Conceptual architecture for the default Xtext-GMF integration

In this figure, and in what follows, we will use the notation as used in this figure. The blue box indicates the coverage of the Xtext definition, while the red box indicates the

2Note that the target GMF editor will typically be a sub-diagram element, but this does not necessar- ily need to be the case. We can also think about showing a different visualization of the same graphical elements from which we instantiate the target editor. 3Obviously, this feature is very important for every developer that wants to integrate these editors. Very surprisingly, during this research there was no official documentation found that describes this important functionality. Chapter 5. Architectural patterns 51 coverage of the GMF editor. In this specific case, since the Xtext coverage is over our entire model, we assume that the Xtext grammar for the entire model is available. We define this coverage in terms of the meta-model elements that the editor can write/read, here illustrated as a tree corresponding to some model. When arrows are used that connect these boxes, we treat them as editors that are showing the covered part of the model. Furthermore, The .diagram and .xtext are files for storing the graphical layout information and the textual model, respectively. We identify the model elements by using URI fragments, and synchronize on saving.

Synchronizing on file changes has the drawback that we are only able to make changes within one editor at a time. Moreover, changing the model in two editors and then saving the model from one editor will result in loosing the unsaved changes made in the other editor, which obviously is not an ideal situation. We will see from the related work in Chapter7 there exist other approaches that can be applied to achieve for example a real-time synchronization.

In the above approach we have defined an Xtext editor with a textual concrete syntax for the full model, which enables us to generically instantiate a partial editor on any part of our textual model. This represents the default behavior of Xtext and GMF, but does not necessarily have to apply in all the cases. Moreover, sometimes we do not have a textual definition for the entire model, but only for some of the modeling elements within our model, which we want to combine together. One such example architecture is depicted in Figure 5.3. In this case, the GMF-editor is defined as a full model diagram, while the Xtext editor is limited to only a part of the model. Note that the dashed line within the Xtext coverage indicates that the subtree on the left and the right are of the same type on which the same Xtext editor can be instantiated. The orange dashed arrow indicated that we follow the GMF-to-Xtext navigational structure. It is important to keep in mind that here we always take the GMF editor as a basis for instantiating Xtext editors.

This scenario turns out to be very problematic for several reasons. If we need to keep the textual sub-models which are instantiated within Xtext, the textual representation of the left and right sub-tree needs to be stored. The most straightforward way is to do so in separate files. However, this approach is only directly applicable in very specific scenarios. Moreover, by decoupling the Xtext editor and its textual model, we also loose Chapter 5. Architectural patterns 52

GMF instantiate Xtext editor load/save from GMF .diagram Xtext Xtext

load/save .xmi

load/save load/save .xtext .xtext

Figure 5.3: GMF diagram defined for the full model, and the Xtext editor defined for a sub-tree. The left and right sub-tree can be opened by the same Xtext editor. From the graphical editor we can instantiate an Xtext editor that covers that part of the model. the global scope. So when for example we want to rename an element in such an Xtext editor instance, we are bound to the scope that is provided by the coverage of that Xtext editor, which in this case is only the sub-tree.

If we choose to store the textual sub-models, during the first instantiation we need an initial textual representation of the model that is being instantiated (including its chil- dren). We can achieve this by using the serialize function of Xtext. Another approach, which is also applicable in very specific situations, is to choose not to store this textual model permanently, but to only use temporarily files for the lifetime of the instantiated partial model Xtext editor. The obvious drawback of this approach is that layout infor- mation will not be be preserved, but as mentioned earlier, this might not be an issue in certain scenarios and can therefore sometimes still be applicable.

The architecture as illustrated in Figure 5.4 encompasses the Xtext-to-GMF navigational structure, where the Xtext editor is defined for the full model, while the GMF editor is limited to a sub-tree. Each GMF editor should use a separate diagram file for storing graphical layout information and pointing to the diagram root element which is located in the textual model. Chapter 5. Architectural patterns 53

Xtext instantiate GMF editor load/save from Xtext .xtext GMF GMF @URI

.diagram .diagram

load/save load/save

Figure 5.4: Multi-editor architecture using a full model Xtext editor and a sub- diagram GMF editor

The multi-editor architecture presented as depicted in Figure 5.5, uses one full-model Xtext editor and two separate GMF editors, defined for different parts of the model. Following the steps we first (1) open a sub-diagram from a higher-level GMF editor by using the Open Diagram functionality (GMF-to-GMF navigation) and then (2) open an Xtext editor from the sub-diagram editor (GMF-to-Xtext navigation).

Xtext GMF load/save .xtext

instantiate instantiate Xtext editor 1 sub-diagram @URI from sub-diagram load/save .diagram 2 Xtext load/save

GMF GMF GMF GMF

Figure 5.5: Multi-editor architecture using one Xtext editor for full model and two different GMF editors, where we can instantiate sub-diagrams.

Since we have created a full model Xtext editor, instantiating this editor requires that the highlight range method is called with the proper begin and end offsets that need to be computed to limit the view. Note that in contrast to the previous architecture (Figure 5.4) where we use one GMF editor for two subtrees and thereby need to use two Chapter 5. Architectural patterns 54 diagram files for our graphical notational model, in this case we use two GMF editors and just one diagram file (Figure 5.5). The reason for having one diagram file in the latter case is because of the coverage of the top-level node by a GMF diagram, by which we make a containment of model elements in subtrees possible (in terms of XMI). This can be equally stated as the top-level node being able to “reach” all the other nodes covered by the used editors.

5.4 Conclusions

In Section 5.2 we discussed how to practically achieve navigational structures when interlinking different editors. These proposed approaches enable us to achieve the last unfulfilled integration requirement (Section 2.3): The editors should provide a proper navigation structure (IR4).

We also looked in Section 5.3 at various multi-editor architectures where we showed that it is important to think about how we combine different Xtext and GMF editors. Based on the observations that were made it is recommended to always have a full model Xtext coverage (if possible), to ensure genericity and to avoid additional synchronization problems. Chapter 6

Implementation

In the previous chapters we have established solutions to our stated problem, where we have also discussed multiple practical approaches. We will confirm these findings in this chapter with a couple of implementations.

6.1 Introduction

In the next sections we discuss what are considered the most representative use cases, covering various aspects of the previously obtained results. Each scenario has certain characteristics which can require custom adaptations, which are discussed in more detail if necessary.

The outline of the chapter is as follows. We start off with a very basic language Greetings in Section 6.2 where we introduce the highlight range approach. In Section 6.3 we use a custom made state machines language as a more elaborate example where we again apply the highlight range method. In addition, we also illustrate how we can show subtrees as labels in GMF, which is also considered a form of integration but currently not available by default in GMF. In Section 6.4 we present a web application example where we illustrate how to instantiate sub-diagrams in GMF. A basic proof-of-concept implementation of the POOSL language is provided in Section 6.5 that encompasses all of the previously demonstrated elements where we show that the proposed solutions can also be applied to a mature language.

55 Chapter 6. Implementation 56

6.2 Greetings

To illustrate the most basic integration we will consider the default Greetings example in Xtext.1 In this example we want to open an Xtext editor by clicking on an in-diagram element that shows us the corresponding textual representation. The Xtext grammar is given in Appendix A.1.

6.2.1 Generating implementation code

We generate the Xtext artifacts and generate the code with the genmodel file. We then create the necessary GMF files and generate the GMF editor with Model as our diagram element and Greeting as our domain model element. We now have the following projects:

• org.xtext.example.mydsl

• org.xtext.example.mydsl.diagram

• org.xtext.example.mydsl.edit

• org.xtext.example.mydsl.editor

• org.xtext.example.mydsl.ui

6.2.2 Customization

We create a custom package in the src folder of org.xtext.example.mydsl.diagram/src with the name org.xtext.example.mydsl.myDsl.diagram.custom and put here the following files:

• Activator.java (Appendix B.1)

• EditPolicyProvider.java (Appendix B.2)

• OpenEditPolicy.java (Appendix B.3)

1http://www.eclipse.org/Xtext/documentation/2.6.0/Xtext%20Documentation.pdf, Section: “1.1. Creating A New Xtext Project”. Chapter 6. Implementation 57

Finally, we add the extension point as defined in Appendix B.5 to plugin.xml of the diagram plugin.

6.2.3 Result

With a sample file as shown in Figure 6.1 we can now click on Mark, for example, and get its corresponding textual representation as shown in Figure 6.2.

Figure 6.1: Greetings example: the full textual model

Figure 6.2: Greetings example: a partial textual model element

6.3 State machines

In this example we will demonstrate integrations for a custom made and simple state machines language (see Appendix A.2 for the Xtext grammar). A state machine consists of states and transitions between states. Each transition contains a simple expression that is evaluated when a transition from one to another state is taken. In this case we want to be able to click on transitions and show the textual representation of the text. We also want to show the expressions as labels in GMF.

6.3.1 Generating implementation code

For our GMF editor we choose Statemachine as our diagram element, State as our modeling object and Transition as a connection. Chapter 6. Implementation 58

6.3.2 Customization

After generating the implementation code we add the same files to our custom package as described in Section 6.2.2 and adapt the following:

• Activator.java: adapt the value for PLUGIN ID to match the Plug-in ID.

• OpenEditPolicy.java: on line 25 adapt the Plug-in ID to match our Xtext editor.

To show the expression as a label within the diagram we need to adapt the generated file TransitionEditPart.java. We add the following public function to the main class

1 §p u b l i c TransitionEditPart getEditpart() { ¤

2 r e t u r n this ;

3 }

¦ ¥ In the TransitionFigure class we add the private variable

1 §p r i v a t e WrappingLabel fFigureTransitionNameFigure; ¤

¦ ¥ and adapt the following getFigureTransitionNameFigure function as follows:

1 §p u b l i c WrappingLabel getFigureTransitionNameFigure() { ¤

2 fFigureTransitionNameFigure = new WrappingLabel();

3

4 TransitionEditPart editPart = getEditpart();

5 EObject semanticElement = editPart.resolveSemanticElement();

6 EObject subSemanticElement = semanticElement.eContents().get(0);

7 ICompositeNode xtextNode = NodeModelUtils.getNode(subSemanticElement) ;

8 String s = xtextNode.getText();

9 fFigureTransitionNameFigure.setText(xtextNode.getText());

10

11 t h i s .add(fFigureTransitionNameFigure);

12 r e t u r n fFigureTransitionNameFigure;

13 }

¦ ¥ Essentially, the above code gets the model element (in this case the expression of the transition), reads the textual representation and sets the value of the label. Chapter 6. Implementation 59

6.3.3 Result

In Listing 6.1 an example model is given.

Listing 6.1: Statemachines: example file

1 §s t a t e s ¤ 2 s t a t e a;

3 s t a t e b;

4 s t a t e c;

5 s t a t e d;

6 s t a t e e;

7 end

8 transitions

9 a => c e x p r e s s i o n 12+3+4;

10 a => d e x p r e s s i o n 2+3;

11 b => e e x p r e s s i o n 3+2+1+0;

12 d => c e x p r e s s i o n 1+1+1;

13 end

¦ ¥ The corresponding graphical model is shown in Figure 6.3. We can now click on tran- sitions or states and show their corresponding textual representation. We also see that expressions are shown as labels.

Figure 6.3: Statemachines example diagram

6.4 Web application

In this web application example we will demonstrate subdiagram instantiations with GMF. Our web application meta-model consists of data tables which in turn contain data columns. The meta-model is depicted in Figure 6.4.2

2Note that this is a custom DSL, which is made only to show how we can hierarchically navigate through a model. Chapter 6. Implementation 60

Figure 6.4: Web application example: meta-model definition

The idea is to have a top-level diagram showing us data tables that are contained in the web application. When double clicking on any of those data tables we want to show all the data columns it contains in a separate window.

6.4.1 Generating implementation code and customization

We need to create two GMF editors: one for modeling element DataTable (WebApplication as the diagram element) and another for modeling element DataColumn (DataTable as the diagram element). After having two generator models, each for one editor, we need to link them. We do this by following the steps as described in Appendix C.2.

6.4.2 Result

We take the following model as an example. Data table a containing data column X and data table b containing data columns Y and Z. The result after opening the web application and its tables is shown in Figure 6.5. On the left panel we have two files: default.core contains the model and default.core diagram contains the diagram. We can instantiate the latter and get the top right panel where we get the two data Chapter 6. Implementation 61 tables. Double clicking on any of these data table produces the corresponding tabs at the bottom.

Figure 6.5: Web application example: instantiated subdiagrams

6.5 POOSL

6.5.1 Generating implementation code

In this section we demonstrate the implementation of the POOSL language. We use an existing definition for the Xtext grammar to generate the Xtext implementation code and a meta-model. Because of lack of time we show only a partial implementation for the graphical editor. We use basically the same approach as shown in examples from the previous sections.

We have used the POOSL definition and the use cases from Chapter2 as a basis (the high-level meta-model is given in Appendix A.4). For generating a high-level GMF editor we take system as our root diagram element.

6.5.2 Result

The result of the high-level view is shown in Figure 6.6. The instance physicalLayer is a cluster process which contains two process instances. By double clicking on the element we open up a separate GMF editor (Figure 6.7). Chapter 6. Implementation 62

Figure 6.6: POOSL example: GMF editor for the system element, showing its high- level instances

Figure 6.7: POOSL example: Opening up a GMF sub-diagram from a cluster class element

For each instance we can show its instance parameters (Figure 6.8) and its process class definition (Figure 6.9). In case of a process class we show an Xtext editor. In case of a cluster class we can either show an Xtext or GMF editor by using the right-click menu. To show the definition of system in an Xtext editor we right click on the background and instantiate the Xtext editor (Figure 6.10).3

3This works since the ”background” is effectively a diagram element corresponding to our system. Chapter 6. Implementation 63

Figure 6.8: POOSL example: Showing instance parameters in Xtext

Figure 6.9: POOSL example: Showing a cluster class definition in Xtext

Figure 6.10: POOSL example: Showing system and its instances

6.6 Evaluation

In the previous sections we have shown implementations of a few languages covering dif- ferent aspects of our proposed solutions. The main conclusion of these implementations is that the solutions of applying partial model editors can be relatively easily applied, which was exactly one of the main goals of this thesis. However, it must be noted that the synchronization between these editors turned out to be problematic which was partly related to practical implementation issues, but partly also to the fact that the problem in general is far from trivial to solve. The problem manifested itself mainly when mul- tiple partial model Xtext editors were used, instantiated by using the highlight range approach. We therefore restricted ourselves to one active (partial model) Xtext editor Chapter 6. Implementation 64 which could be synchronized with one or multiple active GMF editors, while working on one file and synchronizing on file save.

The used languages have a few interesting points worth mentioning. The custom made state machine language is a good example where we show that besides showing a partial model Xtext editor, we can also take a sidestep and integrate additional parts into our GMF editor. In this case we showed that we can take a textual representation of a subtree from our model and display it as a label, which is not possible to achieve by using the default functionality of GMF. Although it is a small customization it illustrates that besides the main paths followed in this thesis there are more points of integration possible. One could think of other examples such as pretty printing of these labels and custom embedded editors.

The web application example shows that in case of sub-diagrams we can relatively easy achieve the desired GMF-to-GMF navigational case, where we simply used the existing functionality of GMF. The implementation of the POOSL language shows that we can combine sub-diagrams together with instantiating partial model Xtext editors into one whole, which works satisfactory. Chapter 7

Related work

In this chapter we discuss related work in terms of related technologies where certain textual and/or graphical integrations have been implemented, and related research re- garding this problem.

7.1 Related technologies

In Chapter3 we discussed the tools that are directly related to our stated problem, and whether and how they can be used. In this section we will discuss a few interesting tools where certain textual and graphical integrations already have been implemented, or that seemed promising for further investigation.

7.1.1 Sirius

Sirius is a framework that provides multi-view workbenches through graphical, table or tree modeling editors [29]. It is developed by the company Thales and until recently was only used internally. Sirius uses EMF for models and GMF for the graphical modeling. According to the authors there is also support for Xtext which enables concurrent use of table and textual editors.1 Sirius is tightly integrated with the Eclipse IDE and, according to the authors, provides direct synchronization between different editors.

1http://www.eclipse.org/sirius/doc/Release%20Notes.html#sirius1.0M4

65 Chapter 7. Related work 66

The ideas in general are promising but until recently there was no publicly available source code, and therefore the project was not investigated in further detail. Further- more, it is not clear whether the integration and synchronization is possible on partial models. If an integration with Xtext does not limit the Xtext editor, then we will probably be able to apply the highlight range approach.

Sirius currently does have stable release which can be installed via the Eclipse Market- place.2 It is planned as part of the next Eclipse distribution: Eclipse Luna.

7.1.2 Meta Programming System (MPS)

MPS is a DSL development environment where users can design own extensible DSLs [30], developed by the company JetBrains. A language is defined by an abstract syntax defi- nition and an editor that supports the concrete syntax via a cell based editing style [31]. The concrete syntax does not have to be stored because it is part of of the language definition and hence known by the constructed language engine [32].

Unlike Xtext, TEF, TCS or EMFText, which are parsing based approaches, MPS dis- tinguishes itself mainly by applying so called projectional editors. Text is “projected” from the AST and changes are essentially affecting the AST directly. This means that text does not need to be parsed, which effectively avoids a lot of problems that other parser-based strategies have to deal with. An example is depicted in Figure 7.1.

In terms of partial models, these projections can be considered as separate partial model editors, defined within one bigger workspace. This approach seems the ideal since we can bind in the same way other and multiple editors on the same AST, avoiding problems like the earlier discussed GMF model referencing by URI fragments. The major drawback of MPS, however, is its non-trivial learning curve because of its contrastive approach which requires a significant investment in terms of time.

7.1.3 Yakindu Statechart Tools

Yakindu Statechart Tools (YST) is a set of Eclipse plug-ins, based on on EMF, GEF, and GMF [33], which provide an integrated modeling environment for the specification and development of reactive, event-driven systems based on the concept of statecharts [28].

2http://www.eclipse.org/sirius/ Chapter 7. Related work 67

Figure 7.1: Projectional editors in MPS where effectively textual editors are embed- ded in other textual parts

A custom cell editor and other relevant functionality has been developed as a separate plugin that is used by YST to edit parts of a model textually and with syntax highlight- ing. An example integration is shown in Figure 7.2 based on a simple state transition system (Appendix C.3 describes the exact steps to implement this).

Figure 7.2: Yakindu wrapper example integrated with a state transition system

We discussed already in Chapter4 that the major drawback of this approach is its lack of genericity since we have to define such an Xtext editor for each type of label where we want to use this. When editing labels, however, this extended cell editor only operates on plain text which is defined as a String within our meta-model. This is not desirable since we want to edit parts of our model which are not defined as a String, but rather are complete subtrees of our AST. Another drawback to note is that the user depends on the plugins as these are provided by the YST developers. This might not be desirable in all Chapter 7. Related work 68 cases since such third-party plug-ins can diverge in functionality and even get unusable in future versions of Eclipse or other related and used frameworks.

7.1.4 BPEL Designer

The Eclipse BPEL Designer is a development tool for WS-BPEL 2.0 processes, based on the Eclipse frameworks GEF and EMF.3 Bettini et al. presented an integration approach with Xtext in [34] where the goal was to create a custom editor for specific expression languages when editing the properties of a BPEL process. Bettini points out that the main problem with this integration was that the expressions which were supposed to be edited in such an Xtext editor were stored as a BPEL process file, which is defined in a custom format that and therefore not readable by an Xtext editor defined with the corresponding grammar for expressions. Moreover, Xtext requires an EditorInput based on a physical file, so it was not possible to isolate the expression and instantiate the Xtext editor with it.

To solve this Bettini proposed to create temporary (and hidden) files for these expressions upon instantiation. These files would be given as input to Xtext, thereby satisfying the requirement of an EditorInput with a physical file.4 An example of the resulting integration is shown in Figure 7.3.

7.2 Related research

Research on integrating textual and graphical editors in Eclipse has been carried out in different areas, depending on the specific needs of the author. As discussed in the previous section, Bettini investigated integrating Xtext for a part of a BPEL process model and used temporary files to solve the need of Xtext to operate on physical files [34]. This integration is bound to the properties view (see also Figure 7.3) and therefore only applies to one model element at a time, that contains that specific expression. However, this work seems to be only published as an extended abstract and is therefore very limited, in the sense that it provides no further details on the exact approach that has

3http://www.eclipse.org/bpel/ 4http://code.google.com/a/eclipselabs.org/p/bpel-xtext Chapter 7. Related work 69

Figure 7.3: Xtext integration in BPEL Designer been carried out. It would be for example interesting to see how synchronization between these editors has been accomplished.

Scheidgen investigated a similar problem in more detail where he focused on embedding textual editors into graphical editors [35]. Since this research has much resemblance with the work presented in this thesis, it is worth mention it in more detail. The approach of this research is as follows. Upon request, instantiate an embedded editor from a graphical element, and give an initial textual representation of the partial model. This embedded editor operates on a copy of the subtree corresponding to the model element that is used. The user is allowed to change this textual model, which is parsed in the background during changes. During these changes the AST of the host editor is not affected, until the user decides to commit the changes and closes the embedded editor. When changes are committed, the old subtree is replaced with the new one. This is illustrated in Figure 7.4.

Scheidgen correctly identifies multiple problems and proposes several solutions to ap- proach them. One problem the author discusses is that of preserving layout information, and more specifically, preserving whitespace. Scheidgen proposes two solutions: either store whitespace within the model, or create this automatically. The main issue with both solutions is that it does not seem to work for incorrect partial models, that is, we cannot save them. This is in conflict with one of our requirements where we state Chapter 7. Related work 70

embedded editor host editor 1. copy 2. create initial representation 3. constant changes foo 4. replace the edited bar 2 repr. representation model element model model 3 1

4

Figure 7.4: Embedding textual editors into graphical host editors using the approach of Scheidgen that the user should be able to save incomplete (partial) models, which is considered a practically important requirement for the user. One additional point of remark is that we would also like to save comments within code (a must in some cases), which are not necessarily defined by the meta-model. In contrast to this approach, the highlight range method does not suffer from these problems since the partial model is directly edited from one file, in case we define the concrete syntax for the full model. If a full concrete textual definition is not applicable and if we therefore would need to define separate textual editors, it would be a better solution to store this layout information (including comments, and incorrect model elements) to separate files. This is roughly in line with the approach used by Bettini, except that we do want to keep these partial model files after the changes are saved and the partial model editor is closed. Another issue that is discussed by Scheidgen is that of how to deal with cross references when the identifier of a model element has been changed. In our case, this issue is solved quite easily: when the identifier is changed manually, we consider this as simply a change of identity; in the other case, when we want to apply this globally, we simply use the rename functionality as provided by Xtext/Eclipse.

Until now we have mainly seen research within the scope of embedding and using textual model editors. In case of multiple active editors, as discussed earlier, it is important to define a proper synchronization to keep model representations in editors consistent with each other. In our case, we synchronize only when changes are saved by the user, Chapter 7. Related work 71 and can therefore effectively work within only one editor concurrently. A real-time synchronization approach would be interesting to apply, but was outside the scope of this project. The work of van Rust et al. proposes a robust real-time synchronization between textual and graphical editors that deals with this problem [26]. The approach also recovers from errors during parsing and text-to-model synchronizations, preserves textual and graphical layout in the presence of erroneous texts and models, and provides provides synchronized editor services such as selection sharing and navigation between editors. The implementation that was carried out considered the Spoofax language workbench and GMF. It is left as future work to investigate whether and how this fits within the scope of partial model editors.

During the final stage of this project, another relevant research project worth mentioning has been discovered which was carried out by Schneider who proposed to use transient- view-based model representations [36]. This approach uses a single editor and applies views for other automatically derived representations, using own in-memory resources without using files. These views show parts of the model and are synchronized automat- ically on changes from the host editor. The transient-view approach has been realized in a tool called KIELER, which is an academic experimental modeling environment.5

5https://www.informatik.uni-kiel.de/rtsys/kieler/

Chapter 8

Conclusions

8.1 Results

The major contribution of this work consists of giving an overall overview of the most important integration aspects, how partial model editors for Xtext and GMF can be constructed, and how these editors can be synchronized. The work consists of a con- ceptual and a practical approach for applying and integrating partial model editors in a generic and structured way. The conceptual part describes various aspects such as different forms of model representations, the synchronization between these editors and how we can navigate through them. This conceptual part has been been formalized in the form of several integration requirements. The practical part shows how we can apply this based on the chosen tools, and to what tool-specific constraints we are bound. This has been demonstrated with smaller custom made DSLs to show different parts of the proposed solution space, but also with the more mature language POOSL where we combine the concepts from the smaller DSLs into a big whole.

These results enable us to answer our previously posed research questions from Chap- ter1:

• Which EMF-based frameworks can and should be used? We discussed multiple textual and graphical EMF based frameworks in Chapter3. For the textual framework we have chosen Xtext over EMFtext mainly because it has already been used to construct an Xtext grammar for POOSL. From the set

73 Chapter 8. Conclusions 74

of applicable graphical frameworks we chose GMF over Graphiti because Graphiti (in contrast to GMF) does not generate implementation code and has not been published yet as a major version.

• How can this integration of editors be done in a systematic and generic way? Based on the answer for the previous question, we have investigated the exist- ing out-of-the-box integration between Xtext and GMF that covered most of our specified integration requirements. However, this existing integration turned out to be lacking with respect to partial model editing, but it also did not provide any navigational structure through which multiple editors could be combined.

To solve this in the most generic way we proposed the highlight range approach for Xtext editors which basically applies views on a full textual models. For GMF editors we argued that dedicated editors for each partial model are practically the only option. We also argued that although we have to define a GMF editor for each root modeling element we want to graphically display, the amount of these dedicated editors is considered to be easily manageable in most cases.

The synchronization between these editors turned out to be problematic which was partly related to practical implementation issues, but partly also to the fact that the problem in general is far from trivial to solve. The problem manifested itself mainly when multiple partial model Xtext editors were used, instantiated by using the highlight range approach. We therefore restricted ourselves to one active (partial model) Xtext editor which could be synchronized with one or multiple active GMF editors, while working on one file and synchronizing on file save.

Aside from the synchronization issues, by combining these approaches we have shown how to successfully integrate Xtext and GMF editors into a modular and maintainable solution.

8.2 Further discussion on co-evolution

Businge conducted a series of empirical analyzes to investigate the co-evolution of the Eclipse framework and its third-party plug-ins [37]. He observed that the use of unstable and unsupported Eclipse interfaces results in incompatibilities of the systems built on top of Eclipse and its new releases. The conclusion of his work is that many developers Chapter 8. Conclusions 75 work on top of existing frameworks, which is also the case in this project where we base our proposed solutions on EMF, Xtext and GMF.

In terms of creating partial model editors, we need to consider the solution for Xtext and GMF separately. The highlight range approach is basically based on one function, which the corresponding Xtext editor class inherits from a Eclipse editor class. Since this is therefore core functionality of Eclipse, used by almost any framework that uses editors, it is expected to outlast next versions of Eclipse. So even if the Xtext framework at some point gets discontinued, it is still possible to apply the same solution to alternatives such as EMFText. In case of GMF we have chosen to use dedicated editors, which in terms of creating partial model editors only has a direct negative effect on co-evolution if the project gets discontinued.

The solutions provided for synchronization are depending on the very core concepts of Eclipse such as Resources and listeners, which means that it does not depend on any unstable or unsupported interfaces. It is therefore also expected to be applicable in the near future.

It should be noted, however, that wrapper classes such as XtextNewTabEditor.java (Appendix B.4) that contain these core solutions, might need customization as new versions of Eclipse, EMF or any other used helper class emerge.

8.3 Future work

The main recommendation for improving the current work is to solve the synchronization issues between partial model Xtext editors that are instantiated using the highlight range approach. It would be also interesting to investigate whether and how the work of Rust et al. [26] can be used to establish a real-time synchronization between these partial model editors.

Appendix A

Xtext grammars and model definitions

A.1 Greetings Xtext grammar

Listing A.1: Xtext grammar: Greetings

1 §grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals ¤ 2

3 generate myDsl"http://www.xtext.org/example/mydsl/MyDsl"

4

5 Model :

6 greetings+=Greeting*;

7

8 Greeting :

9 ’Hello’ name=ID’!’;

¦ ¥

A.2 Statemachines Xtext grammar

Listing A.2: Xtext grammar: Statemachines

1 §grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals ¤ 2

3 generate myDsl"http://www.xtext.org/example/mydsl/MyDsl"

4

5 Statemachine:

6 {Statemachine}

7 ’states’

77 Appendix A. Concrete syntax definitions 78

8 (states+=State)+

9 ’end’

10 ’transitions’

11 (transitions+=Transition)+

12 ’end’;

13

14 State :

15 ’state’ name=ID’;’;

16

17 Transition:

18 fromState=[State]’=>’ toState=[State]’expression’ expression=Expression’; ’

19 ;

20

21 Expression :

22 TerminalExpression ({Operation.left= c u r r e n t }

23 op=’+’ right=Expression)?

24 ;

25

26 TerminalExpression r e t u r n s Expression:

27 ’(’ Expression’)’|

28 {IntLiteral} value=INT

29 ;

¦ ¥

A.3 Web application Ecore definition

Listing A.3: Web application ecore file

1 § ¤

2

3 xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="core" nsURI ="core" nsPrefix="core">

4

5

6 eType ="#//DataTable" containment="true"/>

7

8

9 Appendix A. Concrete syntax definitions 79

10

11 eType ="#//DataColumn" containment="true"/>

12

13

14

15

16

17

¦ ¥ Appendix A. Concrete syntax definitions 80

A.4 POOSL high-level meta-model

Figure A.1 shows the high-level meta-model of POOSL, with the most relevant modeling elements.

Figure A.1: High-level meta-model of POOSL Appendix B

Integration code

B.1 Activator.java

Listing B.1: Activator.java

1 §package org.xtext.example.mydsl.myDsl.diagram.custom; ¤

2

3 import org.eclipse.core.runtime.IStatus;

4 import org.eclipse.core.runtime.Status;

5 import org.eclipse.ui.plugin.AbstractUIPlugin;

6 import org.osgi.framework.BundleContext;

7

8 p u b l i c class Activator extends AbstractUIPlugin {

9

10 // Plug-inID

11 p u b l i c static final String PLUGIN_ID ="org.xtext.example.mydsl.myDsl .diagram.custom";

12

13 // Shared instance

14 p r i v a t e static Activator plugin;

15

16 // Constructor

17 p u b l i c Activator() {}

18

19 @Override

20 p u b l i c void start(BundleContext context) throws Exception {

21 //TODO Auto-generated method stub

22 super .start(context);

81 Appendix B. Integration code 82

23 plugin = t h i s ;

24 }

25

26 @Override

27 p u b l i c void stop(BundleContext context) throws Exception {

28 //TODO Auto-generated method stub

29 plugin = n u l l ;

30 super .stop(context);

31 }

32

33 p u b l i c static Activator getDefault() {

34 r e t u r n plugin ;

35 }

36

37 p u b l i c static void logError(Throwable t) {

38 getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, t. getMessage(), t));

39 }

40 }

¦ ¥

B.2 EditPolicyProvider.java

Listing B.2: EditPolicyProvider.java

1 §package org.xtext.example.mydsl.myDsl.diagram.custom; ¤

2

3 import org.eclipse.gef.EditPart;

4 import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;

5 import org.eclipse.gmf.runtime.common.core.service.IOperation;

6 import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles ;

7 import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy. CreateEditPoliciesOperation;

8 import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy. IEditPolicyProvider;

9

10 p u b l i c class EditPolicyProvider extends AbstractProvider implements IEditPolicyProvider {

11

12 @Override Appendix B. Integration code 83

13 p u b l i c boolean provides(IOperation operation) {

14 //TODO Auto-generated method stub

15 i f ( operation i n s t a n c e o f CreateEditPoliciesOperation) {

16 r e t u r n true ;

17 }

18 r e t u r n false ;

19 }

20

21 @Override

22 p u b l i c void createEditPolicies(EditPart editPart) {

23 //TODO Auto-generated method stub

24 editPart.installEditPolicy(EditPolicyRoles.OPEN_ROLE, new OpenEditPolicy());

25 }

26

27 }

¦ ¥

B.3 OpenEditPolicy.java

Listing B.3: OpenEditPolicy.java

1 §package org.xtext.example.mydsl.myDsl.diagram.custom; ¤

2

3 import org.eclipse.emf.ecore.EObject;

4 import org.eclipse.gef.EditPart;

5 import org.eclipse.gef.Request;

6 import org.eclipse.gef.commands.Command;

7 import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart ;

8 import org.eclipse.gmf.runtime.notation.View;

9

10

11 p u b l i c class OpenEditPolicy extends org.eclipse.gmf.runtime.diagram.ui .editpolicies.OpenEditPolicy {

12 @Override

13 p r o t e c t e d Command getOpenCommand(Request request) {

14 EditPart targetEditPart = getTargetEditPart(request);

15 f i n a l EditPart editPart = getTargetEditPart(request);

16 i f ( f a l s e == targetEditPart.getModel() i n s t a n c e o f View ) {

17 r e t u r n null ; Appendix B. Integration code 84

18 }

19

20 r e t u r n new Command () {

21

22 p u b l i c void execute () {

23 IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart) editPart ;

24 EObject semanticElement = graphicalEditPart.resolveSemanticElement ();

25 new XtextNewTabEditor(graphicalEditPart, semanticElement,"org. xtext.example.mydsl.MyDsl").openEditor();

26 }

27

28 };

29 }

30 }

¦ ¥

B.4 XtextNewTabEditor.java

Listing B.4: XtextNewTabEditor.java

1 §package org.xtext.example.mydsl.myDsl.diagram.custom; ¤

2

3 import org.eclipse.core.resources.IFile;

4 import org.eclipse.emf.ecore.EObject;

5 import org.eclipse.emf.ecore.resource.Resource;

6 import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;

7 import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart ;

8 import org.eclipse..text.DocumentEvent;

9 import org.eclipse.jface.text.IDocumentListener;

10 import org.eclipse.ui.IWorkbenchPage;

11 import org.eclipse.ui.PlatformUI;

12 import org.eclipse.ui.part.FileEditorInput;

13 import org.eclipse.xtext.nodemodel.ICompositeNode;

14 import org.eclipse.xtext.nodemodel.util.NodeModelUtils;

15 import org.eclipse.xtext.resource.XtextResource;

16 import org.eclipse.xtext.ui.editor.XtextEditor;

17 import org.eclipse.xtext.ui.editor.info. ResourceWorkingCopyFileEditorInput; Appendix B. Integration code 85

18

19 p u b l i c class XtextNewTabEditor {

20 p r i v a t e IGraphicalEditPart hostEditPart;

21 p r i v a t e String semanticElementFragment;

22 p r i v a t e XtextResource xtextResource;

23 p r o t e c t e d int editorOffset;

24 p r o t e c t e d int initialEditorSize;

25 p r o t e c t e d int initialDocumentSize;

26 p r i v a t e EObject semanticElement;

27 p r i v a t e IWorkbenchPage page;

28 p r i v a t e XtextEditor editor;

29 p r i v a t e ResourceWorkingCopyFileEditorInput editorInput;

30 p r i v a t e String editorID;

31 p u b l i c XtextNewTabEditor(IGraphicalEditPart editPart, EObject semanticElement, String editorID) {

32 t h i s .hostEditPart = editPart;

33 t h i s .semanticElement = semanticElement;

34 t h i s .editorID = editorID;

35 }

36

37 p u b l i c void openEditor() {

38 t r y {

39 i f (semanticElement == n u l l ){

40 r e t u r n ;

41 }

42

43

44 Resource semanticResource = semanticElement.eResource();

45

46 xtextResource = (XtextResource) semanticResource;

47

48 i f (!(semanticResource i n s t a n c e o f XtextResource)) {

49 r e t u r n ;

50 }

51 semanticElementFragment = semanticResource.getURIFragment( semanticElement);

52 i f (semanticElementFragment == n u l l ||"".equals( semanticElementFragment)) {

53 r e t u r n ;

54 }

55 Appendix B. Integration code 86

56 page = PlatformUI.getWorkbench().getActiveWorkbenchWindow(). getActivePage();

57

58 ICompositeNode xtextNode = getCompositeNode(semanticElement);

59 editorOffset = xtextNode.getOffset();

60 initialEditorSize = xtextNode.getLength();

61

62 IFile file = WorkspaceSynchronizer.getFile(xtextResource);

63 FileEditorInput editorInput = new FileEditorInput(file);

64

65 editor = (XtextEditor) page.openEditor(editorInput, editorID);

66

67 editor.showHighlightRangeOnly( t r u e );

68 editor.setHighlightRange(editorOffset+1, initialEditorSize-1, t r u e ) ;

69

70 editor.getDocument().addDocumentListener(new IDocumentListener() {

71

72 @Override

73 p u b l i c void documentChanged(DocumentEvent event) {

74 semanticElement = hostEditPart.resolveSemanticElement();

75

76 i f (semanticElement == n u l l ){

77 r e t u r n ;

78 }

79 ICompositeNode xtextNode = getCompositeNode(semanticElement);

80 i f (xtextNode == n u l l ){

81 r e t u r n ;

82 }

83

84 editorOffset = xtextNode.getOffset();

85 Integer nodeSize = xtextNode.getLength();

86

87 editor.showHighlightRangeOnly( t r u e );

88 editor.setHighlightRange(editorOffset+1, nodeSize-1, t r u e );

89 editor.setFocus();

90 }

91

92 @Override

93 p u b l i c void documentAboutToBeChanged(DocumentEvent event) {

94 } Appendix B. Integration code 87

95 });

96

97

98

99 } catch (Exception e) {

100 Activator.logError(e);

101 }

102 }

103

104

105 p r o t e c t e d ICompositeNode getCompositeNode(EObject semanticElement) {

106 r e t u r n NodeModelUtils.getNode(semanticElement);

107 }

108 }

¦ ¥

B.5 plugin.xml extension point

This is the extension point for the Greetings example. One needs to change GreetingEditPart to match the EditPart that needs to be instantiated.

Listing B.5: plugin.xml extension point

1 §

2

3 class ="org.xtext.example.mydsl.myDsl.diagram.custom. EditPolicyProvider">

4

5

6

7

8 class ="org.xtext.example.mydsl.myDsl.diagram.edit.parts. GreetingEditPart"

9 id="org.xtext.example.mydsl.myDsl.diagram.edit.parts. GreetingEditPart">

10

11

12

¦ ¥

Appendix C

Tutorials

C.1 Creating an Xtext editor

Before creating an Xtext editor, make sure that Eclipse and Xtext are installed correctly. To create a default Xtext project template, we proceed as follows:

1. Select File > New ... > Project and then select Xtext > Xtext Project. Click Next to continue to the next page.

2. After filling in the fields we click on Finish and our project is automatically created.

Assuming that our project name is org.xtext.example.mydsl, we can navigate to org.xtext.example.mydsl > src > org.xtext.example.mydsl. Here we will find a .xtext file that contains our grammar.

After defining a custom grammar, we simply right click on the .xtext file and then select Run as > Generate Xtext artifacts. The first time we call this generation procedure we will get the following message within the Eclipse console:

*ATTENTION* It is recommended to use the ANTLR 3 parser generator (BSD licence - http://www.antlr.org/license.html). Do you agree to download it (size 1MB) from

89 Appendix C. Tutorials 90

’http://download.itemis.com/antlr-generator-3.2.0.jar’? (type ’y’ or ’n’ and hit enter)

After typing in “y” and pressing enter, Xtext will automatically generate the necessary Xtext artifacts, such as the ecore file which describes our meta-model, based on our previously defined grammar. This ecore file is located in org.xtext.example.mydsl > model > generated (by default MyDsl.ecore).1

C.2 Creating a GMF editor

Before discussing how to create GMF editors, we assume that EMF and the GMF plug- ins are installed. The first step in creating a GMF editor is usually to define an EMF model (Ecore file). If we have previously created an Xtext editor, the EMF model is automatically generated. We assume in any case that we already have our EMF model defined.

A convenient way to create GMF editors based on an existing EMF model is to use the so called GMF Dashboard, which is a utility that aides in the process of performing all the necessary steps. We can find this utility by selecting: Window > Show view > Other > GMF Dashboard. The utility is displayed in Figure C.1.

Figure C.1: GMF Dashboard

1This information is based on Xtext version 2.4.3. Appendix C. Tutorials 91

We can now select the .ecore file as the Domain Model, and the .genmodel as the Domain Gen Model. If the generator model is not present, we can click on derive to generate it automatically. Next we derive a graphical definition model (.gmfgraph) and a tooling definition model (.gmftool) by for each clicking on the Derive link that is displayed on the dashboard. Clicking on this link will pop-up a wizard in which we can follow the displayed steps. When these files are created, we need to combine them into a mapping model (.gmfmap) by clicking on Combine. We can now finally click on Transform to create a diagram generator model (.gmfgen), and consequently click on Generate diagram editor to generate the source code for the GMF editor. This process is also illustrated in Figure C.2. For a detailed description on how to create GMF editors see also [38].

Figure C.2: Workflow for the creation of a GMF editor

Another way to create GMF editors is to use the tool EuGENia [39]. This tool auto- mates the creation of the .gmfgraph, .gmftool, .gmfmap and .gmfgen files by using an annotated Ecore meta-model. Appendix C. Tutorials 92

C.3 Integrating YST plugins

In this section we describe how to integrate the YST plugins to enable a cell editor with syntax highlighting. We take a statemachine as an example, defined according to the metamodel as shown in Figure C.3.

Figure C.3: Yakindu wrapper example integrated with a state transition system

After generating the implementation code we need to import the plugins from the YST repository:2

• de.itemis.gmf.runtime.commons

• de.itemis.gmf.runtime.commons-feature

• de.itemis.gmf.runtime.treelayout

• de.itemis.xtext.utils.gmf

• de.itemis.xtext.utils.gmf-feature

• de.itemis.xtext.utils.jface

• de.itemis.xtext.utils.jface-feature

Now we need a custom Xtext editor that will be used within the cell editor. We generate the Xtext editor according to the following Xtext grammar:

2http://svn.codespot.com/a/eclipselabs.org/yakindu/BASE/ Appendix C. Tutorials 93

1 § grammar org.xtext.example.mydsl.Statename with org.eclipse. ¤ xtext.common.Terminals

2

3 generate statename"http://www.xtext.org/example/mydsl/ Statename"

4

5 State :

6 ’state’ name=ID;

¦ ¥ Next we open the EditPart corresponding to the label we want to edit. In our case this is the StateNameEditPart. We adapt the following parts of the class. First we adapt the head of the class to extend the ITextAwareEditPart class, which enables us to use the customized cell editor functions:

1 § p u b l i c class StateNameEditPart extends CompartmentEditPart ¤ implements ITextAwareEditPart , IXtextAwareEditPart

¦ ¥ Next, we adapt the set and get functions, setManager and getManager, respectively. We replace them with the following:

1 § p r o t e c t e d XtextDirectEditManager getManager() { ¤

2 r e t u r n new XtextDirectEditManager( t h i s , StatenameActivator. getInstance().getInjector(StatenameActivator. ORG_XTEXT_EXAMPLE_MYDSL_STATENAME),SWT.SINGLE);

3 }

4

5 p r o t e c t e d void setManager(XtextDirectEditManager manager) {

6 t h i s .manager = manager;

7 }

¦ ¥ The above functions enable us to instantiate our dedicated Xtext editor, as defined earlier. Note from the code snippet that the ID defined in

1 § StatenameActivator.ORG\_XTEXT\_EXAMPLE\_MYDSL\_STATENAME ¤

¦ ¥ corresponds to the editor ID of our Xtext editor.

The last piece of customization are the two distinct functions performDirectEdit: Appendix C. Tutorials 94

1 § p r o t e c t e d void performDirectEdit(Point eventLocation) { ¤

2 i f (getManager().getClass() == XtextDirectEditManager. c l a s s ){

3 ((XtextDirectEditManager) getManager()).show(eventLocation

4 .getSWTPoint());

5 }

6 }

7

8 p r i v a t e void performDirectEdit( char initialCharacter) {

9 i f (getManager() i n s t a n c e o f XtextDirectEditManager) {

10 ((XtextDirectEditManager) getManager()).show(initialCharacter);

11 } e l s e //

12 {

13 performDirectEdit();

14 }

15 }

¦ ¥ We can now compile our project to get the result as shown in Figure C.4.3

Figure C.4: Yakindu wrapper example integrated with a state transition system

3Strictly speaking, the label should only represent the name of the state and not the textual defi- nition of the entire state. That said, we only use this example to demonstrate the syntax highlighting functionality. Bibliography

[1] Zlatka Manevska. User Interaction Layer for POOSL. December 2012.

[2] Piet HA van der Putten and Jeroen PM Voeten. Specification of reactive hard- ware/software systems. CIP-Data Library Technishe Universiteit Eindhoven, 1997.

[3] Arjan J Mooij, Jozef Hooman, and Rob Albers. Early fault detection using design models for collision prevention in medical equipment. In Foundations of Health Information Engineering and Systems, pages 170–187. Springer, 2014.

[4] Leo J. van Bokhoven. Constructive tool design for formal languages: From seman- tics to executing models. Technische Universiteit Eindhoven, 2002.

[5] SHE, March 2014. URL http://www.es.ele.tue.nl/she/.

[6] Dave Steinberg, Frank Budinsky, Marcelo Paternostro, and Ed Merks. EMF: Eclipse Modeling Framework. Addison-Wesley, Boston, MA, 2 edition. ISBN 978-0-321- 33188-5.

[7] Eclipse Modeling Framework (EMF), March 2014. URL http://www.eclipse. org/emf/.

[8] Moritz Eysholdt and Heiko Behrens. Xtext: implement your language faster than the quick and dirty way. In Proceedings of the ACM international conference com- panion on Object oriented programming systems languages and applications com- panion, pages 307–309. ACM, 2010.

[9] Arno Haase, Markus V¨olter,Sven Efftinge, and Bernd Kolb. Introduction to ope- narchitectureware 4.1. 2. In MDD Tool Implementers Forum, 2007.

95 Bibliography 96

[10] Florian Heidenreich, Jendrik Johannes, Sven Karol, Mirko Seifert, and Christian Wende. Model-based language engineering with emftext. In Generative and Trans- formational Techniques in Software Engineering IV, pages 322–345. Springer, 2013.

[11] Markus Scheidgen. Integrating content assist into textual modelling editors. In Modellierung, volume 12, page 14, 2008.

[12] Fr´ed´ericJouault, Jean B´ezivin,and Ivan Kurtev. Tcs:: a dsl for the specification of textual concrete syntaxes in model engineering. In Proceedings of the 5th inter- national conference on Generative programming and component engineering, pages 249–254. ACM, 2006.

[13] Holger Krahn, Bernhard Rumpe, and Steven V¨olkel. Integrated definition of ab- stract and concrete syntax for textual languages. In Model Driven Engineering Languages and Systems, pages 286–300. Springer, 2007.

[14] Sebastian Erdweg, Tijs van der Storm, Markus V¨olter,Meinte Boersma, Remi Bosman, William R Cook, Albert Gerritsen, Angelo Hulshout, Steven Kelly, Alex Loh, et al. The state of the art in language workbenches. In Software Language Engineering, pages 197–217. Springer, 2013.

[15] Graphical Editing Framework (GEF), March 2014. URL http://www.eclipse. org/gef/.

[16] Draw2D, March 2014. URL http://www.eclipse.org/gef/draw2d/index.php.

[17] GEF (MVC), March 2014. URL http://www.eclipse.org/gef/gef_mvc/index. php.

[18] Zest, March 2014. URL http://www.eclipse.org/gef/zest/index.php.

[19] (SWT), March 2014. URL http://www.eclipse.org/ swt/.

[20] Dimitrios S Kolovos, Louis M Rose, Richard F Paige, and Fiona AC Polack. Raising the level of abstraction in the development of GMF-based graphical model editors. In Proceedings of the 2009 ICSE Workshop on Modeling in Software Engineering, pages 13–19. IEEE Computer Society, 2009. Bibliography 97

[21] Enrico Schnepel. Gengmf: Efficient editor development for large meta models using the graphical modelling framework. Proc. Special Interest Group on Model-Driven Software Engineering (SIG-MDSE), 9, 2008.

[22] Graphiti, March 2014. URL http://www.eclipse.org/graphiti/.

[23] Ivar Refsdal. Comparison of GMF and Graphiti based on experiences from the development of the PREDIQT tool. Master’s thesis, University of Oslo, 2011.

[24] Filippelli et al. Concepts for the model-driven generation of graphical editors in Eclipse by using the Graphiti framework. 2012.

[25] Christopher Guntli. Create a dsl in eclipse. Technical report, Tech. rep. HSR- University of Applied Science in Rapperswil, 2010.

[26] Oskar van Rest, Guido Wachsmuth, Jim RH Steel, J¨ornGuy S¨uß,and Eelco Visser. Robust real-time synchronization between textual and graphical editors. In Theory and Practice of Model Transformations, pages 92–107. Springer, 2013.

[27] Markus Voelter and Konstantin Solomatov. Language modularization and com- position with projectional language workbenches illustrated with mps. Software Language Engineering, SLE, 2010.

[28] Yakindu Statechart Tools, March 2014. URL http://statecharts.org/.

[29] Sirius, March 2014. URL http://www.eclipse.org/proposals/modeling. sirius/.

[30] Meta Programming System (MPS), March 2014. URL http://www.jetbrains. com/mps/.

[31] Bernhard Merkle. Textual modeling tools: overview and comparison of language workbenches. In Proceedings of the ACM international conference companion on Object oriented programming systems languages and applications companion, pages 139–148. ACM, 2010.

[32] Markus Voelter. Language and ide modularization and composition with mps. In Generative and transformational techniques in software engineering IV, pages 383– 430. Springer, 2013. Bibliography 98

[33] Reinhard von Hanxleden and Dipl-Inf Christian Motika. A synccharts editor based on yakindu sct. 2013.

[34] Lorenzo Bettini, Vincenzo Caselli, and Francesco Guidieri. Extending the bpel designer with xtext based editors. ECLIPSE IT 2011, page 332, 2011.

[35] Markus Scheidgen. Textual modelling embedded into graphical modelling. In Model Driven Architecture–Foundations and Applications, pages 153–168. Springer, 2008.

[36] Christian Schneider. On integrating graphical and textual modeling. Real-Time and Embedded Systems Group, Christian-Albrechts-Universit¨atzu Kiel, 2011.

[37] John Businge. Co-evolution of the eclipse framework and its third-party plug-ins. 2013.

[38] Learn Eclipse GMF in 15 minutes, March 2014. URL http://www.ibm.com/ developerworks/library/os-ecl-gmf/.

[39] EuGENia, March 2014. URL http://www.eclipse.org/epsilon/doc/eugenia/.