Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 637413b9..e4371b45 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 94e516e0..fcc4e567 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 4cc84448..71adb7f6 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());
}
});
}

Back to the top