diff options
author | Ansgar Radermacher | 2017-11-15 13:03:53 +0000 |
---|---|---|
committer | Ansgar Radermacher | 2017-11-16 11:39:51 +0000 |
commit | 5ce3416449bbc91dc5f757b4f66e4afa562c4c25 (patch) | |
tree | 97125046cfd76ad024badadb35a0ea5de25fd96d | |
parent | 204da4c9f3dbbd6ac4cdd86a06d24ed6bb12f09b (diff) | |
download | org.eclipse.papyrus-5ce3416449bbc91dc5f757b4f66e4afa562c4c25.tar.gz org.eclipse.papyrus-5ce3416449bbc91dc5f757b4f66e4afa562c4c25.tar.xz org.eclipse.papyrus-5ce3416449bbc91dc5f757b4f66e4afa562c4c25.zip |
Bug 527291 - [State Machine Diagram] Region within state is created when diagram is opened
- add non-null element-type check to custom state-creation command
Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
-rw-r--r-- | plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/policies/CustomStateCreationEditPolicy.java | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/policies/CustomStateCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/policies/CustomStateCreationEditPolicy.java index 5a06ac13c7b..0a4306b3515 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/policies/CustomStateCreationEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/policies/CustomStateCreationEditPolicy.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2014 CEA LIST. + * Copyright (c) 2014, 2017 CEA LIST. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -8,6 +8,7 @@ * * Contributors: * CEA LIST - Initial API and implementation + * Ansgar Radermacher, ansgar.radermacher@cea.fr, Bug 527291 - avoid unwanted region creation */ package org.eclipse.papyrus.uml.diagram.statemachine.custom.policies; @@ -88,9 +89,12 @@ public class CustomStateCreationEditPolicy extends SideAffixedNodesCreationEditP // used by popup-bar assistant CreateViewRequest createViewRequest = (CreateViewRequest) request; for (ViewDescriptor vd : createViewRequest.getViewDescriptors()) { - Command cmd = getCustomCreateCommand(request, null, vd.getElementAdapter().getAdapter(IElementType.class), vd.getSemanticHint()); - if (cmd != null) { - return cmd; + IElementType elementType = vd.getElementAdapter().getAdapter(IElementType.class); + if (elementType != null) { + Command cmd = getCustomCreateCommand(request, null, elementType, vd.getSemanticHint()); + if (cmd != null) { + return cmd; + } } } } @@ -98,12 +102,13 @@ public class CustomStateCreationEditPolicy extends SideAffixedNodesCreationEditP // used by palette CreateUnspecifiedTypeRequest unspecReq = (CreateUnspecifiedTypeRequest) request; for (Object elementTypeObj : unspecReq.getElementTypes()) { - IElementType elementType = (IElementType) elementTypeObj; - - CreateRequest createRequest = unspecReq.getRequestForType(elementType); - Command cmd = getCustomCreateCommand(request, createRequest, elementType, ((IHintedType) elementType).getSemanticHint()); - if (cmd != null) { - return cmd; + if (elementTypeObj instanceof IHintedType) { + IHintedType hintedType = (IHintedType) elementTypeObj; + CreateRequest createRequest = unspecReq.getRequestForType(hintedType); + Command cmd = getCustomCreateCommand(request, createRequest, hintedType, hintedType.getSemanticHint()); + if (cmd != null) { + return cmd; + } } } } |