EMF Demo

简介: <h2>Install EMF Plugin of Eclipse</h2> <div>Ecore Diagram Editor<br></div> <div><br></div> <h2>Create EMF Project</h2> <div>Take "Empty EMF Project" for instance</div> <div><img src="http:/

Install EMF Plugin of Eclipse

Ecore Diagram Editor

Create EMF Project

Take "Empty EMF Project" for instance

Create Ecore Model

New "Ecore Model" under folder "model"

Create "EPackage", "EInterface", "EClass", "EEnum"

Create "EReference", "EAttribute", "EOperation"


Open With "XML Editor"
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="fruit" nsURI="http:///fruit.ecore" nsPrefix="fruit">
  <eClassifiers xsi:type="ecore:EClass" name="Fruit" abstract="true" interface="true">
    <eOperations name="grow">
      <eParameters name="years" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"/>
    </eOperations>
    <eOperations name="harvest" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject">
      <eParameters name="amount" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"/>
    </eOperations>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="weight" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Apple" eSuperTypes="#//Fruit">
    <eOperations name="appleColor" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="color" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Pear" eSuperTypes="#//Fruit">
    <eOperations name="pearWater" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="water" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Factory">
    <eOperations name="create" eType="#//Fruit">
      <eParameters name="fruitKind" eType="#//FruitKind"/>
    </eOperations>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EEnum" name="FruitKind">
    <eLiterals name="APPLE" value="1"/>
    <eLiterals name="PEAR" value="2"/>
    <eLiterals name="PEACH" value="3"/>
  </eClassifiers>
</ecore:EPackage>

Create EMF Generator Model

New "EMF Generator Model" via loading above "Ecore Model" file

Open With "EMF Generator"


Generate Model Code

Select "generate * Code"



After do "Generate Model Code", you can see model code as below:


Install UML Plugin of Eclipse

UML Designer

Export UML Model

Click "Export Model..."


Choose "UML model"


Finally you can see UML Model file as below:

Generate Ecore Diagram

Right click "Initialize Ecore Diagram..."



Select a representation type



Select a semantic element


Select all and navigate to class diagram



Add Related Elements



Select all Related Elements



Layout Diagram



Finally you can see diagram as below:

Export diagram as image



相关文章
|
3月前
|
Java Maven Windows
java -jar 启动 boot 程序 no main manifest attribute, in .\vipsoft-model-web-0.0.1-SNAPSHOT.jar
java -jar 启动 boot 程序 no main manifest attribute, in .\vipsoft-model-web-0.0.1-SNAPSHOT.jar
59 0
|
5月前
|
算法 Java 数据安全/隐私保护
eclipse导入BASE64Encoder类的方法
eclipse导入BASE64Encoder类的方法
90 1
|
Java 数据安全/隐私保护
Spire.doc jar包实现word文件添加水印demo
Spire.doc jar包实现word文件添加水印demo
447 0
|
Java Maven Android开发
springMvc22-eclipse创建Maven项目没有src/main/java并不能新建的问题
springMvc22-eclipse创建Maven项目没有src/main/java并不能新建的问题
850 0
|
Java
【错误记录】IntelliJ IDEA 中 Java 代码中的中文注释报错 ( Menu / File / Settings / Editor / File Encodings 中修改工程编码 )
【错误记录】IntelliJ IDEA 中 Java 代码中的中文注释报错 ( Menu / File / Settings / Editor / File Encodings 中修改工程编码 )
875 0
【错误记录】IntelliJ IDEA 中 Java 代码中的中文注释报错 ( Menu / File / Settings / Editor / File Encodings 中修改工程编码 )
|
Java
图片上传接口 (alipay.offline.material.image.upload)JAVA版本demo
说明:       该接口一般结合口碑开店接口使用,官方文档:[url]https://docs.open.alipay.com/common/105258[/url]       以及结合会员卡中的上传背景图片等联合使用 调用代码示例: //上传门店照片接口(alipay.
1304 0
EMF介绍系列(六、自定义命令)
EMF生成的应用程序里,用户的发出的每一条命令都是可以撤销(Undo)的,例如修改了产品的价格,按一下撤销按钮就能恢复原来的价格,当然还可 以通过重做(Redo)再回到新的价格。为了实现这个功能,应用程序里维护了一个用于存放命令的类似栈的数据结构(CommandStack),每一条执 行过的命令都被存放在那里,需要撤销时取出最近一条命令进行撤销。
1423 0