Bug 164695 - [Workbench] Project copy doesn't validate location and uses invalid location as default
Summary: [Workbench] Project copy doesn't validate location and uses invalid location ...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: IDE (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.4 M6   Edit
Assignee: Tod Creasey CLA
QA Contact:
URL:
Whiteboard: hasPatch
Keywords: contributed
: 32670 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-11-15 14:19 EST by John Arthorne CLA
Modified: 2008-03-25 08:00 EDT (History)
4 users (show)

See Also:


Attachments
Patch attachement (1.09 KB, patch)
2007-02-28 09:00 EST, Jakub Jurkiewicz CLA
no flags Details | Diff
Patch for I20071213-1700 (860 bytes, patch)
2008-01-29 01:44 EST, 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 John Arthorne CLA 2006-11-15 14:19:34 EST
Build: I2006114

1) Create a new project whose location is outside the workspace (say c:\temp\p1).
2) Select the project in the Navigator, and Hit Ctrl+C, Ctrl+V.
3) The project copy dialog opens. Accept the default and hit Ok.

-> An error occurs because the location overlaps the location of the project being copied.  There are two problems here:

a) If the project is not in the default location, it should populate the dialog with a new location that is different from the original location (such as c:\temp\Copy of P1). I.e., it should provide reasonable defaults that don't cause the copy to fail.
b) The location provided in the dialog should be validated using IWorkspace#validateProjectLocation.  The Ok button should be greyed out until a valid location is supplied.
Comment 1 John Arthorne CLA 2006-11-15 14:20:36 EST
CCing Susan: in case this is code you are still working in.
Comment 2 Susan McCourt CLA 2006-11-15 16:49:45 EST
I'm not working in here now, but I'll check against M2 behavior and see if this is a regression I caused.  
Comment 3 Susan McCourt CLA 2006-11-15 18:06:09 EST
Verified this bug occurs in M2 and in 3.2.1.

The default location proposal is not valid, yet there is no initial validation performed.  (For example, backspace and retype the last character of the project name, and now the location is validated).

The default location is chosen in ProjectContentsLocationArea using the existing project's location name.  So it will always be wrong when using it for a project copy. 

I'll leave this up to the current owner to sort out...
Comment 4 Tod Creasey CLA 2006-11-27 09:57:35 EST
Not a Vista specific problem
Comment 5 Jakub Jurkiewicz CLA 2007-02-28 09:00:09 EST
Created attachment 59971 [details]
Patch attachement

Nobody was assigned to this bug, so I tried to create a patch. I hope that I understood well, what the problem was about.
Please verify my work.
Comment 6 Tod Creasey CLA 2007-06-21 10:54:20 EDT
Thanks for the patch!
Comment 7 Tod Creasey CLA 2007-10-11 11:15:28 EDT
Jakub this patch does not update the path.

I think the problem here is that the new location is the old location by default when it should be based on the new name.

For instance if I copy a project Foo in c:\foo I will get a name Copy of Foo but the default directory will still be c:\foo not c:\copy of foo.

I think a better solution would be to always use the default location in the copy dialog as there is no good way to guess another one.
Comment 8 Francis Upton IV CLA 2008-01-29 01:44:30 EST
Created attachment 88094 [details]
Patch for  I20071213-1700

Actually this problem has a very simple solution.  Use a different constructor in calling the ProjectContentsLocationArea that does not pass the existing project.  For a copy, the location of the existing project is irrelevant.  We always want to have the default location suggested, and have the default location in the file system.

I tested this patch copying both projects that have a default location and ones that don't and it works fine.

Also, I think this bug 32670 is a dup of this one.
Comment 9 Francis Upton IV CLA 2008-02-08 18:22:22 EST
Tod, can you have a look my recent patch?; I think it's pretty straightforward and would be nice to get in.
Comment 10 Tod Creasey CLA 2008-02-14 12:52:13 EST
Patch released for build >20080214
Comment 11 Tod Creasey CLA 2008-03-24 15:15:55 EDT
Verified in I20080323-2000
Comment 12 Tod Creasey CLA 2008-03-25 08:00:48 EDT
*** Bug 32670 has been marked as a duplicate of this bug. ***