Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-10-16 16:40:15 +0000
committerGerrit Code Review @ Eclipse.org2014-10-16 16:40:15 +0000
commit201e0d972b28be5dda8c5a7bcee9536ed48a8728 (patch)
treeaeac65d764eee2eb632fb53eecd055a44e1a30f1 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence
parent86ff76287b3cf82048736d5c2ecf6e63b5befd52 (diff)
parentd2a7bf8fdf8132210bc900b54e0a49ed0ee78752 (diff)
downloadorg.eclipse.papyrus-201e0d972b28be5dda8c5a7bcee9536ed48a8728.tar.gz
org.eclipse.papyrus-201e0d972b28be5dda8c5a7bcee9536ed48a8728.tar.xz
org.eclipse.papyrus-201e0d972b28be5dda8c5a7bcee9536ed48a8728.zip
Merge "Bug 417826 - [Sequence Diagram] Selector not displayed in lifelines"
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomLifelineNameEditPart.java6
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineLabelEditPolicy.java19
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java29
3 files changed, 51 insertions, 3 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomLifelineNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomLifelineNameEditPart.java
index d6e01d435e0..f6b91dc2cee 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomLifelineNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomLifelineNameEditPart.java
@@ -168,8 +168,10 @@ public class CustomLifelineNameEditPart extends LifelineNameEditPart {
Lifeline lifeline = (Lifeline) this.resolveSemanticElement();
// handle possible change in the name container size
// In AutoSize mode, the width should be resized if the content of the text gets changed. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=383723
- if (notifier.equals(lifeline.getRepresents()) || UMLPackage.Literals.NAMED_ELEMENT__NAME.equals(feature) || UMLPackage.Literals.LIFELINE__REPRESENTS.equals(feature) || UMLPackage.Literals.LIFELINE__DECOMPOSED_AS.equals(feature)
- || UMLPackage.Literals.LIFELINE__SELECTOR.equals(feature) || event.getNotifier() instanceof Bounds) {
+ if(notifier.equals(lifeline.getRepresents()) || notifier.equals(lifeline.getSelector())
+ || UMLPackage.Literals.NAMED_ELEMENT__NAME.equals(feature) || UMLPackage.Literals.LIFELINE__REPRESENTS.equals(feature)
+ || UMLPackage.Literals.LIFELINE__DECOMPOSED_AS.equals(feature) || UMLPackage.Literals.LIFELINE__SELECTOR.equals(feature)
+ || event.getNotifier() instanceof Bounds) {
((CustomLifelineEditPart) getParent()).updateLifelinePosition();
}
if (notifier instanceof EAnnotation && ((EAnnotation) notifier).getSource().equals(VisualInformationPapyrusConstants.CUSTOM_APPEARENCE_ANNOTATION)) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineLabelEditPolicy.java
index 696138ea76a..5d60441f222 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineLabelEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineLabelEditPolicy.java
@@ -15,6 +15,7 @@ import org.eclipse.uml2.uml.ConnectableElement;
import org.eclipse.uml2.uml.Lifeline;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.ValueSpecification;
public class LifelineLabelEditPolicy extends AbstractMaskManagedEditPolicy {
@@ -36,6 +37,10 @@ public class LifelineLabelEditPolicy extends AbstractMaskManagedEditPolicy {
getDiagramEventBroker().addNotificationListener(ce.getType(), this);
}
}
+ ValueSpecification selector = lifeline.getSelector();
+ if(selector != null) {
+ getDiagramEventBroker().addNotificationListener(selector, this);
+ }
}
@Override
@@ -54,6 +59,10 @@ public class LifelineLabelEditPolicy extends AbstractMaskManagedEditPolicy {
getDiagramEventBroker().removeNotificationListener(ce.getType(), this);
}
}
+ ValueSpecification selector = lifeline.getSelector();
+ if(selector != null) {
+ getDiagramEventBroker().removeNotificationListener(selector, this);
+ }
}
@Override
@@ -93,6 +102,16 @@ public class LifelineLabelEditPolicy extends AbstractMaskManagedEditPolicy {
getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this);
}
refreshDisplay();
+ } else if(object.equals(getUMLElement().getSelector())
+ || notification.getFeature().equals(UMLPackage.Literals.LIFELINE__SELECTOR)) {
+ // change selector
+ if(notification.getNewValue() instanceof ValueSpecification) {
+ getDiagramEventBroker().addNotificationListener((ValueSpecification)notification.getNewValue(), this);
+ }
+ if(notification.getOldValue() instanceof ValueSpecification) {
+ getDiagramEventBroker().removeNotificationListener((ValueSpecification)notification.getOldValue(), this);
+ }
+ refreshDisplay();
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java
index 80ba632ca3f..8ecb37daed7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java
@@ -10,13 +10,21 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEd
import org.eclipse.papyrus.uml.diagram.common.helper.StereotypedElementLabelHelper;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineNameEditPart;
import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
+import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil;
import org.eclipse.uml2.uml.ConnectableElement;
+import org.eclipse.uml2.uml.Expression;
import org.eclipse.uml2.uml.Lifeline;
+import org.eclipse.uml2.uml.LiteralSpecification;
+import org.eclipse.uml2.uml.OpaqueExpression;
+import org.eclipse.uml2.uml.TimeExpression;
import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.ValueSpecification;
public class LifelineLabelHelper extends StereotypedElementLabelHelper {
public static final String SHOW_REPRESENT_NAME = "representsName";
+
+ public static final String SHOW_REPRESENT_SELECTOR = "representsSelector";
public static final String SHOW_REPRESENT_TYPE = "representsType";
@@ -24,7 +32,7 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
public static final String SHOW_LIFELINE_NAME = "lifelineName";
- public static final Collection<String> DEFAULT_LABEL_DISPLAY = Arrays.asList(SHOW_REPRESENT_NAME, SHOW_REPRESENT_TYPE);
+ public static final Collection<String> DEFAULT_LABEL_DISPLAY = Arrays.asList(SHOW_REPRESENT_NAME, SHOW_REPRESENT_SELECTOR, SHOW_REPRESENT_TYPE);
/**
* singelton instance
@@ -52,6 +60,7 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
protected LifelineLabelHelper() {
// initialize the map
masks.put(SHOW_REPRESENT_NAME, "Show represent name");
+ masks.put(SHOW_REPRESENT_SELECTOR, "Show represent selector");
masks.put(SHOW_REPRESENT_TYPE, "Show represent type");
masks.put(SHOW_UNDEFINED_TYPE, "Always show undefined type");
masks.put(SHOW_LIFELINE_NAME, "Always show lifeline name");
@@ -116,6 +125,24 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
// represents is not null
if (displayValue.contains(SHOW_REPRESENT_NAME)) {
appendString(sb, element.getName(), UNAMED);
+ boolean displaySelector = displayValue.contains(SHOW_REPRESENT_SELECTOR);
+ if (lifeline.getRepresents() == null || displayValue.contains(LifelineLabelHelper.SHOW_LIFELINE_NAME)) {
+ displaySelector = false;
+ }
+ if (displaySelector) {
+ ValueSpecification selector = lifeline.getSelector();
+ // Add the selector if it is a LiteralSpecification
+ if(selector instanceof LiteralSpecification) {
+ sb.append("[").append(ValueSpecificationUtil.getSpecificationValue(selector)).append("]");
+ }
+ // Add the selector if it is an Expression
+ if(selector instanceof Expression || selector instanceof OpaqueExpression || selector instanceof TimeExpression) {
+ String specificationValue = ValueSpecificationUtil.getSpecificationValue(selector);
+ if(specificationValue != null && specificationValue.length() > 0) {
+ sb.append("[").append(specificationValue).append("]");
+ }
+ }
+ }
}
// if neither <1> or <2> are checked, show lifeline name (or <unnamed> when the lifeline has no name)
else if (!displayValue.contains(SHOW_REPRESENT_TYPE)) {

Back to the top