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.core;
13 import net.sourceforge.phpdt.core.IJavaModelStatus;
14 import net.sourceforge.phpdt.core.JavaModelException;
16 import org.eclipse.core.resources.IResourceStatus;
17 import org.eclipse.core.resources.IWorkspaceRunnable;
18 import org.eclipse.core.runtime.CoreException;
22 * An operation created as a result of a call to JavaCore.run(IWorkspaceRunnable, IProgressMonitor)
23 * that encapsulates a user defined IWorkspaceRunnable.
25 public class BatchOperation extends JavaModelOperation {
26 protected IWorkspaceRunnable runnable;
27 public BatchOperation(IWorkspaceRunnable runnable) {
28 this.runnable = runnable;
32 * @see org.eclipse.jdt.internal.core.JavaModelOperation#executeOperation()
34 protected void executeOperation() throws JavaModelException {
36 this.runnable.run(progressMonitor);
37 } catch (CoreException ce) {
38 if (ce instanceof JavaModelException) {
39 throw (JavaModelException)ce;
41 if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
42 Throwable e= ce.getStatus().getException();
43 if (e instanceof JavaModelException) {
44 throw (JavaModelException) e;
47 throw new JavaModelException(ce);
53 * @see org.eclipse.jdt.internal.core.JavaModelOperation#verify()
55 protected IJavaModelStatus verify() {
56 // cannot verify user defined operation
57 return JavaModelStatus.VERIFIED_OK;