diff options
| author | Kevin Sawicki | 2011-04-22 22:39:59 +0000 |
|---|---|---|
| committer | Chris Aniszczyk | 2011-05-06 00:20:06 +0000 |
| commit | 8e3aae9d211ce852c364ee4823a14ad3893c591b (patch) | |
| tree | b3c88205374e40e1fcd09c7b78b35395a86cb0ec | |
| parent | 99dd356b60813ad490441e416e448f8e74694a91 (diff) | |
| download | egit-github-8e3aae9d211ce852c364ee4823a14ad3893c591b.tar.gz egit-github-8e3aae9d211ce852c364ee4823a14ad3893c591b.tar.xz egit-github-8e3aae9d211ce852c364ee4823a14ad3893c591b.zip | |
Add clone action to gist task editor page
Change-Id: I104553771e5324b1cd51d4bee57e570fd83115bb
Signed-off-by: Kevin Sawicki <kevin@github.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
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 3d88a4d9..80ab3ede 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 f7cb88aa..ea7aaa9b 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 339bb8a2..2368cd40 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 |
