Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » GEF5 And Drag And Drop
GEF5 And Drag And Drop [message #1785568] Mon, 16 April 2018 20:44 Go to next message
Kyle Girard is currently offline Kyle GirardFriend
Messages: 12
Registered: March 2012
Junior Member
In my RCP application I have FXCanvas as a component of my part. I have placed a few controls around the canvas ( a few lists and buttons etc) using JavaFX. I would like to be able to drag and drop from these lists onto the graph.

If I understand things correctly, these widgets are not under the control of GEF they are just standard JavaFX widgets, so they use the regular JavaFX drag and drop... between the lists I can drag and drop so the JavaFX side of things is working but how do I integrate the regular JavaFX drag and drop the different parts/visuals of my graph?

Do have have to get my parts to set their visuals as JavaFX drag and drop targets and convert events as required to match the interface of IOnDragHandlers retrieved via ClickDragGesture.ON_DRAG_POLICY_KEY?

I am hoping there is a better way then what I'm hacking together right now....

Should all the lists and buttons be created via the GEF side of things? Seems odd since they aren't really part of the graph....
Re: GEF5 And Drag And Drop [message #1785588 is a reply to message #1785568] Tue, 17 April 2018 08:32 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 162
Registered: February 2016
Senior Member
Hi Kyle,

could you please post a screenshot so that we can better imagine the problem you are currently facing?
Re: GEF5 And Drag And Drop [message #1785613 is a reply to message #1785588] Tue, 17 April 2018 13:43 Go to previous messageGo to next message
Kyle Girard is currently offline Kyle GirardFriend
Messages: 12
Registered: March 2012
Junior Member
Sure.

I've attached basically what I'm talking about... the list on the left is just a JavaFX ListView... I want to drag it on to the graph on the right and have it create a node in the graph.

index.php/fa/32621/0/

if I make the different parts of my graph listen for javaFx drag drop related events it sort of works...i get notified of the drop event but but it is quite disconnected from the GEF MVC framework IOnDragHandler... so I'm wondering what the best way is connect them...

or if there is another completely different way of doing it...
Re: GEF5 And Drag And Drop [message #1785837 is a reply to message #1785613] Fri, 20 April 2018 12:14 Go to previous messageGo to next message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
Hi Kyle,

the default gestures provided by GEF do not yet cover drag and drop. You can add support for drag and drop by implementing a DragDropGesture similarly to the default gestures provided by GEF (ClickDragGesture, etc.). I created https://bugs.eclipse.org/bugs/show_bug.cgi?id=533872 to keep track of the issue.

regards,
Matthias

Re: GEF5 And Drag And Drop [message #1786049 is a reply to message #1785837] Tue, 24 April 2018 20:19 Go to previous messageGo to next message
Kyle Girard is currently offline Kyle GirardFriend
Messages: 12
Registered: March 2012
Junior Member
Thanks for the info, Implemented those gestures as you suggested and seems work for my purposes anyway...
Re: GEF5 And Drag And Drop [message #1797719 is a reply to message #1786049] Mon, 05 November 2018 15:39 Go to previous messageGo to next message
Hans MeierFriend
Messages: 7
Registered: June 2018
Junior Member
Hi Kyle,

I am trying to achieve a similar thing (Items to drag are part of the GEF world already), but I can't find an working example.

Could you post your solution?


Implementing the IOnDragHandler as shown in the CreateAndTranslateShapeOnDragHandler of the GEF MVC example leads to errors in "geo-translation" (i.e. while dragging the dragged shape is not under the mouse cursor but a few hundred pixels away).
It seems that this solution first creates the new shape (on start drag) on the target canvas, than moves this shape on drag.

I think a better solution would be to create the shape on drop (end drag) but I couldn't get it to work starting from the description above.

Best regards,
Hans
Re: GEF5 And Drag And Drop [message #1797797 is a reply to message #1797719] Tue, 06 November 2018 13:52 Go to previous messageGo to next message
Hans MeierFriend
Messages: 7
Registered: June 2018
Junior Member
Problem was the infinite canvas, i.e. the visible area does not necessarily correspond to the bounds of the canvas.
In case it helps anyone:
Starting from CreateAndTranslateShapeOnDragHandler of the GEF MVC example.

@Override
public void startDrag(MouseEvent event) {
hostPart = getHost();
}

@Override
public void drag(MouseEvent e, Dimension delta) {
// nothing to do
}

@Override
public void abortDrag() {
hostPart = null;
}

@Override
public void endDrag(MouseEvent e, Dimension delta) {
// see original, most of the startDrag functionality

if (hostPart == null) {
return;
}
...
Point location = getLocation(e);
copy.getBounds().setLocation(location.x() - getXOffset(), location.y());
...
hostPart = null;
}
protected Point getLocation(MouseEvent e) {
Point2D location = ((InfiniteCanvasViewer) getHost().getRoot().getViewer()).getCanvas().getContentGroup()
.sceneToLocal(e.getSceneX(), e.getSceneY());
return new Point(location.getX(), location.getY());
}

getXOffset is the constant width of the other part (where I drag from).
Re: GEF5 And Drag And Drop [message #1802135 is a reply to message #1797797] Fri, 01 February 2019 17:45 Go to previous message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
Hi,

the gesture was provided to us as a christmas present via PR. Thank you very much!

I currently try to get up-to-date with my GEF-TODO-List. This PR is on there.

Best regards,
Matthias
Previous Topic:ViewportPolicy fitToSize method reloads css
Next Topic:Drag an object from GEF and drop it in SWT composite
Goto Forum:
  


Current Time: Mon Dec 02 12:02:28 GMT 2024

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

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

Back to the top