Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoribull2010-03-08 23:22:05 -0500
committeribull2010-03-08 23:22:05 -0500
commit6811abcca7f2fd085936197acaa74b64c4132956 (patch)
treea6ed4c03a5bed3ecec1d8bd1dcf79ca15e99740d /bundles/org.eclipse.equinox.p2.repository
parent90215b3eeef942560b1ca950c70aceee175d3da6 (diff)
downloadrt.equinox.p2-6811abcca7f2fd085936197acaa74b64c4132956.tar.gz
rt.equinox.p2-6811abcca7f2fd085936197acaa74b64c4132956.tar.xz
rt.equinox.p2-6811abcca7f2fd085936197acaa74b64c4132956.zip
bug 305064: [api] Add a progress monitor to the execute batch method
https://bugs.eclipse.org/bugs/show_bug.cgi?id=305064
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository')
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/IRunnableWithProgress.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepository.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/spi/AbstractArtifactRepository.java7
3 files changed, 38 insertions, 4 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/IRunnableWithProgress.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/IRunnableWithProgress.java
new file mode 100644
index 000000000..b4b73442b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/IRunnableWithProgress.java
@@ -0,0 +1,32 @@
+package org.eclipse.equinox.p2.repository;
+
+import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+
+/**
+ * The <code>IRunnableWithProgress</code> interface should be implemented by any
+ * class whose instances are intended to be executed as a long-running operation.
+ * Long-running operations are typically presented at the UI via a modal dialog
+ * showing a progress indicator and a Cancel button.
+ * The class must define a <code>run</code> method that takes a progress monitor.
+ *
+ * @since 2.0
+ */
+public interface IRunnableWithProgress {
+
+ /**
+ * Runs this operation. Progress should be reported to the given progress monitor.
+ * This method is usually invoked by an <code>IRunnableContext</code>'s <code>run</code> method,
+ * which supplies the progress monitor.
+ * A request to cancel the operation should be honored and acknowledged
+ * by throwing <code>InterruptedException</code>.
+ *
+ * @param monitor the progress monitor to use to display progress and receive
+ * requests for cancelation
+ * @exception OperationCanceledException if the operation detects a request to cancel,
+ * using <code>IProgressMonitor.isCanceled()</code>, it should exit by throwing
+ * <code>OperationCanceledException</code>
+ */
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, OperationCanceledException;
+}
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepository.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepository.java
index ce2b41a64..e5d782559 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepository.java
@@ -18,6 +18,7 @@ import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.IRunnableWithProgress;
import org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository;
/**
@@ -175,6 +176,6 @@ public interface IArtifactRepository extends IRepository<IArtifactKey> {
* @return The result of running the runnable. Any exceptions thrown during
* the execution will be returned in the status.
*/
- public IStatus executeBatch(Runnable runnable);
+ public IStatus executeBatch(IRunnableWithProgress runnable, IProgressMonitor monitor);
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/spi/AbstractArtifactRepository.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/spi/AbstractArtifactRepository.java
index 93f4173a5..2ae04bd70 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/spi/AbstractArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/spi/AbstractArtifactRepository.java
@@ -20,6 +20,7 @@ import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.repository.IRunnableWithProgress;
import org.eclipse.equinox.p2.repository.artifact.*;
import org.eclipse.equinox.p2.repository.spi.AbstractRepository;
@@ -89,14 +90,14 @@ public abstract class AbstractArtifactRepository extends AbstractRepository<IArt
public IArtifactDescriptor createArtifactDescriptor(IArtifactKey key) {
return new ArtifactDescriptor(key);
}
-
+
public IArtifactKey createArtifactKey(String classifier, String id, Version version) {
return new ArtifactKey(classifier, id, version);
}
- public IStatus executeBatch(Runnable runnable) {
+ public IStatus executeBatch(IRunnableWithProgress runnable, IProgressMonitor monitor) {
try {
- runnable.run();
+ runnable.run(monitor);
} catch (Exception e) {
return new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e);
}

Back to the top