Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Schnekenburger2016-11-24 13:01:37 -0500
committerRemi Schnekenburger2016-11-25 03:16:36 -0500
commitfb4962fcf392c5315e08ef5b99990f27b911f2d5 (patch)
tree84b18c1fed3693050b01bb093e9c3c9f21bd85e7
parent9acdd2bd1a0266852e086f52f81dc9480c96627d (diff)
downloadorg.eclipse.papyrus-fb4962fcf392c5315e08ef5b99990f27b911f2d5.tar.gz
org.eclipse.papyrus-fb4962fcf392c5315e08ef5b99990f27b911f2d5.tar.xz
org.eclipse.papyrus-fb4962fcf392c5315e08ef5b99990f27b911f2d5.zip
Bug 508147: [State Machine] Trigger Listeners are used to update views,
and not non-UI-thread safe - adding check to be sure we are on UI thread or not - deprecate some classes based on trigger listener - update bundle version number This patch should not be ported as is in Oxygen, but implementation of internal transitions é entry/do/exit behavior should be changed for Oxygen. https://bugs.eclipse.org/bugs/show_bug.cgi?id=508147 Change-Id: I6115dd2ca1e32cb78435ab161c4c141ad55e6941 Signed-off-by: Remi Schnekenburger <remi.schnekenburger@cea.fr>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/META-INF/MANIFEST.MF2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/AbstractModifcationTriggerListener.java11
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/DropTargetListener.java1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/InternalStateListener.java14
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/StateBehaviorsListener.java9
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/pom.xml2
6 files changed, 31 insertions, 8 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/META-INF/MANIFEST.MF
index d6074bddff9..77a71e31f2e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/META-INF/MANIFEST.MF
@@ -66,7 +66,7 @@ Require-Bundle: org.eclipse.emf.ecore;visibility:=reexport;bundle-version="[2.12
Bundle-Vendor: %providerName
Ant-Version: Apache Ant 1.7.0
Eclipse-LazyStart: true
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 2.0.100.qualifier
Bundle-Activator: org.eclipse.papyrus.uml.diagram.statemachine.part.UMLDiagramEditorPlugin
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.statemachine; singleton:=true
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/AbstractModifcationTriggerListener.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/AbstractModifcationTriggerListener.java
index d25818e87c4..d4cb2dabf20 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/AbstractModifcationTriggerListener.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/AbstractModifcationTriggerListener.java
@@ -21,14 +21,18 @@ import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.gmfdiag.canonical.editpolicy.PapyrusCanonicalEditPolicy;
import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
-
-
+/**
+* @deprecated this is a bad way to create/synchronize views. Behavior similar to {@link PapyrusCanonicalEditPolicy} should be used instead.
+*/
+@Deprecated
public abstract class AbstractModifcationTriggerListener extends TriggerListener {
@Override
@@ -78,6 +82,9 @@ public abstract class AbstractModifcationTriggerListener extends TriggerListener
* @return
*/
protected DiagramEditPart getDiagramEditPart() {
+ if(Display.getCurrent()==null) { // UI-thread safe...
+ return null;
+ }
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchPage page = wb.getActiveWorkbenchWindow().getActivePage();
IEditorPart editor = page.getActiveEditor();
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/DropTargetListener.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/DropTargetListener.java
index 30cd4438eb4..25e0193172c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/DropTargetListener.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/DropTargetListener.java
@@ -31,6 +31,7 @@ import org.eclipse.swt.dnd.TransferData;
* This class is used to handle drop event on diagram
*
* @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
+ * @deprecated class is not used.
*/
public abstract class DropTargetListener extends DiagramDropTargetListener {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/InternalStateListener.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/InternalStateListener.java
index 6600bdf03eb..dbd32983fd0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/InternalStateListener.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/InternalStateListener.java
@@ -28,16 +28,20 @@ import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.internal.commands.RefreshEditPartCommand;
import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
+import org.eclipse.papyrus.infra.gmfdiag.canonical.editpolicy.PapyrusCanonicalEditPolicy;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.InternalTransitionEditPart;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.RegionCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.TransitionEditPart;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.Transition;
import org.eclipse.uml2.uml.TransitionKind;
import org.eclipse.uml2.uml.UMLPackage;
/**
* Listener of internal state transition
+ * @deprecated this is a bad way to create/synchronize views. Behavior similar to {@link PapyrusCanonicalEditPolicy} should be used instead.
*/
+@Deprecated
public class InternalStateListener extends AbstractModifcationTriggerListener {
private static final String DROP_INTERNAL_TRANSITION_COMMAND_LABEL = "Drop internal transition";
@@ -55,6 +59,9 @@ public class InternalStateListener extends AbstractModifcationTriggerListener {
Object newValue = notif.getNewValue();
Object notifier = notif.getNotifier();
if (newValue instanceof TransitionKind && notifier instanceof EObject) {
+ if(Display.getCurrent()==null) { // UI Thread safe (getDiagramEditPart will be null in this case...)
+ return null;
+ }
CompositeCommand cc = new CompositeCommand("Modification command triggered by modification of the kind of the current selected transition");
EObject eNotifier = (EObject) notifier;
// Handle deletion of the old EditPart
@@ -137,6 +144,9 @@ public class InternalStateListener extends AbstractModifcationTriggerListener {
}
private Command getCreationCommand(boolean isBecomingInternal, EObject eNotifier) {
+ if(Display.getCurrent() ==null) { // non UI-thread safe (getDiagramEditPart will be null..)
+ return null;
+ }
// IGraphicalEditPart
if (eNotifier instanceof Transition) {
Transition transition = (Transition) eNotifier;
@@ -148,7 +158,9 @@ public class InternalStateListener extends AbstractModifcationTriggerListener {
// get the region
dropTarget = getChildByEObject(transition.getContainer(), getDiagramEditPart(), false);
// get the compartment
- dropTarget = dropTarget.getChildBySemanticHint(String.valueOf(RegionCompartmentEditPart.VISUAL_ID));
+ if(dropTarget!=null) {
+ dropTarget = dropTarget.getChildBySemanticHint(String.valueOf(RegionCompartmentEditPart.VISUAL_ID));
+ }
}
if (dropTarget != null) {
Request request = new DropObjectsRequest();
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/StateBehaviorsListener.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/StateBehaviorsListener.java
index 6967c7b49f7..7538a204e03 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/StateBehaviorsListener.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/listeners/StateBehaviorsListener.java
@@ -26,7 +26,9 @@ import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.internal.commands.RefreshEditPartCommand;
import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
+import org.eclipse.papyrus.infra.gmfdiag.canonical.editpolicy.PapyrusCanonicalEditPolicy;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.StateEditPart;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.Behavior;
import org.eclipse.uml2.uml.UMLPackage;
@@ -35,7 +37,9 @@ import org.eclipse.uml2.uml.UMLPackage;
*
* @author Arthur Daussy
*
+ * @deprecated this is a bad way to create/synchronize views. Behavior similar to {@link PapyrusCanonicalEditPolicy} should be used instead.
*/
+@Deprecated
public class StateBehaviorsListener extends AbstractModifcationTriggerListener {
/**
@@ -147,9 +151,8 @@ public class StateBehaviorsListener extends AbstractModifcationTriggerListener {
*/
protected StateEditPart getContainingEditPart(Object toTest) {
// If not EObject found return null;
- if (toTest instanceof EObject)
- {
- IGraphicalEditPart found = getChildByEObject((EObject) toTest, getDiagramEditPart(), false);
+ if (toTest instanceof EObject && Display.getCurrent() != null) {
+ IGraphicalEditPart found = getChildByEObject((EObject) toTest, getDiagramEditPart(), false);
if (found instanceof StateEditPart) {
return (StateEditPart) found;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/pom.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/pom.xml
index 573a3ac891f..049fe93ddd2 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/pom.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/pom.xml
@@ -7,6 +7,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.diagram.statemachine</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.100-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file

Back to the top