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

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() {

					public void dragStart(DragSourceEvent event) {

					public void dragSetData(DragSourceEvent event) {

					public void dragFinished(DragSourceEvent event) {


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

					public void drop(DropTargetEvent event) {

					public boolean performDrop(Object data) {
						return true;

					public boolean validateDrop(Object target, int operation,
							TransferData transferType) {
						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;

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

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

	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!
Previous Topic:Open all children of a treeviewer node
Next Topic:ListViewer: List items in horizontal order
Goto Forum:

Current Time: Sun Nov 29 01:55:05 GMT 2015

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

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