KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > operation > IRunnableWithProgress


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jface.operation;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
14
15 import org.eclipse.core.runtime.IProgressMonitor;
16
17 /**
18  * The <code>IRunnableWithProgress</code> interface should be implemented by any
19  * class whose instances are intended to be executed as a long-running operation.
20  * Long-running operations are typically presented at the UI via a modal dialog
21  * showing a progress indicator and a Cancel button.
22  * The class must define a <code>run</code> method that takes a progress monitor.
23  * The <code>run</code> method is usually not invoked directly, but rather by
24  * passing the <code>IRunnableWithProgress</code> to the <code>run</code> method of
25  * an <code>IRunnableContext</code>, which provides the UI for the progress monitor
26  * and Cancel button.
27  *
28  * @see IRunnableContext
29  */

30 public interface IRunnableWithProgress {
31     /**
32      * Runs this operation. Progress should be reported to the given progress monitor.
33      * This method is usually invoked by an <code>IRunnableContext</code>'s <code>run</code> method,
34      * which supplies the progress monitor.
35      * A request to cancel the operation should be honored and acknowledged
36      * by throwing <code>InterruptedException</code>.
37      *
38      * @param monitor the progress monitor to use to display progress and receive
39      * requests for cancelation
40      * @exception InvocationTargetException if the run method must propagate a checked exception,
41      * it should wrap it inside an <code>InvocationTargetException</code>; runtime exceptions are automatically
42      * wrapped in an <code>InvocationTargetException</code> by the calling context
43      * @exception InterruptedException if the operation detects a request to cancel,
44      * using <code>IProgressMonitor.isCanceled()</code>, it should exit by throwing
45      * <code>InterruptedException</code>
46      *
47      * @see IRunnableContext#run
48      */

49     public void run(IProgressMonitor monitor) throws InvocationTargetException JavaDoc,
50             InterruptedException JavaDoc;
51 }
52
Popular Tags