blob: 47576e5f047cff0f998012a67f84148e566cbb09 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/*******************************************************************************
* Copyright (c) 2001, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Rational Software - initial implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.model;
import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.CModelException;
/**
* An operation created as a result of a call to JavaCore.run(IWorkspaceRunnable, IProgressMonitor)
* that encapsulates a user defined IWorkspaceRunnable.
*/
public class BatchOperation extends CModelOperation {
protected IWorkspaceRunnable runnable;
public BatchOperation(IWorkspaceRunnable runnable) {
this.runnable = runnable;
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.core.JavaModelOperation#executeOperation()
*/
@Override
protected void executeOperation() throws CModelException {
try {
this.runnable.run(fMonitor);
} catch (CoreException ce) {
if (ce instanceof CModelException) {
throw (CModelException)ce;
}
if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
Throwable e= ce.getStatus().getException();
if (e instanceof CModelException) {
throw (CModelException) e;
}
}
throw new CModelException(ce);
}
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.core.JavaModelOperation#verify()
*/
@Override
protected ICModelStatus verify() {
// cannot verify user defined operation
return CModelStatus.VERIFIED_OK;
}
}
|