containment and emf treenode model [message #559525] |
Thu, 16 September 2010 21:53  |
Eclipse User |
|
|
|
I'm attempting to use containment in a few exercises in order to restrict the stored model to a single xsi file. A second objective is to have the tree nodes displayed in the generated editor as a tree. I haven't been able to solve this. The closest I get is the ecore model below, which does have a container for the treenodes, and does let me specify the node parent and child relationships, but the generated editor unfortunately just displays as a list. Is there some easy way that I'm missing that would allow you to specify a tree display of contained objects? Thanks, Jay
<?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="nodes"
nsURI="http:///my/nodes.ecore" nsPrefix="my.nodes">
<eClassifiers xsi:type="ecore:EClass" name="Node">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="label" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="children" upperBound="-1"
eType="#//Node"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="parent" eType="#//Node"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Nodes">
<eStructuralFeatures xsi:type="ecore:EReference" name="NodeStore" upperBound="-1"
eType="#//Node" containment="true"/>
</eClassifiers>
</ecore:EPackage>
|
|
|
|
|
Re: containment and emf treenode model [message #559702 is a reply to message #559692] |
Fri, 17 September 2010 12:02  |
Eclipse User |
|
|
|
Yes, this seems to work well. A small ecore tree model with Root, Inner and Leaf nodes, along with abstract classes to limit the children available, i.e. no children available for the leaf node, and only the single Root node.
<?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="nodes2"
nsURI="http:///my/nodes2.ecore" nsPrefix="my.nodes2">
<eClassifiers xsi:type="ecore:EClass" name="Node" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="label" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Root" eSuperTypes="#//Node">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="RootData" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="children" upperBound="-1"
eType="#//LeafOrInnerNode" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="InnerNode" eSuperTypes="#//LeafOrInnerNode">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="InnerNodeData" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloat"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="children" upperBound="-1"
eType="#//LeafOrInnerNode" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="LeafNode" eSuperTypes="#//LeafOrInnerNode">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="LeafNodeData" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="LeafOrInnerNode" abstract="true" eSuperTypes="#//Node"/>
</ecore:EPackage>
|
|
|
Powered by
FUDForum. Page generated in 0.03659 seconds