diff options
| author | Jens Baumgart | 2010-08-11 16:46:00 +0000 |
|---|---|---|
| committer | Chris Aniszczyk | 2010-08-11 20:40:10 +0000 |
| commit | 247ef7cd289b745715a7294517a558fdc70008c2 (patch) | |
| tree | 958f954f25a5332096b490e0f036e8f385159abd | |
| parent | 80c4652c22ce05151abfc4f5e4709a38befc6453 (diff) | |
| download | egit-247ef7cd289b745715a7294517a558fdc70008c2.tar.gz egit-247ef7cd289b745715a7294517a558fdc70008c2.tar.xz egit-247ef7cd289b745715a7294517a558fdc70008c2.zip | |
Fix bug in General Project Import
Enable import as general project if the repository folder
is child of the workspace root.
Bug: 322260
Change-Id: I9ea0df65fbc4c75fdd82f0d6f2707f196e54aa1b
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2 files changed, 33 insertions, 10 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCreateGeneralProjectPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCreateGeneralProjectPage.java index 77fc94b939..c01913b020 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCreateGeneralProjectPage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCreateGeneralProjectPage.java @@ -16,6 +16,7 @@ import java.io.FilenameFilter; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.egit.ui.UIText; @@ -47,6 +48,8 @@ public class GitCreateGeneralProjectPage extends WizardPage { private IProject[] wsProjects; + private boolean defaultLocation; + /** * Creates a new project creation wizard page. * @@ -59,6 +62,12 @@ public class GitCreateGeneralProjectPage extends WizardPage { setPageComplete(false); setTitle(UIText.WizardProjectsImportPage_ImportProjectsTitle); setDescription(UIText.WizardProjectsImportPage_ImportProjectsDescription); + // check for default location: is workspace location parent of path? + IPath parent = new Path(path).removeLastSegments(1); + if(ResourcesPlugin.getWorkspace().getRoot().getLocation().equals(parent)) + defaultLocation = true; + else + defaultLocation = false; } /** @@ -96,7 +105,10 @@ public class GitCreateGeneralProjectPage extends WizardPage { .setText(UIText.GitCreateGeneralProjectPage_ProjectNameLabel); projectText = new Text(workArea, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(projectText); - projectText.addModifyListener(new ModifyListener() { + if(defaultLocation) + projectText.setEnabled(false); + else + projectText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { checkPage(); @@ -130,6 +142,13 @@ public class GitCreateGeneralProjectPage extends WizardPage { return projectText.getText(); } + /** + * @return true if the project has default location + */ + public boolean isDefaultLocation() { + return defaultLocation; + } + private void checkPage() { String projectName = projectText.getText(); setErrorMessage(null); @@ -183,14 +202,16 @@ public class GitCreateGeneralProjectPage extends WizardPage { projectName)); return; } - IProject newProject = ResourcesPlugin.getWorkspace().getRoot() - .getProject(projectName); - IStatus locationResult = ResourcesPlugin.getWorkspace() - .validateProjectLocation(newProject, - new Path(myDirectory.getPath())); - if (!locationResult.isOK()) { - setErrorMessage(locationResult.getMessage()); - return; + if(!defaultLocation) { + IProject newProject = ResourcesPlugin.getWorkspace().getRoot() + .getProject(projectName); + IStatus locationResult = ResourcesPlugin.getWorkspace() + .validateProjectLocation(newProject, + new Path(myDirectory.getPath())); + if (!locationResult.isOK()) { + setErrorMessage(locationResult.getMessage()); + return; + } } } finally { setPageComplete(getErrorMessage() == null); diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCreateProjectViaWizardWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCreateProjectViaWizardWizard.java index dae346e5c0..2b084fb167 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCreateProjectViaWizardWizard.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCreateProjectViaWizardWizard.java @@ -241,6 +241,7 @@ public class GitCreateProjectViaWizardWizard extends Wizard implements try { final String projectName = myCreateGeneralProjectPage .getProjectName(); + final boolean defaultLocation = myCreateGeneralProjectPage.isDefaultLocation(); getContainer().run(true, false, new WorkspaceModifyOperation() { @@ -255,7 +256,8 @@ public class GitCreateProjectViaWizardWizard extends Wizard implements .getWorkspace() .newProjectDescription( projectName); - desc.setLocation(new Path(myGitDir)); + if (!defaultLocation) + desc.setLocation(new Path(myGitDir)); IProject prj = ResourcesPlugin .getWorkspace().getRoot() |
