GEF 5: Allow only some Connections [message #1798131] |
Tue, 13 November 2018 06:52  |
Hans Meier Messages: 7 Registered: June 2018 |
Junior Member |
|
|
Hi everyone,
the GEF 5 examples show how to create connections between shapes.
In my use case there are multiple types of shapes and only some of them are allowed to be connected. E.g. there may be Shapes A1, A2, B1, B2 and the A's are allowed to connect to B's, but A1 must not be connected with A2 and B1 must not be conneted with B2,...
There was a related issue for GEF 4 (https://www.eclipse.org/forums/index.php/m/1750732/#msg_1750732 mentioned in question 3). Nebojsa described how the FXBendConnectionPolicy could be extended by overriding findOrCreateAnchor(Point positionInLocal, boolean canConnect).
However, in GEF 5 the BendConnectionPolicy method findOrCreateAnchor is private and overriding the move(Point initialMouseInScene, Point currentMouseInScene) method would basically require me to copy the whole class due to the amount of private variables and methods.
To be honest, I am not sure if I am even looking at the correct place to implement the described behavior. Maybe it was changed in GEF 5?
The AnchorProvider does not seem to be able to distinguish incoming edges to decide whether or not to offer an anchor. The BendConnectionPolicy.canConnect(int explicitAnchorIndex) method doesn't appear to be to be able to do that, either.
Could you give me a hint here?
Thanks and best regards,
Hans
|
|
|
Re: GEF 5: Allow only some Connections [message #1802137 is a reply to message #1798131] |
Fri, 01 February 2019 17:59   |
|
Hi Hans,
you correctly analysed the BendConnectionPolicy logic and access restrictions. The methods are declared private when it was uncertain how the API should look like. Probably, this was a mistake and we should refactor.
However, BendConnectionPolicy will just create a BendPoint during interaction. The BendPoints are applied when the operation is executed locally. Therefore, you could exchange the operation (createOperation()), or code executed after BendPoint creation (locallyExecuteOperation(), move()).
Moreover, as pointed out in the other thread, it is possible to add logic via the handlers, i.e. BendOnSegmentHandleDragHandler, BendSegmentOnDragHandler, etc.
Here, you can add arbitrary logic that does not need to delegate to BendConnectionPolicy if that would lead to undesired results.
Best regards,
Matthias
|
|
|
|
Powered by
FUDForum. Page generated in 0.02593 seconds