summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-09-10 14:42:43 (EDT)
committerSteffen Pingel2012-09-10 14:42:43 (EDT)
commit2d49eec5ec62ff293744ed90aff1cd6c978e0a1b (patch)
treeccf3269b544466cecbf462d1acf0481eb0c3ede8
parent6fd180ca8ac0895713f59853d3535c8b05dfeb62 (diff)
downloadorg.eclipse.mylyn.tasks-2d49eec5ec62ff293744ed90aff1cd6c978e0a1b.zip
org.eclipse.mylyn.tasks-2d49eec5ec62ff293744ed90aff1cd6c978e0a1b.tar.gz
org.eclipse.mylyn.tasks-2d49eec5ec62ff293744ed90aff1cd6c978e0a1b.tar.bz2
389103: prevent concurrent updates of repository configurationrefs/changes/89/7689/2
Change-Id: Ib20537dd92e03edda72ffefc6e0b221f21ceb37b Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=389103
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskJobFactory.java35
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/UpdateRepositoryConfigurationAction.java52
2 files changed, 10 insertions, 77 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 d87d52b..5f4aa99 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
@@ -21,18 +21,19 @@ 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.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.mylyn.commons.core.ExtensionPointReader;
import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants.ObjectSchedulingRule;
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManager;
import org.eclipse.mylyn.internal.tasks.core.sync.SubmitTaskAttachmentJob;
import org.eclipse.mylyn.internal.tasks.core.sync.SubmitTaskJob;
import org.eclipse.mylyn.internal.tasks.core.sync.SynchronizeQueriesJob;
import org.eclipse.mylyn.internal.tasks.core.sync.SynchronizeRepositoriesJob;
import org.eclipse.mylyn.internal.tasks.core.sync.SynchronizeTasksJob;
+import org.eclipse.mylyn.internal.tasks.core.sync.UpdateRepositoryConfigurationJob;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
import org.eclipse.mylyn.tasks.core.IRepositoryModel;
@@ -159,36 +160,10 @@ public class TaskJobFactory implements ITaskJobFactory {
public TaskJob createUpdateRepositoryConfigurationJob(final AbstractRepositoryConnector connector,
final TaskRepository taskRepository, final ITask task) {
- TaskJob updateJob = new TaskJob(Messages.TaskJobFactory_Refreshing_repository_configuration) {
- private IStatus error;
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- monitor = SubMonitor.convert(monitor);
- monitor.beginTask(Messages.TaskJobFactory_Receiving_configuration, IProgressMonitor.UNKNOWN);
- try {
- try {
- connector.updateRepositoryConfiguration(taskRepository, task, monitor);
- } catch (CoreException e) {
- error = e.getStatus();
- }
- } finally {
- monitor.done();
- }
- return Status.OK_STATUS;
- }
-
- @Override
- public boolean belongsTo(Object family) {
- return family == taskRepository;
- }
-
- @Override
- public IStatus getStatus() {
- return error;
- }
- };
+ UpdateRepositoryConfigurationJob updateJob = new UpdateRepositoryConfigurationJob(
+ Messages.TaskJobFactory_Refreshing_repository_configuration, taskRepository, connector);
updateJob.setPriority(Job.INTERACTIVE);
+ updateJob.setRule(new ObjectSchedulingRule(taskRepository));
return updateJob;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/UpdateRepositoryConfigurationAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/UpdateRepositoryConfigurationAction.java
index fb412a0..4024b78 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/UpdateRepositoryConfigurationAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/UpdateRepositoryConfigurationAction.java
@@ -11,25 +11,18 @@
package org.eclipse.mylyn.internal.tasks.ui.views;
-import java.text.MessageFormat;
import java.util.Iterator;
-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.jobs.Job;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.mylyn.commons.workbench.WorkbenchUtil;
import org.eclipse.mylyn.internal.tasks.ui.actions.AbstractTaskRepositoryAction;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
-import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.TasksUi;
-import org.eclipse.ui.PlatformUI;
+import org.eclipse.mylyn.tasks.core.sync.TaskJob;
/**
* @author Mik Kersten
+ * @author Steffen Pingel
*/
public class UpdateRepositoryConfigurationAction extends AbstractTaskRepositoryAction {
@@ -47,46 +40,11 @@ public class UpdateRepositoryConfigurationAction extends AbstractTaskRepositoryA
for (Iterator<?> iter = selection.iterator(); iter.hasNext();) {
final TaskRepository repository = getTaskRepository(iter.next());
if (repository != null) {
- final AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector(
- repository.getConnectorKind());
- if (connector != null) {
- final String jobName = MessageFormat.format(
- Messages.UpdateRepositoryConfigurationAction_Updating_repository_configuration_for_X,
- repository.getRepositoryUrl());
- Job updateJob = new Job(jobName) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- monitor.beginTask(jobName, IProgressMonitor.UNKNOWN);
- try {
- performUpdate(repository, connector, monitor);
- } finally {
- monitor.done();
- }
- return Status.OK_STATUS;
- }
- };
- // show the progress in the system task bar if this is a user job (i.e. forced)
- updateJob.setProperty(WorkbenchUtil.SHOW_IN_TASKBAR_ICON_PROPERTY, Boolean.TRUE);
- updateJob.setUser(true);
- updateJob.schedule();
- }
+ TaskJob job = TasksUiInternal.updateRepositoryConfiguration(repository);
+ // show the progress in the system task bar if this is a user job (i.e. forced)
+ job.setProperty(WorkbenchUtil.SHOW_IN_TASKBAR_ICON_PROPERTY, Boolean.TRUE);
}
}
}
- public void performUpdate(final TaskRepository repository, final AbstractRepositoryConnector connector,
- IProgressMonitor monitor) {
- try {
- connector.updateRepositoryConfiguration(repository, monitor);
- } catch (final CoreException e) {
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- TasksUiInternal.displayStatus(
- Messages.UpdateRepositoryConfigurationAction_Error_updating_repository_configuration,
- e.getStatus());
- }
- });
- }
- }
-
}