Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Muskalla2010-08-02 11:30:08 +0000
committerChris Aniszczyk2010-08-04 15:41:51 +0000
commit3f2df4e8ddf1206c8ff1cdb93d4c990666d59284 (patch)
tree448be497b9a553a8b5965a1984586a61c5795643
parentd418845e423fe8a39242bad850429ad84b814404 (diff)
downloadegit-3f2df4e8ddf1206c8ff1cdb93d4c990666d59284.tar.gz
egit-3f2df4e8ddf1206c8ff1cdb93d4c990666d59284.tar.xz
egit-3f2df4e8ddf1206c8ff1cdb93d4c990666d59284.zip
Use project name from project description file
When we have a .project file, we should always create the project metainformation based on this file. I don't see any reason to use the file path to determinate the project name. In addition, Platform.getLocation has nothing to do with the workspace but rather the working directory of the platform. Also refactored the ProjectRecord a little bit to simplify it. This also fixes bug 314035 to use the project name of the .project file. Bug: 314035 Change-Id: I589c510550946be9b92d00746c3f4bb91447d515 Signed-off-by: Benjamin Muskalla <bmuskalla@eclipsesource.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/ProjectRecord.java49
1 files changed, 8 insertions, 41 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/ProjectRecord.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/ProjectRecord.java
index 0099247284..7807c0fba4 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/ProjectRecord.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/ProjectRecord.java
@@ -1,11 +1,10 @@
-package org.eclipse.egit.ui.internal.clone;
-
/*******************************************************************************
* Copyright (c) 2004, 2008 IBM Corporation and others.
* Copyright (C) 2007, Martin Oberhuber (martin.oberhuber@windriver.com)
* Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2009, Mykola Nikishov <mn@mn.com.ua>
* Copyright (C) 2010, Wim Jongman <wim.jongman@remainsoftware.com>
+ * Copyright (C) 2010, Benjamin Muskalla <bmuskalla@eclipsesource.com>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -13,6 +12,8 @@ package org.eclipse.egit.ui.internal.clone;
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
+package org.eclipse.egit.ui.internal.clone;
+
import java.io.File;
import org.eclipse.core.resources.IProjectDescription;
@@ -20,7 +21,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.egit.ui.UIText;
import org.eclipse.osgi.util.NLS;
@@ -38,53 +38,24 @@ class ProjectRecord {
*/
ProjectRecord(File file) {
projectSystemFile = file;
- setProjectName();
+ initProjectDescription();
}
/**
* Set the name of the project based on the projectFile.
*/
- private void setProjectName() {
+ private void initProjectDescription() {
try {
- // If we don't have the project name try again
- if (projectName == null) {
IPath path = new Path(projectSystemFile.getPath());
- // if the file is in the default location, use the directory
- // name as the project name
- if (isDefaultLocation(path)) {
- projectName = path.segment(path.segmentCount() - 2);
- description = ResourcesPlugin.getWorkspace()
- .newProjectDescription(projectName);
- } else {
- description = ResourcesPlugin.getWorkspace()
- .loadProjectDescription(path);
- projectName = description.getName();
- }
-
- }
+ description = ResourcesPlugin.getWorkspace()
+ .loadProjectDescription(path);
+ projectName = description.getName();
} catch (CoreException e) {
// no good couldn't get the name
}
}
/**
- * Returns whether the given project description file path is in the
- * default location for a project
- *
- * @param path
- * The path to examine
- * @return Whether the given path is the default location for a project
- */
- private boolean isDefaultLocation(IPath path) {
- // The project description file must at least be within the project,
- // which is within the workspace location
- if (path.segmentCount() < 2)
- return false;
- return path.removeLastSegments(2).toFile().equals(
- Platform.getLocation().toFile());
- }
-
- /**
* Get the name of the project
*
* @return String
@@ -98,12 +69,8 @@ class ProjectRecord {
* UI.
*
* @return String the label
- * @since 3.4
*/
public String getProjectLabel() {
- if (description == null)
- return projectName;
-
String path = projectSystemFile.getParent();
return NLS.bind(UIText.WizardProjectsImportPage_projectLabel,

Back to the top