Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguy perron2017-03-16 15:29:10 +0000
committerGerrit Code Review @ Eclipse.org2017-03-23 10:38:09 +0000
commit7a915035cf8266d989a89c6b5465ddd01cb42c3f (patch)
tree6ce71930242a3963af6ff36761675f036ea371e2 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus
parente03a1b2a94e57ed52c8d7ef7f3479c8309a9fe01 (diff)
downloadorg.eclipse.papyrus-7a915035cf8266d989a89c6b5465ddd01cb42c3f.tar.gz
org.eclipse.papyrus-7a915035cf8266d989a89c6b5465ddd01cb42c3f.tar.xz
org.eclipse.papyrus-7a915035cf8266d989a89c6b5465ddd01cb42c3f.zip
Bug 368888 - [activity diagram] activity partition "represents" property
is not displayed on diagram Change-Id: I535e4b076819cf343d2fe17fbf3f412fccf122af Signed-off-by: guy.perron@ericsson.com <guy.perron@ericsson.com>
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomActivityPartitionEditPart.java14
-rwxr-xr-xplugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomActivityPartitionNameEditPart.java36
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomUMLEditPartFactory.java3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityPartitionLabelEditPolicy.java97
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/helper/ActivityPartitionLabelHelper.java135
5 files changed, 285 insertions, 0 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomActivityPartitionEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomActivityPartitionEditPart.java
index e0750afd253..94c238bbcb4 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomActivityPartitionEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomActivityPartitionEditPart.java
@@ -12,13 +12,16 @@ package org.eclipse.papyrus.uml.diagram.activity.edit.part;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.GetChildLayoutEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure;
import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityPartitionEditPart;
+import org.eclipse.papyrus.uml.diagram.activity.edit.policies.ActivityPartitionLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.editparts.FloatingLabelEditPart;
import org.eclipse.papyrus.uml.diagram.common.locator.RoundedRectangleLabelPositionLocator;
@@ -32,6 +35,8 @@ public class CustomActivityPartitionEditPart extends ActivityPartitionEditPart {
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy());
+ installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new ActivityPartitionLabelEditPolicy());
+
}
@Override
@@ -51,4 +56,13 @@ public class CustomActivityPartitionEditPart extends ActivityPartitionEditPart {
super.addBorderItem(borderItemContainer, borderItemEditPart);
}
}
+
+ @Override
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof CustomActivityPartitionNameEditPart) {
+ ((CustomActivityPartitionNameEditPart) childEditPart).setLabel(getPrimaryShape().getPartitionLabel());
+ return true;
+ } else
+ return super.addFixedChild(childEditPart);
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomActivityPartitionNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomActivityPartitionNameEditPart.java
new file mode 100755
index 00000000000..bb93529d7ff
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomActivityPartitionNameEditPart.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2017 Ericsson Communications and others.
+ *
+ * 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
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.activity.edit.part;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel;
+import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityPartitionNameEditPart;
+
+
+
+public class CustomActivityPartitionNameEditPart extends ActivityPartitionNameEditPart {
+ /**
+ * Constructor.
+ *
+ * @param view
+ */
+ public CustomActivityPartitionNameEditPart(View view) {
+ super(view);
+ }
+
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof PapyrusWrappingLabel) {
+ return;
+ } else {
+ super.setLabelTextHelper(figure, text);
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomUMLEditPartFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomUMLEditPartFactory.java
index bb0a8f67f14..b695f9a5066 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomUMLEditPartFactory.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomUMLEditPartFactory.java
@@ -34,6 +34,7 @@ import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityFinalNodeEdit
import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityParameterNodeEditPart;
import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityPartitionActivityPartitionContentCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityPartitionEditPart;
+import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityPartitionNameEditPart;
import org.eclipse.papyrus.uml.diagram.activity.edit.parts.AddStructuralFeatureValueActionEditPart;
import org.eclipse.papyrus.uml.diagram.activity.edit.parts.AddVariableValueActionEditPart;
import org.eclipse.papyrus.uml.diagram.activity.edit.parts.BroadcastSignalActionEditPart;
@@ -253,6 +254,8 @@ public class CustomUMLEditPartFactory extends UMLEditPartFactory {
return new CustomForkNodeEditPart(view);
case JoinNodeEditPart.VISUAL_ID:
return new CustomJoinNodeEditPart(view);
+ case ActivityPartitionNameEditPart.VISUAL_ID:
+ return new CustomActivityPartitionNameEditPart(view);
}
}
return super.createEditPart(context, model);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityPartitionLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityPartitionLabelEditPolicy.java
new file mode 100644
index 00000000000..59d991d4b62
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityPartitionLabelEditPolicy.java
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * Copyright (c) 2017 Ericsson Communications.
+ *
+ * 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:
+ * Ericsson Communications - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.activity.edit.policies;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityPartitionEditPart;
+import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityPartitionNameEditPart;
+import org.eclipse.papyrus.uml.diagram.activity.helper.ActivityPartitionLabelHelper;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy;
+import org.eclipse.uml2.uml.ActivityPartition;
+import org.eclipse.uml2.uml.Element;
+
+public class ActivityPartitionLabelEditPolicy extends AbstractMaskManagedEditPolicy {
+
+ @Override
+ public void addAdditionalListeners() {
+ super.addAdditionalListeners();
+
+ ActivityPartition activityPartition = getUMLElement();
+ // check host semantic element is not null
+ if (activityPartition == null) {
+ return;
+ }
+ // adds a listener to the element itself, and to linked elements, like Type
+ getDiagramEventBroker().addNotificationListener(activityPartition, this);
+ Element el = activityPartition.getRepresents();
+ if (el != null) {
+ getDiagramEventBroker().addNotificationListener(el, this);
+ }
+ }
+
+ @Override
+ protected void removeAdditionalListeners() {
+ super.removeAdditionalListeners();
+ ActivityPartition activityPartition = getUMLElement();
+ // check host semantic element is not null
+ if (activityPartition == null) {
+ return;
+ }
+ getDiagramEventBroker().removeNotificationListener(activityPartition, this);
+ Element el = activityPartition.getRepresents();
+ if (el != null) {
+ getDiagramEventBroker().removeNotificationListener(el, this);
+ }
+ }
+
+
+ @Override
+ public void refreshDisplay() {
+ // calls the helper for this edit Part
+ ActivityPartitionEditPart lp = (ActivityPartitionEditPart) getHost();
+ List children = lp.getChildren();
+ for (Object p : children) {
+ if (p instanceof ActivityPartitionNameEditPart) {
+ ActivityPartitionLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) p);
+ }
+ }
+ }
+
+
+ @Override
+ public Collection<String> getDefaultDisplayValue() {
+ return ActivityPartitionLabelHelper.DEFAULT_LABEL_DISPLAY;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Map<String, String> getMasks() {
+ return ActivityPartitionLabelHelper.getInstance().getMasks();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ActivityPartition getUMLElement() {
+ return (ActivityPartition) hostSemanticElement;
+
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/helper/ActivityPartitionLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/helper/ActivityPartitionLabelHelper.java
new file mode 100644
index 00000000000..37cea71b521
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/helper/ActivityPartitionLabelHelper.java
@@ -0,0 +1,135 @@
+/*****************************************************************************
+ * Copyright (c) 2017 Ericsson Communications.
+ *
+ * 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:
+ * Ericsson Communications - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.activity.helper;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.activity.edit.parts.ActivityPartitionNameEditPart;
+import org.eclipse.papyrus.uml.diagram.common.helper.StereotypedElementLabelHelper;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
+import org.eclipse.uml2.uml.ActivityPartition;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.NamedElement;
+
+public class ActivityPartitionLabelHelper extends StereotypedElementLabelHelper {
+
+ public static final String SHOW_REPRESENT_NAME = "representsName"; //$NON-NLS-1$
+
+ public static final String SHOW_REPRESENT_SELECTOR = "representsSelector"; //$NON-NLS-1$
+
+ public static final String SHOW_REPRESENT_TYPE = "representsType"; //$NON-NLS-1$
+
+ public static final String SHOW_UNDEFINED_TYPE = "undefinedType"; //$NON-NLS-1$
+
+ public static final String SHOW_ACTIVITY_PARTITION_NAME = "activitypartitionName"; //$NON-NLS-1$
+
+ public static final Collection<String> DEFAULT_LABEL_DISPLAY = Arrays.asList(SHOW_REPRESENT_NAME, SHOW_REPRESENT_SELECTOR, SHOW_REPRESENT_TYPE);
+
+ private static final String UNNAMED = "<Unnamed>"; //$NON-NLS-1$
+
+
+ /**
+ * singleton instance
+ */
+ private static ActivityPartitionLabelHelper labelHelper;
+
+ /**
+ * Returns the singleton instance of this class
+ *
+ * @return the singleton instance.
+ */
+ public static ActivityPartitionLabelHelper getInstance() {
+ if (labelHelper == null) {
+ labelHelper = new ActivityPartitionLabelHelper();
+ }
+ return labelHelper;
+ }
+
+ /** Map for masks */
+ protected final Map<String, String> masks = new HashMap<String, String>();
+
+ /**
+ * Creates a new Operation label helper.
+ */
+ protected ActivityPartitionLabelHelper() {
+ // 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_ACTIVITY_PARTITION_NAME, "Always show activity partition name");
+ }
+
+ /**
+ * Returns the map of masks used to display
+ *
+ * @return the map of masks used to display
+ */
+ public Map<String, String> getMasks() {
+ return masks;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ActivityPartition getUMLElement(GraphicalEditPart editPart) {
+ return (ActivityPartition) UMLUtil.resolveUMLElement(editPart);
+ }
+
+ @Override
+ protected String elementLabel(GraphicalEditPart editPart) {
+ GraphicalEditPart graphicalEditPart = editPart;
+ if (editPart instanceof ActivityPartitionNameEditPart) {
+ graphicalEditPart = (GraphicalEditPart) editPart.getParent();
+ }
+ Collection<String> displayValue = DEFAULT_LABEL_DISPLAY;
+ IMaskManagedLabelEditPolicy policy = (IMaskManagedLabelEditPolicy) editPart.getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (policy != null) {
+ displayValue = policy.getCurrentDisplayValue();
+ }
+ return getCustomLabel(getUMLElement(graphicalEditPart), displayValue);
+ }
+
+ private String getCustomLabel(ActivityPartition activitypartition, Collection<String> displayValue) {
+ StringBuilder sb = new StringBuilder();
+ appendName(activitypartition, displayValue, sb);
+ return sb.toString();
+ }
+
+ protected void appendName(ActivityPartition activitypartition, Collection<String> displayValue, StringBuilder sb) {
+ Element represents = activitypartition.getRepresents();
+ String activitypartitionName = UMLLabelInternationalization.getInstance().getLabel(activitypartition);
+
+ if (represents instanceof NamedElement) {
+ activitypartitionName = ((NamedElement) represents).getName() ;
+ }
+ appendString(sb, activitypartitionName, UNNAMED);
+ return;
+ }
+
+ private void appendString(StringBuilder sb, String str, String defaultValue) {
+ if (str != null) {
+ sb.append(str);
+ } else {
+ sb.append(defaultValue);
+ }
+ }
+
+}

Back to the top