aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Kinzler2010-04-26 07:20:19 (EDT)
committerChris Aniszczyk2010-04-26 16:32:29 (EDT)
commit2a37cbe8457669294d7bdd2e930f5f7cb0fc88bb (patch)
tree604362b395bceb32c6777f8277029f96e5be5d22
parentd94684dfa0313def9a9b5afdefc0b5e3af6e6350 (diff)
downloadegit-2a37cbe8457669294d7bdd2e930f5f7cb0fc88bb.zip
egit-2a37cbe8457669294d7bdd2e930f5f7cb0fc88bb.tar.gz
egit-2a37cbe8457669294d7bdd2e930f5f7cb0fc88bb.tar.bz2
RepositoriesView: use the GitImportProject wizardrefs/changes/01/601/4
The generic ImportExistingProject wizard from the org.eclipse.ui.ide plug-in does not allow to specify a directory in 3.4. Instead of the generic ImportExistingProject wizard, the RepositoriesView should use the Git wizard which allows to limit the scope to a directory in the file system and also adds project filtering capabilities as well as the option to add the imported projects to Team support. Change-Id: I4b66358e98a960af6c88e8d6656d24a6ee5279bb Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitImportProjectsWizard.java64
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java11
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java102
3 files changed, 77 insertions, 100 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitImportProjectsWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitImportProjectsWizard.java
new file mode 100644
index 0000000..5160755
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitImportProjectsWizard.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2010 SAP AG.
+ * 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
+ *
+ * Contributors:
+ * Mathias Kinzler (SAP AG) - initial implementation
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.clone;
+
+import java.io.File;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jgit.lib.Repository;
+
+/**
+ * A wizard used to import existing projects from a {@link Repository}
+ */
+public class GitImportProjectsWizard extends Wizard {
+
+ private final String myWorkingDir;
+
+ private final File myGitDir;
+
+ /**
+ * @param repository
+ * the repository
+ * @param path
+ * a path, either the working directory of the repository or a
+ * sub-directory thereof
+ */
+ public GitImportProjectsWizard(Repository repository, String path) {
+ super();
+ myWorkingDir = path;
+ myGitDir = repository.getDirectory();
+ setWindowTitle("Import existing projects");
+ }
+
+ @Override
+ public void addPages() {
+
+ GitProjectsImportPage page = new GitProjectsImportPage() {
+
+ @Override
+ public void setVisible(boolean visible) {
+ setGitDir(myGitDir);
+ setProjectsList(myWorkingDir);
+ super.setVisible(visible);
+ }
+
+ };
+ addPage(page);
+ }
+
+ @Override
+ public boolean performFinish() {
+ GitProjectsImportPage page = (GitProjectsImportPage) getPages()[0];
+ return page.createProjects();
+
+ }
+
+}
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 e6134a4..43ec84c 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
@@ -220,16 +220,7 @@ public class GitProjectsImportPage extends WizardPage {
* Creates a new project creation wizard page.
*/
public GitProjectsImportPage() {
- this("gitWizardExternalProjectsPage"); //$NON-NLS-1$
- }
-
- /**
- * Create a new instance of the receiver.
- *
- * @param pageName
- */
- public GitProjectsImportPage(String pageName) {
- super(pageName);
+ super("gitWizardExternalProjectsPage"); //$NON-NLS-1$
setPageComplete(false);
setTitle(UIText.WizardProjectsImportPage_ImportProjectsTitle);
setDescription(UIText.WizardProjectsImportPage_ImportProjectsDescription);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
index 68898d6..ed3fc59 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
@@ -50,6 +50,7 @@ import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIIcons;
import org.eclipse.egit.ui.UIText;
import org.eclipse.egit.ui.internal.clone.GitCloneWizard;
+import org.eclipse.egit.ui.internal.clone.GitImportProjectsWizard;
import org.eclipse.egit.ui.internal.repository.RepositoryTreeNode.RepositoryTreeNodeType;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
@@ -97,7 +98,6 @@ import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.ui.views.properties.PropertySheet;
import org.eclipse.ui.views.properties.PropertySheetPage;
-import org.eclipse.ui.wizards.datatransfer.ExternalProjectImportWizard;
import org.osgi.service.prefs.BackingStoreException;
/**
@@ -834,97 +834,19 @@ public class RepositoriesView extends ViewPart implements ISelectionProvider {
@Override
public void widgetSelected(SelectionEvent e) {
- // TODO the ExternalProjectImportWizard
- // does not allow to set a path in 3.4
- // use the GitCloneWizard page in a new
- // GitImportWizard instead
- Wizard wiz = new ExternalProjectImportWizard() {
-
- @Override
- public void addPages() {
- super.addPages();
- // we could add some page with a single
- }
-
- @Override
- public boolean performFinish() {
-
- final Set<IPath> previousLocations = new HashSet<IPath>();
- // we want to share only new projects
- for (IProject project : ResourcesPlugin.getWorkspace()
- .getRoot().getProjects()) {
- previousLocations.add(project.getLocation());
- }
-
- boolean success = super.performFinish();
- if (success) {
- // IWizardPage page = getPage("Share");
- // TODO evaluate checkbox or such, but
- // if we do share
- // always, we don't even need another
- // page
-
- IWorkspaceRunnable wsr = new IWorkspaceRunnable() {
-
- public void run(IProgressMonitor monitor)
- throws CoreException {
- File gitDir = repo.getDirectory();
- File gitWorkDir = repo.getWorkDir();
- Path workPath = new Path(gitWorkDir
- .getAbsolutePath());
-
- // we check which projects are
- // in the workspace
- // pointing to a location in the
- // repo's
- // working directory
- // and share them
- for (IProject prj : ResourcesPlugin
- .getWorkspace().getRoot()
- .getProjects()) {
-
- if (workPath.isPrefixOf(prj
- .getLocation())) {
- if (previousLocations.contains(prj
- .getLocation())) {
- continue;
- }
- ConnectProviderOperation connectProviderOperation = new ConnectProviderOperation(
- prj, gitDir);
- connectProviderOperation
- .run(new SubProgressMonitor(
- monitor, 20));
-
- }
- }
-
- }
- };
-
- try {
- ResourcesPlugin.getWorkspace().run(
- wsr,
- ResourcesPlugin.getWorkspace()
- .getRoot(),
- IWorkspace.AVOID_UPDATE,
- new NullProgressMonitor());
- scheduleRefresh();
- } catch (CoreException ce) {
- MessageDialog
- .openError(
- getShell(),
- UIText.RepositoriesView_Error_WindowTitle,
- ce.getMessage());
- }
-
- }
- return success;
- }
-
- };
+ // Instead of the generic ExternalProjectImportWizard
+ // from the org.eclipse.ui.ide plug-in, we use our
+ // own wizard (the generic one does not allow to set the
+ // path in 3.4; in addition, we have added project filtering
+ // capabilities)
+ Wizard wiz = new GitImportProjectsWizard(repo, path);
WizardDialog dlg = new WizardDialog(getSite().getShell(), wiz);
- dlg.open();
+ if (dlg.open() == Window.OK)
+ // TODO if we drop the "existing projects" node, we can
+ // probably do without refresh
+ scheduleRefresh();
+
}
});