Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2007-11-07 07:33:27 +0000
committerspingel2007-11-07 07:33:27 +0000
commit2c0c1eac2aaab8112dee5a706346d95b19bb1fb8 (patch)
treeffe74a8a42659d059c2b9dbf85096a0929a0f8da
parent8220ddc571a9400be01bca85e8e12cf0e1f5cf2b (diff)
downloadorg.eclipse.mylyn.tasks-2c0c1eac2aaab8112dee5a706346d95b19bb1fb8.tar.gz
org.eclipse.mylyn.tasks-2c0c1eac2aaab8112dee5a706346d95b19bb1fb8.tar.xz
org.eclipse.mylyn.tasks-2c0c1eac2aaab8112dee5a706346d95b19bb1fb8.zip
NEW - bug 143011: [api] synchronization jobs should be cancellable
https://bugs.eclipse.org/bugs/show_bug.cgi?id=143011
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/SynchronizeQueryJob.java3
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/SynchronizeTaskJob.java7
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java3
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java14
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java10
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracWikiHandler.java17
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracRenderingEngine.java4
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/NewTracTaskPage.java12
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracCustomQueryPage.java20
9 files changed, 39 insertions, 51 deletions
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 f3b8bf61a..e47937258 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
@@ -16,6 +16,7 @@ import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
@@ -166,6 +167,8 @@ class SynchronizeQueryJob extends Job {
}
taskList.notifyContainersUpdated(null);
return Status.OK_STATUS;
+ } catch (OperationCanceledException e) {
+ return Status.CANCEL_STATUS;
} finally {
monitor.done();
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/SynchronizeTaskJob.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/SynchronizeTaskJob.java
index c9bc53c07..cd2671e89 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/SynchronizeTaskJob.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/SynchronizeTaskJob.java
@@ -83,6 +83,7 @@ class SynchronizeTaskJob extends Job {
monitor.beginTask(LABEL_SYNCHRONIZING, repositoryTasks.size());
setProperty(IProgressConstants.ICON_PROPERTY, TasksUiImages.REPOSITORY_SYNCHRONIZE);
+ // sort tasks by repository
for (final AbstractTask repositoryTask : repositoryTasks) {
if (monitor.isCanceled()) {
@@ -127,12 +128,11 @@ class SynchronizeTaskJob extends Job {
return Status.CANCEL_STATUS;
}
+ // synchronize tasks per repository if multi-sync is supported
for (TaskRepository repository : repToTasks.keySet()) {
Set<AbstractTask> tasksToSynch = repToTasks.get(repository);
try {
synchronizeTasks(new SubProgressMonitor(monitor, tasksToSynch.size()), repository, tasksToSynch);
- } catch (OperationCanceledException e) {
- return Status.CANCEL_STATUS;
} catch (final CoreException e) {
for (AbstractTask task : tasksToSynch) {
updateStatus(repository, task, e.getStatus());
@@ -146,7 +146,8 @@ class SynchronizeTaskJob extends Job {
}
}
}
-
+ } catch (OperationCanceledException e) {
+ return Status.CANCEL_STATUS;
} catch (Exception e) {
StatusHandler.fail(e, "Synchronization failed", false);
} finally {
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java
index 8825f9d98..5e81fd5df 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java
@@ -14,7 +14,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
@@ -46,7 +45,7 @@ public class TracClientManager implements ITaskRepositoryListener {
readCache();
}
- public synchronized ITracClient getRepository(TaskRepository taskRepository) throws MalformedURLException {
+ public synchronized ITracClient getRepository(TaskRepository taskRepository) {
ITracClient repository = clientByUrl.get(taskRepository.getUrl());
if (repository == null) {
AbstractWebLocation location = taskRepositoryLocationFactory.createWebLocation(taskRepository);
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
index 5c943bd60..339295a1c 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
@@ -9,7 +9,6 @@
package org.eclipse.mylyn.internal.trac.core;
import java.io.File;
-import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -18,6 +17,7 @@ import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.internal.trac.core.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.core.TracAttributeFactory.Attribute;
@@ -71,12 +71,9 @@ public class TracRepositoryConnector extends AbstractRepositoryConnector {
public boolean hasWiki(TaskRepository repository) {
// check the access mode to validate Wiki support
- try {
- ITracClient client = getClientManager().getRepository(repository);
- if (client instanceof ITracWikiClient) {
- return true;
- }
- } catch (MalformedURLException e) {
+ ITracClient client = getClientManager().getRepository(repository);
+ if (client instanceof ITracWikiClient) {
+ return true;
}
return false;
}
@@ -219,7 +216,10 @@ public class TracRepositoryConnector extends AbstractRepositoryConnector {
}
return true;
+ } catch (OperationCanceledException e) {
+ throw e;
} catch (Exception e) {
+ // TODO catch TracException
throw new CoreException(TracCorePlugin.toStatus(e, repository));
}
} finally {
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
index f74ad0002..c68bcfb1e 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
@@ -20,6 +20,7 @@ import java.util.StringTokenizer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.mylyn.internal.trac.core.TracAttributeFactory.Attribute;
import org.eclipse.mylyn.internal.trac.core.model.TracAttachment;
import org.eclipse.mylyn.internal.trac.core.model.TracComment;
@@ -72,7 +73,10 @@ public class TracTaskDataHandler extends AbstractTaskDataHandler {
createDefaultAttributes(attributeFactory, data, client, true);
updateTaskData(repository, attributeFactory, data, ticket);
return data;
+ } catch (OperationCanceledException e) {
+ throw e;
} catch (Exception e) {
+ // TODO catch TracException
throw new CoreException(TracCorePlugin.toStatus(e, repository));
}
}
@@ -327,7 +331,10 @@ public class TracTaskDataHandler extends AbstractTaskDataHandler {
server.updateTicket(ticket, taskData.getNewComment());
return null;
}
+ } catch (OperationCanceledException e) {
+ throw e;
} catch (Exception e) {
+ // TODO catch TracException
throw new CoreException(TracCorePlugin.toStatus(e, repository));
}
}
@@ -340,7 +347,10 @@ public class TracTaskDataHandler extends AbstractTaskDataHandler {
client.updateAttributes(new NullProgressMonitor(), false);
createDefaultAttributes(attributeFactory, data, client, false);
return true;
+ } catch (OperationCanceledException e) {
+ throw e;
} catch (Exception e) {
+ // TODO catch TracException
throw new CoreException(TracCorePlugin.toStatus(e, repository));
}
}
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracWikiHandler.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracWikiHandler.java
index ca5110774..80ad431aa 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracWikiHandler.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracWikiHandler.java
@@ -8,7 +8,6 @@
package org.eclipse.mylyn.internal.trac.core;
-import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
@@ -93,16 +92,12 @@ public class TracWikiHandler extends AbstractWikiHandler {
}
private ITracWikiClient getTracWikiClient(TaskRepository repository) throws TracException {
- try {
- ITracClient client = connector.getClientManager().getRepository(repository);
- if (client instanceof ITracWikiClient) {
- return (ITracWikiClient) client;
- } else {
- throw new TracException("The access mode of " + repository.toString()
- + " does not support Wiki page editting.");
- }
- } catch (MalformedURLException e) {
- throw new TracException(e);
+ ITracClient client = connector.getClientManager().getRepository(repository);
+ if (client instanceof ITracWikiClient) {
+ return (ITracWikiClient) client;
+ } else {
+ throw new TracException("The access mode of " + repository.toString()
+ + " does not support Wiki page editting.");
}
}
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracRenderingEngine.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracRenderingEngine.java
index 914ded788..4d83b87c2 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracRenderingEngine.java
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracRenderingEngine.java
@@ -8,8 +8,6 @@
package org.eclipse.mylyn.internal.trac.ui.editor;
-import java.net.MalformedURLException;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
@@ -63,8 +61,6 @@ public class TracRenderingEngine extends AbstractRenderingEngine {
throw new CoreException(TracCorePlugin.toStatus(new TracException(
"Preview is available only in XML-RPC access mode"), repository));
}
- } catch (MalformedURLException e) {
- throw new CoreException(TracCorePlugin.toStatus(e, repository));
} catch (TracException e) {
throw new CoreException(TracCorePlugin.toStatus(e, repository));
} finally {
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/NewTracTaskPage.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/NewTracTaskPage.java
index bd6c6544e..c5e1be52c 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/NewTracTaskPage.java
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/NewTracTaskPage.java
@@ -9,7 +9,6 @@
package org.eclipse.mylyn.internal.trac.ui.wizard;
import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
@@ -99,13 +98,7 @@ public class NewTracTaskPage extends WizardPage {
private void updateAttributesFromRepository() {
TracRepositoryConnector connector = (TracRepositoryConnector) TasksUiPlugin.getRepositoryManager()
.getRepositoryConnector(TracCorePlugin.REPOSITORY_KIND);
- final ITracClient client;
- try {
- client = connector.getClientManager().getRepository(taskRepository);
- } catch (MalformedURLException e) {
- StatusHandler.displayStatus("Error updating attributes", TracCorePlugin.toStatus(e, taskRepository));
- return;
- }
+ final ITracClient client = connector.getClientManager().getRepository(taskRepository);
if (!client.hasAttributes()) {
try {
@@ -121,7 +114,8 @@ public class NewTracTaskPage extends WizardPage {
getContainer().run(true, true, runnable);
} catch (InvocationTargetException e) {
- StatusHandler.displayStatus("Error updating attributes", TracCorePlugin.toStatus(e.getCause(), taskRepository));
+ StatusHandler.displayStatus("Error updating attributes", TracCorePlugin.toStatus(e.getCause(),
+ taskRepository));
return;
} catch (InterruptedException e) {
return;
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracCustomQueryPage.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracCustomQueryPage.java
index a04e7075a..81971f075 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracCustomQueryPage.java
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracCustomQueryPage.java
@@ -8,7 +8,6 @@
package org.eclipse.mylyn.internal.trac.ui.wizard;
import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
@@ -364,24 +363,14 @@ public class TracCustomQueryPage extends AbstractRepositoryQueryPage {
private boolean hasAttributes() {
TracRepositoryConnector connector = (TracRepositoryConnector) TasksUiPlugin.getRepositoryManager()
.getRepositoryConnector(TracCorePlugin.REPOSITORY_KIND);
- try {
- ITracClient client = connector.getClientManager().getRepository(repository);
- return client.hasAttributes();
- } catch (MalformedURLException e) {
- return false;
- }
+ ITracClient client = connector.getClientManager().getRepository(repository);
+ return client.hasAttributes();
}
private void updateAttributesFromRepository(final boolean force) {
TracRepositoryConnector connector = (TracRepositoryConnector) TasksUiPlugin.getRepositoryManager()
.getRepositoryConnector(TracCorePlugin.REPOSITORY_KIND);
- final ITracClient client;
- try {
- client = connector.getClientManager().getRepository(repository);
- } catch (MalformedURLException e) {
- StatusHandler.displayStatus("Error updating attributes", TracCorePlugin.toStatus(e, repository));
- return;
- }
+ final ITracClient client = connector.getClientManager().getRepository(repository);
if (!client.hasAttributes() || force) {
try {
@@ -404,7 +393,8 @@ public class TracCustomQueryPage extends AbstractRepositoryQueryPage {
service.run(true, true, runnable);
}
} catch (InvocationTargetException e) {
- StatusHandler.displayStatus("Error updating attributes", TracCorePlugin.toStatus(e.getCause(), repository));
+ StatusHandler.displayStatus("Error updating attributes", TracCorePlugin.toStatus(e.getCause(),
+ repository));
return;
} catch (InterruptedException e) {
return;

Back to the top