Home » Eclipse Projects » GEF » Connections in gef4
Connections in gef4 [message #1750732] |
Tue, 27 December 2016 16:11 |
Nebojsa Rajic 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
|
|
|
Re: Connections in gef4 [message #1750775 is a reply to message #1750732] |
Wed, 28 December 2016 14:41 |
|
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 #1759965 is a reply to message #1759959] |
Thu, 20 April 2017 14:37 |
|
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
|
|
| | |
Goto Forum:
Current Time: Tue Sep 17 18:56:20 GMT 2024
Powered by FUDForum. Page generated in 0.04640 seconds
|