From a74d91a377dc6494fd78c8723ac5db6eebb7c6f5 Mon Sep 17 00:00:00 2001 From: jeremie.tatibouet Date: Mon, 30 May 2016 17:59:57 +0200 Subject: [Fix] - Bug 477573 - Invalid string representation generation for an internal transition having an effect behavior. Change-Id: I93e3c56e4f24ac96987efcc4089989f11093fd49 Signed-off-by: jeremie.tatibouet --- .../custom/parsers/TransitionPropertiesParser.java | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'plugins/uml') diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/parsers/TransitionPropertiesParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/parsers/TransitionPropertiesParser.java index 4c66c49be6a..ff4ca342925 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/parsers/TransitionPropertiesParser.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/parsers/TransitionPropertiesParser.java @@ -8,6 +8,7 @@ * * Contributors: * CEA LIST - Initial API and implementation + * Jeremie TATIBOUET (CEA LIST) - Fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=477573 */ package org.eclipse.papyrus.uml.diagram.statemachine.custom.parsers; @@ -153,14 +154,16 @@ public class TransitionPropertiesParser implements IParser, ISemanticParser { * Get the unformatted registered string value which shall be displayed */ protected String getValueString(IAdaptable element, int flags) { - Object obj = element.getAdapter(EObject.class); - View view = null; - if (obj instanceof View) { - view = (View) obj; - obj = view.getElement(); + EObject semanticElement = element.getAdapter(EObject.class); + View view = element.getAdapter(View.class); + // If it is not possible to adapt directly the element + // as an EObject then it might be possible to first retrieve + // the view and then obtain the EObject that is behind the view + if(semanticElement == null && view != null){ + semanticElement = view.getElement(); } - if (obj instanceof Transition) { - Transition trans = (Transition) obj; + if (semanticElement instanceof Transition && view != null) { + Transition trans = (Transition) semanticElement; StringBuilder result = new StringBuilder(); String textForTrigger = getTextForTrigger(view, trans); if (textForTrigger != null && !EMPTY_STRING.equals(textForTrigger)) { @@ -169,13 +172,11 @@ public class TransitionPropertiesParser implements IParser, ISemanticParser { result.append(getTextForGuard(trans)); String textForEffect = getTextForEffect(view, trans); if (textForEffect != null && !EMPTY_STRING.equals(textForEffect)) { - if (textForEffect != null && !EMPTY_STRING.equals(textForEffect)) { - result.append("/"); //$NON-NLS-1$ - if (lineBreakBeforeEffect(view)) { - result.append("\n"); //$NON-NLS-1$ - } - result.append(textForEffect); + result.append("/"); //$NON-NLS-1$ + if (lineBreakBeforeEffect(view)) { + result.append("\n"); //$NON-NLS-1$ } + result.append(textForEffect); } return result.toString(); } -- cgit v1.2.3