Community
Participate
Working Groups
This is a side effect of the change for Bug 351468. The change to add support for resource transfer to WPE in DesignerSourceDropTargetListener works fine for drag and drop from Project Explorer view. However, DnD from the Navigator and Package Explorer views causes the source (resource file in this case) to be deleted after the drop. Both views have drag source listeners, NavigatorDragAdapter and ResourceTransferDragAdapter respectively, that "clean up" the source. For example, the NavigatorDragAdapter.dragFinished() states that the implementation responds to a drag that has moved resources outside the Navigator by deleting the corresponding source resource. Seems our DesignerSourceDropTargetListener must change the event detail to something other than a move, DND.DROP_MOVE. The Javadoc note in the navigator CommonDropAdapterAssistant states that... "Contrary to the SWT DropTargetListener specification, you must make sure that the aDropTargetEvent.detail is not set to DND.DROP_MOVE unless actual work is required in the DragSourceListener.dragFinished(org.eclipse.swt.dnd.DragSourceEvent) to complete the operation (for example removing the moved file). In particular for the LocalSelectionTransfer case, DND.DROP_MOVE cannot be used as it will cause incorrect behavior in some existing drag handlers. In case of move operations where no action is required on the source side (e.g. LocalSelectionTransfer) you must set aDropTargetEvent.detail to DND.DROP_NONE to signal this to the drag source. Even though the SWT specification says this is canceling the drop, it is not really doing so, it is only preventing the DND.DROP_MOVE from being passed through to the dragFinished() method." I will create and attach a patch shortly.
Created attachment 202565 [details] patch to change the event detail after drop Here's the patch. The change is based on the javadoc recommendation and handles the event detail the same way the pagedesigner's ResouceDropTargetListener does. See the overriding code in ResouceDropTargetListener.setCurrentEvent() that is called by the drop() routine.
Correcting the version value - looks like rev 1.7 of DesignerSourceDropTargetListener is part of 3.3.1 only. I think this is important to get into 3.3.1 otherwise there's the potential loss of data by deleting a user file.
* Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such. This is stop-ship defect. Dnd of a resource from the Project Explorer results in the resource being deleted. This is a serious regression. * Is there a work-around? If so, why do you believe the work-around is insufficient? No workaround. * How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added? Manual testing in the adopter product where we have a reproducible use case. * Give a brief technical overview. Who has reviewed this fix? See description * What is the risk associated with this fix? low.
The patch has been checked into HEAD. See rev. 1.8 of DesignerSourceDropTargetListener.
Verified in WTP build M-3.3.1-20110906122954