Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 267849

Summary: [ui] Can't drag URL into "Add Site" dialog's location field
Product: [Eclipse Project] Equinox Reporter: Andrew Overholt <overholt>
Component: p2Assignee: Susan McCourt <susan>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: irbull, leberre, pascal, susan
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux-GTK   
Whiteboard:
Attachments:
Description Flags
o.e.equinox.p2.ui patch
none
o.e.equinox.p2.ui patch none

Description Andrew Overholt CLA 2009-03-10 09:58:12 EDT
As per:

http://wiki.eclipse.org/Equinox/p2/UI_Manual_Tests#Sanity_checking_of_the_repositories

I was trying to drag the 3.5 I-build URL into the "Add Site" Location field entry box and I got nothing.  I was, however, able to drag it into the Name field.
Comment 1 Susan McCourt CLA 2009-03-10 11:47:47 EDT
That is odd, I'm seeing the correct behavior on windows.
Marking 3.5 to investigate and at least doc.
Comment 2 Susan McCourt CLA 2009-03-10 18:46:38 EDT
*** Bug 267973 has been marked as a duplicate of this bug. ***
Comment 3 Susan McCourt CLA 2009-03-11 10:53:32 EDT
Pascal, are you seeing this on Mac or this is a Linux-only problem?
Comment 4 Ian Bull CLA 2009-03-11 11:33:32 EDT
Is this related (a dup) of Bug 223991?
Comment 5 Pascal Rapicault CLA 2009-03-11 12:01:15 EDT
There is something funny about the setup of this location field because I can drag on the "work with" field of the "available software" dialog but not on the location.
Comment 6 Susan McCourt CLA 2009-03-11 12:18:27 EDT
(In reply to comment #4)
> Is this related (a dup) of Bug 223991?

Definitely a platform difference, but this bug deserves special attention.  Bug 223991 documents platform differences in drag/drop, stuff we can doc for users.  ie, "drag works in X field on Windows, but not Linux" or "different drag sources behave differently on different platforms."

This bug is weirder.

Andrew and Daniel are seeing that the *name* field accepts the drop, but the location field does not.  That is definitely not right.   On Windows, it works as expected.  

Either there's a subtle bug on the wizard code (I looked briefly to make sure I'm setting the drop target on the right widget, but it could be something more subtle), or else a subtle SWT bug.  

(In reply to comment #5)
> There is something funny about the setup of this location field because I can
> drag on the "work with" field of the "available software" dialog but not on the
> location.
> 

Pascal, on the Mac does the Name field accept the drag?
Comment 7 Daniel Le Berre CLA 2009-03-11 12:23:42 EDT
Susan,

Just one thought: the difference between the name and the location field is that the location field cannot be empty.

I have no idea how this is encoded in java/SWT but could it be a sort of decorator on the field itself, which means that the drop target should be the decorator, not the field?

Comment 8 Susan McCourt CLA 2009-03-11 12:29:17 EDT
(In reply to comment #7)
> Susan,
> 
> Just one thought: the difference between the name and the location field is
> that the location field cannot be empty.
> 
> I have no idea how this is encoded in java/SWT but could it be a sort of
> decorator on the field itself, which means that the drop target should be the
> decorator, not the field?

I don't think so.  Our UI code is setting up an SWT drop target on the location widget.  The enforcement of "can't be empty" is above SWT, in our code.

My suspicion is that it somehow involves the widget parentage, but this is just a hunch.  My plan is to write an SWT snippet that mimics our usage and if it fails in the same way, we can assume the bug is SWT.  If not, then something is subtly wrong in my code...
Comment 9 Susan McCourt CLA 2009-04-16 17:51:20 EDT
I've double checked my code.  The SWT drop target is being set up on the correct widget.  My previous hunch was that the widget parentage might be weird, and indeed it was a bit wonky.  I changed this to fix a layout problem in bug 268002, so I'm wondering if I happen to have fixed this problem.

If not, I'll write an SWT snippet and forward this bug to SWT.

Pascal - can you check on the Mac.  You should be able to drag a URL from a browser to the location field, but not the name field.

Daniel and/or Andrew - can you check on Linux?

You'll need the code from HEAD or the 20090416 N-build, or the next I-build to pick up the change I made in bug 268002.

Comment 10 Ian Bull CLA 2009-04-17 01:23:23 EDT
I just checked this on linux with the latest from head, and it still doesn't work (for me at least).  

Comment 11 Ian Bull CLA 2009-04-17 02:04:27 EDT
Created attachment 132173 [details]
o.e.equinox.p2.ui patch

It seems that our drop targets are not setup the way snippet 284 describes.  

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet284.java?view=co

I used this snippet as a template and it appears to work on Linux now.  (I don't know if it still works on Windows :))
Comment 12 Ian Bull CLA 2009-04-17 02:06:01 EDT
Created attachment 132174 [details]
o.e.equinox.p2.ui patch

It seems that our drop targets are not setup the way snippet 284 describes.  

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet284.java?view=co

I used this snippet as a template and it appears to work on Linux now.  (I don't know if it still works on Windows :))
Comment 13 Ian Bull CLA 2009-04-17 02:35:10 EDT
Sorry, I should have said, this isn't a patch to fix it, it just demonstrates that it is possible on Linux. I am looking at the root cause now.  It appears that in URLDropAdapter#dropTargetIsValid(DropTargetEvent event) we call

URLTransfer.getInstance().nativeToJava(event.currentDataType) and this returns null on linux.  If I remove this check, it works fine. (However, I assume this check is here for a reason).  

On linux it looks like the event.currentDataType is not properly setup until after the drop occurs.  This means that we cannot call nativeToJava until after the drop happens.  On other platforms I assume this can be called during the drop hover.

Comment 14 Susan McCourt CLA 2009-04-17 11:17:13 EDT
thanks, Ian...
Is it still true that you *can* drag to the name field in the same dialog?  That's the part of this bug report that really threw me.
Comment 15 Ian Bull CLA 2009-04-17 11:37:34 EDT
Yes, 

Actually, there is no drop target set for the nickname field, so by default swt text fields must accept text drops.  Our drop target on the location field is just a little too restrictive on linux. I'm not sure if this is an SWT bug, or we can just remove the 

 && URLTransfer.getInstance().nativeToJava(event.currentDataType) != null)

in the hover event. I guess since there is different behviour on different platforms this is an SWT bug, but for 3.5 it might be easier just to remove this check.  (We already check that the text being dropped is a URL).

Comment 16 Susan McCourt CLA 2009-04-17 11:49:46 EDT
(In reply to comment #15)
> Yes, 
> 
> Actually, there is no drop target set for the nickname field, so by default swt
> text fields must accept text drops.  

I see....so that's another platform difference.  Because on windows the name field doesn't accept a drop (as expected).  That is the part that led me to believe this bug was something different.

Our drop target on the location field is
> just a little too restrictive on linux. I'm not sure if this is an SWT bug, or
> we can just remove the 
> 
>  && URLTransfer.getInstance().nativeToJava(event.currentDataType) != null)
> 
> in the hover event. I guess since there is different behviour on different
> platforms this is an SWT bug, but for 3.5 it might be easier just to remove
> this check.  (We already check that the text being dropped is a URL).
> 

So this is the "prefetch" problem described in bug 223991 (as you first mentioned).  I will mark this as a duplicate of that bug.  

Thanks, Ian, for helping to sort this out.



*** This bug has been marked as a duplicate of bug 223991 ***