Redundant space in compartments [message #673671] |
Tue, 24 May 2011 12:53 |
Niels Brouwers Messages: 80 Registered: July 2009 |
Member |
|
|
Hi all,
I am struggling with compartments for some time now. Of course, I read the tutorial on compartments (GMF Tutorial Part 2), but I can't get it to work correctly. The problem is that I can add elements to a compartment, but the figure always takes up too much space, no matter what I try.
The example below is created to show my graphical definition and my mapping definition in a concise way. The real project I am working on is bigger, and I don't want to annoy you all with this one
The example is as follows: Class A with a name (String) and a 'many' containment reference with Class B. Class B has a name and a type. The graphical editor should allow creating top node A, with child nodes B to be added in a compartment. The figure of class B should be two labels horizontally alligned; one showing the name, the other showing the type.
Note: I've archived the project. See the attached zip file.
Meta-model:
<?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="mm"
nsURI="http://example.com/mm" nsPrefix="mm">
<eClassifiers xsi:type="ecore:EClass" name="A">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="bees" upperBound="-1" eType="#//B"
containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="B">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Model">
<eStructuralFeatures xsi:type="ecore:EReference" name="aas" upperBound="-1" eType="#//A"
containment="true"/>
</eClassifiers>
</ecore:EPackage>
Graphical model:
<?xml version="1.0" encoding="UTF-8"?>
<gmfgraph:Canvas xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gmfgraph="http://www.eclipse.org/gmf/2006/GraphicalDefinition" name="mm">
<figures
name="Default">
<descriptors
name="AFigure">
<actualFigure
xsi:type="gmfgraph:Rectangle"
name="AFigure">
<layout
xsi:type="gmfgraph:FlowLayout"/>
<children
xsi:type="gmfgraph:Label"
name="ANameFigure"
text="<...>"/>
<children
xsi:type="gmfgraph:Rectangle"
name="Compartment">
<layout
xsi:type="gmfgraph:StackLayout"/>
</children>
</actualFigure>
<accessors
figure="//@figures.0/@descriptors.0/@actualFigure/@children.0"/>
<accessors
figure="//@figures.0/@descriptors.0/@actualFigure/@children.1"/>
</descriptors>
<descriptors
name="BFigure">
<actualFigure
xsi:type="gmfgraph:Rectangle"
name="BFigure">
<layout
xsi:type="gmfgraph:FlowLayout"
forceSingleLine="true"/>
<children
xsi:type="gmfgraph:Label"
name="BNameFigure"
text="<...>"/>
<children
xsi:type="gmfgraph:Label"
name="BTypeFigure"
text="<...>"/>
</actualFigure>
<accessors
figure="//@figures.0/@descriptors.1/@actualFigure/@children.0"/>
<accessors
figure="//@figures.0/@descriptors.1/@actualFigure/@children.1"/>
</descriptors>
</figures>
<nodes
name="A"
figure="AFigure"/>
<nodes
name="B"
figure="BFigure"/>
<compartments
name="BCompartment"
figure="AFigure"
accessor="//@figures.0/@descriptors.0/@accessors.1"/>
<labels
name="AName"
figure="AFigure"
accessor="//@figures.0/@descriptors.0/@accessors.0"/>
<labels
name="BName"
figure="BFigure"
accessor="//@figures.0/@descriptors.1/@accessors.0"/>
<labels
name="BType"
figure="BFigure"
accessor="//@figures.0/@descriptors.1/@accessors.1"/>
</gmfgraph:Canvas>
Mapping model:
<?xml version="1.0" encoding="UTF-8"?>
<gmfmap:Mapping xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gmfmap="http://www.eclipse.org/gmf/2008/mappings"
xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
<nodes>
<containmentFeature
href="../model/My.ecore#//Model/aas"/>
<ownedChild>
<domainMetaElement
href="../model/My.ecore#//A"/>
<labelMappings
xsi:type="gmfmap:FeatureLabelMapping">
<diagramLabel
href="My.gmfgraph#AName"/>
<features
href="../model/My.ecore#//A/name"/>
</labelMappings>
<tool
xsi:type="gmftool:CreationTool"
href="My.gmftool#//@palette/@tools.0/@tools.0"/>
<diagramNode
href="My.gmfgraph#A"/>
<children
compartment="//@nodes.0/@ownedChild/@compartments.0">
<containmentFeature
href="../model/My.ecore#//A/bees"/>
<ownedChild>
<domainMetaElement
href="../model/My.ecore#//B"/>
<labelMappings
xsi:type="gmfmap:FeatureLabelMapping">
<diagramLabel
href="My.gmfgraph#BName"/>
<features
href="../model/My.ecore#//B/name"/>
</labelMappings>
<labelMappings
xsi:type="gmfmap:FeatureLabelMapping">
<diagramLabel
href="My.gmfgraph#BType"/>
<features
href="../model/My.ecore#//B/type"/>
</labelMappings>
<tool
xsi:type="gmftool:CreationTool"
href="My.gmftool#//@palette/@tools.0/@tools.1"/>
<diagramNode
href="My.gmfgraph#B"/>
</ownedChild>
</children>
<compartments
children="//@nodes.0/@ownedChild/@children.0">
<compartment
href="My.gmfgraph#BCompartment"/>
</compartments>
</ownedChild>
</nodes>
<diagram>
<diagramCanvas
href="My.gmfgraph#mm"/>
<domainModel
href="../model/My.ecore#/"/>
<domainMetaElement
href="../model/My.ecore#//Model"/>
<palette
href="My.gmftool#//@palette"/>
</diagram>
</gmfmap:Mapping>
The generated editor does indeed allow me the add class A's as top node and let me add child nodes B in a compartment box. The Class B figure is correct, with the problem that there is an empty space between subsequent class B elements. See the figure below:
Can someone please help me with this?
Thanks in advance!
Kind regards,
Niels Brouwers.
Kind regards,
Niels Brouwers.
[Updated on: Tue, 24 May 2011 12:56] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03212 seconds