Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Avoiding duplicate link between node.
Avoiding duplicate link between node. [message #636848] Wed, 03 November 2010 05:36 Go to next message
Abhijit Gurav is currently offline Abhijit GuravFriend
Messages: 25
Registered: November 2010
Junior Member
Hi,

I have hierarchy of class like,

B-->A
C --> A

D --> B
E --> C



What I want to achieve is , to avoid duplicate link between B, C, D and E with OCL.

Anybody have any idea about the same.

Note : I have seen similar post http://www.eclipse.org/forums/index.php?t=tree&th=48418& amp;#page_top but not working in may case Confused since I have parent Class is only one which is "A".

Thanks in advance
-AG
Re: Avoiding duplicate link between node. [message #636868 is a reply to message #636848] Wed, 03 November 2010 08:12 Go to previous messageGo to next message
Asiri Rathnayake is currently offline Asiri RathnayakeFriend
Messages: 80
Registered: September 2010
Location: Colombo, Sri Lanka.
Member
Hi,

What do you mean by duplicate links? Can you give more information regarding your model? like which model element is used to represent links and how B, C, D & E are linked together?

- Asiri
Re: Avoiding duplicate link between node. [message #636873 is a reply to message #636868] Wed, 03 November 2010 08:23 Go to previous messageGo to next message
Abhijit Gurav is currently offline Abhijit GuravFriend
Messages: 25
Registered: November 2010
Junior Member
Hi Asiri,

Thanks for reply Smile


Duplicate links means, there should be only one link exist in any nodes. When user try to connect any source and target node which are already linked, then connection should not be allowed.

I have separate link class to connect all other and B, C, D & E are just simple class as shown earlier.

As far as linking is concern this classes are like different task which has to be connected and run one after the other in the way they are connected.

Hence, having two links between same source and target node make no sense here.

is anything else you need, please tell me.

Regards,
-AG

Re: Avoiding duplicate link between node. [message #636879 is a reply to message #636848] Wed, 03 November 2010 08:33 Go to previous messageGo to next message
Asiri Rathnayake is currently offline Asiri RathnayakeFriend
Messages: 80
Registered: September 2010
Location: Colombo, Sri Lanka.
Member
Hi,

If I understand you correctly, your B, C , D & E classes have a structure like below:

class B {
	private List<X> sourceConnections;
	private List<X> targetConnections;
}

Here 'X' would be the model class you use to represent links. Have I understood you correctly?

The problem is since you have allowed 'many' source and target connections on your node B, you are able to connect the same two node multiple times. There are two ways to overcome this problem.

1. You can change your model so that it becomes something like:

class B {
	private X sourceConnection;
	private X targetConnection;
}

Here we have effectively limited the model so that one object may have only one incoming connection and one outgoing connection.

2. You can add an OCL constraint to your connection mapping. Learn about link constraints from here http://wiki.eclipse.org/index.php/GMF_Constraints#Link_Const raints and may be add two constraints on the source edge and the target edge; inside ocl code just check whether your sourceConnections list / targetConnections list is not empty and return false if so.

Hope this helps.

- Asiri
Re: Avoiding duplicate link between node. [message #636914 is a reply to message #636879] Wed, 03 November 2010 10:35 Go to previous message
Abhijit Gurav is currently offline Abhijit GuravFriend
Messages: 25
Registered: November 2010
Junior Member
Hi,

Thanks for prompt response.

Let me try your approach.

Regards,
-AG
Previous Topic:Change the appearance of outgoing connections when clicking on a specific node
Next Topic:GMF copy and paste
Goto Forum:
  


Current Time: Thu Apr 25 20:18:28 GMT 2024

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

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

Back to the top