Bug 24593 - [DND] Navigator DND does not work
Summary: [DND] Navigator DND does not work
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Linux-Motif
: P2 major (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Knut Radloff CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-09 15:39 EDT by Knut Radloff CLA
Modified: 2003-01-30 13:43 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Knut Radloff CLA 2002-10-09 15:39:53 EDT
build 20021001

Dragging items in the resource navigator does not work. The drag icon appears, 
but there is no drop location feedback.
NavigatorDragAdapter.dragStart checks whether the drag source actually has 
focus. Display.getFocusControl returns null even though the tree viewer does 
have focus. When I comment out this check and dragStart lets the drop operation 
continue the drop adapter still does not get a dragEnter event.
Package view DND no longer works either.

Did SWT change anything wrt. Motif DND that could have broken this?
Comment 1 Knut Radloff CLA 2002-10-09 16:47:15 EDT
This stopped working going from SWT build 2106 to 2107.
Comment 2 Veronika Irvine CLA 2002-10-10 10:20:59 EDT
Between 2106 and 2107 I added the code to fix 22959 - the case where you had 
multiple drop targets stacked on top of one another.

Reassign the bug to Platform SWT and I will investigate.

Comment 3 Knut Radloff CLA 2002-10-10 11:29:30 EDT
Note that getFocusControl returning null may be a separate issue or it may be 
the reason why the DragEnter event is not sent. 
DragEnter event is handled by NavigatorDropAdapter.dragEnter
Comment 4 Veronika Irvine CLA 2003-01-30 08:57:37 EST
SWT is behaving as expected.  This is a problem in the UI code.

The reason you are getting no feedback during drag over is because on drag 
enter you are setting the event.detail field to DND_DROP_NONE.  Once the 
event.detail field is set on drag enter it will not be changed by SWT unless 
the user does something to change the operation such as hold down the shift key 
or the control key.  What you are seeing is the correct feedback for 
DND.DROP_NONE.

The reason you are setting the event.detail to DND.DROP_NONE is because in 
NavigatorDropAdaptor.validateTarget you return false with the message "Cannot 
move <file name>.  The source and destination are the same".

In subsequent drag over callbacks you are also getting the same error message 
from validateTarget even though the source is still <file name> from drag enter 
and the target passed in to validateTarget is whatever file or folder you are 
currently above.

Note that on motif there is no API in Table to have both a selection and 
a "drop selection".  On windows, I can call native code to get this effect.  
Therefore, as the cursor moves over different items in the tree, the selection 
in the tree changes.  If you are asking the tree for its current selection to 
determine the drag source data each time you get an event, then you will not 
get the correct info.  You need to store the drag source selection somewhere 
when the drag source initiates the drag and not rely on the selection in the 
tree.

As an aside: Why does NavigatorDropAdapter implement its own tree expansion? 
ResourceNavigator.initDragAndDrop calls setFeedbackEnabled(false) which turns 
off the for free tree expansion provided by SWT.  By doing your own expansion 
you are potentially behaving differently which is not good.
Comment 5 Knut Radloff CLA 2003-01-30 13:19:27 EST
SWT must have done something a while ago because the original bug says I did 
not get a DragEnter event. Anyway, I realized that the way I do a local drag 
within the same widget is bogus and added a LocalSelectionTransfer when I fixed 
bug 29778.
Drag move works fine. Drag move is not allowed within the same folder. It works 
when you drag to a different folder.
Drag copy is a different story on Motif. The drop doesn't happen when I release 
the mouse. I'll have to look into it. validateTarget returns true in that case 
so it should work.

setFeedbackEnabled(false) only turns off the insertion feedback. I'm not sure 
why the navigator does its own auto expand. Perhaps SWT added that feature at 
some point when the navigator drop support was already written? I'll get rid of 
the code. Thanks for pointing it out!
Comment 6 Knut Radloff CLA 2003-01-30 13:39:38 EST
I figured out why copy does not work.
When the dragged item is already selected I get all the normal drag behavior 
except for the final drop event. When the dragged item is not selected when I 
start the drag (i.e., the drag click selects it) I do get the drop event and 
the drag succeeds.
Comment 7 Knut Radloff CLA 2003-01-30 13:43:11 EST
Updated bug 30249 with the findings from comment #6. Closing this bug since 
original problem is fixed.