blob: 2d640d33073c499b7840daceaab886a2931ad1b9 (
plain)
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
|
package rba.tool.editor.ui.util.concurrent;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import rba.tool.editor.ui.editor.model.manager.ResourceManagerUI;
public abstract class AbstractSwitchProjectProgress<R, P> implements IUnitOfProgress<Object, IProject> {
private final boolean showConfirmDialog;
public AbstractSwitchProjectProgress() {
this(true);
}
public AbstractSwitchProjectProgress(boolean showConfirmDialog) {
this.showConfirmDialog = showConfirmDialog;
}
@Override
public R exec(IProject state) throws Exception {
SubMonitor progress = SubMonitor.convert(null, 6);
if (!ResourceManagerUI.INSTANCE.isCurrentProject(state)) {
if (ResourceManagerUI.INSTANCE.doConfirm(state, showConfirmDialog)) {
ResourceManagerUI.INSTANCE.switchToProject(state, progress.newChild(2));
if (progress.isCanceled()) {
throw new InterruptedException();
}
return internalExec(state, progress.newChild(4));
} else {
throw new InterruptedException();
}
}
return internalExec(state, progress.newChild(4));
}
protected abstract R internalExec(IProject state, IProgressMonitor monitor);
}
|