Hi,
I would like to restrict certain combinations of connections and have
looked into validLink() to achieve that but I’m getting myself into all
sorts of problems so was wondering if overriding the validLink() within
the JGoView would be a better place to achieve what I am wanting to do…
Ok so heres what I would like to happen (Its based loosly on the
processor application to some degree…). I have a couple of different
node types lets call them A,B and C for now.
-
When a node A is placed and an attempt to connect a special output
port (Lets call this link) to another nodes input. It will normally
allow this. (So A can connect to B’s input) -
If a subsequent link from that node A, attempts to connect to
node B then it is ignored (can use !isAlreadyLinked() for that as per
the example) -
If node A then attempts to connect to another instance of B on the diagram then this is allowed
-
if node A attempts to connect to node C then this is disallowed, as
only nodes of the same type as to that of the original connection can
be connected. So if I wanted to connect A to C I would have to first
remove all of the other conenctions and then connect A to C.
Phew… so thats basically what I want to do. At the moment what I have
tried has leaned around that of the validLink override from JGoPort.
What I had was something like this…
if(getNumFromLinks() == 0 )
&nbs p; {
&nbs p;
RemoteNode node = (RemoteNode)to.getParent();
&nbs p;
this.AllowNodesofType = node.getQueueType();
&nbs p;
return true;
&nbs p; }
So on the first connection I set my allowable node types and on
subsequent calls, if getNumFromLinks() > 0 then I would check to see
what the remote node type is verses that of my AllowNodesofType value
and return TRUE for them being the same or FALSE if they are not.
What would appear to happen is that the validLink appears to get called
before an attempt to connect it to the second node is undertaken, so
many of these can occur by the looks of it which I think leaves my
value of AllowNodesofType suspect
So is it better to do this checking at the view level when I have the
to and from node within validLink() or should what I am trying to do
work at the port level ?
Any ideas on this am I on the right track for doing this
Thanks
Wayne