A framework is a reusable design represented by a set of components and the way they interact. A framework implement an architecture § Framework = Components + Design + Domain Specific Solution
and implement software quickly, effectively and at minimum cost. § The approach focuses on the construction of a software model. § The model (text or graphic) specifies how the software system should work before the code is generated. § The software is created automatically (translate the model to code) § Tested and then deployed.
for integrating development tools § Architecture based on plug-ins § SWT (Standard Widget Toolkit) is a generic graphics and GUI widget set § JFace is set of UI frameworks for common UI tasks § Workbench and Workspace are core – Editors, Views, and Perspectives
is stored as XMI but defined as text or diagram). A subset of UML class diagrams semantics 1. EMF provides tools and runtime environment. 3. Translate to Java Classes and Interfaces
empty modeling project in your workspace File → New → Other… and choose Empty EMF Project § Click Next, enter a name for the project, e.g., org.eclipse.example.mymodel, and hit Finish
click the model folder in your new modeling project then New → Other… → Ecore Model, then click Next and give the ecore file the name myModel.ecore. § It will open in the default Ecore editor, which allows the definition of Ecore models in a tree-based view
Give the package of your new model a name and an URI. This will be done in the properties view. The URI is used to identify the model later. Name the package myModel, Set the Ns Prefix to org.eclipse.example.myModel and the Ns URI to https://org/eclipse/example/myModel.
Attributes § Define model elements as children of the root package by right clicking on the myModel package and on the EClass respectively Add EClass as children, New Child → EClass Add EAttribute as children, New Child → EAttribute
EReference between Course and Student, New Child → EReference EType of the reference to “Student” upper bound to “-1”, the equivalent of “many”. set the property Containment to “true”
EReference between Student and Computer, New Child → EReference EType of the reference to “Computer” upper bound to “1” (default) set the property Containment to “false” § Save all
This allows to configure properties for the code generation that are not part of the model itself. § Generate a maximum of four different plugins for a defined model: 1. Model plugin contains all entities, packages and factories to create instances of the model. 2. Edit plugin contains providers to display a model in a UI. For example, the providers offer a label for every model element, which can be used to display an entity showing an icon and a name. 3. Editor plugin is a generated example editor to create and modify instances of a model. 4. Test plugin contains templates to write tests cases for a model.
click the model folder in the project then § New → Other… → EMF Generator Model → Next § and enter myModel.genmodel as the file name. § Select Ecore model as the model importer. § select Browse Workspace… and select our previously created myModel.ecore
on the generator model, we can now generate the source code. § EMF allows you to generate 4 different plugins. § To generate the plugins, right-click on the root node of the genmodel and select the plugin. For our tutorial, please select “generate all”.
there is a corresponding generated § Java interface § Java implementation class § For each package, there is a § XXXPackage interface and implementation class § XXXFactory interface and implementation class
instances use § XXXPackage.eINSTANCE § XXXFactory.eINSTANCE § Use the Factory to create instances of your model classes, e.g: TaskList t = ExampleFactory.eINSTANCE.createTaskList(); § Use the Package to access the meta-model definition, e.g: EClass c = ExamplePackage.eINSTANCE.getTaskList(); List attrs = c.getEAttributes();
§ plain old Java object (POJO) § We have generated over 1,000 LOC, § Even very simple code is considered to be worth $1 per LOC. So, $1,000 just by clicking some buttons