summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Ehrnhoefer2011-11-27 14:00:31 (EST)
committerSteffen Pingel2011-11-27 14:00:31 (EST)
commitdca8657902a64a5a9d273dc2beb51cf928cfb840 (patch)
tree68dc8e5ea6c68c1d12cffd0ca566bb3677ec6853
parenta471ecb8a423d0327c82d8a132945bf61d4901ac (diff)
downloadorg.eclipse.mylyn.tasks-dca8657902a64a5a9d273dc2beb51cf928cfb840.zip
org.eclipse.mylyn.tasks-dca8657902a64a5a9d273dc2beb51cf928cfb840.tar.gz
org.eclipse.mylyn.tasks-dca8657902a64a5a9d273dc2beb51cf928cfb840.tar.bz2
NEW - bug 353433: [patch] Copy Details - URL should falls back to
connector.getTaskUrl if no taskUrl in ITask https://bugs.eclipse.org/bugs/show_bug.cgi?id=353433
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/CopyDetailsActionTest.java21
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java24
2 files changed, 40 insertions, 5 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/CopyDetailsActionTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/CopyDetailsActionTest.java
index 508d25e..823e755 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/CopyDetailsActionTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/CopyDetailsActionTest.java
@@ -13,11 +13,17 @@ package org.eclipse.mylyn.tasks.tests;
import junit.framework.TestCase;
+import org.eclipse.mylyn.internal.provisional.commons.ui.ClipboardCopier;
+import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
import org.eclipse.mylyn.internal.tasks.ui.actions.CopyTaskDetailsAction;
+import org.eclipse.mylyn.internal.tasks.ui.actions.CopyTaskDetailsAction.Mode;
+import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
import org.eclipse.mylyn.tasks.tests.connector.MockTask;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
/**
* @author Steffen Pingel
+ * @author Thomas Ehrnhoefer
*/
public class CopyDetailsActionTest extends TestCase {
@@ -59,4 +65,19 @@ public class CopyDetailsActionTest extends TestCase {
assertEquals("abc", CopyTaskDetailsAction.getTextForTask(task));
}
+ public void testGetSummaryAndUrl() {
+ MockTask task = new MockTask("321");
+ task.setSummary("s321");
+ task.setTaskKey("321");
+ MockRepositoryConnector connector = new MockRepositoryConnector() {
+ @Override
+ public String getTaskUrl(String repositoryUrl, String taskId) {
+ return "http://321.com";
+ }
+ };
+ ((TaskRepositoryManager) TasksUi.getRepositoryManager()).addRepositoryConnector(connector);
+ assertEquals("321: s321" + ClipboardCopier.LINE_SEPARATOR + "http://321.com",
+ CopyTaskDetailsAction.getTextForTask(task, Mode.SUMMARY_URL));
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java
index 2bdcd93..11a08a6 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/CopyTaskDetailsAction.java
@@ -18,11 +18,13 @@ import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
/**
* @author Mik Kersten
* @author Steffen Pingel
+ * @author Thomas Ehrnhoefer
*/
public class CopyTaskDetailsAction extends BaseSelectionListenerAction {
@@ -89,9 +91,9 @@ public class CopyTaskDetailsAction extends BaseSelectionListenerAction {
break;
case URL:
if (object instanceof IRepositoryElement) {
- IRepositoryElement element = (IRepositoryElement) object;
- if (element.getUrl() != null) {
- sb.append(element.getUrl());
+ String taskUrl = getUrl((IRepositoryElement) object);
+ if (TasksUiInternal.isValidUrl(taskUrl)) {
+ sb.append(taskUrl);
}
}
break;
@@ -119,9 +121,10 @@ public class CopyTaskDetailsAction extends BaseSelectionListenerAction {
}
sb.append(task.getSummary());
- if (TasksUiInternal.isValidUrl(task.getUrl())) {
+ String taskUrl = getUrl((IRepositoryElement) object);
+ if (TasksUiInternal.isValidUrl(taskUrl)) {
sb.append(ClipboardCopier.LINE_SEPARATOR);
- sb.append(task.getUrl());
+ sb.append(taskUrl);
}
} else if (object instanceof IRepositoryQuery) {
RepositoryQuery query = (RepositoryQuery) object;
@@ -139,4 +142,15 @@ public class CopyTaskDetailsAction extends BaseSelectionListenerAction {
return sb.toString();
}
+ private static String getUrl(IRepositoryElement element) {
+ if (element.getUrl() != null) {
+ return element.getUrl();
+ } else if (element instanceof ITask) {
+ ITask task = (ITask) element;
+ return TasksUi.getRepositoryConnector(task.getConnectorKind()).getTaskUrl(task.getRepositoryUrl(),
+ task.getTaskId());
+ }
+ return null;
+ }
+
}