Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Drag & Drop from TreeView to GMF Editor(How to drag an item from a treeview & detect the "drop" on an element in the GMF Editor?)
Drag & Drop from TreeView to GMF Editor [message #1219029] Fri, 29 November 2013 20:11 Go to next message
Greg Dart is currently offline Greg Dart
Messages: 17
Registered: September 2013
Junior Member
Hi,

I have researched this extensively in forums and web search, but just got more and more confused. Please could someone set out the correct approach? My impression is that there is an "old wrong" way to do this and a new but largely undocumented way.

I have a Treeviewer in a ViewPart. I am quite comfortable creating DND between normal eclipse plugins, e.g from TreeViewer to TableViewer.

I want to enable the GMF diagram so that when an appropriate object from the Treeviewer is dropped on the correct type of element, a command is fired that I can intercept and handle with whatever custom code.

I understand from research that I should implement an extension point? Perhaps: org.eclipse.gmf.runtime.common.ui.services.dnd.dragDropListenerProviders?

If so, what are "TransferID"?

Do I need to use "DiagramDropTargetListener"? If so to do what?

Can anyone please provide an example of how to do this?

I would like as much as possible to avoid modifying the generated code.

Thanks,
Greg
Re: Drag & Drop from TreeView to GMF Editor [message #1220399 is a reply to message #1219029] Wed, 11 December 2013 13:58 Go to previous message
Ralph Gerbig is currently offline Ralph Gerbig
Messages: 697
Registered: November 2009
Senior Member
Hi,

I found this:

Quote:
If you only need to handle the D&D from within the same eclipse app, you can look at the lines 288-361 here:

http://git.eclipse.org/c/gmf-tooling/org.eclipse.gmf-tooling.git/tree/test-examples/shortcut/xpand/org.eclipse.gmf.tooling.examples.shortcut.diagram/src/org/eclipse/gmf/tooling/examples/shortcut/diagram/part/ShortcutDiagramEditor.java

This code handles the D&D of the LocalTransfer / LocalSelectionTransfer which you can use at the source part in your treeview (EMF-generated trees have this out of the box). It transforms the D&D into DropObjectRequest which can be handled separately in the corresponding target editpart.

By default this code is generated when one enables the shortcuts for the diagram, and the default EditPolicy handles DropObjectsRequest by adding shortcut. You can change this by registering CustomBehavior for the diagram.


Ralph
Previous Topic:How to create a new project programatically?
Next Topic:how to chnage the color of diagram elements
Goto Forum:
  


Current Time: Sun Oct 26 07:09:04 GMT 2014

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

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