Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfbecker2010-05-17 23:40:17 -0400
committerfbecker2010-05-17 23:40:17 -0400
commit723d4743832b364cf55f07d9952f23edd10ca8e2 (patch)
tree17bfefdeef4c8f3fd64d310a26a3d75720d340e0
parent5a487b28b0754b8bd80eb18e745be2dec4fc8bdf (diff)
downloadorg.eclipse.mylyn.tasks-723d4743832b364cf55f07d9952f23edd10ca8e2.tar.gz
org.eclipse.mylyn.tasks-723d4743832b364cf55f07d9952f23edd10ca8e2.tar.xz
org.eclipse.mylyn.tasks-723d4743832b364cf55f07d9952f23edd10ca8e2.zip
ASSIGNED - bug 178474: [patch] open corresponding task should highlight or expand comment number
https://bugs.eclipse.org/bugs/show_bug.cgi?id=178474
-rw-r--r--org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/search/OpenSearchResultAction.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/OpenRepositoryTaskJob.java36
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java14
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiUtil.java22
5 files changed, 66 insertions, 10 deletions
diff --git a/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/search/OpenSearchResultAction.java b/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/search/OpenSearchResultAction.java
index 99b007a01..eb1480a95 100644
--- a/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/search/OpenSearchResultAction.java
+++ b/org.eclipse.mylyn.tasks.search/src/org/eclipse/mylyn/internal/tasks/ui/search/OpenSearchResultAction.java
@@ -55,7 +55,7 @@ public class OpenSearchResultAction extends Action {
for (Iterator<AbstractTask> it = selection.iterator(); it.hasNext();) {
AbstractTask repositoryHit = it.next();
TasksUiUtil.openTask(repositoryHit.getRepositoryUrl(), repositoryHit.getTaskId(),
- repositoryHit.getUrl());
+ repositoryHit.getUrl(), 0);
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/OpenRepositoryTaskJob.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/OpenRepositoryTaskJob.java
index 0086d992f..ac01f41cd 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/OpenRepositoryTaskJob.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/OpenRepositoryTaskJob.java
@@ -12,6 +12,8 @@
package org.eclipse.mylyn.internal.tasks.ui;
import java.text.MessageFormat;
+import java.util.Date;
+import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -25,9 +27,11 @@ import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
@@ -49,14 +53,17 @@ public class OpenRepositoryTaskJob extends Job {
private TaskOpenListener listener;
+ private final long timestamp;
+
public OpenRepositoryTaskJob(String repositoryKind, String repositoryUrl, String taskId, String taskUrl,
- IWorkbenchPage page) {
+ long timestamp, IWorkbenchPage page) {
super(MessageFormat.format(Messages.OpenRepositoryTaskJob_Opening_repository_task_X, taskId));
this.repositoryKind = repositoryKind;
this.taskId = taskId;
this.repositoryUrl = repositoryUrl;
this.taskUrl = taskUrl;
+ this.timestamp = timestamp;
}
/**
@@ -79,7 +86,9 @@ public class OpenRepositoryTaskJob extends Job {
if (repository == null) {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
- MessageDialog.openError(null, Messages.OpenRepositoryTaskJob_Repository_Not_Found,
+ MessageDialog.openError(
+ null,
+ Messages.OpenRepositoryTaskJob_Repository_Not_Found,
MessageFormat.format(
Messages.OpenRepositoryTaskJob_Could_not_find_repository_configuration_for_X,
repositoryUrl)
@@ -95,7 +104,7 @@ public class OpenRepositoryTaskJob extends Job {
AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector(repositoryKind);
try {
- TaskData taskData = connector.getTaskData(repository, taskId, monitor);
+ final TaskData taskData = connector.getTaskData(repository, taskId, monitor);
if (taskData != null) {
task = TasksUi.getRepositoryModel().createTask(repository, taskData.getTaskId());
TasksUiPlugin.getTaskDataManager().putUpdatedTaskData(task, taskData, true);
@@ -105,6 +114,27 @@ public class OpenRepositoryTaskJob extends Job {
if (listener != null && event != null) {
listener.taskOpened(event);
}
+ if (timestamp != 0 && event != null) {
+ List<TaskAttribute> commentAttributes = taskData.getAttributeMapper().getAttributesByType(
+ taskData, TaskAttribute.TYPE_COMMENT);
+ if (commentAttributes.size() > 0) {
+ for (TaskAttribute commentAttribute : commentAttributes) {
+ TaskAttribute commentCreateDate = commentAttribute.getMappedAttribute(TaskAttribute.COMMENT_DATE);
+ if (commentCreateDate != null) {
+ Date dateValue = taskData.getAttributeMapper().getDateValue(commentCreateDate);
+ if (dateValue.getTime() < timestamp) {
+ continue;
+ }
+ TaskAttribute dn = commentAttribute.getMappedAttribute(TaskAttribute.COMMENT_NUMBER);
+ TaskEditor editor = (TaskEditor) event.getEditor();
+ if (dn != null) {
+ editor.selectReveal(TaskAttribute.PREFIX_COMMENT + dn.getValue());
+ }
+ break;
+ }
+ }
+ }
+ }
}
});
} else {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
index d43bff451..09657b6b9 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
@@ -958,6 +958,17 @@ public class TasksUiInternal {
*/
public static boolean openRepositoryTask(String connectorKind, String repositoryUrl, String id,
TaskOpenListener listener) {
+ return openRepositoryTask(connectorKind, repositoryUrl, id, listener, 0);
+ }
+
+ /**
+ * Only override if task should be opened by a custom editor, default behavior is to open with a rich editor,
+ * falling back to the web browser if not available.
+ *
+ * @return true if the task was successfully opened
+ */
+ public static boolean openRepositoryTask(String connectorKind, String repositoryUrl, String id,
+ TaskOpenListener listener, long timestamp) {
IRepositoryManager repositoryManager = TasksUi.getRepositoryManager();
AbstractRepositoryConnector connector = repositoryManager.getRepositoryConnector(connectorKind);
String taskUrl = connector.getTaskUrl(repositoryUrl, id);
@@ -977,7 +988,8 @@ public class TasksUiInternal {
}
IWorkbenchPage page = window.getActivePage();
- OpenRepositoryTaskJob job = new OpenRepositoryTaskJob(connectorKind, repositoryUrl, id, taskUrl, page);
+ OpenRepositoryTaskJob job = new OpenRepositoryTaskJob(connectorKind, repositoryUrl, id, taskUrl, timestamp,
+ page);
job.setListener(listener);
job.schedule();
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java
index 0ccc0d1e7..5e0730ef6 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java
@@ -208,7 +208,7 @@ public class TaskListDropAdapter extends ViewerDropAdapter {
if (repositoryUrl != null && taskId != null) {
// attempt to open task in background
// TODO: consider attaching a listener to OpenRepsitoryTaskJob to move task to drop target
- TasksUiInternal.openRepositoryTask(connector.getConnectorKind(), repositoryUrl, taskId);
+ TasksUiInternal.openRepositoryTask(connector.getConnectorKind(), repositoryUrl, taskId, null, 0);
}
} else {
// create local task, using title of web page as a summary
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiUtil.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiUtil.java
index ed1ff2682..448176410 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiUtil.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiUtil.java
@@ -258,11 +258,11 @@ public class TasksUiUtil {
/**
* Either pass in a repository and taskId, or fullUrl, or all of them
*
- * @deprecated Use {@link #openTask(String,String,String)} instead
+ * @deprecated Use {@link #openTask(String,String,String,long)} instead
*/
@Deprecated
public static boolean openRepositoryTask(String repositoryUrl, String taskId, String fullUrl) {
- return openTask(repositoryUrl, taskId, fullUrl);
+ return openTask(repositoryUrl, taskId, fullUrl, 0);
}
/**
@@ -318,8 +318,20 @@ public class TasksUiUtil {
* Either pass in a repository and taskId, or fullUrl, or all of them
*
* @since 3.0
+ * @deprecated Use {@link #openTask(String,String,String,long)} instead
*/
+ @Deprecated
public static boolean openTask(String repositoryUrl, String taskId, String fullUrl) {
+ return openTask(repositoryUrl, taskId, fullUrl, 0);
+ }
+
+ /**
+ * Either pass in a repository and taskId, or fullUrl, or all of them the timestamp is used for seleting the correct
+ * comment
+ *
+ * @since 3.4
+ */
+ public static boolean openTask(String repositoryUrl, String taskId, String fullUrl, long timestamp) {
AbstractTask task = TasksUiInternal.getTask(repositoryUrl, taskId, fullUrl);
if (task != null) {
@@ -332,12 +344,14 @@ public class TasksUiUtil {
fullUrl);
if (connector != null) {
if (repositoryUrl != null && taskId != null) {
- opened = TasksUiInternal.openRepositoryTask(connector.getConnectorKind(), repositoryUrl, taskId);
+ opened = TasksUiInternal.openRepositoryTask(connector.getConnectorKind(), repositoryUrl, taskId, null,
+ timestamp);
} else {
repositoryUrl = connector.getRepositoryUrlFromTaskUrl(fullUrl);
taskId = connector.getTaskIdFromTaskUrl(fullUrl);
if (repositoryUrl != null && taskId != null) {
- opened = TasksUiInternal.openRepositoryTask(connector.getConnectorKind(), repositoryUrl, taskId);
+ opened = TasksUiInternal.openRepositoryTask(connector.getConnectorKind(), repositoryUrl, taskId,
+ null, timestamp);
}
}
}

Back to the top