Chapter Graphical Editing Framework The Graphical Editing Framework

Chapter 3
State of the ART
3.1 Introduction
This Chapter aims to complete the information presented in the chapter with the same name from the
MEng Hons Project Phase 1 Report by oering a more in depth description of the Graphical Editing
Framework and the Xtext Framework.
These are the main technologies used to realise this project and the information presented here is the
key to understanding the planning, implementation and testing aspects described in this report.
3.2 Graphical Editing Framework
The Graphical Editing Framework (GEF) is a framework used to build graphical editors and applications
that can be easily integrated in the Eclipse UI.
We are using GEF 3.11, which is also used to create the Visual Expressions plug-in for e2 studio.
This aspect translates to less problems during integration and maintenance of this project.
It can be installed into Eclipse by Help->Install New Software and using the http://download.
eclipse.org/tools/gef/updates/legacy/releases/. link.
3.2.1 Draw2d
Draw2D sits at the base of GEF and is a layout and rendering toolkit building on top of SWT. It handles
2 dimensional drawing and works along four concepts: Event dispatcher, Lightweight system, Update
manager and Layout managers.
Draw2D handles the event dispatching, the updating of gures and acts as a container of all gures.
More features include ecient layout and rendering support, various gure and layout implementations
and borders. Moreover, it allows to create complex drawings by the use of the parent-child relationship
between gures.
Renesas Electronics Europe Ltd
R Confidential
24
Figure 3.1: GEF, Draw2d, RCP
3.2.2 The GEF MVC Architecture
Before we can explain the interactions between the Model, the View and the Controller, we have to dene
them and the concepts that lie behind these denitions.
Every part of the Graphical Editor that we want to display and edit will have a Model, a Figure and
an EditPart.
The Model
The model contains the information we need to visualise and edit. It is usually designed as a tree structure
to help capturing the elements of the view. It starts from a base class that is extended to represent each
of the graphical elements.
Figures- View
The Figues are what the user will see. They can be modelled from basic Draw2d gures such as rectangles,
triangles, lines and points. The connection with Controller is realised inside the EditPart classes through
the createFigure() function which returns the Figure.
Control
Under the Control section of the GEF Architecutre we nd more components. We describe bellow the
purpose of these components.
EditParts
The EditParts are the core part of the Controller and the most basic part of GEF. An EditPart connects
the Model with the View. The gures are refreshed every time the user performs a change.
Renesas Electronics Europe Ltd
R Confidential
25
EditPart factory
The EditPart factory is the rst connection point between the Model and the Controller. Its main
purpose is to detect which EditPart is used depending on the element of the model.
EditPolicies
The changes performed by the user are handled by the EditPolices. Each EditPolicy species what
happens inside the EditPart when a task is performed. An EditPolicy is installed on an EditPart through
the createEditPolicies() function.
Requests
A request is what leads to a change to happen and it is strongly connected with an EditPolicy. We
say that a request has been triggered when the user performs an action that is detected by the GEF
framework. Some types of requests can be selection, delete, move or change layout requests. Depending
on the type of the request the EditPolicy decides which command is executed.
Commands
The Command object is created inside the EditPolicy as a result of a Request. The EditPolicy decides if
and how the command will be executed. Most of the commands have 4 main functions: one function for
setting the parent of the gure we will make the change on, one function setting the gure we perform
the change on, an execution function which denes the change and an undo- revert function which will
dene how the change performed can be reverted.
Actions
Context menus and action bars are used to improve the functionality of an editor. Because they are
outside the View, the commands can not be triggered by a Request directly, but by an Action. In other
words, the action requests a command from outside the View.
3.2.3 MVC Interaction
Now that we have explained the concepts behind the Model- View- Controller Architecture we can
describe how the interactions between these is realised. Please keep in mind that under the Control
section we nd the EditParts, the EditPart factory, the EditPolicies, the Requests, the Commands and
the Actions.
• The EditPart factory assigns an EditPart for each corresponding node in the model.
• The EditPart is initiated and creates its corresponding Figure.
• The EditPolicies are installed.
Renesas Electronics Europe Ltd
R Confidential
26
• Requests and Actions trigger Commands that change the model.
• The EditPart refreshes the gures and the View based on the new information from the model.
Figure 3.2: The MVC Architecture
3.3 Xtext
As mentioned to you, the Graphical Editor is part of a Multi-page Editor which oers a rich text editor
together with a Form-based Memory and Sections Pages. This previous implementation of the Multi-page
Editor lies on top of an Xtext plug-in project.
Xtext is a Java framework used to develop or model small textual domain-specic programming
languages. The version of Xtext used by our project is 2.11 and it can be installed into Eclipse by using
the following link:
http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/
3.4 Runtime Concepts
Xtext includes some Runtime Concepts that govern the plug-in’s back-end and the generation of the
model from the dened Domain Specic Language(DSL).
IDE Concepts
These concepts create almost immediately the features of a Rich Text Editor which can be included into
an Eclipse-based IDE such as e2 studio.
Some of these features include Content Assist, Linking, Code Formatting, Scoping, Validation and
Quick Fixes.
The Grammar
The grammar of the language we want to dene or model lies at the base of Xtext. It is usually a single
le that captures the syntax of the programming language as a domain-specic language.
Renesas Electronics Europe Ltd
R Confidential
27
When an input le is analysed by an on-the-y parser, a model (Xtext model) is produced. Each
element of the model has an URI. This is the key for locating and editing parts of the input le.
Code Generator
The Code Generator feature of Xtext will generate, among other Java code, Java classes for each of the
elements of this model. Based on these classes, we can build other editing features.
3.5 Summary
We have presented in this chapter the main information required for a better understanding of this
report. 

x

Hi!
I'm Mack!

Would you like to get a custom essay? How about receiving a customized one?

Check it out