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.PHPCore;
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;
25 * An <code>IRunnableWithProgress</code> that adapts and <code>IWorkspaceRunnable</code>
26 * so that is can be executed inside <code>IRunnableContext</code>. <code>OperationCanceledException</code>
27 * thrown by the apapted runnabled are cought and rethrown as a <code>InterruptedException</code>.
29 public class WorkbenchRunnableAdapter implements IRunnableWithProgress {
31 private IWorkspaceRunnable fWorkspaceRunnable;
33 public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable) {
34 fWorkspaceRunnable= runnable;
38 * @see IRunnableWithProgress#run(IProgressMonitor)
40 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
42 PHPCore.run(fWorkspaceRunnable, monitor);
43 } catch (OperationCanceledException e) {
44 throw new InterruptedException(e.getMessage());
45 } catch (CoreException e) {
46 throw new InvocationTargetException(e);