Home » Eclipse Projects » GEF » Connections in gef4
|Connections in gef4 [message #1750732]
||Tue, 27 December 2016 16:11
| Nebojsa Rajic
Registered: June 2016
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:
BendConnectionPolicy (extends FXBendConnectionPolicy)
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.
|Re: Connections in gef4 [message #1759965 is a reply to message #1759959]
||Thu, 20 April 2017 14:37
|| Matthias Wienand
Registered: March 2015
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.
[Updated on: Thu, 20 April 2017 14:41]
Report message to a moderator
Current Time: Sun Oct 01 00:04:03 GMT 2023
Powered by FUDForum
. Page generated in 0.02310 seconds