Community
Participate
Working Groups
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 .....
Moving to Veronika.
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.
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.
Jim already has the info for the API document. I also need to update the javadoc to reflect this information.
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
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.
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.