Introduce checkCanceled on IProgressMonitor

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>
diff --git a/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF
index 09df9e6..03ecad8 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 @@
 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 a94af2d..438382b 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 89ade75..9a89607 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 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 5b72ed2..4dbd19d 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 @@
 	 * @see #isCanceled()
 	 * @since 3.9
 	 */
+	@Override
 	public SubMonitor checkCanceled() throws OperationCanceledException {
 		if (isCanceled()) {
 			throw new OperationCanceledException();