1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.actions;
13 import java.lang.reflect.InvocationTargetException;
15 //import net.sourceforge.phpeclipse.PHPeclipsePlugin;
17 import org.eclipse.core.resources.IWorkspaceRunnable;
18 import org.eclipse.core.runtime.CoreException;
19 import org.eclipse.core.runtime.IProgressMonitor;
20 import org.eclipse.core.runtime.OperationCanceledException;
21 import org.eclipse.jface.operation.IRunnableWithProgress;
24 * An <code>IRunnableWithProgress</code> that adapts and
25 * <code>IWorkspaceRunnable</code> so that is can be executed inside
26 * <code>IRunnableContext</code>. <code>OperationCanceledException</code>
27 * thrown by the apapted runnabled are cought and rethrown as a
28 * <code>InterruptedException</code>.
30 public class WorkbenchRunnableAdapter implements IRunnableWithProgress {
32 private IWorkspaceRunnable fWorkspaceRunnable;
34 public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable) {
35 fWorkspaceRunnable = runnable;
39 * @see IRunnableWithProgress#run(IProgressMonitor)
41 public void run(IProgressMonitor monitor) throws InvocationTargetException,
42 InterruptedException {
44 PHPeclipsePlugin.run(fWorkspaceRunnable, monitor);
45 } catch (OperationCanceledException e) {
46 throw new InterruptedException(e.getMessage());
47 } catch (CoreException e) {
48 throw new InvocationTargetException(e);