6a8566537a8f959f5d1589234500e95f1be97eb1
[phpeclipse.git] /
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.actions;
12
13 import java.lang.reflect.InvocationTargetException;
14
15 //import net.sourceforge.phpeclipse.PHPeclipsePlugin;
16
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;
22
23 /**
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>.
29  */
30 public class WorkbenchRunnableAdapter implements IRunnableWithProgress {
31
32         private IWorkspaceRunnable fWorkspaceRunnable;
33
34         public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable) {
35                 fWorkspaceRunnable = runnable;
36         }
37
38         /*
39          * @see IRunnableWithProgress#run(IProgressMonitor)
40          */
41         public void run(IProgressMonitor monitor) throws InvocationTargetException,
42                         InterruptedException {
43                 try {
44                         PHPeclipsePlugin.run(fWorkspaceRunnable, monitor);
45                 } catch (OperationCanceledException e) {
46                         throw new InterruptedException(e.getMessage());
47                 } catch (CoreException e) {
48                         throw new InvocationTargetException(e);
49                 }
50         }
51
52 }