aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-22 18:39:59 (EDT)
committerChris Aniszczyk2011-05-05 20:20:06 (EDT)
commit8e3aae9d211ce852c364ee4823a14ad3893c591b (patch)
treeb3c88205374e40e1fcd09c7b78b35395a86cb0ec
parent99dd356b60813ad490441e416e448f8e74694a91 (diff)
downloadegit-github-8e3aae9d211ce852c364ee4823a14ad3893c591b.zip
egit-github-8e3aae9d211ce852c364ee4823a14ad3893c591b.tar.gz
egit-github-8e3aae9d211ce852c364ee4823a14ad3893c591b.tar.bz2
Add clone action to gist task editor pagerefs/changes/30/3230/2
Change-Id: I104553771e5324b1cd51d4bee57e570fd83115bb 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/internal/github/ui/gist/GistTaskEditorPage.java58
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/Messages.java3
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/messages.properties1
3 files changed, 62 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistTaskEditorPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistTaskEditorPage.java
index 3d88a4d..80ab3ed 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistTaskEditorPage.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistTaskEditorPage.java
@@ -13,6 +13,18 @@ package org.eclipse.mylyn.internal.github.ui.gist;
import java.util.Iterator;
import java.util.Set;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.egit.ui.UIIcons;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylyn.github.ui.internal.IssueSummaryPart;
import org.eclipse.mylyn.internal.github.core.gist.GistAttribute;
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorActionPart;
@@ -21,7 +33,10 @@ import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorPartDescriptor;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.handlers.IHandlerService;
/**
* Gist task editor page class
@@ -39,6 +54,49 @@ public class GistTaskEditorPage extends AbstractTaskEditorPage {
}
/**
+ * @see org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage#fillToolBar(org.eclipse.jface.action.IToolBarManager)
+ */
+ public void fillToolBar(IToolBarManager toolBarManager) {
+ super.fillToolBar(toolBarManager);
+
+ Action cloneGist = new Action(
+ Messages.GistTaskEditorPage_LabelCloneGistAction,
+ UIIcons.CLONEGIT) {
+
+ public void run() {
+ ICommandService srv = (ICommandService) getSite().getService(
+ ICommandService.class);
+ IHandlerService hsrv = (IHandlerService) getSite().getService(
+ IHandlerService.class);
+ Command command = srv.getCommand(CloneGistHandler.ID);
+
+ ExecutionEvent event = hsrv.createExecutionEvent(command, null);
+ if (event.getApplicationContext() instanceof IEvaluationContext) {
+ IEvaluationContext context = (IEvaluationContext) event
+ .getApplicationContext();
+ IStructuredSelection selection = new StructuredSelection(
+ getModel().getTaskData());
+ context.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME,
+ selection);
+ try {
+ command.executeWithChecks(event);
+ } catch (ExecutionException ignored) {
+ // Ignored
+ } catch (NotDefinedException ignored) {
+ // Ignored
+ } catch (NotEnabledException ignored) {
+ // Ignored
+ } catch (NotHandledException ignored) {
+ // Ignored
+ }
+ }
+ }
+
+ };
+ toolBarManager.prependToGroup("open", cloneGist); //$NON-NLS-1$
+ }
+
+ /**
* @see org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage#createPartDescriptors()
*/
protected Set<TaskEditorPartDescriptor> createPartDescriptors() {
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/Messages.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/Messages.java
index f7cb88a..ea7aaa9 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/Messages.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/Messages.java
@@ -89,6 +89,9 @@ public class Messages extends NLS {
public static String GistRepositorySettingsPage_Title;
/** */
+ public static String GistTaskEditorPage_LabelCloneGistAction;
+
+ /** */
public static String GistTaskEditorPageFactory_PageText;
static {
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/messages.properties b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/messages.properties
index 339bb8a..2368cd4 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/messages.properties
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/messages.properties
@@ -21,4 +21,5 @@ GistRepositorySettingsPage_StatusSuccess=Success\!
GistRepositorySettingsPage_TaskContacting=Contacting server
GistRepositorySettingsPage_TaskValidating=Validating Settings...
GistRepositorySettingsPage_Title=Gist repository settings
+GistTaskEditorPage_LabelCloneGistAction=Clone Gist
GistTaskEditorPageFactory_PageText=Gist