[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.modeling.gmf] Problems with label referencing a derived attribute
|
Hi,
I'm trying to do this:
I have three classes: RootClass, Action and Element. Action and
Element are children of RootClass. What I want to do is that the value of
the attribute actionName of the class Element is equal to the value of the
attribute name of the class Action.
Below, it shows the ecore metamodel:
<?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="my"
nsURI="my" nsPrefix="my">
<eClassifiers xsi:type="ecore:EClass" name="RootClass">
<eStructuralFeatures xsi:type="ecore:EReference" name="actions"
upperBound="-1"
eType="#//Action" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="elements"
upperBound="-1"
eType="#//Element" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Action">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Element">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="actionName"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
derived="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="action"
eType="#//Action"/>
</eClassifiers>
</ecore:EPackage>
I did the following:
I generated the genmodel, model code and edit code.
I modified the file ElementImpl.java of the package my.impl, I replaced
?return actionName;? for ?return this.getAction().getName();? in the
getActionName() method.
I did the gmfgraph, gmftool and gmfmap models.
I generated gmfgen model, and .diagram code.
The problem is that in gmfmap model, if I put the feature label mapping of
actionName, when I run the .diagram and I create an Element node the node
is created in the top-left corner (this is the way to GMF for indicating
an error).
How can I do the label of actionName?
Below, it shows the models, the last two models are gmfmap without
actionName FLM(Feature Label Mapping) and gmfmap with actionName FLM:
gmfgraph 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="my">
<figures
name="Default">
<descriptors
name="ActionFigure">
<actualFigure
xsi:type="gmfgraph:Rectangle"
name="ActionFigure">
<children
xsi:type="gmfgraph:Label"
name="ActionNameFigure"
text="ActionName"/>
</actualFigure>
<accessors
figure="//@figures.0/@descriptors.0/@actualFigure/@children.0"/>
</descriptors>
<descriptors
name="ElementFigure">
<actualFigure
xsi:type="gmfgraph:Rectangle"
name="ElementFigure">
<children
xsi:type="gmfgraph:Label"
name="ElementNameFigure"
text="ElementName"/>
<children
xsi:type="gmfgraph:Label"
name="ElementActionNameFigure"
text=""/>
</actualFigure>
<accessors
figure="//@figures.0/@descriptors.1/@actualFigure/@children.0"/>
<accessors
figure="//@figures.0/@descriptors.1/@actualFigure/@children.1"/>
</descriptors>
</figures>
<nodes
name="Action"
figure="ActionFigure"/>
<nodes
name="Element"
figure="ElementFigure"/>
<labels
name="ActionName"
figure="ActionFigure"
accessor="//@figures.0/@descriptors.0/@accessors.0"/>
<labels
name="ElementName"
figure="ElementFigure"
accessor="//@figures.0/@descriptors.1/@accessors.0"/>
<labels
name="ElementActionName"
figure="ElementFigure"
accessor="//@figures.0/@descriptors.1/@accessors.1"/>
</gmfgraph:Canvas>
gmftool model:
<?xml version="1.0" encoding="UTF-8"?>
<gmftool:ToolRegistry xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
<palette
title="myPalette">
<tools
xsi:type="gmftool:ToolGroup"
title="my">
<tools
xsi:type="gmftool:CreationTool"
title="Action"
description="Create new Action"/>
<tools
xsi:type="gmftool:CreationTool"
title="Element"
description="Create new Element"/>
</tools>
</palette>
</gmftool:ToolRegistry>
gmfmap model without actionName FLM:
<?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="My.ecore#//RootClass/elements"/>
<ownedChild>
<domainMetaElement
href="My.ecore#//Element"/>
<labelMappings
xsi:type="gmfmap:FeatureLabelMapping">
<diagramLabel
href="My.gmfgraph#ElementName"/>
<features
href="My.ecore#//Element/name"/>
</labelMappings>
<tool
xsi:type="gmftool:CreationTool"
href="My.gmftool#//@palette/@tools.0/@tools.1"/>
<diagramNode
href="My.gmfgraph#Element"/>
</ownedChild>
</nodes>
<nodes>
<containmentFeature
href="My.ecore#//RootClass/actions"/>
<ownedChild>
<domainMetaElement
href="My.ecore#//Action"/>
<labelMappings
xsi:type="gmfmap:FeatureLabelMapping">
<diagramLabel
href="My.gmfgraph#ActionName"/>
<features
href="My.ecore#//Action/name"/>
</labelMappings>
<tool
xsi:type="gmftool:CreationTool"
href="My.gmftool#//@palette/@tools.0/@tools.0"/>
<diagramNode
href="My.gmfgraph#Action"/>
</ownedChild>
</nodes>
<diagram>
<diagramCanvas
href="My.gmfgraph#my"/>
<domainModel
href="My.ecore#/"/>
<domainMetaElement
href="My.ecore#//RootClass"/>
<palette
href="My.gmftool#//@palette"/>
</diagram>
</gmfmap:Mapping>
gmfmap model with actionName FLM:
<?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="My.ecore#//RootClass/elements"/>
<ownedChild>
<domainMetaElement
href="My.ecore#//Element"/>
<labelMappings
xsi:type="gmfmap:FeatureLabelMapping">
<diagramLabel
href="My.gmfgraph#ElementName"/>
<features
href="My.ecore#//Element/name"/>
</labelMappings>
<labelMappings
xsi:type="gmfmap:FeatureLabelMapping">
<diagramLabel
href="My.gmfgraph#ElementActionName"/>
<features
href="My.ecore#//Element/actionName"/>
</labelMappings>
<tool
xsi:type="gmftool:CreationTool"
href="My.gmftool#//@palette/@tools.0/@tools.1"/>
<diagramNode
href="My.gmfgraph#Element"/>
</ownedChild>
</nodes>
<nodes>
<containmentFeature
href="My.ecore#//RootClass/actions"/>
<ownedChild>
<domainMetaElement
href="My.ecore#//Action"/>
<labelMappings
xsi:type="gmfmap:FeatureLabelMapping">
<diagramLabel
href="My.gmfgraph#ActionName"/>
<features
href="My.ecore#//Action/name"/>
</labelMappings>
<tool
xsi:type="gmftool:CreationTool"
href="My.gmftool#//@palette/@tools.0/@tools.0"/>
<diagramNode
href="My.gmfgraph#Action"/>
</ownedChild>
</nodes>
<diagram>
<diagramCanvas
href="My.gmfgraph#my"/>
<domainModel
href="My.ecore#/"/>
<domainMetaElement
href="My.ecore#//RootClass"/>
<palette
href="My.gmftool#//@palette"/>
</diagram>
</gmfmap:Mapping>
Thanks for your time.