Community
Participate
Working Groups
I used ViewerDropAdapter to implement the drop part of drag and drop for a TreeViewer. By default this should give visual feedback (insert before or insert after marker) when hovering between two treeitems of the underlaying tree. This does not happen anymore. I looked in the code and found out that this happens by setting DND.FEEDBACK_BEFORE or DND.FEEDBACK_AFTER bits set in the event.feedback attribute. But somehow the feedback is not shown. I found how to get it working when I copied ViewerDropAdapter into MyViewerDropAdapter,and I change the method private void setFeedBack(DropTargetEvent event, int location){ .. case LOCATION_BEFORE: event.feedback |= DND.FEEDBACK_INSERT_BEFORE; break; case LOCATION_AFTER: event.feedback |= DND.FEEDBACK_INSERT_AFTER; break; .. } into private void setFeedBack(DropTargetEvent event, int location){ .. case LOCATION_BEFORE: event.feedback |= DND.FEEDBACK_INSERT_BEFORE; event.feedback &= ~DND.FEEDBACK_SELECT; break; case LOCATION_AFTER: event.feedback |= DND.FEEDBACK_INSERT_AFTER; event.feedback &= ~DND.FEEDBACK_SELECT; break; .. } so, you have to un-set the DND.FEEDBACK_SELECT flag when you want either FEEDBACK_INSERT_BEFORE or _AFTER feedback showing. I think this is because of the method TreeDragUnderEffect.checkEffect(int effect) which literally states that DND.FEEDBACK_INSERT_BEFORE, DND.FEEDBACK_SELECT, DND.FEEDBACK_INSERT_AFTER are mutually exclusive, and erases all of them when more than one is set.
When did this stop working for you? Was it between 2.0.2 and 2.1, or earlier?
sorry, cannot tell, I have not been writing Eclipse code for a while. It used to work in Eclipse 1. Now (using version 2.1.0) it seems broken. Someone on the newsgroup suggested that maybe it is a change in the SWT, that now a DND.FEEDBACK_SELECT is set by default.
We made a change in the Navigator to not use the separator line. Since the items are sorted, it would be misleading to suggest that an item can be inserted at an arbitrary position. It's possible that this change was made down in ViewerDropAdapter. Veronika, do you know if there was any SWT change in this area? Bram, you tagged this PR against version 2.0.2 of Eclipse. Is this accurate? Above you only mention 1.0 and 2.1.
This check for mutual exclusion of selection and insertion markers was added Oct. 22, 2001 (early on the 2.0 development). I think the TreeViewer code needs to remove the seletion feedback when adding the insertion feedback.
Created attachment 4576 [details] Recommended fix (path file)
The two changes in SWT caused the ViewerDropAdapter to break. First, selection feedback is now default, and second, it clears the feedback if more than one kind of feedback is set. The ViewerDropAdapter added the feedback using OR, so FEEDBACK_INSERT_AFTER and FEEDBACK_INSERT_BEFORE no longer work. The attached patch is the recommended fix to ViewerDropAdapter. It sets the feedback without using OR, so it replaces any default value. This bug exists in release 2.1.
When I try to apply the patch file Eclipse complains that it contains more than one patch. However, the fix is obvious and I applied it manually. Thanks for the patch, John.
Released fix. Fixed in >20030417.