aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Wagenknecht2018-06-13 05:10:09 -0400
committerGunnar Wagenknecht2018-06-13 09:32:12 -0400
commitfed556917739ed2076b7e51f08ab2872224ff40a (patch)
treef9f5cc4f27350a80251d231b3a822f1e3b3753b9
parent375440fab1b3538ce6d10239b919fa5283a464d7 (diff)
downloadrt.equinox.bundles-fed556917739ed2076b7e51f08ab2872224ff40a.tar.gz
rt.equinox.bundles-fed556917739ed2076b7e51f08ab2872224ff40a.tar.xz
rt.equinox.bundles-fed556917739ed2076b7e51f08ab2872224ff40a.zip
Introduce checkCanceled on IProgressMonitorI20180615-0655I20180615-0300I20180614-2045I20180614-2000
This also introduced a new class for utility methods dealing with progress monitors and cleans up IProgressMonitor interface. The version has been updated to indicate the addition of new API. Bug: 531680 Change-Id: I211e50f649380b3611708d0d0ee20a9f4c82de6f Signed-off-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
-rw-r--r--bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.common/pom.xml4
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java21
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubMonitor.java1
4 files changed, 25 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF
index 09df9e63..03ecad8e 100644
--- a/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.common; singleton:=true
-Bundle-Version: 3.10.100.qualifier
+Bundle-Version: 3.11.0.qualifier
Bundle-Localization: plugin
Export-Package: org.eclipse.core.internal.boot;x-friends:="org.eclipse.core.resources,org.eclipse.core.runtime.compatibility,org.eclipse.pde.build",
org.eclipse.core.internal.runtime;common=split;mandatory:=common;
diff --git a/bundles/org.eclipse.equinox.common/pom.xml b/bundles/org.eclipse.equinox.common/pom.xml
index a94af2d1..438382ba 100644
--- a/bundles/org.eclipse.equinox.common/pom.xml
+++ b/bundles/org.eclipse.equinox.common/pom.xml
@@ -5,7 +5,7 @@
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/org/documents/edl-v10.php
-
+
Contributors:
Igor Fedorenko - initial implementation
-->
@@ -19,6 +19,6 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
- <version>3.10.100-SNAPSHOT</version>
+ <version>3.11.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java
index 89ade753..9a896079 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java
@@ -133,6 +133,27 @@ public interface IProgressMonitor {
public boolean isCanceled();
/**
+ * Checks whether cancellation of this monitor has been requested and throws
+ * an {@link OperationCanceledException} if it was the case.
+ * <p>
+ * This method is a shorthand for:
+ * <pre>
+ * if (monitor.isCanceled())
+ * throw new OperationCanceledException();
+ * </pre>
+ * </p>
+ *
+ * @return this monitor instance for convenience (eg., chaining)
+ * @throws OperationCanceledException if {@link #isCanceled()} returns <code>true</code>
+ * @since 3.11
+ */
+ default IProgressMonitor checkCanceled() throws OperationCanceledException {
+ if (isCanceled())
+ throw new OperationCanceledException();
+ return this;
+ }
+
+ /**
* Sets the cancel state to the given value.
*
* @param value <code>true</code> indicates that cancelation has
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 5b72ed2a..4dbd19d8 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
@@ -599,6 +599,7 @@ public final class SubMonitor implements IProgressMonitorWithBlocking {
* @see #isCanceled()
* @since 3.9
*/
+ @Override
public SubMonitor checkCanceled() throws OperationCanceledException {
if (isCanceled()) {
throw new OperationCanceledException();