Skip to main content

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 DartFriend
Messages: 17
Registered: September 2013
Junior Member

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:

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.

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 GerbigFriend
Messages: 702
Registered: November 2009
Senior Member

I found this:

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

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.

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

Current Time: Mon Apr 19 07:27:31 GMT 2021

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

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

Back to the top