将图表添加到EMF模型

时间:2016-05-20 12:40:30

标签: eclipse eclipse-emf eclipse-emf-ecore m2m ecore

我正在编写从BPMN2到另一个模型的ATL翻译。目标模型编辑器需要GMF图来打开ATL转换的输出。在以下规则中,我创建图表的问题是图表和模型不是写在同一个文件中。如果我为其输出选择相同的文件,则会覆盖另一个。

rule def2mod {
    from
        b: BPMN20!Definitions
    to
        m: reo!Module,
        m : GMF!Diagram(
            type<-'Reo',
            name<-'test',
            measurementUnit<-#Pixel
        )   
}

我已在以下网址发布了atl代码和我的输入:https://github.com/behnaaz/BPMN2ATL.git

将这些文件的内容合并到一个文件中也无济于事。 输出生成为: 文件1:

<?xml version="1.0" encoding="ISO-8859-1"?>
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmi:id="_zHQiAB6HEeaECbYRnMkrCw" type="Reo" name="test" measurementUnit="Pixel"/>

文件2:

<?xml version="1.0" encoding="ISO-8859-1"?>
<reo:Module xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:channels="http://www.cwi.nl/reo/channels" xmlns:components="http://www.cwi.nl/reo/components" xmlns:reo="http://www.cwi.nl/reo" xsi:schemaLocation="http://www.cwi.nl/reo/channels Reo/reo.ecore#//channels http://www.cwi.nl/reo/components Reo/reo.ecore#//components http://www.cwi.nl/reo Reo/reo.ecore" xmi:id="_zHOFwB6HEeaECbYRnMkrCw" name="d">
  <connectors xmi:type="reo:Connector" xmi:id="_zHOFwR6HEeaECbYRnMkrCw" name="p">
    <nodes xmi:type="reo:Node" xmi:id="_zHOFwh6HEeaECbYRnMkrCw" sourceEnds="_zHOF0x6HEeaECbYRnMkrCw" sinkEnds="_zHOF2B6HEeaECbYRnMkrCw"/>
    <nodes xmi:type="reo:Node" xmi:id="_zHOFwx6HEeaECbYRnMkrCw" sourceEnds="_zHOF1h6HEeaECbYRnMkrCw" sinkEnds="_zHOF0R6HEeaECbYRnMkrCw"/>
    <nodes xmi:type="reo:Node" xmi:id="_zHOFxB6HEeaECbYRnMkrCw" name="in" sourceEnds="_zHOF0B6HEeaECbYRnMkrCw"/>
    <nodes xmi:type="reo:Node" xmi:id="_zHOFxR6HEeaECbYRnMkrCw" name="int" sinkEnds="_zHOF1B6HEeaECbYRnMkrCw"/>
    <primitives xmi:type="channels:Sync" xmi:id="_zHOFxh6HEeaECbYRnMkrCw">
      <sourceEnds xmi:type="reo:SourceEnd" xmi:id="_zHOFxx6HEeaECbYRnMkrCw"/>
      <sinkEnds xmi:type="reo:SinkEnd" xmi:id="_zHOFyB6HEeaECbYRnMkrCw"/>
    </primitives>
    <primitives xmi:type="channels:Sync" xmi:id="_zHOFyR6HEeaECbYRnMkrCw">
      <sourceEnds xmi:type="reo:SourceEnd" xmi:id="_zHOFyh6HEeaECbYRnMkrCw"/>
      <sinkEnds xmi:type="reo:SinkEnd" xmi:id="_zHOFyx6HEeaECbYRnMkrCw"/>
    </primitives>
    <primitives xmi:type="channels:Sync" xmi:id="_zHOFzB6HEeaECbYRnMkrCw">
      <sourceEnds xmi:type="reo:SourceEnd" xmi:id="_zHOFzR6HEeaECbYRnMkrCw"/>
      <sinkEnds xmi:type="reo:SinkEnd" xmi:id="_zHOFzh6HEeaECbYRnMkrCw"/>
    </primitives>
    <primitives xmi:type="channels:Sync" xmi:id="_zHOFzx6HEeaECbYRnMkrCw">
      <sourceEnds xmi:type="reo:SourceEnd" xmi:id="_zHOF0B6HEeaECbYRnMkrCw" node="_zHOFxB6HEeaECbYRnMkrCw"/>
      <sinkEnds xmi:type="reo:SinkEnd" xmi:id="_zHOF0R6HEeaECbYRnMkrCw" node="_zHOFwx6HEeaECbYRnMkrCw"/>
    </primitives>
    <primitives xmi:type="channels:Sync" xmi:id="_zHOF0h6HEeaECbYRnMkrCw">
      <sourceEnds xmi:type="reo:SourceEnd" xmi:id="_zHOF0x6HEeaECbYRnMkrCw" node="_zHOFwh6HEeaECbYRnMkrCw"/>
      <sinkEnds xmi:type="reo:SinkEnd" xmi:id="_zHOF1B6HEeaECbYRnMkrCw" node="_zHOFxR6HEeaECbYRnMkrCw"/>
    </primitives>
  </connectors>
  <components xmi:type="components:Reader" xmi:id="_zHOF1R6HEeaECbYRnMkrCw">
    <sourceEnds xmi:type="reo:SourceEnd" xmi:id="_zHOF1h6HEeaECbYRnMkrCw" node="_zHOFwx6HEeaECbYRnMkrCw"/>
  </components>
  <components xmi:type="components:Writer" xmi:id="_zHOF1x6HEeaECbYRnMkrCw">
    <sinkEnds xmi:type="reo:SinkEnd" xmi:id="_zHOF2B6HEeaECbYRnMkrCw" node="_zHOFwh6HEeaECbYRnMkrCw"/>
  </components>
</reo:Module>

1 个答案:

答案 0 :(得分:0)

到目前为止起作用的是在java代码运行时中打开emf模型并以编程方式添加图表:

//module is my emf model generated by ATL
Diagram diagram = ViewService.createDiagram(module, ModuleEditPart.MODEL_ID,
    ReoDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
res.getContents().add(diagram);
res.getContents().add(diagram.getElement());
res.save(module, Collections.EMPTY_MAP);