Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java22
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java29
2 files changed, 45 insertions, 6 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 c5592ce277..f988aa2405 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
@@ -4,6 +4,7 @@ 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>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -94,6 +95,12 @@ public class GitProjectsImportPage extends WizardPage {
IProjectDescription description;
/**
+ * Relative path to repository, '../.git' is by default. If you'll set
+ * it null you're on your own, no checks for null performed.
+ */
+ File repository = new File("../.git"); //$NON-NLS-1$
+
+ /**
* Create a record for a project based on the info in the file.
*
* @param file
@@ -104,6 +111,19 @@ public class GitProjectsImportPage extends WizardPage {
}
/**
+ * Create a record for a project based on the info in the file.
+ *
+ * @param file
+ * @param aRepository
+ * relative path to repository
+ */
+ ProjectRecord(File file, File aRepository) {
+ projectSystemFile = file;
+ setProjectName();
+ repository = aRepository;
+ }
+
+ /**
* @param parent
* The parent folder of the .project file
* @param level
@@ -712,7 +732,7 @@ public class GitProjectsImportPage extends WizardPage {
monitor, openTicks));
if (share) {
ConnectProviderOperation connectProviderOperation = new ConnectProviderOperation(
- project);
+ project, record.repository);
connectProviderOperation
.run(new SubProgressMonitor(monitor, 20));
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java
index c546e3cbff..87893278f4 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java
@@ -1,5 +1,6 @@
/*******************************************************************************
* Copyright (C) 2009, Robin Rosenberg
+ * Copyright (C) 2009, Mykola Nikishov <mn@mn.com.ua>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,8 +11,11 @@ package org.eclipse.egit.ui.internal.sharing;
import java.io.File;
import java.io.IOException;
+import java.net.URI;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -121,7 +125,7 @@ class ExistingOrNewPage extends WizardPage {
try {
Repository repository = new Repository(gitDir);
repository.create();
- for (IProject project : getProjects()) {
+ for (IProject project : getProjects().keySet()) {
// If we don't refresh the project directories right
// now we won't later know that a .git directory
// exists within it and we won't mark the .git
@@ -228,10 +232,25 @@ class ExistingOrNewPage extends WizardPage {
return true;
}
- public IProject[] getProjects() {
- IProject[] ret = new IProject[tree.getSelection().length];
- for (int i = 0; i < ret.length; ++i)
- ret[i] = (IProject)tree.getSelection()[i].getData();
+ /**
+ * @return map between project and repository root directory (converted to a
+ * path relative to project's root) for all projects selected by
+ * user
+ */
+ public Map<IProject, File> getProjects() {
+ final TreeItem[] selection = tree.getSelection();
+ Map<IProject, File> ret = new HashMap<IProject, File>(selection.length);
+ for (int i = 0; i < selection.length; ++i) {
+ final TreeItem treeItem = selection[i];
+ final IProject project = (IProject) treeItem.getData();
+ final File selectedRepo = new File(treeItem.getText(2));
+ File localPathToRepo = selectedRepo;
+ if (selectedRepo.isAbsolute()) {
+ final URI projectLocation = project.getLocationURI();
+ localPathToRepo = new File(projectLocation.relativize(selectedRepo.toURI()).getPath());
+ }
+ ret.put(project, localPathToRepo);
+ }
return ret;
}
}

Back to the top