Connecting only one Link between nodes [message #222789] |
Wed, 25 March 2009 19:53 |
|
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 #223596 is a reply to message #223352] |
Tue, 31 March 2009 11:12 |
|
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 #223797 is a reply to message #223737] |
Wed, 01 April 2009 05:49 |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03411 seconds