Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » GEF 5: Allow only some Connections
GEF 5: Allow only some Connections [message #1798131] Tue, 13 November 2018 06:52 Go to next message
Hans MeierFriend
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 Go to previous messageGo to next message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
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
Re: GEF 5: Allow only some Connections [message #1807187 is a reply to message #1802137] Fri, 24 May 2019 09:54 Go to previous message
Patrick Muscat is currently offline Patrick MuscatFriend
Messages: 14
Registered: May 2018
Junior Member
Hi Everyone,

We also encountered the same limitation on the BendConnectionPolicy and decided to modify the method "getCompatibleAnchor" to check the anchorProvider's existence "anchorProvider != null" AND that it returns an Anchor: "anchorProvider.get(this.getAdaptable(), "TODO") != null" and our IAnchorProviders return null if they do not apply on the currently modified connection (based on the type of the link on our case).

It works but the question of the good practice remains, for example if their won't be performance issues to ask IAnchorProvider its Anchor (but it is for only one Connection) ... And the "TODO" about de role is still under study for connection's direction.

Patrick
Previous Topic:HoverFeedbackPart
Next Topic:Cross Viewer Drag & Drop
Goto Forum:
  


Current Time: Sat Sep 18 05:18:31 GMT 2021

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

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

Back to the top