Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » [Zest] How to use Drag and Drop (DND) with zest?
[Zest] How to use Drag and Drop (DND) with zest? [message #767598] Sun, 18 December 2011 12:58 Go to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 756
Registered: July 2009
Senior Member
Does anyone have an example on how to use drag and drop with zest?

Re: [Zest] How to use Drag and Drop (DND) with zest? [message #767620 is a reply to message #767598] Sun, 18 December 2011 14:00 Go to previous messageGo to next message
Fabian Steeg is currently offline Fabian SteegFriend
Messages: 72
Registered: July 2009
Member
To drop things on a graph you could define a drop target for the Graph control:

Graph graphControl = viewer.getGraphControl();
DropTarget dropTarget = new DropTarget(graphControl, DND.DROP_MOVE | DND.DROP_COPY);
dropTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() }); // or your Transfer
dropTarget.addDropListener(new DropTargetListener() { /*...*/ });
Re: [Zest] How to use Drag and Drop (DND) with zest? [message #767632 is a reply to message #767620] Sun, 18 December 2011 14:36 Go to previous message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 756
Registered: July 2009
Senior Member
Sorry, I should have written that I am using GraphViewer:

I tried this:

				viewer.addDropSupport(DND.DROP_LINK,
				new Transfer[] { LocalTransfer.getInstance() },
				new ViewerDropAdapter(viewer) {

					@Override
					public boolean validateDrop(Object target, int operation,
							TransferData transferType) {
						if (target != null) {
							System.out.println(target);
						}
						
						return false;
					}

					@Override
					public boolean performDrop(Object data) {
						return true;
					}

					@Override
					protected Object determineTarget(DropTargetEvent event) {
						Graph g = viewer.getGraphControl();
						Point p = g.getDisplay().map(g.getShell(), g, event.x,
								event.y);
						IFigure fig = g.getFigureAt(p.x, p.y);
						return fig;
					}
				});


Problems:
- g.getFigureAt() does not seem to get the figure under mouse position at its correct location: i am not sure whether this is the right way to listen for a drag target...
- validateDrop() provides a GraphLabel, I would expect it to provide my model object...

Any hints?
Previous Topic:[ZEST] Problem with number of node and also color of node
Next Topic:[Zest/Draw2D] Drag and drop
Goto Forum:
  


Current Time: Fri Dec 19 06:45:32 GMT 2014

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

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