aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Trutz2011-06-12 18:01:27 (EDT)
committerKevin Sawicki2011-06-12 18:01:27 (EDT)
commit07e1a5df14f594144e085a7386ae6cb68fc46b97 (patch)
treefa5821523d2f0c2fe0fbc206bc2cc133beb65fcd
parent25dabf49f20931cfbc7479676f82205d1ee7ffc6 (diff)
downloadegit-github-07e1a5df14f594144e085a7386ae6cb68fc46b97.zip
egit-github-07e1a5df14f594144e085a7386ae6cb68fc46b97.tar.gz
egit-github-07e1a5df14f594144e085a7386ae6cb68fc46b97.tar.bz2
Import Wizard for Github repositories.refs/changes/03/3603/3
Change-Id: I5d7d61e066a1bdb7b4f644cc75ff83418e955845 Signed-off-by: Christian Trutz <christian.trutz@gmail.com> Signed-off-by: Kevin Sawicki <kevin@github.com>
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java5
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java19
-rw-r--r--org.eclipse.mylyn.github.ui/plugin.properties3
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/Messages.java6
-rwxr-xr-xorg.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/RepositoryImportWizard.java46
-rwxr-xr-xorg.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/RepositorySearchWizardPage.java123
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/messages.properties2
7 files changed, 203 insertions, 1 deletions
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java
index 3e5525b..066b6fc 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java
@@ -26,6 +26,11 @@ public interface IGitHubConstants {
String SEGMENT_SHOW = "/show"; //$NON-NLS-1$
/**
+ * SEGMENT_SEARCH
+ */
+ String SEGMENT_SEARCH = "/search"; //$NON-NLS-1$
+
+ /**
* SEGMENT_ORGANIZATIONS
*/
String SEGMENT_ORGANIZATIONS = "/organizations"; //$NON-NLS-1$
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java
index 11ec359..5efa631 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java
@@ -113,6 +113,25 @@ public class RepositoryService extends GitHubService {
}
/**
+ * Search repositories
+ *
+ * @param query
+ * @return list of repositories
+ * @throws IOException
+ */
+ public List<Repository> searchRepositories(String query) throws IOException {
+ StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_V2_API);
+ uri.append(IGitHubConstants.SEGMENT_REPOS);
+ uri.append(IGitHubConstants.SEGMENT_SEARCH);
+ uri.append('/').append(query);
+
+ PagedRequest<Repository> request = createPagedRequest();
+ request.setUri(uri);
+ request.setType(RepositoryContainer.class);
+ return getAll(request);
+ }
+
+ /**
* Create a new repository
*
* @param repository
diff --git a/org.eclipse.mylyn.github.ui/plugin.properties b/org.eclipse.mylyn.github.ui/plugin.properties
index f6fcb70..2a4da57 100644
--- a/org.eclipse.mylyn.github.ui/plugin.properties
+++ b/org.eclipse.mylyn.github.ui/plugin.properties
@@ -8,4 +8,5 @@ importRepositoriesWizardName=GitHub Task Repositories
githubMenuLabel=GitHub
createGistPublicParamName=Public Gist
createPublicGistLabel=Create Public Gist
-createPrivateGistLabel=Create Private Gist \ No newline at end of file
+createPrivateGistLabel=Create Private Gist
+cloneGitHubRepository=Projects from GitHub
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/Messages.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/Messages.java
index 03d5344..2f882ed 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/Messages.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/Messages.java
@@ -38,6 +38,12 @@ public class Messages extends NLS {
public static String CredentialsWizardPage_Title;
/** */
+ public static String RepositorySearchWizardPage_SearchButton;
+
+ /** */
+ public static String RepositorySearchWizardPage_SearchForRepositories;
+
+ /** */
public static String RepositorySelectionWizardPage_Description;
/** */
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/RepositoryImportWizard.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/RepositoryImportWizard.java
new file mode 100755
index 0000000..62e9af7
--- /dev/null
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/RepositoryImportWizard.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Christian Trutz
+ * 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:
+ * Christian Trutz - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.internal.github.ui;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * {@link IImportWizard} for cloning GitHub repositories.
+ */
+public class RepositoryImportWizard extends Wizard implements IImportWizard {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addPages() {
+ addPage(new RepositorySearchWizardPage());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean performFinish() {
+ // TODO clone GitHub repositotry via egit
+ return true;
+ }
+
+}
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/RepositorySearchWizardPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/RepositorySearchWizardPage.java
new file mode 100755
index 0000000..6d6e8f1
--- /dev/null
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/RepositorySearchWizardPage.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Christian Trutz
+ * 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:
+ * Christian Trutz - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.internal.github.ui;
+
+import java.io.IOException;
+
+import org.eclipse.egit.github.core.Repository;
+import org.eclipse.egit.github.core.client.GitHubClient;
+import org.eclipse.egit.github.core.client.IGitHubConstants;
+import org.eclipse.egit.github.core.service.RepositoryService;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Search for GitHub repositories wizard page.
+ */
+public class RepositorySearchWizardPage extends WizardPage {
+
+ private Text searchForText;
+ private Button searchButton;
+ private List repoList;
+ private ListViewer repoListViewer;
+
+ /**
+ *
+ */
+ protected RepositorySearchWizardPage() {
+ super(RepositorySearchWizardPage.class.getName());
+ setPageComplete(false);
+ }
+
+ /**
+ *
+ */
+ public void createControl(Composite parent) {
+ final Composite root = new Composite(parent, SWT.NONE);
+ setControl(root);
+ root.setLayout(new GridLayout(3, false));
+
+ Label searchForLabel = new Label(root, SWT.NONE);
+ searchForLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,
+ false, 3, 1));
+ searchForLabel
+ .setText(Messages.RepositorySearchWizardPage_SearchForRepositories);
+
+ searchForText = new Text(root, SWT.BORDER);
+ searchForText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
+ false, 2, 1));
+
+ searchButton = new Button(root, SWT.NONE);
+ searchButton.setText(Messages.RepositorySearchWizardPage_SearchButton);
+ searchButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent selectionEvent) {
+
+ Shell shell = root.getShell();
+ Cursor prevCursor = shell.getCursor();
+ Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
+ shell.setCursor(busy);
+ try {
+
+ GitHubClient client = new GitHubClient(
+ IGitHubConstants.HOST_API_V2, -1,
+ IGitHubConstants.PROTOCOL_HTTPS);
+ RepositoryService repositoryService = new RepositoryService(
+ client);
+ java.util.List<Repository> repositories = repositoryService
+ .searchRepositories(searchForText.getText());
+ repoListViewer.setInput(repositories.toArray());
+ } catch (IOException ioException) {
+ repoListViewer.setInput(new Object[] {});
+ GitHubUi.logError(ioException);
+ } finally {
+ shell.setCursor(prevCursor);
+ busy.dispose();
+ }
+
+ setPageComplete(false);
+ }
+ });
+
+ repoListViewer = new ListViewer(root, SWT.BORDER | SWT.V_SCROLL);
+ repoList = repoListViewer.getList();
+ repoList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3,
+ 1));
+ repoListViewer.setContentProvider(new ArrayContentProvider());
+ repoListViewer.setLabelProvider(new LabelProvider());
+ repoListViewer
+ .addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ setPageComplete(!repoListViewer.getSelection()
+ .isEmpty());
+
+ }
+ });
+
+ }
+}
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/messages.properties b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/messages.properties
index f2f485b..73c00cd 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/messages.properties
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/messages.properties
@@ -4,6 +4,8 @@ CredentialsWizardPage_ErrorUser=Enter GitHub login name
CredentialsWizardPage_LabelPassword=Password:
CredentialsWizardPage_LabelUser=User ID:
CredentialsWizardPage_Title=GitHub Credentials
+RepositorySearchWizardPage_SearchButton=Search
+RepositorySearchWizardPage_SearchForRepositories=Search for repositories that have to do with:
RepositorySelectionWizardPage_Description=Select repositories to import
RepositorySelectionWizardPage_ErrorLoading=Error loading repositories: {0}
RepositorySelectionWizardPage_LabelAddGist=Add Gist task repository