summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorRyan Schmitt2010-05-12 04:11:39 (EDT)
committer Matthias Sohn2010-05-12 04:11:39 (EDT)
commite1b0a72f34ed00da4f66397edd4f044cef477a27 (patch)
treefe53dc56e9fb098fd5a2890c0166e2e7c3dcb8d4
parent4397edb6478e768ed6474c6d622a22edac69e20d (diff)
downloadegit-e1b0a72f34ed00da4f66397edd4f044cef477a27.zip
egit-e1b0a72f34ed00da4f66397edd4f044cef477a27.tar.gz
egit-e1b0a72f34ed00da4f66397edd4f044cef477a27.tar.bz2
Refactored GitProjectsImportPagerefs/changes/30/530/2
Extract inner class ProjectRecord to improve readability. [ms] : rebased to current master Change-Id: Iec631ae27610ccf147c4ac3445aead9d017b07ef Signed-off-by: Ryan Schmitt <ryan.schmitt@boeing.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java106
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/ProjectRecord.java136
2 files changed, 137 insertions, 105 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java
index cf3ae8f..14bf0d8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java
@@ -82,110 +82,6 @@ public class GitProjectsImportPage extends WizardPage {
private IImportStructureProvider structureProvider;
- class ProjectRecord {
- File projectSystemFile;
-
- String projectName;
-
- Object parent;
-
- int level;
-
- IProjectDescription description;
-
- /**
- * Create a record for a project based on the info in the file.
- *
- * @param file
- */
- ProjectRecord(File file) {
- projectSystemFile = file;
- setProjectName();
- }
-
- /**
- * @param parent
- * The parent folder of the .project file
- * @param level
- * The number of levels deep in the provider the file is
- */
- ProjectRecord(Object parent, int level) {
- this.parent = parent;
- this.level = level;
- setProjectName();
- }
-
- /**
- * Set the name of the project based on the projectFile.
- */
- private void setProjectName() {
- 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();
- }
-
- }
- } 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
- */
- public String getProjectName() {
- return projectName;
- }
-
- /**
- * Gets the label to be used when rendering this project record in the
- * UI.
- *
- * @return String the label
- * @since 3.4
- */
- public String getProjectLabel() {
- if (description == null)
- return projectName;
-
- String path = projectSystemFile == null ? structureProvider
- .getLabel(parent) : projectSystemFile.getParent();
-
- return NLS.bind(UIText.WizardProjectsImportPage_projectLabel,
- projectName, path);
- }
- }
-
private TreeViewer projectsList;
private ProjectRecord[] selectedProjects = new ProjectRecord[0];
@@ -346,7 +242,7 @@ public class GitProjectsImportPage extends WizardPage {
else
item.setChecked(false);
}
- return ((ProjectRecord) element).getProjectLabel();
+ return ((ProjectRecord) element).getProjectLabel(structureProvider);
}
});
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
new file mode 100644
index 0000000..75c450c
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/ProjectRecord.java
@@ -0,0 +1,136 @@
+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>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProjectDescription;
+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;
+import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
+
+class ProjectRecord {
+ File projectSystemFile;
+
+ String projectName;
+
+ Object parent;
+
+ int level;
+
+ IProjectDescription description;
+
+ /**
+ * Create a record for a project based on the info in the file.
+ *
+ * @param file
+ */
+ ProjectRecord(File file) {
+ projectSystemFile = file;
+ setProjectName();
+ }
+
+ /**
+ * @param parent
+ * The parent folder of the .project file
+ * @param level
+ * The number of levels deep in the provider the file is
+ */
+ ProjectRecord(Object parent, int level) {
+ this.parent = parent;
+ this.level = level;
+ setProjectName();
+ }
+
+ /**
+ * Set the name of the project based on the projectFile.
+ */
+ private void setProjectName() {
+ 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();
+ }
+
+ }
+ } 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
+ */
+ public String getProjectName() {
+ return projectName;
+ }
+
+ /**
+ * Gets the label to be used when rendering this project record in the
+ * UI.
+ * @param structureProvider
+ *
+ * @return String the label
+ * @since 3.4
+ */
+ public String getProjectLabel(IImportStructureProvider structureProvider) {
+ if (description == null)
+ return projectName;
+
+ String path = projectSystemFile == null ? structureProvider
+ .getLabel(parent) : projectSystemFile.getParent();
+
+ return NLS.bind(UIText.WizardProjectsImportPage_projectLabel,
+ projectName, path);
+ }
+
+ @Override
+ public String toString() {
+ return projectName;
+ }
+} \ No newline at end of file