Skip to main content



      Home
Home » Eclipse Projects » GEF » Connection with Selectable End Points
Connection with Selectable End Points [message #92116] Tue, 02 September 2003 15:33 Go to next message
Eclipse UserFriend
Originally posted by: brianv.phreaker.net

I need a connection with selectable endpoints - ie. endpoints which can be
selected seperately from the connection. (So I can select either the
connection or the source point or the target point individually)

Since I also need to set properties for the endpoints, I suppose I have to
use separate EditParts for each endpoint, as well as the usual EditPart for
the connection. I would then connect the connection to these endpoint
EditParts.

In my connections Model constructor, I've added 2 endpoint models as
children of the connection model. I've installed a CONTAINER_ROLE for my
connection's EditPart and overriden getModelChildren() to return the 2
endpoint models.

For the figures of the endpoints , I will use PolygonDecorations.
I'm unsure of what to do in refreshVisuals for the endpoints EditParts.
I should probably be using an ArrowLocator as a constraint, but am not too
sure of how exactly to code this.

Will this work ?

((GraphicalEditPart) getParent()).setLayoutConstraint(
this,
getFigure(),
new ArrowLocator(getParent(), ConnectionLocator.TARGET);


Another requirement is; when I drag the endpoint editparts, the connection
should re-rout... exactly what happens during re-anchoring the source or
target endpoints of a normal connection. In other words, I should see the
feedback of the connection re-routing itself while moving the edit part to
which it is connected to...
How to I implement this ?

I also need to attach a connection to an existing connection... earlier on
the newsgroup it was stated that a specific anchor was to be created for
this purpose... which Anchor do I use for this ?

Any suggestions appreciated,
Brian.

p.s. I am aware that a normal connection can have decorations, but it is
imperative that the endpoints of my connections are individually selectable.
Re: Connection with Selectable End Points [message #92203 is a reply to message #92116] Wed, 03 September 2003 09:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

I have managed to draw the endpoint editparts at each end of the
connection.. they are properly oriented / located using the arrow locator.

In order to make the endpoints selectable, I had to put this in the activate
method of the endpoints EditPart.
installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new
NonResizableEditPolicy());

So now I can select the endpoints and drag them as well; however, the
connection does not re-rout WHILE I'm dragging the endpoint. It re-routs
only when the endpoint is finally in place.
I need the feedback to be visible while I'm dragging the "fake" endpoint..
how do I do this ?

If, on the other hand, I select the connection and it's default endpoint,
and drag that, then my "fake" endpoints move as well.

Thanks,
Brian.
Re: Connection with Selectable End Points [message #92389 is a reply to message #92203] Thu, 04 September 2003 10:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

For all those who are interested, I think I've solved this... ;)
I overrode getDragTracker in the dummy endPoints edit parts to return a a
special dragtracker.

This tracker was derived from ConnectionEndpointTracker and and it's command
was set to RequestConstants.REQ_RECONNECT_TARGET

In this tracker, I had to override handleButtonDown similar to how it was
written in SelectEditPartTracker...

Now I can select the endpoint, drag it , and the connection re-routs while
dragging the endpoint.

Contrary to my previous post, I do not need to install a PRIMARY_DRAG_ROLE
for these endpoints.

Ole !

Thanks,
Brian.
Re: Connection with Selectable End Points [message #92404 is a reply to message #92389] Thu, 04 September 2003 10:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

> For all those who are interested, I think I've solved this... ;)
> I overrode getDragTracker in the dummy endPoints edit parts to return a a
> special dragtracker.
>
> This tracker was derived from ConnectionEndpointTracker and and it's
command
> was set to RequestConstants.REQ_RECONNECT_TARGET
>
> In this tracker, I had to override handleButtonDown similar to how it was
> written in SelectEditPartTracker...

Nice! So, you send all requests to the conneciton editpart, and not the
endpoint, right? Or, at least the feedback goes to the connection, i'm
assuming.

> Now I can select the endpoint, drag it , and the connection re-routs while
> dragging the endpoint.
>
> Contrary to my previous post, I do not need to install a PRIMARY_DRAG_ROLE
> for these endpoints.
>
> Ole !
>
> Thanks,
> Brian.
>
>
>
Re: Connection with Selectable End Points [message #92433 is a reply to message #92404] Thu, 04 September 2003 10:50 Go to previous message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

> Nice! So, you send all requests to the conneciton editpart, and not the
> endpoint, right? Or, at least the feedback goes to the connection, i'm
> assuming.
>
Yup, I guess this is what's happening... I traced thru the code in
ConnectionEndPointEditPolicy and realized that this is what I need...

So in the fake end Point editParts, in the overridden getDragTracker... I
return a tracker similar to this ...

ConnectionEndpointTracker((ConnectionEditPart) this.getParent());

since this.getParent() is the Connection EditPart, I think the request are
going to the connection... and because the fake endpoints are children of
the connection, they move when the connection moves.... all seems very
logical (after having done it of course...) lol.

Another problem I faced with the tracker was , even though the connection
was re-routing and anchoring during the drag, finally when you release the
mouse it wasn't sticking to it's new position. I traced this to some code in
the overridden handleButtonDown(int button) ...

stateTransition(STATE_INITIAL, STATE_DRAG);

I had to comment this out.. and then it all fell into place ... hurrah !
Previous Topic:Send child figure to back
Next Topic:Document of Book
Goto Forum:
  


Current Time: Tue May 13 18:27:36 EDT 2025

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

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

Back to the top