Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Connecting only one Link between nodes
Connecting only one Link between nodes [message #222789] Wed, 25 March 2009 19:53 Go to next message
govind Ra is currently offline govind RaFriend
Messages: 95
Registered: July 2009
Member
Hi All..

I have gmf projects with different figures Say A and B.. which can be
there on my editor C

I can add (drag and drop ) figures x in A or B.

In my link mapping i have described xsrc to xdestination for link 1
,link2, link3

ie. X and X can be connected by any of these links.

I want 2 conditions to be satasified
1. That x and x can be connected by only one link (link 1 ,link2, link3).
2. x and x can be connected in only A or only B ie. link should go out of
parent editparts A and B.

I think one can get the links from editpart and check for links.size()==1
but dont know where exactly i need to put it.Don't have clue about 2 one.

Any example or snippet

Thanks and Regards
Govind R
Re: Connecting only one Link between nodes [message #223062 is a reply to message #222789] Sat, 28 March 2009 07:53 Go to previous messageGo to next message
govind Ra is currently offline govind RaFriend
Messages: 95
Registered: July 2009
Member
Any Clue??


Regards
Govind R
Re: Connecting only one Link between nodes [message #223352 is a reply to message #222789] Mon, 30 March 2009 16:48 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello govind,

> 2. x and x can be connected in only A or only B ie. link should go out
> of parent editparts A and B.
Link constraint written in java like: "source instanceof A ? target instanceof
A : target instanceof B" ?

-----------------
Alex Shatalin
Re: Connecting only one Link between nodes [message #223596 is a reply to message #223352] Tue, 31 March 2009 11:12 Go to previous messageGo to next message
govind Ra is currently offline govind RaFriend
Messages: 95
Registered: July 2009
Member
Hi Alex...

Thanks for the reply..

Actually the the above solution is works fine...but i add a 2 A i diagram
and add 1 x in each A then when i try to connect it connects which should
not .

As the instance remains same.

So i modified the code in LinkCreateCommand Class

ie.canExecute()method..

public boolean canExecute() {
EObject targetContainer;// i created this
if (source == null && target == null) {
return false;
}
if (source != null && false == source instanceof X) {
return false;
}
if (target != null && false == target instanceof X) {
return false;
}
if (getSource() == null) {
return true; // link creation is in progress; source is not defined yet
}
// target may be null here but it's possible to check constraint
if (getContainer() == null) {
return false;
}
//// here is the check i doing to check whether the conatiners are same.
if(target!=null){
targetContainer = getTarget().eContainer();
if(!container.equals(targetContainer)){
return false;
}
}

is the correct way of implementing..

I don't want to do in wrong way..

Regards
Govind R
Re: Connecting only one Link between nodes [message #223737 is a reply to message #223596] Tue, 31 March 2009 17:15 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello govind,

> is the correct way of implementing..
Constraint looks reasonable for me, but if specify these OCL- or even Java-based
constraints in mapping model you'll be able to generate whole code without
manual modification. Unless you don't need it the solution is good.

-----------------
Alex Shatalin
Re: Connecting only one Link between nodes [message #223797 is a reply to message #223737] Wed, 01 April 2009 05:49 Go to previous messageGo to next message
govind Ra is currently offline govind RaFriend
Messages: 95
Registered: July 2009
Member
Hi Alex..

Thanks a lot..i will also check adding constraints.

And any clue of the query ie. 1 point..

Can i check something that where i could come to know the number of links
coming from a editpart.Can i do it here in canExecute method.

As in canExecute() method i dont know how get the Editpart . if i get
that i will able to get Incoming links etc.


Any clue how i should proceed..

Regards
Govind
Re: Connecting only one Link between nodes [message #223883 is a reply to message #223797] Wed, 01 April 2009 12:05 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello govind,

> As in canExecute() method i dont know how get the Editpart . if i get
> that i will able to get Incoming links etc.
You can check this constraint based on an information in a domain model (you
have source/target objects of the link there, so you can check source.getOutgoingLinks().size()...)
Another option is to modify a place where the command is created and pass
EditPart as a parameter into a command (or just check this constraint there).


-----------------
Alex Shatalin
Previous Topic:Howto intercept deletion of figures
Next Topic:Deletion of reference does also delete containment
Goto Forum:
  


Current Time: Fri Apr 26 19:13:42 GMT 2024

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

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

Back to the top