Bug 35540 - [Viewers] [DND] Insert feedback in ViewerDropAdapter not longer working
Summary: [Viewers] [DND] Insert feedback in ViewerDropAdapter not longer working
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.0   Edit
Assignee: Knut Radloff CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-22 11:45 EST by Bram Stieperaere CLA
Modified: 2003-05-26 14:54 EDT (History)
1 user (show)

See Also:


Attachments
Recommended fix (path file) (1.43 KB, text/plain)
2003-04-14 11:30 EDT, John Arthorne CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bram Stieperaere CLA 2003-03-22 11:45:03 EST
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.
Comment 1 Nick Edgar CLA 2003-03-25 22:23:08 EST
When did this stop working for you?  Was it between 2.0.2 and 2.1, or earlier?
Comment 2 Bram Stieperaere CLA 2003-03-26 03:39:36 EST
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. 
Comment 3 Nick Edgar CLA 2003-03-26 09:37:44 EST
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.
Comment 4 Veronika Irvine CLA 2003-03-26 11:01:42 EST
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.
Comment 5 John Arthorne CLA 2003-04-14 11:30:34 EDT
Created attachment 4576 [details]
Recommended fix (path file)
Comment 6 John Arthorne CLA 2003-04-14 11:35:06 EDT
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.
Comment 7 Knut Radloff CLA 2003-04-15 10:26:34 EDT
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.
Comment 8 Knut Radloff CLA 2003-04-17 11:03:02 EDT
Released fix. Fixed in >20030417.