Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 356373 - [Regression] Drag and Drop source file gets deleted after drop in WPE
Summary: [Regression] Drag and Drop source file gets deleted after drop in WPE
Status: VERIFIED FIXED
Alias: None
Product: Java Server Faces
Classification: WebTools
Component: UI (show other bugs)
Version: 3.3.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.3.1   Edit
Assignee: Carlin Rogers CLA
QA Contact:
URL:
Whiteboard: PMC_approved
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-31 13:35 EDT by Carlin Rogers CLA
Modified: 2011-09-06 11:17 EDT (History)
3 users (show)

See Also:
raghunathan.srinivasan: pmc_approved? (david_williams)
raghunathan.srinivasan: pmc_approved? (raghunathan.srinivasan)
raghunathan.srinivasan: pmc_approved? (naci.dai)
raghunathan.srinivasan: pmc_approved? (deboer)
neil.hauge: pmc_approved+
raghunathan.srinivasan: pmc_approved? (kaloyan)
raghunathan.srinivasan: pmc_approved? (cbridgha)
raghunathan.srinivasan: review+


Attachments
patch to change the event detail after drop (1.70 KB, patch)
2011-08-31 16:18 EDT, Carlin Rogers CLA
carlin.rogers: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlin Rogers CLA 2011-08-31 13:35:08 EDT
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.
Comment 1 Carlin Rogers CLA 2011-08-31 16:18:50 EDT
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.
Comment 2 Carlin Rogers CLA 2011-08-31 16:52:53 EDT
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.
Comment 3 Raghunathan Srinivasan CLA 2011-08-31 16:55:53 EDT
* 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.
Comment 4 Carlin Rogers CLA 2011-09-01 11:31:39 EDT
The patch has been checked into HEAD. See rev. 1.8 of DesignerSourceDropTargetListener.
Comment 5 Carlin Rogers CLA 2011-09-06 11:17:40 EDT
Verified in WTP build M-3.3.1-20110906122954