Bug 197113 - Project Explorer drag and drop selection not working properly
Summary: Project Explorer drag and drop selection not working properly
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Linux-GTK
: P3 major (vote)
Target Milestone: 3.4 RC1   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 226162 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-07-19 06:43 EDT by Mark Robinson CLA
Modified: 2008-05-24 00:39 EDT (History)
6 users (show)

See Also:
bokowski: review?
emoffatt: review+


Attachments
Patch for 3.4M5 (1.90 KB, patch)
2008-02-12 04:06 EST, Francis Upton IV CLA
no flags Details | Diff
Added correct copyright notice to the patch and updated it per HEAD (2.68 KB, patch)
2008-05-06 13:45 EDT, Francis Upton IV CLA
no flags Details | Diff
Revised to call hookControl() per Boris' suggestion (2.69 KB, patch)
2008-05-13 15:09 EDT, Francis Upton IV CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Robinson CLA 2007-07-19 06:43:06 EDT
Create a new java project.
Open Project Explorer.
Create 2 new classes - Test1 and Test2.
Close the java code editors.
Select Test1.java in the project explorer.
Select Test2.java by doing a mouse down only (so Test1.java still appears highlighted) then drag Test2.java into the code editor area ()- Test1.java is displayed.

This only occurs in the Project Explorer, the package explorer works fine.
Comment 1 Francis Upton IV CLA 2007-12-15 02:06:02 EST
This is a problem only with the CommonNavigator and it's pretty serious.  

If you click on an element in the tree and drag it, and that element was not previously the selected element, it will end up dropping the previously selected element (even though the drag feedback [at least on Linux] reports that it's dragging the desired element).

The problem seems to be caused by the selection caching mechanism in the CommonViewer.  It is not reporting the current selection correctly.  I verified this by creating a subclass of the CommonNavigator for testing purposes, and overriding the CommonViewer to not use the selection caching.  The problem went away.  I'm sorry I don't have the time to try and come up with a patch to fix the caching mechanism.

I have only verified this problem on Linux, but it makes DnD with the CommonNavigator essentially useless, as you can't predict what's going to happen.  I hope this can be fixed in a 3.3.x maintenance release.
Comment 2 Francis Upton IV CLA 2008-02-11 20:17:51 EST
Another way to reproduce this (without using the Java stuff) is:

1) Create a folder1.
2) Create file1 (in a folder outside of folder1) 
3) Create file2 (in a folder outside of folder1)
4) Mouse down on file1 and drag to folder1
5) bug: file2 (which was previously selected) will go in folder1, not file1 as expected.
Comment 3 Francis Upton IV CLA 2008-02-12 04:06:47 EST
Created attachment 89482 [details]
Patch for 3.4M5

The problem is the caching mechanism added by bug 144294 had a bug.  The DragStart event appears before the SelectionEvent, and inside of the handling of the DragStart event getSelection() was called, getting the old selection.

This patch resets the cache on a mouse down which is a pretty big hammer, but should address the problem.  (I tested it and it works fine on my Linux machine).

This caching mechanism should really not be here, as it's fairly brittle and should be tested on all platforms.  


********* Attention: this is a very serious problem with the CommonNavigator on Linux (and possibly other non-Windows systems), rendering it effectively unusable, because the element you think you are dragging is *not* the element you are actually dragging, even though the GUI feedback shows that it is.  I strongly recommend the solution to this bug be put in a 3.3.x maintenance release.
Comment 4 Francis Upton IV CLA 2008-02-12 04:09:15 EST
Boris, I think you should look at this a little, as it's related to some earlier issues you were involved in.  Bugs 144294 and 140032.
Comment 5 Francis Upton IV CLA 2008-02-12 04:18:24 EST
See bug 218604 which is a proposal to remove the caching from the CommonViewer.
Comment 6 Boris Bokowski CLA 2008-02-12 14:58:01 EST
escalating...

McQ, would we want to put a fix for this into 3.3.2 still?

Quoting from comment #3: "this is a very serious problem with the CommonNavigator on Linux, rendering it effectively unusable, because the element you think you are dragging is *not* the element you are actually dragging, even though the GUI feedback shows that it is."

The problem happens if the element being dragged was not already selected.
Comment 7 Mike Wilson CLA 2008-02-12 15:34:44 EST
Thanks for bringing this to my attention, Boris. It does seem like a relatively nasty bug to me (given the incorrect drag feedback). However, based on conversation with you, it also appears that the bug was introduced in 3.2.1, and wasn't fixed for 3.2.2, 3.3, or 3.3.1, so I can't bring myself to argue that we should crack open 3.3.2 at this late date.

Let's do a solid fix for 3.4, and take the time to ensure that there are no performance impacts, or other unexpected consequences.

Michael (Elder) you're flagged as the owner for this bug. Have you been tracking what's been going on here?

Comment 8 Michael D. Elder CLA 2008-02-13 09:12:05 EST
I agree it's worth fixing for 3.4, and agree with McQ that a fix for 3.2.2 is probably not the best option given how old the issue is. 

I'll target early next week to review and release the patch. 
Comment 9 Francis Upton IV CLA 2008-02-13 14:13:03 EST
(In reply to comment #8)
> I agree it's worth fixing for 3.4, and agree with McQ that a fix for 3.2.2 is
> probably not the best option given how old the issue is. 
> 
> I'll target early next week to review and release the patch. 
> 

How about let's fix 218604 (reduce the number of calls to getSelection) and just remove the caching mechanism?  I can work a patch for that bug.  I think that's the cleanest solution, as caching this is problematic.
Comment 10 Francis Upton IV CLA 2008-05-06 10:35:51 EDT
Boris, can you and Michael (or someone) get this patch in for RC1?  This is really important for 3.4.  I wanted to do the removal of caching as mentioned in bug 218604, but I think I waited too long for 3.4, I'm still interested in that for 3.5.
Comment 11 Francis Upton IV CLA 2008-05-06 13:45:48 EDT
Created attachment 98892 [details]
Added correct copyright notice to the patch and updated it per HEAD
Comment 12 Boris Bokowski CLA 2008-05-06 15:09:58 EDT
Tom, +1 for RC1?
Comment 13 Boris Bokowski CLA 2008-05-07 16:56:44 EDT
Tom, +1?
Comment 14 Boris Bokowski CLA 2008-05-08 17:01:55 EDT
Eric, +1 for RC1?
Comment 15 Eric Moffatt CLA 2008-05-13 09:10:26 EDT
+1 (and I agree that the cache should go away in the future)
Comment 16 Francis Upton IV CLA 2008-05-13 15:09:22 EDT
Created attachment 100016 [details]
Revised to call hookControl() per Boris' suggestion
Comment 17 Boris Bokowski CLA 2008-05-13 15:43:48 EDT
Looks better. Eric, +1?
Comment 18 Francis Upton IV CLA 2008-05-15 11:04:12 EDT
Hi Erik, sorry to bug you, but please check this today so we can get this in.  Thanks.
Comment 19 Eric Moffatt CLA 2008-05-15 14:10:43 EDT
no prob...+1 (and hookControl looks to be the right place)...

I can't really test the patch since it always worked on XP (the selection happens on the mouse down).
Comment 20 Eric Moffatt CLA 2008-05-15 15:03:01 EDT
Committed (on Francis' behalf) in >20080515.

Francis/Boris, I'll leave it to you to manage the defect's state...
Comment 21 Boris Bokowski CLA 2008-05-15 16:48:39 EDT
Marking as fixed.
Comment 22 Francis Upton IV CLA 2008-05-24 00:39:18 EDT
*** Bug 226162 has been marked as a duplicate of this bug. ***