Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Connections in gef4
Connections in gef4 [message #1750732] Tue, 27 December 2016 16:11 Go to next message
Nebojsa Rajic is currently offline Nebojsa RajicFriend
Messages: 5
Registered: June 2016
Junior Member
Hi everybody.

I'm working on the project where we have blocks, ports as their children and connections which should connect those ports (I will attach the picture of two blocks connected with one connection, so you can have visual representation). I have been looking in org.eclipse.gef4.mvc.examples.logo how it's done and have been using lot of code from there. Still, I have few problems:

1. In my ConnectionEditPart (controller for connection, extends AbstractFXContentPart<Connection> and implements ITransformableContentPart<Node, Connection>, IBendableContentPart<Node, Connection>, I have my model of connection and I'm using org.eclipse.gef4.fx.nodes.Connection as visual), two methods are never called: doAttachToContentAnchorage and doDetachFromContentAnchorage. Those are Override methods and I found that that these should be called from parent methods. Should some policy call these methods or is this good behavior? If yes, when and which policy? I try to debug example, these methods aren't called also.

2. Is there possibility to set dynamic anchor visual in port center? Now it's moving around the port as I move connection around the canvas. If there is, how?

3. In example, connection can be connected to any part. In my case, I have some conditions if ports can be connected or not. So I have extended FXBendConnectionPolicy and Override method findOrCreateAnchor(Point positionInLocal, boolean canConnect). In this method I have added just one if to check if ports can connect (my port model have function that is checking this). The problem is that connection model isn't updated on drag, but on release, so if I have connection that is connecting two ports and take start or end point of connection, start dragging around, visually he is disconnected, but in model is still connected, so my check if ports can connect isn't working good. Can I somehow get which end of connection am I dragging? That will solve my problems, but I'm not sure how to get it.

Policies that are connected to ConnectionEditPart are:
FXHoverOnHoverPolicy
FXResizeConnectionPolicy
BendConnectionPolicy (extends FXBendConnectionPolicy)
FXTranslateSelectedOnDragPolicy
FXBendOnSegmentDragPolicy
CloneCurvePolicy
FXConnectionClickableAreaBehavior
FXCloneOnClickPolicy
Also factories for selection, hover and focus feedback, as they are in example.

Hopefully this isn't to much text and to little information. If any information is missing, I will try to provide to you.

Kind Regards,
Nebojsa

index.php/fa/27953/0/
Re: Connections in gef4 [message #1750775 is a reply to message #1750732] Wed, 28 December 2016 14:41 Go to previous messageGo to next message
Alexander Nyssen is currently offline Alexander NyssenFriend
Messages: 230
Registered: July 2009
Location: Lünen
Senior Member
Hi Nebojsa,

1. The methods you mention are needed in case an element is created or removed, or when an IBendableContentPart is reconnected (while this case is not implemented within MVC directly but left to client code; you can look into the Zest EdgePart for an example) . They are responsible of applying the respective operation on the content side and are called via operations of the (transactional) ContentPolicy, which is called from the CreationPolicy and DeletionPolicy by default (and are also intended to be called when the bend points indicate a reconnection, as in EdgePart#bendContent()).

2. Yes, you can do this by exchanging its IComputationStrategy. But the connection should probably end on the outline of the port, to so anchor point should not be located in the center but on the outline. You can take a look at the different strategies we already provide and extend or implement a custom one that places the anchor the desired position. The Geometry API should provide all necessary means.

3. You can overwrite FXBendConnectionPolicy.select() and/or selectSegment(), which will be called when dragging a waypoint or segment. By means of the index you can then determine which end is currently dragged.

Best Regards,
Alexander
Re: Connections in gef4 [message #1750822 is a reply to message #1750775] Thu, 29 December 2016 15:02 Go to previous messageGo to next message
Alexander Nyssen is currently offline Alexander NyssenFriend
Messages: 230
Registered: July 2009
Location: Lünen
Senior Member
I raised https://bugs.eclipse.org/bugs/show_bug.cgi?id=509763 to keep track of either properly documenting the contract mentioned in 1) or implementing it by default (if possible).
Re: Connections in gef4 [message #1759959 is a reply to message #1750822] Thu, 20 April 2017 14:00 Go to previous messageGo to next message
Nebojsa Rajic is currently offline Nebojsa RajicFriend
Messages: 5
Registered: June 2016
Junior Member
Hi,

I'm still working on this project and now I have some new problems. I was wondering is there a way to delete connection after start or end point is disconnected (attached to static anchor)? If there is, how and where?
Also, problem with this is that undo have to return last connected state (when connection was connected to dynamic anchor). So I tried to make ReverseUndoCompositeOperation and add delete and bend policy to it, but I got some errors with this. I tried this when FXBendPolicy is trying to commit.

Thanks in advance.
Kind regards,

Nebojsa
Re: Connections in gef4 [message #1759965 is a reply to message #1759959] Thu, 20 April 2017 14:37 Go to previous messageGo to next message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 128
Registered: March 2015
Senior Member
Hi Nebojsa,

in order to adjust the default behavior, I would suggest extending the corresponding interaction policy (aka handler), which would be the BendFirstAnchorageOnSegmentHandleDragHandler. In the subclass, you can override endDrag(), call the super method, test if the connection is valid afterwards, and delete it using the DeletionPolicy of the root part if it is invalid. All transaction policies that are executed in the context of user interaction will be undoable in one single step, i.e. the deletion will be part of the same transaction as the connection manipulation.

Best regards,
Matthias

[Updated on: Thu, 20 April 2017 14:41]

Report message to a moderator

Re: Connections in gef4 [message #1759971 is a reply to message #1759965] Thu, 20 April 2017 15:25 Go to previous messageGo to next message
Nebojsa Rajic is currently offline Nebojsa RajicFriend
Messages: 5
Registered: June 2016
Junior Member
I did that, now it's working, thank you!
Re: Connections in gef4 [message #1763400 is a reply to message #1750732] Mon, 15 May 2017 09:26 Go to previous message
Nebojsa Rajic is currently offline Nebojsa RajicFriend
Messages: 5
Registered: June 2016
Junior Member
Hi,

It's me again. I'm trying to bind FXTransformPolicy and/or FXTransformConnectionPolicy to my connections, and when I do, connections are moving great when we are moving both blocks and connections.
But when I try to drag connection out of port (the way we create connection, same as example, but instead dragging from plus, we drag from port), connection is created and then we get null point exception in drag aborted, in FXTranslateSelectedOnDragPolicy.
Do you have any idea why is this happening? What do I need to bind transform policy to my connections? My connection part is implementing ITransformableContentPart and IBendableContentPart. We follow example as much as possible.
Previous Topic:[GEF5] Click policies chain
Next Topic:GEF 3.11 is not working in eclipse DS-5 5.26.2
Goto Forum:
  


Current Time: Sun Jan 21 14:55:56 GMT 2018

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

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