summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2013-04-04 19:34:08 (EDT)
committer Steffen Pingel2013-04-04 20:11:32 (EDT)
commitb66afaf054fe4e7fc5756b208c67eb895138fbdb (patch)
treed8a7bb1decac5dd41e3b0a563b8326141fc951fa
parent13588971667d0529469d4d5c448291029280d6c5 (diff)
downloadorg.eclipse.mylyn.tasks-b66afaf054fe4e7fc5756b208c67eb895138fbdb.zip
org.eclipse.mylyn.tasks-b66afaf054fe4e7fc5756b208c67eb895138fbdb.tar.gz
org.eclipse.mylyn.tasks-b66afaf054fe4e7fc5756b208c67eb895138fbdb.tar.bz2
404857: jobs should support running in the backgroundrefs/changes/67/11667/2
Change-Id: I4ea93f46916f92a9c9ac9f5ec8f15198bf45f14d Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=404857
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskJobFactory.java2
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/DeleteTasksJob.java56
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/GetTaskHistoryJob.java3
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/Messages.java4
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/UpdateRepositoryConfigurationJob.java6
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/messages.properties2
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/SubmitJob.java10
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/TaskJob.java13
8 files changed, 57 insertions, 39 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskJobFactory.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskJobFactory.java
index 5f4aa99..c838ef8 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskJobFactory.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskJobFactory.java
@@ -145,6 +145,7 @@ public class TaskJobFactory implements ITaskJobFactory {
SubmitJob job = new SubmitTaskJob(taskDataManager, connector, taskRepository, task, taskData, oldAttributes,
getTaskJobListeners(connector));
job.setPriority(Job.INTERACTIVE);
+ job.setUser(true);
try {
taskList.run(new ITaskListRunnable() {
public void execute(IProgressMonitor monitor) throws CoreException {
@@ -164,6 +165,7 @@ public class TaskJobFactory implements ITaskJobFactory {
Messages.TaskJobFactory_Refreshing_repository_configuration, taskRepository, connector);
updateJob.setPriority(Job.INTERACTIVE);
updateJob.setRule(new ObjectSchedulingRule(taskRepository));
+ updateJob.setUser(true);
return updateJob;
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/DeleteTasksJob.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/DeleteTasksJob.java
index d9981f0..991f3ea 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/DeleteTasksJob.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/DeleteTasksJob.java
@@ -54,33 +54,41 @@ public class DeleteTasksJob extends TaskJob {
protected IStatus run(IProgressMonitor monitor) {
status = new MultiStatus(ITasksCoreConstants.ID_PLUGIN, IStatus.OK,
"Problems occurred while deleting repository tasks", null); //$NON-NLS-1$
- for (ITask task : tasksToDelete) {
- // delete the task on the server using the repository connector
- AbstractRepositoryConnector repositoryConnector = repositoryManager.getRepositoryConnector(task.getConnectorKind());
- TaskRepository repository = repositoryManager.getRepository(task.getConnectorKind(),
- task.getRepositoryUrl());
- if (repositoryConnector.canDeleteTask(repository, task)) {
- try {
- repositoryConnector.deleteTask(repository, task, monitor);
- } catch (OperationCanceledException e) {
- return Status.CANCEL_STATUS;
- } catch (Exception e) {
- String taskId = task.getTaskKey();
- if (taskId == null) {
- taskId = task.getTaskId();
+ try {
+ monitor.beginTask(Messages.DeleteTasksJob_Deleting_tasks, tasksToDelete.size() * 100);
+ for (ITask task : tasksToDelete) {
+ // delete the task on the server using the repository connector
+ AbstractRepositoryConnector repositoryConnector = repositoryManager.getRepositoryConnector(task.getConnectorKind());
+ TaskRepository repository = repositoryManager.getRepository(task.getConnectorKind(),
+ task.getRepositoryUrl());
+ if (repositoryConnector.canDeleteTask(repository, task)) {
+ try {
+ repositoryConnector.deleteTask(repository, task, subMonitorFor(monitor, 100));
+ } catch (OperationCanceledException e) {
+ return Status.CANCEL_STATUS;
+ } catch (Exception e) {
+ String taskId = task.getTaskKey();
+ if (taskId == null) {
+ taskId = task.getTaskId();
+ }
+ status.add(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, NLS.bind(
+ "Problems occurred while deleting {0} from {1}.", taskId, task.getRepositoryUrl()), e)); //$NON-NLS-1$
+ } catch (LinkageError e) {
+ String taskId = task.getTaskKey();
+ if (taskId == null) {
+ taskId = task.getTaskId();
+ }
+ status.add(new Status(
+ IStatus.ERROR,
+ ITasksCoreConstants.ID_PLUGIN,
+ NLS.bind(
+ "Internal Error occurred while deleting {0} from {1}.", taskId, task.getRepositoryUrl()), e)); //$NON-NLS-1$
}
- status.add(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, NLS.bind(
- "Problems occurred while deleting {0} from {1}.", taskId, task.getRepositoryUrl()), e)); //$NON-NLS-1$
- } catch (LinkageError e) {
- String taskId = task.getTaskKey();
- if (taskId == null) {
- taskId = task.getTaskId();
- }
- status.add(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, NLS.bind(
- "Internal Error occurred while deleting {0} from {1}.", taskId, task.getRepositoryUrl()), e)); //$NON-NLS-1$
- }
+ }
}
+ } finally {
+ monitor.done();
}
return Status.OK_STATUS;
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/GetTaskHistoryJob.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/GetTaskHistoryJob.java
index 5fb8f9a..0fb5fbd 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/GetTaskHistoryJob.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/GetTaskHistoryJob.java
@@ -52,7 +52,8 @@ public class GetTaskHistoryJob extends TaskJob {
monitor.setCanceled(false);
monitor.attach(jobMonitor);
try {
- history = connector.getTaskHistory(repository, task, monitor);
+ monitor.beginTask(Messages.GetTaskHistoryJob_Retrieving_Task_History, 100);
+ history = connector.getTaskHistory(repository, task, subMonitorFor(monitor, 100));
} catch (CoreException e) {
errorStatus = e.getStatus();
} catch (OperationCanceledException e) {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/Messages.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/Messages.java
index 293556b..9d32893 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/Messages.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/Messages.java
@@ -25,8 +25,12 @@ public class Messages extends NLS {
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
+ public static String DeleteTasksJob_Deleting_tasks;
+
public static String GetTaskHistoryJob_Retrieving_History;
+ public static String GetTaskHistoryJob_Retrieving_Task_History;
+
public static String SubmitTaskAttachmentJob_Sending_data;
public static String SubmitTaskAttachmentJob_Submitting_attachment;
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/UpdateRepositoryConfigurationJob.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/UpdateRepositoryConfigurationJob.java
index 9c3f089..44bab3c 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/UpdateRepositoryConfigurationJob.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/UpdateRepositoryConfigurationJob.java
@@ -15,7 +15,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.sync.TaskJob;
@@ -41,11 +40,10 @@ public class UpdateRepositoryConfigurationJob extends TaskJob {
@Override
protected IStatus run(IProgressMonitor monitor) {
- monitor = SubMonitor.convert(monitor);
- monitor.beginTask(Messages.UpdateRepositoryConfigurationJob_Receiving_configuration, IProgressMonitor.UNKNOWN);
+ monitor.beginTask(Messages.UpdateRepositoryConfigurationJob_Receiving_configuration, 100);
try {
try {
- connector.updateRepositoryConfiguration(repository, monitor);
+ connector.updateRepositoryConfiguration(repository, subMonitorFor(monitor, 100));
} catch (CoreException e) {
error = e.getStatus();
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/messages.properties b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/messages.properties
index efab6b6..ce4e6a4 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/messages.properties
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/messages.properties
@@ -8,7 +8,9 @@
# Contributors:
# Tasktop Technologies - initial API and implementation
###############################################################################
+DeleteTasksJob_Deleting_tasks=Deleting tasks
GetTaskHistoryJob_Retrieving_History=Retrieving History
+GetTaskHistoryJob_Retrieving_Task_History=Retrieving Task History
SubmitTaskAttachmentJob_Sending_data=Sending data
SubmitTaskAttachmentJob_Submitting_attachment=Submitting attachment
SubmitTaskAttachmentJob_Updating_task=Updating task
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/SubmitJob.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/SubmitJob.java
index 5ecc6c4..594c9cd 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/SubmitJob.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/SubmitJob.java
@@ -124,14 +124,4 @@ public abstract class SubmitJob extends TaskJob {
*/
public abstract RepositoryResponse getResponse();
- /**
- * @since 3.9
- */
- protected IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
- if (!isUser()) {
- return Policy.backgroundMonitorFor(monitor);
- }
- return Policy.subMonitorFor(monitor, ticks);
- }
-
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/TaskJob.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/TaskJob.java
index 91dd8f4..09718e8 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/TaskJob.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/TaskJob.java
@@ -11,10 +11,12 @@
package org.eclipse.mylyn.tasks.core.sync;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.mylyn.commons.core.DelegatingProgressMonitor;
import org.eclipse.mylyn.commons.core.IDelegatingProgressMonitor;
+import org.eclipse.mylyn.commons.net.Policy;
/**
* @author Steffen Pingel
@@ -47,4 +49,15 @@ public abstract class TaskJob extends Job {
public IDelegatingProgressMonitor getMonitor() {
return monitor;
}
+
+ /**
+ * @since 3.9
+ */
+ protected IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
+ if (!isUser()) {
+ return Policy.backgroundMonitorFor(monitor);
+ }
+ return Policy.subMonitorFor(monitor, ticks);
+ }
+
}