290 likes | 493 Vues
Eclipse GMF. Fábio M. Pereira Ramon Rabello. Agenda. GMF – What is it? EMF – Overview GEF – Overview GMF – Models. GMF – What is it?.
E N D
Eclipse GMF Fábio M. Pereira Ramon Rabello
Agenda • GMF – What is it? • EMF – Overview • GEF – Overview • GMF – Models GEF - Graphical Modeling Framework
GMF – What is it? • It provides a generative component and runtime infrastructure for developing graphical editors based on EMF (Eclipse Modeling Framework) and GEF (Graphical Editing Framework) • It enables to produce graphical editors for Eclipse • For example, a UML modeling tool, workflow editor, etc. • Basically, a graphical editing surface for any domain model in EMF GEF - Graphical Modeling Framework
GMF – What is it? GEF - Graphical Modeling Framework
Scenario GEF - Graphical Modeling Framework
Components GEF - Graphical Modeling Framework
GMF Runtime • Its features provide a consistent look and feel with other GMF-based graphical editors • Its editors can be created manually from the ground up and/or be generated from the great tooling currently being developed as part GMF's SDK • It manages diagram persistence, allowing clients to focus on their business logic • Its extensible nature allows GMF Runtime clients to be fully open editors that in turn can be extended by third-parties GEF - Graphical Modeling Framework
GMF Runtime • It is already integrated with various new EMFT components such as validation and OCL should you need such support • It defines an extensible notation meta-model to enable the isolation of notation from semantic concerns • Its features are well designed, coded, tested, and deployed • Future community enhancements to the runtime will easily be integrated with your editor GEF - Graphical Modeling Framework
EMF – Eclipse Modeling Framework • The EMF project is a modeling framework and code generation facility for building tools and other applications based on a structured data model • The key concepts underlying the framework are: meta-data, code generation, and default serialization GEF - Graphical Modeling Framework
EMF Benefits • Increase productivity • Model change notification • Persistence support including default XMI and schema-based XML serialization • A framework for model validation • A very efficient reflective API for manipulating EMF objects generically • Most important of all, EMF provides the foundation for interoperability with other EMF-based tools and applications GEF - Graphical Modeling Framework
Developing an Eclipse plug-in using EMF • 1: Designing the model • The first step is to design the data model for the application - that is, the structure of the data we want to be able to view and edit, and the relationships between data items • You may find a UML tool useful, or a piece of paper • 2: Defining the model • The next step is to define the model to EMF so that code can be generated • 3: Generating the model • Now that the model has been defined, we can proceed to generate the model implementation • 4: Generating an editor • 5: Trying out the generated plug-ins GEF - Graphical Modeling Framework
Defining an EMF Model • Our model definition can be provided to the EMF code generator in a number of ways: • UML: if you have a modeling tool that works with EMF, you can simply draw the class diagram (*.uml) • XMI: we could describe the model directly in an XMI document (*.ecore) • Export the XMI document from the Rational Rose modeling tool (*.mdl) • Annotate Java interfaces with model properties (*.java) • Use XML Schema to describe the form of a serialization of the model (*.xsd; *.wsdl) GEF - Graphical Modeling Framework
GEFGraphical Editing Framework Overview
GEF – Graphical Editing Framework • It allows to easily develop graphical representations for existing models • It is possible to develop feature rich graphical editors using GEF • All graphical visualization is done via the Draw2D framework, which is a standard 2D drawing framework based on SWT from eclipse.org GEF - Graphical Modeling Framework
GEF – Graphical Editing Framework • Its editing possibilities allow you to build graphical editors for nearly every model • With these editors, it is possible to do simple modifications to your model, like changing element properties or complex operations like changing the structure of your model in different ways at the same time • All these modifications to your model can be handled in a graphical editor using very common functions like drag and drop, copy and paste, and actions invoked from menus or toolbars GEF - Graphical Modeling Framework
GMF Generated Diagram Editor GEF - Graphical Modeling Framework
GMF Generation Overview GEF - Graphical Modeling Framework
Develop Graphical Definition It is used to define the figures, nodes, links, etc. that you will display on your diagram GEF - Graphical Modeling Framework
Develop Tooling Definition It is used to specify the palette, creation tools, actions, etc. for your graphical elements GEF - Graphical Modeling Framework
Mapping Definition GEF - Graphical Modeling Framework
Develop Mapping Definition GEF - Graphical Modeling Framework
Create Generator Model GEF - Graphical Modeling Framework
Generate Diagram Plug-in and Run Diagram GEF - Graphical Modeling Framework
Validation • Validation Rules are written in OCL • They are defined in GMF Map model • State has ‘States should have unique names’ validation rule • Rules for source and target of a Transition • ‘StopState cannot be a source for a transition’ for StopState • ‘StartState cannot be a target for a transition’ for Transition GEF - Graphical Modeling Framework
Conclusions • Creating graphical editors for domain models is fairly straightforward • Using GMF is an iterative process • GMF code can be customized • It allows M2M transformations GEF - Graphical Modeling Framework
References • Eclipse GMF website http://www.eclipse.org/gmf • Eclipse Modeling Framework (EMF) website http://www.eclipse.org/emf • Graphical Modeling Framework (GEF) website http://ww.eclipse.org/gef • Using GMF and M2M for Model-Driven Development (Fesenko, T.; Dvorak, R.; Kolb B.; Voelter, M.) • Introducing the GMF Runtime. http://www.eclipse.org/articles/Article-Introducing-GMF/article.html • From Front End To Code - MDSD in Practice. http://www.eclipse.org/articles/Article-FromFrontendToCode-MDSDInPractice/article.html GEF - Graphical Modeling Framework