Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Bégaudeau2018-06-05 12:52:56 +0000
committerStéphane Bégaudeau2018-07-24 16:17:45 +0000
commitdfc57bc57addc6ece0b99fed0c173c908654d803 (patch)
tree58463d8b5daea4c98674a28770b5ff372e750b48
parent8a9d068ae67d693435f677bf033799a169888b68 (diff)
downloadorg.eclipse.sirius-dfc57bc57addc6ece0b99fed0c173c908654d803.tar.gz
org.eclipse.sirius-dfc57bc57addc6ece0b99fed0c173c908654d803.tar.xz
org.eclipse.sirius-dfc57bc57addc6ece0b99fed0c173c908654d803.zip
[509735] Add support for dialog and wizard in the workflow
The open dialog and open wizard tasks will now check if they are in the UI thread before opening respectively a dialog and a wizard. Bug: 509735 Change-Id: I987c5f16d71eb362d861610f89b4801fba5a2b1a Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.properties.core/src/org/eclipse/sirius/properties/core/internal/SiriusContext.java21
-rw-r--r--plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/dialog/DialogTask.java25
-rw-r--r--plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/wizard/WizardTask.java23
3 files changed, 51 insertions, 18 deletions
diff --git a/plugins/org.eclipse.sirius.properties.core/src/org/eclipse/sirius/properties/core/internal/SiriusContext.java b/plugins/org.eclipse.sirius.properties.core/src/org/eclipse/sirius/properties/core/internal/SiriusContext.java
index 88c231a1ae..84e145cc35 100644
--- a/plugins/org.eclipse.sirius.properties.core/src/org/eclipse/sirius/properties/core/internal/SiriusContext.java
+++ b/plugins/org.eclipse.sirius.properties.core/src/org/eclipse/sirius/properties/core/internal/SiriusContext.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016, 2017 Obeo.
+ * Copyright (c) 2016, 2018 Obeo.
* 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
@@ -18,9 +18,9 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.sirius.business.api.query.EObjectQuery;
import org.eclipse.sirius.business.api.session.Session;
-import org.eclipse.sirius.business.api.session.SessionManager;
import org.eclipse.sirius.ext.base.Option;
import org.eclipse.sirius.ext.base.Options;
+import org.eclipse.sirius.viewpoint.DAnalysis;
import org.eclipse.sirius.viewpoint.DRepresentation;
import org.eclipse.sirius.viewpoint.DRepresentationElement;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
@@ -86,6 +86,8 @@ public final class SiriusContext {
result = fromDRepresentation((DRepresentation) input);
} else if (input instanceof DRepresentationElement) {
result = fromDRepresentationElement((DRepresentationElement) input);
+ } else if (input instanceof DAnalysis) {
+ result = fromDAnalysis((DAnalysis) input);
} else if (input instanceof EObject) {
result = fromUnknownEObject((EObject) input);
} else if (input instanceof IAdaptable) {
@@ -114,7 +116,7 @@ public final class SiriusContext {
* element.
*/
private static SiriusContext fromDRepresentation(DRepresentation repr) {
- Session session = new EObjectQuery(repr).getSession();
+ Session session = Session.of(repr).orElse(null);
DSemanticDecorator decorator = null;
if (repr instanceof DSemanticDecorator) {
decorator = (DSemanticDecorator) repr;
@@ -137,6 +139,17 @@ public final class SiriusContext {
}
/**
+ * From a DAnalysis, we can find the session and use the DAnalysis as the semantic element.
+ *
+ * @param dAnalysis
+ * The DAnalysis object
+ */
+ private static SiriusContext fromDAnalysis(DAnalysis dAnalysis) {
+ Session session = Session.of(dAnalysis).orElse(null);
+ return new SiriusContext(dAnalysis, session, null, null, dAnalysis);
+ }
+
+ /**
* From an unkown EObject, we van only deduce the session (if it is part of
* one), and maybe the semantic element of the object itself is inside one
* of the session's semantic resources. This should only be called as a last
@@ -144,7 +157,7 @@ public final class SiriusContext {
* have been exhausted.
*/
private static SiriusContext fromUnknownEObject(EObject obj) {
- Session session = SessionManager.INSTANCE.getSession(obj);
+ Session session = Session.of(obj).orElse(null);
// Session.getSemanticResources() only returns non-controlled resources,
// so we need to identify the top-level Resource containing the element.
Resource res = EcoreUtil.getRootContainer(obj).eResource();
diff --git a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/dialog/DialogTask.java b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/dialog/DialogTask.java
index ff81689b84..ebf5424b56 100644
--- a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/dialog/DialogTask.java
+++ b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/dialog/DialogTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2017 Obeo.
+ * Copyright (c) 2017, 2018 Obeo.
* 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
@@ -117,15 +117,24 @@ public class DialogTask extends AbstractOperationTask {
if (eefView.getPages().size() == 1) {
EEFPage eefPage = eefView.getPages().get(0);
- Shell shell = Display.getCurrent().getActiveShell();
- FormDialog formDialog = new PropertiesFormDialog(shell, this.extPackage, this.context, this.session, siriusInterpreter, variableManager, convertedDialogModelOperation, eefPage);
- formDialog.create();
- formDialog.getShell().setMinimumSize(600, 200);
+ Runnable runnable = () -> {
+ Shell shell = Display.getCurrent().getActiveShell();
+ FormDialog formDialog = new PropertiesFormDialog(shell, this.extPackage, this.context, this.session, siriusInterpreter, variableManager, convertedDialogModelOperation, eefPage);
+ formDialog.create();
+ formDialog.getShell().setMinimumSize(600, 200);
- int returnCode = formDialog.open();
+ int returnCode = formDialog.open();
- if (Window.CANCEL == returnCode) {
- throw new OperationCanceledException();
+ if (Window.CANCEL == returnCode) {
+ throw new OperationCanceledException();
+ }
+ };
+
+ boolean isInUiThread = Display.getCurrent() != null && Display.getCurrent().getActiveShell() != null;
+ if (isInUiThread) {
+ runnable.run();
+ } else {
+ Display.getDefault().syncExec(runnable);
}
}
});
diff --git a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/wizard/WizardTask.java b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/wizard/WizardTask.java
index 88ea4f03c3..9ab215849b 100644
--- a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/wizard/WizardTask.java
+++ b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/wizard/WizardTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2017 Obeo.
+ * Copyright (c) 2017, 2018 Obeo.
* 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
@@ -107,13 +107,24 @@ public class WizardTask extends AbstractOperationTask {
EEFView eefView = eefViewFactory.createEEFView(eefViewDescription, variableManager, siriusInterpreter, editingContextAdapterWrapper, new SiriusDomainClassTester(session), input);
if (!eefView.getPages().isEmpty()) {
- Shell shell = Display.getCurrent().getActiveShell();
- WizardDialog wizardDialog = new PropertiesWizardDialog(shell, this.extPackage, this.context, this.session, siriusInterpreter, variableManager, convertedWizardModelOperation, eefView);
- int returnCode = wizardDialog.open();
+ Runnable runnable = () -> {
+ Shell shell = Display.getCurrent().getActiveShell();
+ WizardDialog wizardDialog = new PropertiesWizardDialog(shell, this.extPackage, this.context, this.session, siriusInterpreter, variableManager, convertedWizardModelOperation,
+ eefView);
- if (Window.CANCEL == returnCode) {
- throw new OperationCanceledException();
+ int returnCode = wizardDialog.open();
+
+ if (Window.CANCEL == returnCode) {
+ throw new OperationCanceledException();
+ }
+ };
+
+ boolean isInUiThread = Display.getCurrent() != null && Display.getCurrent().getActiveShell() != null;
+ if (isInUiThread) {
+ runnable.run();
+ } else {
+ Display.getDefault().syncExec(runnable);
}
}
});

Back to the top