Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Xenos2016-02-05 15:48:39 +0000
committerStefan Xenos2016-03-14 21:16:42 +0000
commit04ff0093b42c511695b2ca47494365e5d8214662 (patch)
tree67ae66fc256bc7372ddf8c40b9f20e744b6813c9 /bundles/org.eclipse.equinox.common
parentab9296ce2fe84e0ab7ce1657c46c387895fff029 (diff)
downloadrt.equinox.bundles-04ff0093b42c511695b2ca47494365e5d8214662.tar.gz
rt.equinox.bundles-04ff0093b42c511695b2ca47494365e5d8214662.tar.xz
rt.equinox.bundles-04ff0093b42c511695b2ca47494365e5d8214662.zip
Bug 385451 - SubMonitor should provide a helper method for doneI20160315-0800I20160314-2000
Add a helper method for invoking done on a nullable IProgressMonitor. Change-Id: Ic5b9889049f1de032f1bb716c649211f86f32e13 Signed-off-by: Stefan Xenos <sxenos@gmail.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.common')
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubMonitor.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubMonitor.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubMonitor.java
index c77a1035..88b904a5 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubMonitor.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubMonitor.java
@@ -120,9 +120,7 @@ package org.eclipse.core.runtime;
* doSomeWork(progress.split(40));
*
* } finally {
- * if (monitor != null) {
- * monitor.done();
- * }
+ * SubMonitor.done(monitor);
* }
* }
* </pre>
@@ -503,6 +501,21 @@ public final class SubMonitor implements IProgressMonitorWithBlocking {
}
/**
+ * Calls {@link #done()} on the given monitor if is non-null. If the given monitor is null,
+ * this is a no-op.
+ * <p>
+ * This is a convenience method intended to reduce the boilerplate around code which must call
+ * {@link #done()} on a possibly-null monitor.
+ *
+ * @param monitor a progress monitor or null
+ */
+ public static void done(IProgressMonitor monitor) {
+ if (monitor != null) {
+ monitor.done();
+ }
+ }
+
+ /**
* <p>Sets the work remaining for this SubMonitor instance. This is the total number
* of ticks that may be reported by all subsequent calls to worked(int), split(int), etc.
* This may be called many times for the same SubMonitor instance. When this method

Back to the top