Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2006-12-01 01:36:06 +0000
committerrelves2006-12-01 01:36:06 +0000
commit1ae98be516fc77417b4dade78a3c951a8a11c22f (patch)
treeff9d8c121bdf4dad82998bc4c75e41aeba778038
parent50ce4b1c098a661471c871f9a7e280b6fe8c8b6f (diff)
downloadorg.eclipse.mylyn.tasks-1ae98be516fc77417b4dade78a3c951a8a11c22f.tar.gz
org.eclipse.mylyn.tasks-1ae98be516fc77417b4dade78a3c951a8a11c22f.tar.xz
org.eclipse.mylyn.tasks-1ae98be516fc77417b4dade78a3c951a8a11c22f.zip
NEW - bug 163608: download query hit task data in the background
https://bugs.eclipse.org/bugs/show_bug.cgi?id=163608
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractQueryHit.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiUtil.java5
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/SynchronizeQueryJob.java92
3 files changed, 94 insertions, 5 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractQueryHit.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractQueryHit.java
index 3f7ab8669..ea993732a 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractQueryHit.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractQueryHit.java
@@ -77,7 +77,7 @@ public abstract class AbstractQueryHit implements ITaskListElement {
if (existingTask instanceof AbstractRepositoryTask) {
this.task = (AbstractRepositoryTask) existingTask;
} else {
- task = createTask();
+ task = createTask();
task.setCompleted(completed);
taskList.addTask(task);
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiUtil.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiUtil.java
index 9b87aa170..3fa75dd55 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiUtil.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiUtil.java
@@ -205,7 +205,10 @@ public class TasksUiUtil {
}
if (connector != null)
- if (repositoryTask.getTaskData() != null) {
+ if (repositoryTask.getTaskData() != null || TasksUiPlugin.getDefault().getTaskDataManager().getTaskData(repositoryTask.getHandleIdentifier()) != null) {
+ if(repositoryTask.getTaskData() == null) {
+ repositoryTask.setTaskData(TasksUiPlugin.getDefault().getTaskDataManager().getTaskData(repositoryTask.getHandleIdentifier()));
+ }
TasksUiUtil.openEditor(task, false, false);
TasksUiPlugin.getSynchronizationManager().setTaskRead(repositoryTask, true);
TasksUiPlugin.getSynchronizationManager().synchronize(connector, repositoryTask, false, null);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/SynchronizeQueryJob.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/SynchronizeQueryJob.java
index b78eeb9f3..e05c755e4 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/SynchronizeQueryJob.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/SynchronizeQueryJob.java
@@ -12,17 +12,22 @@
package org.eclipse.mylar.tasks.ui;
import java.util.Date;
+import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.mylar.internal.context.core.util.DateUtil;
import org.eclipse.mylar.internal.tasks.ui.TaskListImages;
+import org.eclipse.mylar.tasks.core.AbstractQueryHit;
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
+import org.eclipse.mylar.tasks.core.ITaskDataHandler;
import org.eclipse.mylar.tasks.core.QueryHitCollector;
+import org.eclipse.mylar.tasks.core.RepositoryTaskData;
import org.eclipse.mylar.tasks.core.TaskList;
import org.eclipse.mylar.tasks.core.TaskRepository;
import org.eclipse.ui.progress.IProgressConstants;
@@ -32,12 +37,16 @@ import org.eclipse.ui.progress.IProgressConstants;
*/
class SynchronizeQueryJob extends Job {
+ private static final int NUM_HITS_TO_PRIME = 19;
+
private final AbstractRepositoryConnector connector;
private static final String JOB_LABEL = "Synchronizing queries";
private Set<AbstractRepositoryQuery> queries;
+ private Set<TaskRepository> repositories;
+
private boolean synchTasks;
private TaskList taskList;
@@ -48,6 +57,7 @@ class SynchronizeQueryJob extends Job {
this.connector = connector;
this.queries = queries;
this.taskList = taskList;
+ this.repositories = new HashSet<TaskRepository>();
}
@Override
@@ -63,8 +73,8 @@ class SynchronizeQueryJob extends Job {
TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
repositoryQuery.getRepositoryKind(), repositoryQuery.getRepositoryUrl());
if (repository == null) {
- repositoryQuery.setStatus(new Status(Status.ERROR, TasksUiPlugin.PLUGIN_ID,
- IStatus.OK, "No task repository found: " + repositoryQuery.getRepositoryUrl(), null));
+ repositoryQuery.setStatus(new Status(Status.ERROR, TasksUiPlugin.PLUGIN_ID, IStatus.OK,
+ "No task repository found: " + repositoryQuery.getRepositoryUrl(), null));
} else {
QueryHitCollector collector = new QueryHitCollector(TasksUiPlugin.getTaskListManager().getTaskList());
@@ -72,10 +82,38 @@ class SynchronizeQueryJob extends Job {
if (resultingStatus.getException() == null) {
repositoryQuery.updateHits(collector.getHits(), taskList);
+ HashSet<AbstractQueryHit> hits2sync = new HashSet<AbstractQueryHit>();
+ if (connector.getTaskDataHandler() != null) {
+ for (AbstractQueryHit hit : collector.getHits()) {
+ if ((hit.getCorrespondingTask() == null || hit.getCorrespondingTask().getTaskData() == null)
+ && TasksUiPlugin.getDefault().getTaskDataManager().getTaskData(
+ hit.getHandleIdentifier()) == null) {
+ hits2sync.add(hit);
+ }
+ if (hits2sync.size() > NUM_HITS_TO_PRIME)
+ break;
+ }
+ PrimeTaskData job = new PrimeTaskData(repository, hits2sync);
+ job.setPriority(Job.LONG);
+ job.schedule();
+ }
+
+ // for (AbstractQueryHit hit: collector.getHits()) {
+ // if(hit.getCorrespondingTask() != null &&
+ // hit.getCorrespondingTask().getTaskData() == null &&
+ // tasks2syc.size() < 20) {
+ // tasks2syc.add(hit.getCorrespondingTask());
+ // connector.getTaskDataHandler().getTaskData(repository,
+ // hit.getHandleIdentifier());
+ // }
+ // }
+
if (synchTasks) {
+ repositories.add(repository);
// TODO: Should sync changed per repository not per
// query
- TasksUiPlugin.getSynchronizationManager().synchronizeChanged(connector, repository);
+ // TasksUiPlugin.getSynchronizationManager().synchronizeChanged(connector,
+ // repository);
}
} else {
repositoryQuery.setStatus(resultingStatus);
@@ -90,6 +128,10 @@ class SynchronizeQueryJob extends Job {
monitor.worked(1);
}
+ for (TaskRepository repository : repositories) {
+ TasksUiPlugin.getSynchronizationManager().synchronizeChanged(connector, repository);
+ }
+
// HACK: force entire Task List to refresh in case containers need to
// appear or disappear
TasksUiPlugin.getTaskListManager().getTaskList().notifyContainerUpdated(null);
@@ -103,4 +145,48 @@ class SynchronizeQueryJob extends Job {
public void setSynchTasks(boolean syncTasks) {
this.synchTasks = syncTasks;
}
+
+ class PrimeTaskData extends Job {
+
+ private Set<AbstractQueryHit> hits;
+
+ private ITaskDataHandler handler;
+
+ private TaskRepository repository;
+
+ public PrimeTaskData(TaskRepository repository, Set<AbstractQueryHit> hits) {
+ super("");
+ this.hits = hits;
+ this.handler = connector.getTaskDataHandler();
+ this.repository = repository;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ try {
+ monitor.beginTask("Retrieving hit data", hits.size());
+ for (AbstractQueryHit hit : hits) {
+ RepositoryTaskData taskData = handler.getTaskData(repository, hit.getId());
+
+ if (taskData != null) {
+ if (hit.getCorrespondingTask() != null) {
+ hit.getCorrespondingTask().setTaskData(taskData);
+ }
+ TasksUiPlugin.getDefault().getTaskDataManager().put(taskData);
+ }
+ monitor.worked(1);
+ }
+ TasksUiPlugin.getDefault().getTaskDataManager().save();
+ } catch (Throwable e) {
+ // ignore failed task data retrieval
+ } finally {
+ monitor.done();
+ }
+ return Status.OK_STATUS;
+ }
+ }
+
} \ No newline at end of file

Back to the top