Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2016-10-14 19:37:22 +0000
committerSergey Prigogin2016-10-14 19:38:12 +0000
commit0102719c78c4adf685da7873143f8c37f853eb5f (patch)
tree1ab746713da6bfcd56adee38009dee8b4a425518
parent7cb266737ba4c58882c302d8fc03bc820e898b82 (diff)
downloadeclipse.platform.team-0102719c78c4adf685da7873143f8c37f853eb5f.tar.gz
eclipse.platform.team-0102719c78c4adf685da7873143f8c37f853eb5f.tar.xz
eclipse.platform.team-0102719c78c4adf685da7873143f8c37f853eb5f.zip
Fixed compiler warnings and other cleanup.
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Worker.java24
1 files changed, 13 insertions, 11 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Worker.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Worker.java
index d68b7f760..724ca183b 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Worker.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Worker.java
@@ -14,7 +14,10 @@ import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.ProgressMonitorWrapper;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
/**
@@ -25,25 +28,28 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
* to the end of the work queue.
*/
public class Worker implements IRunnableWithProgress {
-
private final WorkQueue work = new WorkQueue();
private boolean isWorking;
- private final List errors = new ArrayList();
+ private final List<Throwable> errors = new ArrayList<>();
private WorkProgressMonitor currentMonitor;
private IRunnableWithProgress currentTask;
private final String taskName;
/**
- * Progress monitor that supports local cancelation of a task.
+ * Progress monitor that supports local cancellation of a task.
*/
private static class WorkProgressMonitor extends ProgressMonitorWrapper {
private boolean localCancel;
+
protected WorkProgressMonitor(IProgressMonitor monitor) {
super(monitor);
}
+
public void cancelTask() {
localCancel = true;
}
+
+ @Override
public boolean isCanceled() {
return localCancel || super.isCanceled();
}
@@ -53,6 +59,7 @@ public class Worker implements IRunnableWithProgress {
this.taskName = taskName;
}
+ @Override
public void run(IProgressMonitor monitor) {
errors.clear();
SubMonitor pm = SubMonitor.convert(monitor, getTaskName(), 100);
@@ -62,9 +69,6 @@ public class Worker implements IRunnableWithProgress {
try {
performNextTask(pm);
checkCancelled(pm);
- } catch (OperationCanceledException e) {
- // Only cancel all the work if the outer monitor is canceled
- checkCancelled(pm);
} catch (InterruptedException e) {
// Only cancel all the work if the outer monitor is canceled
checkCancelled(pm);
@@ -73,13 +77,12 @@ public class Worker implements IRunnableWithProgress {
}
pm.setWorkRemaining(100);
}
+ pm.done();
} catch (OperationCanceledException e) {
// The user chose to cancel
work.clear();
} finally {
isWorking = false;
- if (monitor!= null)
- monitor.done();
currentMonitor = null;
currentTask = null;
}
@@ -94,7 +97,7 @@ public class Worker implements IRunnableWithProgress {
}
public Throwable[] getErrors() {
- return (Throwable[]) errors.toArray(new Throwable[errors.size()]);
+ return errors.toArray(new Throwable[errors.size()]);
}
private void checkCancelled(SubMonitor pm) {
@@ -130,5 +133,4 @@ public class Worker implements IRunnableWithProgress {
public boolean hasWork() {
return isWorking() || !work.isEmpty();
}
-
}

Back to the top