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

Bug 73767

Summary: Dragging a folder into package explorer defaults to overwrite existing folder
Product: [Eclipse Project] JDT Reporter: Randy Hudson <hudsonr>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, markus.kell.r, Mike_Wilson, susan, sxenos
Version: 3.0Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Randy Hudson CLA 2004-09-13 11:46:45 EDT
If you drag a folder into a project in the packages view, and that project 
contains the same folder, you are prompted to *overwrite* the existing folder.  
This differs from the default behavior of the platform, which is to merge the 
existing folders, and overwrite and existing *files* of the same name.  If the 
user mistakes this for the default behavior the contents of the folder will be 
lost.

I didn't actually select "yes", so I don't know if overwrite meant the entire 
folder or just any conflicting files (in which case only the message needs 
fixing).

This problem sounds familiar and may have been fixed in navigator, but not 
packages view.
Comment 1 Markus Keller CLA 2004-09-13 13:23:03 EDT
Unfortunatly, we cannot solve this without help from platform/core (see bug 31883).

*** This bug has been marked as a duplicate of 37954 ***
Comment 2 Randy Hudson CLA 2004-09-13 13:56:31 EDT
I don't see this as a dupe.  If I select "No" from the dialog, the folder is 
merged. So I don't see and missing capabilities in core.  The merging of two 
folders occurs normally.  The problem is in the message, choices, and the 
default button.
Comment 3 Markus Keller CLA 2004-09-14 05:52:58 EDT
Randy, could you please be more specific?
- What is the relevant structure of the source and target of the operation?
- from where to where (View  / OS file explorer) do you drag?
- is to operation a "move" or a "copy"?

The Packages view does not show projects nor folders. Are you talking about the
Package Explorer, or you are moving (copying?) packages?

I could reproduce this scenario which also fails in Resource Navigator:
zzz (Java Project)
+ src (source folder)
  + a (package)
    + A.java

Somewhere else in the file system, have:
...
+ a (folder)
  + file.txt

Now drag-and-drop the folder '.../a' from an OS file explorer onto the source
folder 'src'. A dialog asks: "zzz/src/a exists. Do you want to overwrite?" with
options "Yes", "Yes to All", "No", "Cancel".

Clicking "No" yields the behavior from comment 2.
Clicking "Yes" yields an NPE and no copying taking place:
Error Sep 14, 2004 11:41:41.313 Exception in
org.eclipse.ui.actions.CopyFilesAndFoldersOperation.performCopy():
java.lang.NullPointerException

Moving to Platform/UI, since the bugs are in CopyFilesAndFoldersOperation (also
when dropping to the Package Explorer, since we delegate to
CopyFilesAndFoldersOperation in this situation).
Comment 4 Randy Hudson CLA 2004-09-14 12:02:08 EDT
I was dragging from File Explorer to the Packages view. I was dragging an HTML 
file plus a directory called "images" with several GIF files in it. I was 
prompted to replace the existing "images" folder and selected "NO", upon which 
the two folders were merged.

Merging should be the default behavior.  And the user should be prompted 
whether that want to overwrite individual *files*, not the whole holder.  this 
would be more consistent with the platform's file management.
Comment 5 Michael Van Meekeren CLA 2004-09-14 12:58:03 EDT
I agree with Randy on the last point: clicking "No" should not have merged the
files as the message does not clearly state that is what will happen and
clicking Yes means overwrite AND merge files.  You sort of assume that no is the
opposite of yes in this case.
Markus what build to you get the NPE on?  I can not recreate this on this
mornings UI code from HEAD running on the 3.0.1 build from 0908.
Comment 6 Michael Van Meekeren CLA 2004-09-14 13:02:17 EDT
found a different bug while testing where you can not create both a file and
folder of the same name from the navigator or package explorer, however this is
not a problem.

see bug 73894 
Comment 7 Randy Hudson CLA 2004-09-14 13:31:39 EDT
According to the message, YES means replace the entire folder, not overwrite 
individual files.  So perhaps only the message needs to be corrected.  Compare 
this to the message displayed in File Explorer.
Comment 8 Markus Keller CLA 2004-09-14 13:51:23 EDT
Michael: I can reproduce the NPE on a fresh install of 3.1-I200409140800.
On 3.0.1-M200409081421, there's no NPE, but the folders are merged regardless
whether I press "Yes" or "No". "Cancel" cancels in all cases.

Randy: I cannot drop anything from outside eclipse onto the Packages view (which
is one of the Java Browsing views). If I read "Package Explorer" where you write
"Packages", then I can confirm your observations.
Comment 9 Randy Hudson CLA 2004-09-14 14:08:27 EDT
Yes, Package Explorer.  I don't think anyone uses the PAckages View ;-)
Comment 10 Michael Van Meekeren CLA 2004-09-14 15:56:17 EDT
thanks Markus , please log a separate bug for your NPE
Comment 11 Markus Keller CLA 2004-09-15 03:35:57 EDT
> please log a separate bug for your NPE
Done: bug 73962.
Comment 12 Mike Wilson CLA 2007-06-22 15:47:04 EDT
Note that on the Mac, the *platform* behavior is to always replace the old directory with the new one. That is, it does not merge them.

Comment 13 Susan McCourt CLA 2009-07-15 11:54:22 EDT
"As per http://wiki.eclipse.org/Platform_UI/Bug_Triage_Change_2009"
Comment 14 Susan McCourt CLA 2009-07-15 11:56:23 EDT
oops...this bug refers to the Package Explorer behavior (not navigator or project explorer).  Moving to JDT-UI.
Comment 15 Dani Megert CLA 2009-09-02 04:50:23 EDT
This is still an issues but now the dialog is different: it asks to skip the folder. Same behavior in Project Explorer but Navigator works as expected.
Comment 16 Dani Megert CLA 2010-04-07 04:22:42 EDT
>This is still an issues but now the dialog is different: it asks to skip the
>folder. 
Improving the 'Skip' by actually supporting merge is covered by bug 37954.