aboutsummaryrefslogtreecommitdiffstats
path: root/rba.tool.editor.ui/src/rba/tool/editor/ui/util/concurrent/AbstractSwitchProjectProgress.java
diff options
context:
space:
mode:
authorKenji Hosokawa <khosokawa@jp.adit-jv.com>2021-08-03 18:42:39 +0900
committerKenji Hosokawa <khosokawa@jp.adit-jv.com>2021-08-06 19:32:38 +0900
commitbe4f78978faba3d3ceb88df02a7f93a2e09ff1e0 (patch)
tree1f3f1a96251ac4f655c8a96fc33d5d4ee779cd06 /rba.tool.editor.ui/src/rba/tool/editor/ui/util/concurrent/AbstractSwitchProjectProgress.java
parent71ca7c6cab863767ef30c8bd05b2bbfda8731cb5 (diff)
Initial commit
Bug-AGL: SPEC-4033 Signed-off-by: Kenji Hosokawa <khosokawa@jp.adit-jv.com>
Diffstat (limited to 'rba.tool.editor.ui/src/rba/tool/editor/ui/util/concurrent/AbstractSwitchProjectProgress.java')
-rw-r--r--rba.tool.editor.ui/src/rba/tool/editor/ui/util/concurrent/AbstractSwitchProjectProgress.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/rba.tool.editor.ui/src/rba/tool/editor/ui/util/concurrent/AbstractSwitchProjectProgress.java b/rba.tool.editor.ui/src/rba/tool/editor/ui/util/concurrent/AbstractSwitchProjectProgress.java
new file mode 100644
index 0000000..2d640d3
--- /dev/null
+++ b/rba.tool.editor.ui/src/rba/tool/editor/ui/util/concurrent/AbstractSwitchProjectProgress.java
@@ -0,0 +1,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);
+}