• No results found

Introduction à EMF Eclipse Modeling Framework

N/A
N/A
Protected

Academic year: 2021

Share "Introduction à EMF Eclipse Modeling Framework"

Copied!
35
0
0

Loading.... (view fulltext now)

Full text

(1)

Ingénierie Dirigée par

les Modèles

Introduction à EMF

Introduction à EMF

Eclipse Modeling Framework

(2)

EMF 2

Sources du cours

Tutoriaux et cours d'EMF disponibles sur

http://www.eclipse.org/modeling/emf/

(3)
(4)

EMF 4

C'est quoi EMF ?

● A modeling & data integration framework ● Exploits the facilities offered in Eclipse to...

– Generate code without losing user customizations (merge) – Automate important tasks

– Improve extensibility – Provide a UI layer

● What is an EMF “model”?

– Specification of your application’s data – Object attributes

– Relationships (associations) between objects – Operations available on each object

– Simple constraints (eg. cardinality) on objects and relationships – Essentially it represents the class diagram of the application

(5)

Qu'est-ce qu'il permet ?

● From a model specification, EMF can generate efficient, correct,

and easily customizable implementation code

● Out of the box, EMF provides support for – Java interfaces

– UML

– XML Schema

● EMF converts your models to Ecore (EMF metamodel)

● Tooling support within the Eclipse framework, including support for

generating Eclipse-based and RCP editors

● Reflective API and dynamic model definition

● Persistence API with out of box support for XML/XMI

(6)

EMF 6

Créer un modèle Ecore

Representing the modeled domain in Ecore is the first step in

using EMF

Ecore can be created

– Directly using the EMF editors

– Through a graphical UI provided by external contributions

– By converting a model specification for which a Model Importer

is available

● Java Interfaces

● UML models expressed in Rational Rose® files

● XML Schema

(7)

Exemples

(8)

EMF 8

Exemples

(9)

Exemples

(10)

EMF 10

Unification des technologies UML, Java et XML

The Model Importers available in EMF were carefully chosen

to integrate today’s most important technologies

All three forms provide the same information

– Different visualization/representation

– The application’s “model” of the structure

From a model definition, EMF can generate

– Java implementation code, including UI – XML Schemas

(11)

Scénario d'usage typique

Create an Ecore model that represents the domain you are

working on

– Import UML (e.g. Rose .mdl file) – Import XML Schema

– Import annotated Java interfaces

– Create Ecore model directly using EMF's Ecore editor or a

graphical editor

Generate Java code for model

Prime the model with instance data using generated EMF

model editor

Iteratively refine model (and regenerate code) and develop

Java application

(12)

EMF 12

Composants EMF

EMF Core

● Ecore metamodel

● Model change notification & validation ● Persistence and serialization

● Reflection API

● Runtime support for generated models

EMF Edit

● Helps integrate models with a rich user interface ● Used to build editors and viewers for your model ● Includes default reflective model editor

EMF Codegen

● Code generator for core and edit based components ● Extensible model importer framework

(13)
(14)

EMF 14

Création de modèle Ecore

An Ecore model is created within an Eclipse project via a

wizard

Input: one of the model specifications from the previous slide

Output:

– modelname.ecore

● Ecore model file in XMI format

● Canonical form of the model

– modelname.genmodel

● A “generator model” for specifying generator options

● Decorates .ecore file

● EMF code generator is an EMF .genmodel editor

(15)

L'editeur de modèle Ecore

A generated (and customized)

EMF editor for the Ecore model

– Create, delete, etc. model elements

(EClass, EAttribute, EReference, etc.) using pop-up actions in the editor's tree

– Set names, etc. in the Properties – view

(16)

EMF 16

Vers des éditeurs encore plus améliorés

A graphical editor is a better approach

– GMF Ecore Diagram Example (http://www.eclipse.org/gmf/) – Omondo EclipseUML (http://www.omondo.com/)

(17)

Le générateur EMF

● Similar layout to Ecore model editor ● Automatically keeps in synch

with .ecore changes

● Generate code with pop-up menu

actions

– Generate Model Code – Generate Edit Code – Generate Editor Code – Generate Test Code – Generate All

● Code generation options in

Properties view

● Generator > Reload to

reload .genmodel and .ecore files from original model form

(18)

EMF 18

Le (méta) modèle Ecore

Ecore is EMF's model of a model

– Also called a “metamodel”

(19)
(20)

EMF 20

(21)
(22)

EMF 22

(23)
(24)
(25)
(26)
(27)

Génération de code

EMF framework is lightweight

– Generated code is clean, simple, efficient

EMF can generate

– Model implementation

– UI-independent edit support

– Editor and views for Eclipse IDE-integrated or RCP application – JUnit test skeletons

(28)

EMF 28

Code généré pour le modèle

Interface and implementation for each modeled class

– Includes get/set accessors for attributes and references

(29)
(30)

EMF 30

(31)

Regénération et fusion

Hand-written code can be added to generated code and

preserved during regeneration

– This merge capability has an Eclipse dependency, so is not

available standalone

All generated classes, interfaces, methods and fields include

@generated marker in their Javadoc

To replace generated code:

– Remove @generated marker

– Or include additional text, e.g. @generated NOT

Methods without @generated marker are left alone during

(32)
(33)
(34)

EMF 34

(35)

References

Related documents

The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify

The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify

The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify

This part of study presents a tool for solving Optimal Power Flows (OPFs) in hybrid high voltage direct current (HVDC) and high voltage alternating current (HVAC) systems for

A series of tests of HTS tapes produced by SJTU and AMSC are carried out to test the tape characteristics and to prove the current limiting ability of supercon- ducting

The criticalcurrent of the double-insert YBCO tapes is 500 A, so 10 modulesare needed to meet the requirement of 5 kA critical current.The structure of a single current

--->The user andrew is able to read & write /var/tmp/fstab The user susan can neighter write nor read /var/tmp/fstab All other users (current or future) have the ability

Place the electrodes with the RED and BLACK ends of the lead wires according to pattern depicted on figure below. Using both channels and crisscrossing the electrodes