Mercurial > projects > dwt-addons
diff dwtx/jface/operation/IRunnableWithProgress.d @ 6:1a6747be662d
Jface operations
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 28 Mar 2008 19:31:01 +0100 |
parents | |
children | 89776a9bb8b2 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwtx/jface/operation/IRunnableWithProgress.d Fri Mar 28 19:31:01 2008 +0100 @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ +module dwtx.jface.operation.IRunnableWithProgress; + +import dwtx.core.runtime.IProgressMonitor; + +import dwt.dwthelper.utils; + +/** + * 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. + * The <code>run</code> method is usually not invoked directly, but rather by + * passing the <code>IRunnableWithProgress</code> to the <code>run</code> method of + * an <code>IRunnableContext</code>, which provides the UI for the progress monitor + * and Cancel button. + * + * @see IRunnableContext + */ +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 InvocationTargetException if the run method must propagate a checked exception, + * it should wrap it inside an <code>InvocationTargetException</code>; runtime exceptions are automatically + * wrapped in an <code>InvocationTargetException</code> by the calling context + * @exception InterruptedException if the operation detects a request to cancel, + * using <code>IProgressMonitor.isCanceled()</code>, it should exit by throwing + * <code>InterruptedException</code> + * + * @see IRunnableContext#run + */ + public void run(IProgressMonitor monitor); +}