1) Added missing strings for italic, underline and strike through.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / BatchOperation.java
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.core;
12
13 import net.sourceforge.phpdt.core.IJavaModelStatus;
14 import net.sourceforge.phpdt.core.JavaModelException;
15
16 import org.eclipse.core.resources.IResourceStatus;
17 import org.eclipse.core.resources.IWorkspaceRunnable;
18 import org.eclipse.core.runtime.CoreException;
19
20 /**
21  * An operation created as a result of a call to
22  * JavaCore.run(IWorkspaceRunnable, IProgressMonitor) that encapsulates a user
23  * defined IWorkspaceRunnable.
24  */
25 public class BatchOperation extends JavaModelOperation {
26         protected IWorkspaceRunnable runnable;
27
28         public BatchOperation(IWorkspaceRunnable runnable) {
29                 this.runnable = runnable;
30         }
31
32         /*
33          * (non-Javadoc)
34          * 
35          * @see net.sourceforge.phpdt.internal.core.JavaModelOperation#executeOperation()
36          */
37         protected void executeOperation() throws JavaModelException {
38                 try {
39                         this.runnable.run(progressMonitor);
40                 } catch (CoreException ce) {
41                         if (ce instanceof JavaModelException) {
42                                 throw (JavaModelException) ce;
43                         } else {
44                                 if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
45                                         Throwable e = ce.getStatus().getException();
46                                         if (e instanceof JavaModelException) {
47                                                 throw (JavaModelException) e;
48                                         }
49                                 }
50                                 throw new JavaModelException(ce);
51                         }
52                 }
53         }
54
55         /*
56          * (non-Javadoc)
57          * 
58          * @see net.sourceforge.phpdt.internal.core.JavaModelOperation#verify()
59          */
60         protected IJavaModelStatus verify() {
61                 // cannot verify user defined operation
62                 return JavaModelStatus.VERIFIED_OK;
63         }
64
65 }