summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-14 17:07:14 (EDT)
committer Chris Aniszczyk2011-04-19 18:40:17 (EDT)
commit6bf7a7089ff288e2a0f236fade271a57bea4981b (patch)
treeec3eb124031528bcfc57924a16b51113a794aa9c
parent5ee3f2cca3501446b616904d484e68d6c6d74d1b (diff)
downloadegit-github-6bf7a7089ff288e2a0f236fade271a57bea4981b.zip
egit-github-6bf7a7089ff288e2a0f236fade271a57bea4981b.tar.gz
egit-github-6bf7a7089ff288e2a0f236fade271a57bea4981b.tar.bz2
Update gist notification popup to open gist in task editorrefs/changes/26/3126/3
Change-Id: I4e7e446723741aa160e5d3fc315f4cbf34a89234 Signed-off-by: Kevin Sawicki <kevin@github.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/CreateGistHandler.java13
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/CreateGistJob.java3
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GistNotificationPopup.java21
3 files changed, 28 insertions, 9 deletions
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/CreateGistHandler.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/CreateGistHandler.java
index 637413b..e4371b4 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/CreateGistHandler.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/CreateGistHandler.java
@@ -26,8 +26,8 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.github.internal.GistService;
-import org.eclipse.mylyn.github.internal.GitHub;
import org.eclipse.mylyn.github.internal.GitHubClient;
+import org.eclipse.mylyn.internal.github.core.gist.GistConnector;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.ui.IEditorInput;
@@ -37,6 +37,14 @@ import org.eclipse.ui.handlers.HandlerUtil;
public class CreateGistHandler extends AbstractHandler {
+ /**
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ public boolean isEnabled() {
+ return !TasksUi.getRepositoryManager()
+ .getRepositories(GistConnector.KIND).isEmpty();
+ }
+
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
ISelection selection = HandlerUtil.getCurrentSelection(event);
@@ -65,7 +73,8 @@ public class CreateGistHandler extends AbstractHandler {
private void createGistJob(String name, String extension, String contents) {
Set<TaskRepository> repositories = TasksUi.getRepositoryManager()
- .getRepositories(GitHub.CONNECTOR_KIND);
+ .getRepositories(GistConnector.KIND);
+
TaskRepository repository = repositories.iterator().next();
GitHubClient client = new GitHubClient();
AuthenticationCredentials credentials = repository
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/CreateGistJob.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/CreateGistJob.java
index 94e516e..fcc4e56 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/CreateGistJob.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/CreateGistJob.java
@@ -56,8 +56,7 @@ public class CreateGistJob extends Job {
@SuppressWarnings("restriction")
public void run() {
GistNotificationPopup popup = new GistNotificationPopup(
- PlatformUI.getWorkbench().getDisplay(), created
- .getId(), title);
+ PlatformUI.getWorkbench().getDisplay(), created, title);
popup.create();
popup.open();
}
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GistNotificationPopup.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GistNotificationPopup.java
index 4cc8444..71adb7f 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GistNotificationPopup.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GistNotificationPopup.java
@@ -10,7 +10,14 @@
*******************************************************************************/
package org.eclipse.mylyn.github.ui.internal;
+import java.util.Set;
+
+import org.eclipse.mylyn.github.internal.Gist;
+import org.eclipse.mylyn.internal.github.core.gist.GistConnector;
import org.eclipse.mylyn.internal.provisional.commons.ui.AbstractNotificationPopup;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -26,13 +33,13 @@ import org.eclipse.swt.widgets.Link;
@SuppressWarnings("restriction")
public class GistNotificationPopup extends AbstractNotificationPopup {
- private String id;
+ private Gist gist;
private String title;
- public GistNotificationPopup(Display display, String id, String title) {
+ public GistNotificationPopup(Display display, Gist gist, String title) {
super(display);
- this.id = id;
+ this.gist = gist;
this.title = title;
}
@@ -42,14 +49,18 @@ public class GistNotificationPopup extends AbstractNotificationPopup {
Label label = new Label(composite, SWT.NONE);
label.setText("Title: " + title);
Link link = new Link(composite, SWT.WRAP);
- link.setText("Created Gist: <a>" + id + "</a>");
+ link.setText("Created Gist: <a>" + gist.getId() + "</a>");
link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
link.setBackground(composite.getBackground());
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- Program.launch("https://gist.github.com/" + id);
+ Set<TaskRepository> repositories = TasksUi
+ .getRepositoryManager().getRepositories(
+ GistConnector.KIND);
+ if (!repositories.isEmpty())
+ TasksUiUtil.openTask(repositories.iterator().next(), gist.getId());
}
});
}