Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2013-03-12 17:01:42 -0400
committerFrank Becker2013-03-14 16:23:13 -0400
commit6dd713764206487e8294218204303d2ea9ad2f30 (patch)
treed0f2c5d8366b9c6b4dee1bc49ffbce9129b958d8 /org.eclipse.mylyn.tasks.ui/src/org
parentbd35d685cd27d17e226b81b3369ed6b3a88eabd4 (diff)
downloadorg.eclipse.mylyn.tasks-6dd713764206487e8294218204303d2ea9ad2f30.tar.gz
org.eclipse.mylyn.tasks-6dd713764206487e8294218204303d2ea9ad2f30.tar.xz
org.eclipse.mylyn.tasks-6dd713764206487e8294218204303d2ea9ad2f30.zip
402059: [editor] Provide Copy URL menu item for Task comments
Change-Id: Ie53f33795ae2eb92b72791bea4ef1b1f02e03349 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=402059
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui/src/org')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CommentActionGroup.java10
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyCommentDetailsURLAction.java40
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/Messages.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/messages.properties2
4 files changed, 56 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CommentActionGroup.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CommentActionGroup.java
index 0136bdc8f..b0e97c07b 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CommentActionGroup.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CommentActionGroup.java
@@ -15,6 +15,7 @@ import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.mylyn.tasks.core.ITaskComment;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup;
@@ -27,6 +28,8 @@ public class CommentActionGroup extends ActionGroup {
private CopyCommenterNameAction copyCommenterNameAction;
+ private CopyCommentDetailsURLAction copyCommentDetailsURL;
+
private boolean initialized;
private void initialize() {
@@ -36,6 +39,7 @@ public class CommentActionGroup extends ActionGroup {
initialized = true;
copyDetailsAction = new CopyCommentDetailsAction();
copyCommenterNameAction = new CopyCommenterNameAction();
+ copyCommentDetailsURL = new CopyCommentDetailsURLAction();
}
@Override
@@ -43,6 +47,7 @@ public class CommentActionGroup extends ActionGroup {
updateActions();
manager.add(copyDetailsAction);
manager.add(copyCommenterNameAction);
+ manager.add(copyCommentDetailsURL);
}
private void updateActions() {
@@ -50,6 +55,11 @@ public class CommentActionGroup extends ActionGroup {
IStructuredSelection selection = getStructuredSelection();
copyDetailsAction.selectionChanged(selection);
copyCommenterNameAction.selectionChanged(selection);
+ copyCommentDetailsURL.selectionChanged(selection);
+ Object firstElement = selection.getFirstElement();
+ if (firstElement instanceof ITaskComment) {
+ copyCommentDetailsURL.setEnabled(((ITaskComment) firstElement).getUrl() != null);
+ }
}
public IStructuredSelection getStructuredSelection() {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyCommentDetailsURLAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyCommentDetailsURLAction.java
new file mode 100644
index 000000000..dd6ff4d80
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyCommentDetailsURLAction.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Frank Becker and others.
+ * 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:
+ * Frank Becker - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.actions;
+
+import org.eclipse.mylyn.commons.ui.ClipboardCopier;
+import org.eclipse.mylyn.commons.ui.CommonImages;
+import org.eclipse.mylyn.tasks.core.ITaskComment;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+
+public class CopyCommentDetailsURLAction extends BaseSelectionListenerAction {
+
+ public CopyCommentDetailsURLAction() {
+ super(Messages.CopyCommentDetailsURL_Copy_Comment_URL);
+ setToolTipText(Messages.CopyCommentDetailsURL_Copy_Comment_URL_Tooltip);
+ setImageDescriptor(CommonImages.COPY);
+ }
+
+ @Override
+ public void run() {
+ ClipboardCopier.getDefault().copy(getStructuredSelection(), new ClipboardCopier.TextProvider() {
+ public String getTextForElement(Object element) {
+ if (element instanceof ITaskComment) {
+ ITaskComment comment = (ITaskComment) element;
+ return comment.getUrl();
+ }
+ return null;
+ }
+ });
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/Messages.java
index a8c7f2405..e7866aa38 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/Messages.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/Messages.java
@@ -69,6 +69,10 @@ public class Messages extends NLS {
public static String CopyCommentDetailsAction_Copy_User_ID_Tooltip;
+ public static String CopyCommentDetailsURL_Copy_Comment_URL;
+
+ public static String CopyCommentDetailsURL_Copy_Comment_URL_Tooltip;
+
public static String CopyCommenterNameAction_Copy_User_Name;
public static String CopyCommenterNameAction_Copy_User_Name_Tooltip;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/messages.properties
index f0ab08bef..c4dca34b3 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/messages.properties
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/messages.properties
@@ -38,6 +38,8 @@ CompareAttachmentsAction_Failed_to_find_attachment=Failed to find attachment\:\
CopyCommentDetailsAction_Copy_User_ID=Copy User ID
CopyCommentDetailsAction_Copy_User_ID_Tooltip=Copy User ID of Comment Author to Clipboard
+CopyCommentDetailsURL_Copy_Comment_URL=Copy URL
+CopyCommentDetailsURL_Copy_Comment_URL_Tooltip=Copy the URL of the Comment to Clipboard
CopyCommenterNameAction_Copy_User_Name=Copy User Name
CopyCommenterNameAction_Copy_User_Name_Tooltip=Copy User Name of Comment Author to Clipboard

Back to the top