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;
21 * An operation created as a result of a call to
22 * JavaCore.run(IWorkspaceRunnable, IProgressMonitor) that encapsulates a user
23 * defined IWorkspaceRunnable.
25 public class BatchOperation extends JavaModelOperation {
26 protected IWorkspaceRunnable runnable;
28 public BatchOperation(IWorkspaceRunnable runnable) {
29 this.runnable = runnable;
35 * @see net.sourceforge.phpdt.internal.core.JavaModelOperation#executeOperation()
37 protected void executeOperation() throws JavaModelException {
39 this.runnable.run(progressMonitor);
40 } catch (CoreException ce) {
41 if (ce instanceof JavaModelException) {
42 throw (JavaModelException) ce;
44 if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
45 Throwable e = ce.getStatus().getException();
46 if (e instanceof JavaModelException) {
47 throw (JavaModelException) e;
50 throw new JavaModelException(ce);
58 * @see net.sourceforge.phpdt.internal.core.JavaModelOperation#verify()
60 protected IJavaModelStatus verify() {
61 // cannot verify user defined operation
62 return JavaModelStatus.VERIFIED_OK;