aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-25 18:31:01 (EDT)
committerChris Aniszczyk2011-05-05 20:22:59 (EDT)
commit59bfd0df475f9036c408a4dc310862c33499eeb8 (patch)
tree78a266d185d505959ed0c4280d5109c00d7d43bc
parent3fb03e8738f17fad7be37c4d8c894849feeb37dc (diff)
downloadegit-github-59bfd0df475f9036c408a4dc310862c33499eeb8.zip
egit-github-59bfd0df475f9036c408a4dc310862c33499eeb8.tar.gz
egit-github-59bfd0df475f9036c408a4dc310862c33499eeb8.tar.bz2
Add import wizard for bulk adding GitHub task repositoriesrefs/changes/50/3250/2
Change-Id: Idca217ba34757e6a1eb63b6bf9717680f37c2712 Signed-off-by: Kevin Sawicki <kevin@github.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.mylyn.github.ui/plugin.properties3
-rw-r--r--org.eclipse.mylyn.github.ui/plugin.xml10
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/ImportRepositoriesWizard.java117
3 files changed, 129 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.github.ui/plugin.properties b/org.eclipse.mylyn.github.ui/plugin.properties
index e20b049..8751f28 100644
--- a/org.eclipse.mylyn.github.ui/plugin.properties
+++ b/org.eclipse.mylyn.github.ui/plugin.properties
@@ -3,4 +3,5 @@ org.eclipse.mylyn.github.ui.internal.GitHubRepositoryConnectorUI=GitHub reposito
gistCoreConnectorName=GitHub Gist repository connector
gistUiConnectorName=GitHub Gist repository connector UI
pluginName=Mylyn GitHub Connector UI (Incubation)
-providerName=Eclipse EGit \ No newline at end of file
+providerName=Eclipse EGit
+importRepositoriesWizardName=GitHub Task Repositories \ No newline at end of file
diff --git a/org.eclipse.mylyn.github.ui/plugin.xml b/org.eclipse.mylyn.github.ui/plugin.xml
index 33c1376..da73b42 100644
--- a/org.eclipse.mylyn.github.ui/plugin.xml
+++ b/org.eclipse.mylyn.github.ui/plugin.xml
@@ -101,5 +101,15 @@
overlayIcon="icons/obj16/github_8x8.png">
</connectorUi>
</extension>
+ <extension
+ point="org.eclipse.ui.importWizards">
+ <wizard
+ category="org.eclipse.mylyn.tasks.ui.wizards.import.category"
+ class="org.eclipse.mylyn.github.ui.internal.ImportRepositoriesWizard"
+ icon="icons/obj16/github.png"
+ id="org.eclipse.mylyn.github.ui.importRepositoriesWizard"
+ name="%importRepositoriesWizardName">
+ </wizard>
+ </extension>
</plugin>
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/ImportRepositoriesWizard.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/ImportRepositoriesWizard.java
new file mode 100644
index 0000000..bae092b
--- /dev/null
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/ImportRepositoriesWizard.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * 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:
+ * Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.github.ui.internal;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
+import org.eclipse.mylyn.commons.net.AuthenticationType;
+import org.eclipse.mylyn.github.internal.GitHub;
+import org.eclipse.mylyn.github.internal.Repository;
+import org.eclipse.mylyn.internal.github.core.gist.GistConnector;
+import org.eclipse.mylyn.internal.github.ui.gist.GistRepositorySettingsPage;
+import org.eclipse.mylyn.internal.github.ui.gist.Messages;
+import org.eclipse.mylyn.internal.tasks.core.IRepositoryConstants;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
+import org.eclipse.ui.internal.WorkbenchImages;
+
+/**
+ * Import repositories wizard class.
+ *
+ * @author Kevin Sawicki (kevin@github.com)
+ */
+public class ImportRepositoriesWizard extends Wizard implements IImportWizard {
+
+ private CredentialsWizardPage credentialsPage;
+
+ private RepositorySelectionWizardPage reposPage;
+
+ /**
+ * Create import repositories wizard
+ */
+ public ImportRepositoriesWizard() {
+ setNeedsProgressMonitor(true);
+ setDefaultPageImageDescriptor(WorkbenchImages
+ .getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_IMPORT_WIZ));
+ }
+
+ /**
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ public void addPages() {
+ this.credentialsPage = new CredentialsWizardPage();
+ addPage(this.credentialsPage);
+ this.reposPage = new RepositorySelectionWizardPage();
+ addPage(this.reposPage);
+ }
+
+ /**
+ * @see org.eclipse.jface.wizard.Wizard#getNextPage(org.eclipse.jface.wizard.IWizardPage)
+ */
+ public IWizardPage getNextPage(IWizardPage page) {
+ IWizardPage next = super.getNextPage(page);
+ if (next == reposPage) {
+ reposPage.setUser(credentialsPage.getUserName());
+ reposPage.setPassword(credentialsPage.getPassword());
+ }
+ return next;
+ }
+
+ /**
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
+ * org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+
+ }
+
+ /**
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ public boolean performFinish() {
+ String user = credentialsPage.getUserName();
+ String password = credentialsPage.getPassword();
+ for (Object selected : reposPage.getRepositories()) {
+ Repository repo = (Repository) selected;
+ AuthenticationCredentials credentials = new AuthenticationCredentials(
+ user, password);
+ TaskRepository repository = new TaskRepository(
+ GitHub.CONNECTOR_KIND, GitHub.createGitHubUrl(
+ repo.getOwner(), repo.getName()));
+ repository.setProperty(IRepositoryConstants.PROPERTY_LABEL,
+ repo.getId());
+ repository.setCredentials(AuthenticationType.REPOSITORY,
+ credentials, true);
+ repository.setProperty(IRepositoryConstants.PROPERTY_CATEGORY,
+ IRepositoryConstants.CATEGORY_BUGS);
+ TasksUi.getRepositoryManager().addRepository(repository);
+ }
+ if (reposPage.createGistRepository()) {
+ AuthenticationCredentials credentials = new AuthenticationCredentials(
+ user, password);
+ TaskRepository repository = new TaskRepository(GistConnector.KIND,
+ GistRepositorySettingsPage.URL);
+ repository.setProperty(IRepositoryConstants.PROPERTY_LABEL,
+ Messages.GistRepositorySettingsPage_RepositoryLabelDefault);
+ repository.setCredentials(AuthenticationType.REPOSITORY,
+ credentials, true);
+ repository.setProperty(IRepositoryConstants.PROPERTY_CATEGORY,
+ IRepositoryConstants.CATEGORY_REVIEW);
+ TasksUi.getRepositoryManager().addRepository(repository);
+ }
+ return true;
+ }
+}