Problems with label referencing a derived attribute [message #234211] |
Fri, 19 June 2009 09:27 |
Anthony Messages: 10 Registered: July 2009 |
Junior Member |
|
|
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.
|
|
|
|
Re: Problems with label referencing a derived attribute [message #234264 is a reply to message #234227] |
Fri, 19 June 2009 13:37 |
Anthony Messages: 10 Registered: July 2009 |
Junior Member |
|
|
Alex Shatalin wrote:
> Hello Anthony,
>> 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).
> Is there any errors in .log/exceptions in the debugger?
> -----------------
> Alex Shatalin
I don't know what is .log/exceptions, but if this is the Log Error View
then there are 3 errors (in the Problems view there are 0 errors).
I ran .diagram. When I say Error Log I refer to the Error Log of
diagram (instance launched).
When I create the new My files (default.my, default.my_diagram), Eclipse
writes in Error Log (I exported the log):
!SESSION 2009-06-19 15:17:07.593
-----------------------------------------------
eclipse.buildId=M20080911-1700
java.version=1.6.0_12
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=es_ES
Framework arguments: -product org.eclipse.sdk.ide
Command-line arguments: -product org.eclipse.sdk.ide -data
C:\PFC_Pruebas/../runtime-EclipseApplication_WS2 -dev
file:C:/PFC_Pruebas/.metadata/.plugins/org.eclipse.pde.core/ Eclipse
Application/dev.properties -os win32 -ws win32 -arch x86
!ENTRY org.eclipse.gmf.runtime.emf.type.core 4 11 2009-06-19 15:18:07.828
!MESSAGE Error initializing element type
"org.eclipse.gmf.tests.runtime.emf.type.core.employee": element type with
same ID already exists. It will be ignored.
!ENTRY org.eclipse.gmf.runtime.emf.type.core 4 28 2009-06-19 15:18:07.906
!MESSAGE Error initializing specialization type
" org.eclipse.gmf.tests.runtime.emf.type.core.SpecializesNoSuc hType "
because it specializes type
"org.eclipse.gmf.tests.runtime.emf.type.core.noSuchType" which does not
exist.
!ENTRY org.eclipse.gmf.runtime.emf.type.core 4 27 2009-06-19 15:18:07.906
!MESSAGE Error initializing specialization type
" org.eclipse.gmf.tests.runtime.emf.type.core.multipleMetamode lTypes "
because it specializes more than one metamodel type.
When I create a new element, Eclipse writes in Error Log (I exported the
log):
eclipse.buildId=M20080911-1700
java.version=1.6.0_12
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=es_ES
Framework arguments: -product org.eclipse.sdk.ide
Command-line arguments: -product org.eclipse.sdk.ide -data
C:\PFC_Pruebas/../runtime-EclipseApplication_WS2 -dev
file:C:/PFC_Pruebas/.metadata/.plugins/org.eclipse.pde.core/ Eclipse
Application/dev.properties -os win32 -ws win32 -arch x86
Error
Fri Jun 19 15:24:53 CEST 2009
execute
org.eclipse.core.commands.ExecutionException: While executing the
operation, an exception occurred
at
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:519)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:205)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:168)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:155)
at
org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTo ol.java:399)
at
org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(Abs tractTool.java:411)
at
org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool.perfor mCreation(CreationTool.java:133)
at
org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTo ol.java:178)
at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java :1064)
at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:263)
at
org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouse Released(DomainEventDispatcher.java:374)
at
org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(Li ghtweightSystem.java:538)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:207)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:386)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Caused by: java.lang.NullPointerException
at my.impl.ElementImpl.getActionName(ElementImpl.java:133)
at my.impl.ElementImpl.eGet(ElementImpl.java:197)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1012)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1004)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:999)
at my.diagram.parsers.AbstractParser.getValue(AbstractParser.ja va:150)
at my.diagram.parsers.AbstractParser.getValues(AbstractParser.j ava:141)
at
my.diagram.parsers.MessageFormatParser.getPrintString(Messag eFormatParser.java:173)
at
my.diagram.edit.parts.ElementActionNameEditPart.getLabelText (ElementActionNameEditPart.java:212)
at
my.diagram.edit.parts.ElementActionNameEditPart.refreshLabel (ElementActionNameEditPart.java:413)
at
my.diagram.edit.parts.ElementActionNameEditPart.refreshVisua ls(ElementActionNameEditPart.java:402)
at
my.diagram.edit.parts.ElementActionNameEditPart.setLabel(Ele mentActionNameEditPart.java:170)
at
my.diagram.edit.parts.ElementEditPart.addFixedChild(ElementE ditPart.java:116)
at
my.diagram.edit.parts.ElementEditPart.addChildVisual(Element EditPart.java:135)
at
org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:197)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.addChild(GraphicalEditPart.java:1295)
at
org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(A bstractEditPart.java:727)
at
org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractE ditPart.java:677)
at
org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh( AbstractGraphicalEditPart.java:571)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$3(GraphicalEditPart.java:1)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt$3.run(GraphicalEditPart.java:839)
at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:289)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.refresh(GraphicalEditPart.java:829)
at
org.eclipse.gef.editparts.AbstractEditPart.addNotify(Abstrac tEditPart.java:235)
at
org.eclipse.gef.editparts.AbstractGraphicalEditPart.addNotif y(AbstractGraphicalEditPart.java:219)
at
org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:198)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.addChild(GraphicalEditPart.java:1295)
at
org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(A bstractEditPart.java:727)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.handleNotificationEvent(GraphicalEditPart.java:1440)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.notifyChanged(GraphicalEditPart.java:1414)
at
org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBr oker.fireNotification(DiagramEventBroker.java:500)
at
org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBr oker.resourceSetChanged(DiagramEventBroker.java:395)
at
org.eclipse.gmf.runtime.diagram.ui.internal.DiagramEventBrok erThreadSafe.resourceSetChanged(DiagramEventBrokerThreadSafe .java:72)
at
org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFac tory$DiagramEditingDomain.postcommit(DiagramEditingDomainFac tory.java:213)
at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.deactivate(TransactionalEditingDomainImpl.java:504)
at
org.eclipse.emf.transaction.impl.TransactionImpl.close(Trans actionImpl.java:623)
at
org.eclipse.emf.transaction.impl.TransactionImpl.commit(Tran sactionImpl.java:415)
at
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:163)
at
org.eclipse.gmf.runtime.common.core.command.CompositeCommand .doExecuteWithResult(CompositeCommand.java:403)
at
org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:135)
at
org.eclipse.gmf.runtime.common.core.command.CompositeCommand .doExecuteWithResult(CompositeCommand.java:403)
at
org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:135)
at
org.eclipse.gmf.runtime.common.core.command.CompositeCommand .doExecuteWithResult(CompositeCommand.java:403)
at
org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:135)
at
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:511)
... 37 more
If I have understood, this error is a nullPointer error because when I
create an Element, the initial value of Action (reference) is in blank
(initially Element have 0 references to Action). But the cardinality of
this reference is 0..1. How can I resolve this?
Thanks.
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03759 seconds