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: /**
15: * Interface for UI components which can execute a long-running operation
16: * in the form of an <code>IRunnableWithProgress</code>.
17: * The context is responsible for displaying a progress indicator and Cancel
18: * button to the end user while the operation is in progress; the context
19: * supplies a progress monitor to be used from code running inside the operation.
20: * Note that an <code>IRunnableContext</code> is not a runnable itself.
21: * <p>
22: * For examples of UI components which implement this interface,
23: * see <code>ApplicationWindow</code>, <code>ProgressMonitorDialog</code>,
24: * and <code>WizardDialog</code>.
25: * </p>
26: *
27: * @see IRunnableWithProgress
28: * @see org.eclipse.jface.window.ApplicationWindow
29: * @see org.eclipse.jface.dialogs.ProgressMonitorDialog
30: * @see org.eclipse.jface.wizard.WizardDialog
31: */
32: public interface IRunnableContext {
33: /**
34: * <p>
35: * Runs the given <code>IRunnableWithProgress</code> in this context.
36: * For example, if this is a <code>ProgressMonitorDialog</code> then the runnable
37: * is run using this dialog's progress monitor.
38: * </p>
39: * <p>
40: * If <code>fork</code> is <code>false</code>, the current thread is used
41: * to run the runnable. Note that if <code>fork</code> is <code>true</code>,
42: * it is unspecified whether or not this method blocks until the runnable
43: * has been run. Implementers should document whether the runnable is run
44: * synchronously (blocking) or asynchronously (non-blocking), or if no
45: * assumption can be made about the blocking behaviour.
46: * </p>
47: *
48: * @param fork <code>true</code> if the runnable should be run in a separate thread,
49: * and <code>false</code> to run in the same thread
50: * @param cancelable <code>true</code> to enable the cancelation, and
51: * <code>false</code> to make the operation uncancellable
52: * @param runnable the runnable to run
53: *
54: * @exception InvocationTargetException wraps any exception or error which occurs
55: * while running the runnable
56: * @exception InterruptedException propagated by the context if the runnable
57: * acknowledges cancelation by throwing this exception. This should not be thrown
58: * if cancelable is <code>false</code>.
59: */
60: public void run(boolean fork, boolean cancelable,
61: IRunnableWithProgress runnable)
62: throws InvocationTargetException, InterruptedException;
63: }
|