1 /******************************************************************************* 2 * Copyright (c) 2000, 2015 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.jface.operation; 15 16 import java.lang.reflect.InvocationTargetException; 17 18 /** 19 * Interface for UI components which can execute a long-running operation 20 * in the form of an <code>IRunnableWithProgress</code>. 21 * The context is responsible for displaying a progress indicator and Cancel 22 * button to the end user while the operation is in progress; the context 23 * supplies a progress monitor to be used from code running inside the operation. 24 * Note that an <code>IRunnableContext</code> is not a runnable itself. 25 * <p> 26 * For examples of UI components which implement this interface, 27 * see <code>ApplicationWindow</code>, <code>ProgressMonitorDialog</code>, 28 * and <code>WizardDialog</code>. 29 * </p> 30 * 31 * @see IRunnableWithProgress 32 * @see org.eclipse.jface.window.ApplicationWindow 33 * @see org.eclipse.jface.dialogs.ProgressMonitorDialog 34 * @see org.eclipse.jface.wizard.WizardDialog 35 */ 36 public interface IRunnableContext { 37 /** 38 * <p> 39 * Runs the given <code>IRunnableWithProgress</code> in this context. 40 * For example, if this is a <code>ProgressMonitorDialog</code> then the runnable 41 * is run using this dialog's progress monitor. 42 * </p> 43 * <p> 44 * If <code>fork</code> is <code>false</code>, the current thread is used 45 * to run the runnable. Note that if <code>fork</code> is <code>true</code>, 46 * it is unspecified whether or not this method blocks until the runnable 47 * has been run. Implementers should document whether the runnable is run 48 * synchronously (blocking) or asynchronously (non-blocking), or if no 49 * assumption can be made about the blocking behaviour. 50 * </p> 51 * 52 * @param fork <code>true</code> if the runnable should be run in a separate thread, 53 * and <code>false</code> to run in the same thread 54 * @param cancelable <code>true</code> to enable the cancelation, and 55 * <code>false</code> to make the operation uncancellable 56 * @param runnable the runnable to run 57 * 58 * @exception InvocationTargetException wraps any exception or error which occurs 59 * while running the runnable 60 * @exception InterruptedException propagated by the context if the runnable 61 * acknowledges cancelation by throwing this exception. This should not be thrown 62 * if cancelable is <code>false</code>. 63 */ run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)64 public void run(boolean fork, boolean cancelable, 65 IRunnableWithProgress runnable) throws InvocationTargetException, 66 InterruptedException; 67 } 68