Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Schnekenburger2016-06-16 10:53:29 +0000
committerGerrit Code Review @ Eclipse.org2016-06-21 12:56:24 +0000
commit2fc92a7ef3d6e9f1fa8ad93af5ab5442776eb339 (patch)
treeeebdf8025e4f72eb47b327887da08f1715a99c56
parent8ddaca9f2c8595d94715cc5f34c5302ad9a66d6f (diff)
downloadorg.eclipse.papyrus-2fc92a7ef3d6e9f1fa8ad93af5ab5442776eb339.tar.gz
org.eclipse.papyrus-2fc92a7ef3d6e9f1fa8ad93af5ab5442776eb339.tar.xz
org.eclipse.papyrus-2fc92a7ef3d6e9f1fa8ad93af5ab5442776eb339.zip
bug 496252: [Composite Diagram] NPE in BehaviorPortEditPolicy when port
is not available vie getUMLElement() - adding a check for getUMLElement() not to be null. Change-Id: I3a3f909b4907b4c43242a5131aa79fe3db99989e Signed-off-by: Remi Schnekenburger <remi.schnekenburger@cea.fr> (cherry picked from commit 6a7d6f70fa43fc592fac80525a6472cb7f87f3d2)
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/BehaviorPortEditPolicy.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/BehaviorPortEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/BehaviorPortEditPolicy.java
index 85f6fddb10d..0ac0b7e4364 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/BehaviorPortEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/BehaviorPortEditPolicy.java
@@ -64,7 +64,7 @@ public class BehaviorPortEditPolicy extends GraphicalEditPolicy implements Notif
}
public void udaptePortBehavior() {
- GraphicalEditPart parentEditPart = (GraphicalEditPart)((GraphicalEditPart) getHost()).getParent();
+ GraphicalEditPart parentEditPart = (GraphicalEditPart) ((GraphicalEditPart) getHost()).getParent();
ShapeCompartmentEditPart targetEditPart = (parentEditPart == null) ? null : getPossibleCompartment(parentEditPart);
if (targetEditPart != null) {
// remove old BehaviorPort presentation
@@ -75,16 +75,18 @@ public class BehaviorPortEditPolicy extends GraphicalEditPolicy implements Notif
if (getHost() instanceof PortEditPart) {
IFigure hostFigure = ((PortEditPart) getHost()).getContentPane();
if (hostFigure instanceof PortFigure) {
- PortFigure port = (PortFigure) hostFigure;
-
- if (getUMLElement().isBehavior()) {
- if (parentEditPart.resolveSemanticElement() instanceof Classifier || targetEditPart != null) {
- port.restoreBehaviorFigure();
+ PortFigure portFigure = (PortFigure) hostFigure;
+ Port port = getUMLElement();
+ if (port != null) {
+ if (port.isBehavior()) {
+ if (parentEditPart.resolveSemanticElement() instanceof Classifier || targetEditPart != null) {
+ portFigure.restoreBehaviorFigure();
+ } else {
+ portFigure.removeBehavior();
+ }
} else {
- port.removeBehavior();
+ portFigure.removeBehavior();
}
- } else {
- port.removeBehavior();
}
}
}

Back to the top