Bug 312540 - [LinkedResources] Copy resource in Navigator and Project Explorer always shows dialog
Summary: [LinkedResources] Copy resource in Navigator and Project Explorer always show...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: IDE (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.7   Edit
Assignee: Serge Beauchamp CLA
QA Contact:
URL:
Whiteboard:
Keywords: polish
Depends on:
Blocks:
 
Reported: 2010-05-12 03:53 EDT by Dani Megert CLA
Modified: 2011-03-29 08:36 EDT (History)
3 users (show)

See Also:
serge: review? (Szymon.Brandys)
daniel_megert: review+


Attachments
Screenshot (10.01 KB, image/png)
2011-03-24 10:27 EDT, Oleg Besedin CLA
no flags Details
Patch, with no API change (6.42 KB, patch)
2011-03-24 21:08 EDT, Serge Beauchamp CLA
daniel_megert: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2010-05-12 03:53:54 EDT
N20100511-2000.

When copying an IFile from one to another folder in the Navigator or Project Explorer, I always get the dialog no matter how I've set the preferences on the 'Linked Resources' page (even if I disable linked resources).
Comment 1 Dani Megert CLA 2011-03-22 07:42:22 EDT
This is still the case in 3.7 M6.
Comment 2 Serge Beauchamp CLA 2011-03-23 20:07:43 EDT
Hi, can you be more specific please?

I'm trying to reproduce the issue with 3.7m6 and 3.6.2 without success.

I tried the following:

Having a project with two folders:

p1/
   folder1/
   folder2/

I have file.txt under folder1/.

I drag and drop file.txt while holding the <cntl> key onto folder2/
Result:  it copies the file without showing any dialog

I drag and drop file.txt while holding the <cntl> key onto folder2/
Result:  it moves the file without showing any dialog

I tried also with two different projects, on MacOS X and WIndows 7, without success.
Comment 3 Dani Megert CLA 2011-03-24 03:12:13 EDT
> I'm trying to reproduce the issue with 3.7m6 and 3.6.2 without success.

Maybe you used the Package Explorer instead of the Project Explorer or Navigator? It works fine in the Package Explorer.
Comment 4 Oleg Besedin CLA 2011-03-24 10:27:44 EDT
Created attachment 191825 [details]
Screenshot

For me, Project Explorer works fine, but Ctrl+drag in Navigator produces the dialog.
Comment 5 Oleg Besedin CLA 2011-03-24 10:30:41 EDT
(And if I change "Linked Resources" property to "Copy" drag-and-drop items on a folder or a project, it still shows the link dialog.)
Comment 6 Dani Megert CLA 2011-03-24 11:44:44 EDT
> For me, Project Explorer works fine, but Ctrl+drag in Navigator produces the
> dialog.
Note for me using N20110323-2000: Ctrl+drag to copy a simple file from one folder to another in the Project Explorer gives me the dialog. Can you check again?
Comment 7 Dani Megert CLA 2011-03-24 11:47:19 EDT
Note that the bug exists when copying normal files not just linked resources.
Comment 8 Serge Beauchamp CLA 2011-03-24 12:03:58 EDT
(In reply to comment #3)
> > I'm trying to reproduce the issue with 3.7m6 and 3.6.2 without success.
> 
> Maybe you used the Package Explorer instead of the Project Explorer or
> Navigator? It works fine in the Package Explorer.

Ah, you're right, thanks, I can reproduce it with the Project Explorer.  I'l get back to you shortly on it.
Comment 9 Oleg Besedin CLA 2011-03-24 14:39:21 EDT
(In reply to comment #6)
> > For me, Project Explorer works fine, but Ctrl+drag in Navigator produces the
> > dialog.
> Note for me using N20110323-2000: Ctrl+drag to copy a simple file from one
> folder to another in the Project Explorer gives me the dialog. Can you check
> again?

Yes, using N20110323-2000 no dialog for me in Project Explorer; and I get the dialog in Navigator. Same using I20110310-1119.

This is Windows 7 using 64bit stack.

The behavior does not seem to change when I set "Linked Resources" property to "Copy". Even if I uncheck "Enable linked resources" the dialog still appears in Navigator.
Comment 10 Serge Beauchamp CLA 2011-03-24 21:08:27 EDT
Created attachment 191881 [details]
Patch, with no API change

Considering the current state of 3.7, the current fix does not require API change.
Comment 11 Serge Beauchamp CLA 2011-03-24 21:16:31 EDT
to explain what the changes are (since the diff is confusing), the previous code was 

{display dialog and do copy}

And the new code:

IPreferenceStore store= IDEWorkbenchPlugin.getDefault().getPreferenceStore();
String dndPreference= store.getString(target.isVirtual() ?   
     IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE : 
     IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE);
if (dndPreference.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT)) {
    {display dialog and do copy}
}
else
    operation.copyResources(sources, target);
Comment 12 Serge Beauchamp CLA 2011-03-29 04:11:11 EDT
Szymon and Daniel, could you review this fix please?

thanks,
Comment 13 Dani Megert CLA 2011-03-29 06:35:49 EDT
The patch works and looks good. The only thing we might consider for 3.8 is whether we remove the code duplication and add a helper to CopyFilesAndFoldersOperation similar to copyOrLinkFiles(String[], IContainer, int).

BTW: you don't need PMC +1 since there's no API change involved.
Comment 14 Dani Megert CLA 2011-03-29 06:37:06 EDT
Serge, please update the copyright date in both files when committing to HEAD.
Comment 15 Serge Beauchamp CLA 2011-03-29 08:36:30 EDT
Thanks.  this is now committed on head, along with copyright date updates.