01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jface.operation;
11:
12: import java.lang.reflect.InvocationTargetException;
13:
14: import org.eclipse.core.runtime.IProgressMonitor;
15:
16: /**
17: * The <code>IRunnableWithProgress</code> interface should be implemented by any
18: * class whose instances are intended to be executed as a long-running operation.
19: * Long-running operations are typically presented at the UI via a modal dialog
20: * showing a progress indicator and a Cancel button.
21: * The class must define a <code>run</code> method that takes a progress monitor.
22: * The <code>run</code> method is usually not invoked directly, but rather by
23: * passing the <code>IRunnableWithProgress</code> to the <code>run</code> method of
24: * an <code>IRunnableContext</code>, which provides the UI for the progress monitor
25: * and Cancel button.
26: *
27: * @see IRunnableContext
28: */
29: public interface IRunnableWithProgress {
30: /**
31: * Runs this operation. Progress should be reported to the given progress monitor.
32: * This method is usually invoked by an <code>IRunnableContext</code>'s <code>run</code> method,
33: * which supplies the progress monitor.
34: * A request to cancel the operation should be honored and acknowledged
35: * by throwing <code>InterruptedException</code>.
36: *
37: * @param monitor the progress monitor to use to display progress and receive
38: * requests for cancelation
39: * @exception InvocationTargetException if the run method must propagate a checked exception,
40: * it should wrap it inside an <code>InvocationTargetException</code>; runtime exceptions are automatically
41: * wrapped in an <code>InvocationTargetException</code> by the calling context
42: * @exception InterruptedException if the operation detects a request to cancel,
43: * using <code>IProgressMonitor.isCanceled()</code>, it should exit by throwing
44: * <code>InterruptedException</code>
45: *
46: * @see IRunnableContext#run
47: */
48: public void run(IProgressMonitor monitor)
49: throws InvocationTargetException, InterruptedException;
50: }
|