Bug 35214 - Drag-n-Drop initialization problems.
Summary: Drag-n-Drop initialization problems.
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P2 critical (vote)
Target Milestone: ---   Edit
Assignee: Veronika Irvine CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-18 09:49 EST by Murray Beaton CLA
Modified: 2003-03-26 15:27 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Murray Beaton CLA 2003-03-18 09:49:14 EST
In Eclipse 2.0.* versions, we had enabled full drag-n-drop cabability between 
our viewers.  Recently we moved to Eclipse 2.1, however, the drag-n-drop fails 
to initialize.  We add drag adapters like so to our viewer:

int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getInstance()};
viewer.addDragSupport(dndOperations, transfers, new AClass(viewer));

AClass above would be a subclass of DragSourceAdapter.  The above code work, 
and the Drag is enabled for objects of type 'AClass'.  However, if I attempt 
to add another DragSourceAdapter for type 'BClass', this is where the problem 
comes in.

For example, 
int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getInstance()};
viewer.addDragSupport(dndOperations, transfers, new BClass(viewer));

It seems any time I attempt to add a second DragSourceAdapter, the 
initialization fails with with the following exception.

If there is something which has changed with respect to Drag-n-drop 
initialization, please pass along.
thx. Murray

org.eclipse.swt.SWTError: Can not initialize Drag
at org.eclipse.swt.dnd.DND.error(DND.java:211)
at org.eclipse.swt.dnd.DND.error(DND.java:177)
at org.eclipse.swt.dnd.DragSource.<init>(DragSource.java:135)
at org.eclipse.jface.viewers.StructuredViewer.addDragSupport(StructuredViewer.j
ava:182)
at com.ibm.etools.BClass.addDragSourceViewer(BClass.java:32)
at com.ibm.etools.ui.view.SampleViewer.initDragAndDrop(SampleViewer.java:20
at com.ibm.etools.ui.view.SampleViewer.createPartControl(SampleViewer.java:136)
at org.eclipse.ui.internal.PartPane$4.run(PartPane.java:138)
at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java
:867)
...... etc .....
Comment 1 Grant Gayed CLA 2003-03-18 12:12:20 EST
Moving to Veronika.
Comment 2 Veronika Irvine CLA 2003-03-21 08:20:23 EST
It is not possible to create multiple drag source objects on the same 
control.  

On some platforms, this results in a segmentation fault and on other 
platforms, the result is not clear - which drag source will actually provide 
the data when requested (will the second one be ignored or will it replace the 
first one, on no platform will both drag source suppliers be available)?  As a 
result, in 2.1 we added an exception so that the application would be advised 
that this functionality is not supported.

We will add something to the README to make this change clear.
Comment 3 Steve Northover CLA 2003-03-21 12:02:57 EST
VI to update "API changes docuement" (whatever is was called) we did with Jeem 
to include this information or put the information in the appropriate place.
Comment 4 Veronika Irvine CLA 2003-03-21 12:39:21 EST
Jim already has the info for the API document.
I also need to update the javadoc to reflect this information.
Comment 5 Murray Beaton CLA 2003-03-26 11:05:57 EST
Ok, I can react to this in my code.  However, if it is not possible to add 
multiple drag source adapters to a viewer, why not have the API as singleton, 
ie. 'setDragSupport' as opposed to 'addDragSupport'?  thx. Murray 
Comment 6 Veronika Irvine CLA 2003-03-26 12:00:39 EST
SWT does not own the Viewer code.  This question needs to be redirected to the 
JFace team.  Adding Nick Edgar to this bug report for his comment on the 
Viewer API.
Comment 7 Nick Edgar CLA 2003-03-26 15:27:18 EST
Well, addDragSupport was added in 1.0 before we were aware of the limitation 
<g>.  We could deprecate it and change it to setDragSupport.  I've filed bug 
35727 for this.