This book is a comprehensive introduction to and developer's quick reference for the Eclipse Modeling Framework (EMF). EMF is a powerful framework and. Eclipse EMF. This tutorial describes the usage of Eclipse EMF, a framework for modeling your data model and creating Java code from it. What is Eclipse Modeling Framework (EMF)?. □. EMF is part of the tools project for Eclipse. □. The answer to "What is EMF?" depends on who.
|Language:||English, Spanish, Japanese|
|Genre:||Children & Youth|
|ePub File Size:||22.66 MB|
|PDF File Size:||16.64 MB|
|Distribution:||Free* [*Register to download]|
What every Eclipse developer should know about EMF Contributed by Maximilian Koegel and Jonas Helming. July 27 EMF Book: Eclipse Modeling. EMF: Eclipse Modeling Framework Dave Steinberg Frank Budinsky Marcelo Paternostro Ed Merks Series Editors: Erich Gamma • Lee Nackman • John Wiegand. EMF: Eclipse Modeling Framework Dave Steinberg Frank Budinsky Marcelo Instead the book focuses on annotating existing Java models, XML Schema, and .
Install EMF via the Eclipse update manager. In the New Project wizard, create the "Extended Library Model Example", as shown below: In the next step, click Finish: You now have the model that you will use throughout the rest of the tutorial: On disk, in your workspace, you have the sources of the EMF model you created. That way, you will be able to work with the sources in the IDE, and tweak them where necessary. Name the application LibraryManager and click Finish. The application you now have is already deployable. Right-click the application to run it. When the application starts up, you'll first see the default splash screen: Then you will see the main window containing a window that displays all the NetBeans modules and OSGi bundles that have been deployed.
Next step is to create an EMF Ecore model. On opening the ecorediag file an editor will show, which lets us create the model in a graphical environment. ProcessShapes are connected using a Sequence. Create the EMF Ecore model for the business processes. After saving, the model will be also updated in the. In the next step, be sure, that the model folder is selected and give a name for the EMF generator model, i. Select folder and name for the EMF generator model.
Select the model importer for the generator model. After, we need to select the EMF. The basepackage needs to be set to the project name and the folder, in which the model resides.
Properties view of the genmodel. Now everything is set to generate the model and the edit code. Generate the model and the edit code. Now we may start with the graphical part, defining the notation symbols and map them to the model.
The following view should open: The GMF dashboard. Creation of the GMFGraph model. After being successful, the. This means, that events will be represented by Ellipses and processSteps by Rectangles.
ID Set this to true, to make this attribute one of the ID attribute s of the class. ID attributes will be used to determine if two objects of a class are equal or uniqueness if you put them into a list which requires that or a java. See text. Many Automatic property. True, if Upper Bound!
Name The name of the property. Ordered If this attribute is a list see Many , you can specifiy if the sequence of values should be ordered like a list or if it doesn't matter set.
The default is true but for performance reasons, you can set it to false. Required Automatic property. Transient Transient attributes are not persistet saved to a file when the whole model is saved. Usually, calculated fields like the length of a list are transient, because the length is already given by the number of items in the file.
Unique If Many is true, you can also say that all values must be unique different. For example, in a list of languages, you want each languages just once. Unsettable EMF can manage another state for an attribute for you: Unset. Unset is not the same as "set to null". Unset means the attribute was never set or eUnset was called on it to clear it.
You can use eIsSet to find out if the attribute is set or not. You can specify an upper limit for the number of values one can store in this attribute. Use -1 to say: There is no limit.
Volatile The value of the attribute is computed every time the getter is called. EMF will not generate a private field to store the value. You will have to fill in the body of the getter yourself.
This means, you can change it, the values will be persistet and there can be any number of values. It's not an ID, it can be empty and you can clear it. So there is always exactly one of it, it's an int and it can't be changed because it's a calculated field.
So for most attributes, you will just set the name and the type. If the value is calculated, you will set Changeable to false and usually Transient to true. You can leave Transient alone, for example, for error checking: If you load the list and the length says there should be 5 elements but you find only 4, you know there is something wrong. If the value must exist, set Lower Bound to 1.
Generated Code for Name Save the model and generate the code once more. Makes you wish you could invoke generate from the ecore file, right? You will notice that you can generate just a part of your model by selecting "Generate Model" in the context menu of the node.
Most of the time, this is not useful, though: If we did it here, we would have got just a new BookImpl. Makes one wish that selecting generate from a node would always generate the whole model. Maybe in the next version of EMF.
If you did generate just the book alone, Book. Unfortunately, generating the code once more doesn't help: The missing declarations won't show up. Again, the only way to solve this is to delete the Book.
A Look at the Generated Code Book. Why an interface? EMF promotes code decoupling. Since all code is generated, this is essentially free for you. With the interface, you always work with Book. The imports are automatically created by EMF. Of course, most of the comment is not really useful. Notice the user-doc-comments, though. These help EMF to distinguish between between generated comments and hand-written parts. The list of features is useful when you start with multiple inheritance.
Java usually doesn't offer this but EMF can merge the code from several model classes into a single Java class. It's as if you wrote the code once and then copied it around except for the manual copy bit.
With EMF, all copies of the code will be kept in sync automatically well, mostly. We'll come to that. Also notice the model and generated tags. The first tells EMF that this file is part of the generated model and the second that this part of the file the class definition can be overwritten ie.