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 net.sourceforge.phpeclipse.PHPeclipsePlugin;
19 import org.eclipse.core.resources.IWorkspaceRunnable;
20 import org.eclipse.core.runtime.CoreException;
21 import org.eclipse.core.runtime.IProgressMonitor;
22 import org.eclipse.core.runtime.OperationCanceledException;
23 import org.eclipse.jface.operation.IRunnableWithProgress;
26 * An <code>IRunnableWithProgress</code> that adapts and
27 * <code>IWorkspaceRunnable</code> so that is can be executed inside
28 * <code>IRunnableContext</code>. <code>OperationCanceledException</code>
29 * thrown by the apapted runnabled are cought and rethrown as a
30 * <code>InterruptedException</code>.
32 public class WorkbenchRunnableAdapter implements IRunnableWithProgress {
34 private IWorkspaceRunnable fWorkspaceRunnable;
36 public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable) {
37 fWorkspaceRunnable = runnable;
41 * @see IRunnableWithProgress#run(IProgressMonitor)
43 public void run(IProgressMonitor monitor) throws InvocationTargetException,
44 InterruptedException {
46 PHPeclipsePlugin.run(fWorkspaceRunnable, monitor);
47 } catch (OperationCanceledException e) {
48 throw new InterruptedException(e.getMessage());
49 } catch (CoreException e) {
50 throw new InvocationTargetException(e);