Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » GMF link (Relationship) between two nodes
GMF link (Relationship) between two nodes [message #437998] Fri, 31 July 2009 02:52 Go to next message
Swapnil  is currently offline Swapnil Friend
Messages: 19
Registered: July 2009
Junior Member
Can a link between two nodes has its own properties same as a node.

I mean i am trying to create a graphical editor for the following domain
model:

<?xml version="1.0" encoding="UTF-8"?>
<SMC>
<Roles>
<Role />
<Role />
</Roles>
<Contracts>
<Contract>
<Description />
<Role>lc1</Role>
<Role>rta</Role>
<Terms>
<Term />
<Terms>
</Contract>
</Contracts>
</SMC>

Now there is a reference to Role from a Contract element. While
representing it graphically there will be a link between two Roles.

So can this link (Relationship) be of type Contract & can it have its own
attributes & references?



Please give me some hint on this.


Cheers,

Swapnil
Re: GMF link (Relationship) between two nodes [message #441303 is a reply to message #437998] Fri, 31 July 2009 10:23 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Swapnil,

> Can a link between two nodes has its own properties same as a node.
>
> I mean i am trying to create a graphical editor for the following
> domain model:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <SMC>
> <Roles>
> <Role />
> <Role />
> </Roles>
> <Contracts>
> <Contract>
> <Description />
> <Role>lc1</Role>
> <Role>rta</Role>
> <Terms>
> <Term />
> <Terms>
> </Contract>
> </Contracts>
> </SMC>
> Now there is a reference to Role from a Contract element. While
> representing it graphically there will be a link between two Roles.
>

> So can this link (Relationship) be of type Contract & can it have its
> own attributes & references?
Yes. Just create EClass "RoleReference" in .ecore. This EClass should keep
a reference to Role instance + desired properties + should be located inside
"Conttract" EClass (Contract should have containment reference to "RoleReference"
EClass).

Then you can model RoleReference as a link. See Ecore diagram example - EReference
link visualized there using this idea.

-----------------
Alex Shatalin
Re: GMF link (Relationship) between two nodes [message #442757 is a reply to message #441303] Fri, 31 July 2009 13:25 Go to previous messageGo to next message
Swapnil  is currently offline Swapnil Friend
Messages: 19
Registered: July 2009
Junior Member
Thanks Alex.

The example you mentioned is the Mindmap example? I mean is it the one in
the tutorial?



Cheers,

Swapnil
Re: GMF link (Relationship) between two nodes [message #443559 is a reply to message #442757] Fri, 31 July 2009 15:08 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Swapnil,

> The example you mentioned is the Mindmap example? I mean is it the one
> in the tutorial?
No. it is in CVS and in distributed as a part of GMF. In mindmap Relationship
from Topic to topic is modeled in a same way.

-----------------
Alex Shatalin
Re: GMF link (Relationship) between two nodes [message #443663 is a reply to message #443559] Fri, 31 July 2009 15:29 Go to previous messageGo to next message
Swapnil  is currently offline Swapnil Friend
Messages: 19
Registered: July 2009
Junior Member
Thanks a lot Alex.


Cheers,

Swapnil
Re: GMF link (Relationship) between two nodes [message #467832 is a reply to message #441303] Mon, 03 August 2009 04:24 Go to previous messageGo to next message
Swapnil  is currently offline Swapnil Friend
Messages: 19
Registered: July 2009
Junior Member
Hi Alex,

While creating Generator diagram code using Dashboard for following model
i get some errors:

<?xml version="1.0" encoding="UTF-8"?>
<SMC>
<Roles>
<Role />
<Role />
</Roles>
<Contracts>
<Contract>
<Description />
<Role>lc1</Role>
<Role>rta</Role>
<Terms>
<Term />
<Terms>
</Contract>
</Contracts>
</SMC>


Errors are:

The method getRole() is undefined for the type SMCType
TestSMCDiagramUpdater.java

The type SMCTypeImpl must implement the inherited abstract method
SMCType.setRole(RoleType) SMCTypeImpl.java


So my question is that: Can GMF support three leves of nested references
or is that a bug?

e.g.

<SMC>
<Roles>
<Role />
<Role />
</Roles>
</SMC>

where SMC, Roles & Role are of complex type elements in an XML schema.



Please provide some hints on this.



Cheers,

Swapnil
Re: GMF link (Relationship) between two nodes [message #467929 is a reply to message #467832] Mon, 03 August 2009 11:59 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Swapnil,

> The method getRole() is undefined for the type SMCTypeTestSMCDiagramUpdater.java
>
> The type SMCTypeImpl must implement the inherited abstract method
> SMCType.setRole(RoleType) SMCTypeImpl.java
Is it a compilation problem in SMCTypeImpl.java generated by EMF?

> So my question is that: Can GMF support three leves of nested
> references or is that a bug?
It is possible in GMF to create a node on a diagram and then create subnode
in this node. Do you mean something different by "three leves of nested references"?

> Please provide some hints on this.
I suggest you to edit all the models in corresponding editors instead of
using dashboad.

-----------------
Alex Shatalin
Re: GMF link (Relationship) between two nodes [message #468081 is a reply to message #467929] Tue, 04 August 2009 01:29 Go to previous messageGo to next message
Swapnil  is currently offline Swapnil Friend
Messages: 19
Registered: July 2009
Junior Member
Hi Alex,

These are the compilation errors with GMF diagram generated code.

The problem is that when i set Containment Meta Feature of Role as
roles:RolesType, it gives these compilation error in the code.

In ecore model, there is a reference to Role from Roles, with
containment=true.


<eClassifiers xsi:type="ecore:EClass" name="RolesType">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Roles_._type"/>
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EReference" name="role"
lowerBound="1" upperBound="-1"
eType="#//RoleType" containment="true" resolveProxies="false">
<eAnnotations source="http:///org/eclipse/emf/ecore'
/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="Role"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>



Cheers,

Swapnil
Re: GMF link (Relationship) between two nodes [message #468135 is a reply to message #468081] Tue, 04 August 2009 10:34 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Swapnil,

> The problem is that when i set Containment Meta Feature of Role as
> roles:RolesType, it gives these compilation error in the code.
>
> In ecore model, there is a reference to Role from Roles, with
> containment=true.
Ok. Currently you need to:
- have Roles object represented on diagram
- or create derived feature in SMC EClass representing all the "Role"s below
corresponding "Roles" instance (collection returned by this feature should
be able to handle new elements addition and can be used as a containment
feature for Role's NodeMapping)
- or you can modify generated code manually in order to make it working

-----------------
Alex Shatalin
Re: GMF link (Relationship) between two nodes [message #468155 is a reply to message #468135] Tue, 04 August 2009 12:20 Go to previous messageGo to next message
Swapnil  is currently offline Swapnil Friend
Messages: 19
Registered: July 2009
Junior Member
Hi Alex,

Thanks for the reply.

I actually do have Roles element on the diagram i think that's why it is
getting displayed under Containment Meta Feature drop-down list under
gmfgen (generator model) file as roles:RolesType

Is that what i need to do? And if i do select roles:RolesType from
drop-down menu i get the compilation errors in generated code.


Cheers,

Swapnil
Re: GMF link (Relationship) between two nodes [message #468182 is a reply to message #468155] Tue, 04 August 2009 13:04 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Swapnil,

> I actually do have Roles element on the diagram i think that's why it
If you have a NodeMapping for Roles element in .gmfmap model then you have
to create ChildNodeMapping for Role element below this one to avoid compilation
problems.

-----------------
Alex Shatalin
Re: GMF link (Relationship) between two nodes [message #468183 is a reply to message #468182] Tue, 04 August 2009 13:09 Go to previous messageGo to next message
Swapnil  is currently offline Swapnil Friend
Messages: 19
Registered: July 2009
Junior Member
Got that. Thanks a lot Alex.


Cheers,

Swapnil
Re: GMF link (Relationship) between two nodes [message #468367 is a reply to message #441303] Wed, 05 August 2009 09:55 Go to previous messageGo to next message
Swapnil  is currently offline Swapnil Friend
Messages: 19
Registered: July 2009
Junior Member
Hi Alex,

I checked out Ecore diagram editor example project from CVS.

But this project doesn't contain ecore model (Ecore.ecore) used for this
project. Where can i get it form?




Cheers,

Swapnil
Re: GMF link (Relationship) between two nodes [message #468368 is a reply to message #468367] Wed, 05 August 2009 09:58 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Swapnil,

It is in one of EMF models: org.eclipse.emf.ecore/model/Ecore.ecore

-----------------
Alex Shatalin
Re: GMF link (Relationship) between two nodes [message #468402 is a reply to message #468368] Wed, 05 August 2009 12:40 Go to previous messageGo to next message
Swapnil  is currently offline Swapnil Friend
Messages: 19
Registered: July 2009
Junior Member
Hi Alex,

Is this repository for EMF models?

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/?ro ot=Modeling_Project


But it's not present here.



Cheers,

Swapnil
Re: GMF link (Relationship) between two nodes [message #476648 is a reply to message #468402] Thu, 06 August 2009 00:49 Go to previous messageGo to next message
Swapnil  is currently offline Swapnil Friend
Messages: 19
Registered: July 2009
Junior Member
Found Ecore.ecore. Please ignore my last post.


Cheers,

Swapnil
Re: GMF link (Relationship) between two nodes [message #477598 is a reply to message #441303] Thu, 06 August 2009 05:36 Go to previous messageGo to next message
Swapnil  is currently offline Swapnil Friend
Messages: 19
Registered: July 2009
Junior Member
Hi Alex,

When i drag & drop a link between two nodes on the canvas the two nodes &
the link between them gets disappeared from the canvas. Although in domain
model file (xml file getting created) they are persisted. I mean they are
present in the xml file (domain model file) but not on the canvas
(.diagram file).

Is this a bug or i am i doing something wrong?



Cheers,

Swapnil
Re: GMF link (Relationship) between two nodes [message #478166 is a reply to message #477598] Thu, 06 August 2009 08:35 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Swapnil,

> Is this a bug or i am i doing something wrong?
Try to reopen/refresh diagram by pressing F5.
It really depends on the configuration, but corresponding functionality is
working well with Ecore diagram..

-----------------
Alex Shatalin
Re: GMF link (Relationship) between two nodes [message #478811 is a reply to message #478166] Fri, 07 August 2009 02:47 Go to previous messageGo to next message
Swapnil  is currently offline Swapnil Friend
Messages: 19
Registered: July 2009
Junior Member
Hi Alex,


In Ecore diagram example, the association between two classes is of type
EReference.

But EReference type is not getting created in ecore model file (.ecore
file getting generated).

I mean it is creating two EClasses but EReference & its own properties are
not getting created in Ecore model file:

<?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">
<eClassifiers xsi:type="ecore:EClass" name="Test1">
<eStructuralFeatures xsi:type="ecore:EReference" name="Test1-Test2"
eType="#//Test2" />
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Test2">
<eStructuralFeatures xsi:type="ecore:EReference" name="test2-test1"
eType="#//Test1" />
</eClassifiers>
</ecore:EPackage>



I want to have a link of type Contract & its own properties created as xml
file.

e.g.

<SMC>
<Role>
<Contract /> <!-- Reference to Contract 1 -->
</Role>

<Contract id= "1">
<Term />
<Description />
</Contract>
</SMC>


Can you please tell me what am i missing?



Cheers,

Swapnil
Re: GMF link (Relationship) between two nodes [message #479091 is a reply to message #478811] Sun, 09 August 2009 03:12 Go to previous messageGo to next message
Swapnil  is currently offline Swapnil Friend
Messages: 19
Registered: July 2009
Junior Member
Hi Alex,

I have fixed the issue with my Ecore model. Please ignore my previous post
question.

I have one question now: At runtime model digram file is getting created.

But it uses XPath (?) to reference the created elements. But this is
incompatible with JAXB. Is there any fix for this?

e.g. <Role1>//@sMC/@role.0</Role1>



<?xml version="1.0" encoding="UTF-8"?>
<SMC>
<Role id="Role_1" name="Role_1">
<Description>Role_1</Description>
</Role>
<Role id="Role_2" name="Role_2">
<Description>Role_2</Description>
</Role>
<Contract id="Contract_1" name="Contract_1">
<Abstract>true</Abstract>
<State>state2</State>
<Role1>//@sMC/@role.0</Role1>
<Role2>//@sMC/@role.1</Role2>
</Contract>
</SMC>



Cheers,

Swapnil
Re: GMF link (Relationship) between two nodes [message #480533 is a reply to message #479091] Mon, 17 August 2009 14:39 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Swapnil,

> But it uses XPath (?) to reference the created elements. But this is
> incompatible with JAXB. Is there any fix for this?
It is using EMF to persist references across model objects, so if you need
to travers these references by java code you need to load EMf resource and
use EMF-generated API to traverse it.

-----------------
Alex Shatalin
Previous Topic:gmfgraph Visual Editor
Next Topic:Import all elements from an existing diagram file
Goto Forum:
  


Current Time: Thu Apr 25 08:40:37 GMT 2024

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

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

Back to the top