Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraradermache2012-01-30 14:16:29 +0000
committeraradermache2012-01-30 14:16:29 +0000
commit0aeed5663f521e06bc2a3d3d0f79905f0e96b014 (patch)
treed9194394966eb1b9668c6b153e0cfea1a53294e8 /plugins
parent1a67b33f76c4a86c1b11fa409c0fbba4f6b9dff1 (diff)
downloadorg.eclipse.papyrus-0aeed5663f521e06bc2a3d3d0f79905f0e96b014.tar.gz
org.eclipse.papyrus-0aeed5663f521e06bc2a3d3d0f79905f0e96b014.tar.xz
org.eclipse.papyrus-0aeed5663f521e06bc2a3d3d0f79905f0e96b014.zip
Fix for bug 369305
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomTransitionGuardEditPart.java225
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/factory/CustomUMLEditPartFactory.java19
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/parsers/TransitionPropertiesParser.java13
3 files changed, 158 insertions, 99 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomTransitionGuardEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomTransitionGuardEditPart.java
index 36a8708af47..2cf1ce14315 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomTransitionGuardEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/edit/part/CustomTransitionGuardEditPart.java
@@ -1,20 +1,24 @@
+/*****************************************************************************
+ * Copyright (c) 2010-2012 CEA LIST.
+ *
+ *
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * Ansgar Radermacher (bug 369305)
+ *
+ *****************************************************************************/
+
package org.eclipse.papyrus.uml.diagram.statemachine.custom.edit.part;
-import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.draw2d.IFigure;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.TransitionGuardEditPart;
-import org.eclipse.uml2.uml.Activity;
-import org.eclipse.uml2.uml.CallEvent;
-import org.eclipse.uml2.uml.ChangeEvent;
-import org.eclipse.uml2.uml.Event;
-import org.eclipse.uml2.uml.OpaqueBehavior;
-import org.eclipse.uml2.uml.OpaqueExpression;
-import org.eclipse.uml2.uml.SignalEvent;
-import org.eclipse.uml2.uml.StateMachine;
-import org.eclipse.uml2.uml.TimeEvent;
-import org.eclipse.uml2.uml.Transition;
-import org.eclipse.uml2.uml.Trigger;
public class CustomTransitionGuardEditPart extends TransitionGuardEditPart {
@@ -24,92 +28,121 @@ public class CustomTransitionGuardEditPart extends TransitionGuardEditPart {
// TODO Auto-generated constructor stub
}
- public String getInformationFromTransition(Transition transition) {
- String textToEdit = "";
-
- // Triggers
- if(!transition.getTriggers().isEmpty()) {
- boolean isFirstTrigger = true;
- for(Trigger t : transition.getTriggers()) {
- if(!isFirstTrigger)
- textToEdit = textToEdit + ", ";
- else
- isFirstTrigger = false;
- Event e = t.getEvent();
- if(e instanceof CallEvent) {
- if(((CallEvent)e).getOperation() != null)
- textToEdit = textToEdit + ((CallEvent)e).getOperation().getName();
- else
- textToEdit = textToEdit + ((CallEvent)e).getName();
-
- } else if(e instanceof SignalEvent) {
- if(((SignalEvent)e).getSignal() != null)
- textToEdit = textToEdit + ((SignalEvent)e).getSignal().getName();
- else
- textToEdit = textToEdit + ((SignalEvent)e).getName();
- } else if(e instanceof ChangeEvent) {
-
- textToEdit = textToEdit + "when " + "\"" + retrieveBody((OpaqueExpression)((ChangeEvent)e).getChangeExpression(), "Natural language") + "\"";
- } else if(e instanceof TimeEvent) {
- String absRelPrefix = "" + (((TimeEvent)e).isRelative() ? "after " : "at ");
- textToEdit = textToEdit + absRelPrefix + "\"" + retrieveBody((OpaqueExpression)((TimeEvent)e).getWhen().getExpr(), "Natural language") + "\"";
- } else { // any receive event
- textToEdit = textToEdit + "all";
- }
- }
- }
-
- // Guard
- if(transition.getGuard() != null && transition.getGuard().getSpecification() != null) {
- textToEdit = textToEdit + " [" + "\"" + retrieveBody((OpaqueExpression)transition.getGuard().getSpecification(), "Natural language") + "\"" + "]";
- }
-
- if(transition.getEffect() != null) {
- textToEdit = textToEdit + " / ";
- String behaviorKind = "";
- behaviorKind = behaviorKind + ((behaviorKind.equals("") && (transition.getEffect() instanceof Activity)) ? "Activity " : "");
- behaviorKind = behaviorKind + ((behaviorKind.equals("") && (transition.getEffect() instanceof StateMachine)) ? "StateMachine " : "");
- behaviorKind = behaviorKind + ((behaviorKind.equals("") && (transition.getEffect() instanceof OpaqueBehavior)) ? "OpaqueBehavior " : "");
- textToEdit = textToEdit + behaviorKind + " " + transition.getEffect().getName();
- }
-
- return textToEdit;
- }
-
- @Override
- protected void handleNotificationEvent(Notification notification) {
- // TODO Auto-generated method stub
- super.handleNotificationEvent(notification);
-
-
- refreshVisuals();
- }
-
+ /**
+ * Label should be capable of wrapping, i.e. of displaying text in multiple lines
+ * which is in particular required when the code of an operation is shown instead of the operations name
+ * [see bug 369305]
+ *
+ * @see org.eclipse.papyrus.diagram.statemachine.edit.parts.TransitionGuardEditPart#setLabelTextHelper(org.eclipse.draw2d.IFigure,
+ * java.lang.String)
+ *
+ * @param figure
+ * @param text
+ */
@Override
- protected void refreshVisuals() {
- // TODO Auto-generated method stub
- super.refreshVisuals();
-
- WrappingLabel transitionGuardLabel = (WrappingLabel)getFigure();
- Transition transition = (Transition)((View)getModel()).getElement();
- transitionGuardLabel.setText(getInformationFromTransition(transition));
- }
-
- private String retrieveBody(OpaqueExpression exp, String languageName) {
- String body = "";
- if(exp == null)
- return body;
- int index = 0;
- for(String _languageName : exp.getLanguages()) {
- if(_languageName.equals(languageName)) {
- if(index < exp.getBodies().size())
- return exp.getBodies().get(index);
- else
- return "";
- }
- index++;
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if(figure instanceof WrappingLabel) {
+ ((WrappingLabel)figure).setText(text);
+ // [addition for bug 369305]
+ ((WrappingLabel)figure).setTextWrap(true);
+ } else if(figure instanceof ILabelFigure) {
+ ((ILabelFigure)figure).setText(text);
+ } else {
+ ((Label)figure).setText(text);
}
- return body;
}
+ /**
+ * The following code has been commented, since the custom class was not in use (CustomUMLEditPartFactory
+ * returned generated TransitionGuardEditPart instead of this one) before adding setLabelTextHelper above.
+ *
+ *
+ * public String getInformationFromTransition(Transition transition) {
+ * String textToEdit = "";
+ *
+ * // Triggers
+ * if(!transition.getTriggers().isEmpty()) {
+ * boolean isFirstTrigger = true;
+ * for(Trigger t : transition.getTriggers()) {
+ * if(!isFirstTrigger)
+ * textToEdit = textToEdit + ", ";
+ * else
+ * isFirstTrigger = false;
+ * Event e = t.getEvent();
+ * if(e instanceof CallEvent) {
+ * if(((CallEvent)e).getOperation() != null)
+ * textToEdit = textToEdit + ((CallEvent)e).getOperation().getName();
+ * else
+ * textToEdit = textToEdit + ((CallEvent)e).getName();
+ *
+ * } else if(e instanceof SignalEvent) {
+ * if(((SignalEvent)e).getSignal() != null)
+ * textToEdit = textToEdit + ((SignalEvent)e).getSignal().getName();
+ * else
+ * textToEdit = textToEdit + ((SignalEvent)e).getName();
+ * } else if(e instanceof ChangeEvent) {
+ *
+ * textToEdit = textToEdit + "when " + "\"" + retrieveBody((OpaqueExpression)((ChangeEvent)e).getChangeExpression(), "Natural language") + "\"";
+ * } else if(e instanceof TimeEvent) {
+ * String absRelPrefix = "" + (((TimeEvent)e).isRelative() ? "after " : "at ");
+ * textToEdit = textToEdit + absRelPrefix + "\"" + retrieveBody((OpaqueExpression)((TimeEvent)e).getWhen().getExpr(), "Natural language") + "\"";
+ * } else { // any receive event
+ * textToEdit = textToEdit + "all";
+ * }
+ * }
+ * }
+ *
+ * // Guard
+ * if(transition.getGuard() != null && transition.getGuard().getSpecification() != null) {
+ * textToEdit = textToEdit + " [" + "\"" + retrieveBody((OpaqueExpression)transition.getGuard().getSpecification(), "Natural language") + "\"" +
+ * "]";
+ * }
+ *
+ * if(transition.getEffect() != null) {
+ * textToEdit = textToEdit + " / ";
+ * String behaviorKind = "";
+ * behaviorKind = behaviorKind + ((behaviorKind.equals("") && (transition.getEffect() instanceof Activity)) ? "Activity " : "");
+ * behaviorKind = behaviorKind + ((behaviorKind.equals("") && (transition.getEffect() instanceof StateMachine)) ? "StateMachine " : "");
+ * behaviorKind = behaviorKind + ((behaviorKind.equals("") && (transition.getEffect() instanceof OpaqueBehavior)) ? "OpaqueBehavior " : "");
+ * textToEdit = textToEdit + behaviorKind + " " + transition.getEffect().getName();
+ * }
+ *
+ * return textToEdit;
+ * }
+ *
+ * @Override
+ * protected void handleNotificationEvent(Notification notification) {
+ * // TODO Auto-generated method stub
+ * super.handleNotificationEvent(notification);
+ *
+ *
+ * refreshVisuals();
+ * }
+ * @Override
+ * protected void refreshVisuals() {
+ * // TODO Auto-generated method stub
+ * super.refreshVisuals();
+ *
+ * WrappingLabel transitionGuardLabel = (WrappingLabel)getFigure();
+ * Transition transition = (Transition)((View)getModel()).getElement();
+ * transitionGuardLabel.setText(getInformationFromTransition(transition));
+ * }
+ *
+ * private String retrieveBody(OpaqueExpression exp, String languageName) {
+ * String body = "";
+ * if(exp == null)
+ * return body;
+ * int index = 0;
+ * for(String _languageName : exp.getLanguages()) {
+ * if(_languageName.equals(languageName)) {
+ * if(index < exp.getBodies().size())
+ * return exp.getBodies().get(index);
+ * else
+ * return "";
+ * }
+ * index++;
+ * }
+ * return body;
+ * }
+ */
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/factory/CustomUMLEditPartFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/factory/CustomUMLEditPartFactory.java
index 7e0258d10e6..341ab7cf819 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/factory/CustomUMLEditPartFactory.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/factory/CustomUMLEditPartFactory.java
@@ -1,3 +1,19 @@
+/*****************************************************************************
+ * Copyright (c) 2010-2012 CEA LIST.
+ *
+ *
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * David Servat
+ * Ansgar Radermacher (bug 369305)
+ *
+ *****************************************************************************/
+
package org.eclipse.papyrus.uml.diagram.statemachine.custom.factory;
import org.eclipse.gef.EditPart;
@@ -13,6 +29,7 @@ import org.eclipse.papyrus.uml.diagram.statemachine.custom.edit.part.CustomState
import org.eclipse.papyrus.uml.diagram.statemachine.custom.edit.part.CustomStateMachineEditPart;
import org.eclipse.papyrus.uml.diagram.statemachine.custom.edit.part.CustomStateMachineNameEditPart;
import org.eclipse.papyrus.uml.diagram.statemachine.custom.edit.part.CustomStateNameEditPart;
+import org.eclipse.papyrus.uml.diagram.statemachine.custom.edit.part.CustomTransitionGuardEditPart;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.ConnectionPointReferenceNameEditPart;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.FinalStateEditPart;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PackageEditPart;
@@ -56,7 +73,7 @@ public class CustomUMLEditPartFactory extends UMLEditPartFactory {
case StateCompartmentEditPart.VISUAL_ID:
return new CustomStateCompartmentEditPart(view);
case TransitionGuardEditPart.VISUAL_ID:
- return new TransitionGuardEditPart(view);
+ return new CustomTransitionGuardEditPart(view);
case ConnectionPointReferenceNameEditPart.VISUAL_ID:
return new CustomConnectionPointReferenceNameEditPart(view);
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 b64f2da9e0e..07b0487e41f 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
@@ -45,6 +45,7 @@ import org.eclipse.uml2.uml.Constraint;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Event;
import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.OpaqueBehavior;
import org.eclipse.uml2.uml.OpaqueExpression;
import org.eclipse.uml2.uml.SignalEvent;
import org.eclipse.uml2.uml.TimeEvent;
@@ -152,7 +153,7 @@ public class TransitionPropertiesParser implements IParser, ISemanticParser {
result.append(getTextForGuard(trans));
String textForEffect = getTextForEffect(trans);
if(textForEffect != null && !EMPTY_STRING.equals(textForEffect)) {
- result.append("/ ").append(textForEffect); //$NON-NLS-1$
+ result.append("/\n").append(textForEffect); //$NON-NLS-1$
}
return result.toString();
}
@@ -187,8 +188,16 @@ public class TransitionPropertiesParser implements IParser, ISemanticParser {
Behavior effect = trans.getEffect();
if(effect != null) {
EClass eClass = effect.eClass();
+ if(effect instanceof OpaqueBehavior) {
+ OpaqueBehavior ob = (OpaqueBehavior)effect;
+ if(ob.getBodies().size() > 0) {
+ // return body of behavior (only handle case of a single body)
+ result.append(ob.getBodies().get(0));
+ return result.toString();
+ }
+ }
if(eClass != null) {
- result.append(eClass.getName()).append(" :").append(effect.getName()); //$NON-NLS-1$
+ result.append(eClass.getName()).append(": ").append(effect.getName()); //$NON-NLS-1$
}
}
return result.toString();

Back to the top