Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Not able to implement drag and drop; dragSetData not getting called(Not able to implement drag and drop; dragSetData not getting called)
Not able to implement drag and drop; dragSetData not getting called [message #1042981] Wed, 17 April 2013 05:47 Go to next message
Pavan D is currently offline Pavan DFriend
Messages: 7
Registered: February 2011
Junior Member


I am trying to incorporate a drag-and-drop feature with our product. I have created a new custom view which has a tree structure and am interested in dropping the content from this tree to an already existing tree structure within the application itself.

I have used the same custom transfer type which the product is expecting. However, while debugging I found out that neither the DragSourceEvent's data or datatype are getting set. Both are null values. Moreover my dragSetData is not getting called as well.

Requesting you to provide me some suggestions....
Re: Not able to implement drag and drop; dragSetData not getting called [message #1053202 is a reply to message #1042981] Fri, 03 May 2013 06:11 Go to previous message
Bastian Wagenfeld is currently offline Bastian WagenfeldFriend
Messages: 183
Registered: January 2013
Senior Member
Hi,

I'm facing the same problem.
I'm using two Eclipse 4 parts where each part has one JFace viewer. The DragSource is a TreeViewer, the DropTarget is a CheckboxTableViewer.
Here is the code for the two Viewer and the custom Transfer object:

Transfer[] transfer = new Transfer[] { SeriesTransfer.getInstance() };
		treeViewer.addDragSupport(DND.DROP_COPY, transfer,
				new DragSourceAdapter() {

					@Override
					public void dragStart(DragSourceEvent event) {
						System.out.println("start");
					}

					@Override
					public void dragSetData(DragSourceEvent event) {
						System.out.println("set");
					}

					@Override
					public void dragFinished(DragSourceEvent event) {
					}

				});


checkboxTableViewer.addDropSupport(DND.DROP_COPY, transfer,
				new ViewerDropAdapter(checkboxTableViewer) {

					@Override
					public void drop(DropTargetEvent event) {
						System.out.println("drop");
						super.drop(event);
					}

					@Override
					public boolean performDrop(Object data) {
						System.out.println("perform");
						return true;
					}

					@Override
					public boolean validateDrop(Object target, int operation,
							TransferData transferType) {
						System.out.println(transferType.type);
						return true;
					}

				});


public class SeriesTransfer extends ByteArrayTransfer {

	private static final String TYPE_NAME = TimeSeries.class.getName();
	private static final int TYPE_ID = registerType(TYPE_NAME);
	private static SeriesTransfer instance;

	private SeriesTransfer() {
	};

	public static SeriesTransfer getInstance() {
		if (instance == null)
			instance = new SeriesTransfer();
		return instance;
	}

	@Override
	protected int[] getTypeIds() {
		return new int[] { TYPE_ID };
	}

	@Override
	protected String[] getTypeNames() {
		return new String[] { TYPE_NAME };
	}

	@Override
	public boolean isSupportedType(TransferData transferData) {
		return super.isSupportedType(transferData);
	}
}


Dragging the item works and dragStart and validateDrop are called (also the methods of the super- interface dragEnter and dragOver. But the items cannot be dropped and neither thedragSetData method is called nor the drop method.

The isSupportedType method returns true, if the object is of the specified type.

What am I missing?

Thank you!
Bastian
Previous Topic:Serializable DataBinding
Next Topic:Content Assist Issues when modifying org.eclipse.jface.text
Goto Forum:
  


Current Time: Fri Apr 19 00:45:10 GMT 2024

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

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

Back to the top