Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Problems with label referencing a derived attribute
Problems with label referencing a derived attribute [message #234211] Fri, 19 June 2009 09:27 Go to next message
Anthony is currently offline AnthonyFriend
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 #234227 is a reply to message #234211] Fri, 19 June 2009 09:46 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
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
Re: Problems with label referencing a derived attribute [message #234264 is a reply to message #234227] Fri, 19 June 2009 13:37 Go to previous messageGo to next message
Anthony is currently offline AnthonyFriend
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.
Re: Problems with label referencing a derived attribute [message #234271 is a reply to message #234264] Fri, 19 June 2009 13:49 Go to previous messageGo to next message
Anthony is currently offline AnthonyFriend
Messages: 10
Registered: July 2009
Junior Member
I resolved the last problem (now I only have the 2 first errors in Error
log) writing in the file ElementImpl.java, in the method getActionName():
try{
return this.getAction().getName();
}catch (Exception e){
return actionName;
}

but now the label of actionName only updates when I restart the .diagram
instance. When I change the value of Action Reference, the value of the
ActionName label is the same until I restart the instance.
How can I do to update automatically the label without restarting the
diagram instance?

Thanks.
Re: Problems with label referencing a derived attribute [message #234284 is a reply to message #234271] Fri, 19 June 2009 15:24 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Anthony,

You have to listen for any changes in Action Reference/name of the referenced
action and fire corresponding EMF notifications then necessary (additional
piece of code for ElementImpl.java).
You can use EMF-generated code as an example of eNotify method execution.
In addition i suggest you to verify that "notify" property was set to true
for GenFeature representing Element.actionName .genmodel model.

-----------------
Alex Shatalin
Re: Problems with label referencing a derived attribute [message #234407 is a reply to message #234284] Mon, 22 June 2009 08:54 Go to previous messageGo to next message
Anthony is currently offline AnthonyFriend
Messages: 10
Registered: July 2009
Junior Member
Alex Shatalin wrote:

> Hello Anthony,

> You have to listen for any changes in Action Reference/name of the
referenced
> action and fire corresponding EMF notifications then necessary (additional
> piece of code for ElementImpl.java).
> You can use EMF-generated code as an example of eNotify method execution.
> In addition i suggest you to verify that "notify" property was set to true
> for GenFeature representing Element.actionName .genmodel model.

> -----------------
> Alex Shatalin

Hello,
I didn't know what are the listeners, I studied them and now I know what
they are :). I added the listeners in MyFactoryImpl.java in the
createAction() and createElement() classes, and I did an Adapter to see
that the listeners are right.
I have studied the problem and I have seen that the true problem is that
the label of the derived attribute isn't refreshed, i.e. when I change the
action reference or the name of the action referenced, the value of the
label is the same until I select the label to edit it. When I select it,
the label takes the correct value.
So I think the true problem is the label don't refresh automatically.

Where do I add the listener and how I refresh the label?

Thanks.
Re: Problems with label referencing a derived attribute [message #234421 is a reply to message #234407] Mon, 22 June 2009 10:50 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Anthony,

Label contents will be refreshed on EMF notification that corresponding attribute
value was changed.
So, label is a listener for corresponding domain model attribute and you
have to send a notification that attribute value was changed.
To send this notification you have to listen "action reference" reference
and then this reference is changed you can send notification that derived
attribute was changed too.

-----------------
Alex Shatalin
Re: Problems with label referencing a derived attribute [message #234491 is a reply to message #234421] Mon, 22 June 2009 19:09 Go to previous messageGo to next message
Anthony is currently offline AnthonyFriend
Messages: 10
Registered: July 2009
Junior Member
Hello,

thanks a lot for your help :). The problem is solved.

Greetings.
Re: Problems with label referencing a derived attribute [message #234594 is a reply to message #234421] Wed, 24 June 2009 15:46 Go to previous messageGo to next message
Anthony is currently offline AnthonyFriend
Messages: 10
Registered: July 2009
Junior Member
Hello,

I though the problem was solved but it isn't. The label of
Element.ActionName works fine when I change Element.action (reference).
But when I change Action.Name, the label don't refresh.

The code I wrote in the ActionNameAdapter.java is:

..
..
..
public void notifyChanged(Notification msg)
.
.
.
else if(msg.getNotifier() instanceof Action
&& feature == MyPackage.eINSTANCE.getAction_Name())
{
String oldActionName = msg.getOldStringValue();
String newActionName = msg.getNewStringValue();

if(source.eNotificationRequired())
source.eNotify(new NotificationImpl(

(InternalEObject)msg.getNotifier(),
Notification.SET,
MyPackage.ELEMENT__ACTION_NAME,
oldActionName, newActionName));
}

}
..
..
..
private ActionNameAdapter (EObjectImpl sourc){
source = sourc;
}
public static ActionNameAdapter INSTANCE(EObjectImpl sourc){
return new ActionNameAdapter(sourc);
}


The call I make to add the listener is:

ActionNameAdapterFactory.INSTANCE.adapt(this, ActionNameAdapter.class);

And the method createAdapter of ActionNameAdapterFactory.java is:

protected Adapter createAdapter(Notifier target) {
return ActionNameAdapter.INSTANCE((EObjectImpl)target);
}


Thanks.
Re: Problems with label referencing a derived attribute [message #234635 is a reply to message #234594] Thu, 25 June 2009 09:33 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Anthony,

You are currently listening Element instance, so you can get any notifications
concerning Element attribute/reference changes (like: Element.action) but
to be able to receive notifications concerning Action attributes you have
to listen corresponding Action instance. In other words, you have to call:

ActionNameAdapterFactory.INSTANCE.adapt(this.getAction(), ActionNameAdapter.class);

BTW, you don't need to use AdapterFactory - you can add/remove EMF adapters
by manually instantiating corresponding class + calling:

Notifier.eAdapters().add(adapter);
Notifier.eAdapters().remove(adapter);

-----------------
Alex Shatalin
Previous Topic:[Announce] GMF 2.2.0 is available
Next Topic:extension point documentProviders
Goto Forum:
  


Current Time: Wed Apr 24 18:00:17 GMT 2024

Powered by FUDForum. Page generated in 0.03694 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top