Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/messages.properties3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/Messages.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy.java57
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedFloatingLabelEditPolicy.java50
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java10
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/ActivityParameterNodeLabelHelper.java145
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/FloatingLabelHelper.java148
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/stereotype/AppliedStereotypeParser.java13
8 files changed, 269 insertions, 159 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/messages.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/messages.properties
index cf04fa5b87b..0d5288bf8f0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/messages.properties
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/messages.properties
@@ -44,6 +44,9 @@ AppliedStereotypeLabel_PackageImportAccessTag=access
AppliedStereotypeLabel_AbstractionTag=abstraction
AppliedStereotypeLabel_PackageMergeTag=merge
+############# Label Customization ###################
+ICustomAppearance_PIN_DISP_TYPE=Pin Type
+
############# Palette Customisation #################
PapyrusPaletteCustomizerDialog_AddButtonTooltip=Add the selection to the palette
PapyrusPaletteCustomizerDialog_RemoveButtonTooltip=Remove the selection from the palette
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/Messages.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/Messages.java
index b31c97e5235..cae8c6b57fe 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/Messages.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/Messages.java
@@ -88,6 +88,8 @@ public class Messages extends NLS {
public static String RotateAction_rotate_command;
+ public static String ICustomAppearance_PIN_DISP_TYPE;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy.java
new file mode 100644
index 00000000000..1d016313226
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Boutheina Bannour (CEA LIST) boutheina.bannour@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.editpolicies;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusUMLElementFigure;
+
+/**
+ * Edit Policy for Applied Stereotype Label for {@link ContextLink}.
+ */
+public class CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy extends AppliedStereotypeLinkLabelDisplayEditPolicy {
+
+ public static final String APPLIED_STEREOTYPE_LABEL = "context"; //$NON-NLS-1$
+
+ /**
+ * Creates the EditPolicy, with the correct tag.
+ */
+ public CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy() {
+ super(APPLIED_STEREOTYPE_LABEL); //$NON-NLS-1$
+ }
+
+ @Override
+ public void activate() {
+ // retrieve the view
+ View view = getView();
+ if (view == null) {
+ return;
+ }
+ // call the refresh overridden in this class
+ refreshDisplay();
+ }
+
+ /**
+ * Refreshes the tag display
+ */
+ @Override
+ protected void refreshStereotypeDisplay() {
+ IFigure figure = ((GraphicalEditPart) getHost()).getFigure();
+ // the tag displayed here is <code>&laquo context &raquo</code> see the class constructor
+ if (figure instanceof IPapyrusUMLElementFigure) {
+ ((IPapyrusUMLElementFigure) figure).setStereotypeDisplay(tag, null);
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedFloatingLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedFloatingLabelEditPolicy.java
index 7de6f25b5f0..450abb48d6e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedFloatingLabelEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedFloatingLabelEditPolicy.java
@@ -12,7 +12,6 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
@@ -24,17 +23,11 @@ import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.diagram.common.helper.FloatingLabelHelper;
import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance;
-import org.eclipse.uml2.uml.InstanceSpecification;
import org.eclipse.uml2.uml.MultiplicityElement;
import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.Parameter;
-import org.eclipse.uml2.uml.Port;
-import org.eclipse.uml2.uml.Signal;
import org.eclipse.uml2.uml.TypedElement;
import org.eclipse.uml2.uml.UMLPackage;
-// TODO: Auto-generated Javadoc
/**
* Specific edit policy for label displaying stereotypes and their properties for edges representing
* UML elements.
@@ -77,45 +70,6 @@ public class MaskManagedFloatingLabelEditPolicy extends AbstractMaskManagedEditP
*/
@Override
public Collection<String> getDefaultDisplayValue() {
- NamedElement umlElement = getUMLElement();
- if (umlElement != null) {
-
- /**
- * default uml operation display.
- */
- if (umlElement instanceof Operation) {
- return ICustomAppearance.DEFAULT_UML_OPERATION;
- }
-
- /**
- * default uml Port ins composite diagrams.
- */
- if (umlElement instanceof Port) {
- return ICustomAppearance.DEFAULT_UML_PORT;
- }
-
- /**
- * default uml Parameter in composite diagrams.
- */
- if (umlElement instanceof Parameter) {
- return ICustomAppearance.DEFAULT_UML_PARAMETER;
- }
-
- /**
- * default uml instancespecification .
- */
- if (umlElement instanceof InstanceSpecification) {
- return ICustomAppearance.DEFAULT_UML_INSTANCESPECIFICATION;
- }
-
- /**
- * default uml Signal .
- */
- if (umlElement instanceof Signal) {
- return Arrays.asList(ICustomAppearance.DISP_NAME, ICustomAppearance.DISP_TYPE);
- }
-
- }
return ICustomAppearance.DEFAULT_UML_FLOATING_LABEL;
}
@@ -248,7 +202,7 @@ public class MaskManagedFloatingLabelEditPolicy extends AbstractMaskManagedEditP
getDiagramEventBroker().removeNotificationListener(((MultiplicityElement) umlElement).getLowerValue(), this);
}
}
-
+
/**
* @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy#getCurrentDisplayValue()
*
@@ -256,7 +210,7 @@ public class MaskManagedFloatingLabelEditPolicy extends AbstractMaskManagedEditP
*/
@Override
public Collection<String> getCurrentDisplayValue() {
- if (getView() == null){
+ if (getView() == null) {
return Collections.emptySet();
}
return super.getCurrentDisplayValue();
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java
index 632e08bd68d..f89a00b1015 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java
@@ -100,16 +100,12 @@ public class AutomaticCompartmentLayoutManager extends AbstractLayout {
minimumWith = wl.getPreferredSize().width + 2;
}
}
-
}
if (!visibleCompartments.isEmpty()) {
for (Object o : container.getChildren()) {
- // only for child which are compartment
- if (o instanceof ResizableCompartmentFigure) {
- IFigure child = (IFigure) o;
- minimumHeight += child.getPreferredSize().height;
- minimumWith = Math.max(minimumWith, child.getPreferredSize().width);
- }
+ IFigure child = (IFigure) o;
+ minimumHeight += child.getPreferredSize().height;
+ minimumWith = Math.max(minimumWith, child.getPreferredSize().width);
}
} else {
for (IFigure child : visibleOthers) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/ActivityParameterNodeLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/ActivityParameterNodeLabelHelper.java
new file mode 100644
index 00000000000..26520778547
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/ActivityParameterNodeLabelHelper.java
@@ -0,0 +1,145 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST 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
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.common.helper;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance;
+import org.eclipse.uml2.uml.ActivityParameterNode;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.State;
+
+
+public class ActivityParameterNodeLabelHelper extends StereotypedElementLabelHelper {
+
+ /**
+ * String for separate masked label part
+ */
+ private static final String SEPARATOR = ": ";
+
+ private static final String STATE_SEPARATOR = ", ";
+
+ private static final String START_STATE_SEQUENCE = "[";
+
+ private static final String END_STATE_SEQUENCE = "]";
+
+ private static ActivityParameterNodeLabelHelper labelHelper;
+
+ /**
+ * Returns the singleton instance of this class
+ *
+ * @return the singleton instance.
+ */
+ public static ActivityParameterNodeLabelHelper getInstance() {
+ if (labelHelper == null) {
+ labelHelper = new ActivityParameterNodeLabelHelper();
+ }
+ return labelHelper;
+ }
+
+ /** Map for masks */
+ protected final Map<String, String> masks = new HashMap<String, String>();
+
+ /**
+ * Creates a new {@link ActivityParameterNode} label helper.
+ */
+ protected ActivityParameterNodeLabelHelper() {
+ // initialize the map
+ masks.put(ICustomAppearance.DISP_NAME, "Name");
+ masks.put(ICustomAppearance.DISP_PARAMETER_NAME, "Parameter Name");
+ masks.put(ICustomAppearance.DISP_TYPE, "Type");
+ masks.put(ICustomAppearance.DISP_STATE, "States");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String elementLabel(GraphicalEditPart editPart) {
+ Collection<String> displayValue = ICustomAppearance.DEFAULT_UML_ACTIVITYPARAMETERNODE;
+
+ IMaskManagedLabelEditPolicy policy = (IMaskManagedLabelEditPolicy) editPart.getParent().getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if (policy != null) {
+ displayValue = policy.getCurrentDisplayValue();
+ }
+ return parse(displayValue, getUMLElement(editPart));
+ }
+
+ public Map<String, String> getMasks() {
+ return masks;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ActivityParameterNode getUMLElement(GraphicalEditPart editPart) {
+ return (ActivityParameterNode) ((View) editPart.getModel()).getElement();
+ }
+
+ protected String parse(Collection<String> values, ActivityParameterNode node) {
+ StringBuilder result = new StringBuilder();
+ if (node == null) {
+ return "";
+ }
+ // building label value take from
+ // org.eclipse.papyrus.uml.diagram.activity.parser.custom.ActivityParameterNodeParser#getPrintString
+ if (values.contains(ICustomAppearance.DISP_NAME)) {
+ appendName(result, node);
+ }
+ if (values.contains(ICustomAppearance.DISP_PARAMETER_NAME) || result.length() == 0) {
+ appendName(result, node.getParameter());
+ }
+ if (values.contains(ICustomAppearance.DISP_TYPE)) {
+ appendName(result, node.getType());
+ }
+ if (values.contains(ICustomAppearance.DISP_STATE)) {
+ StringBuffer stateLabel = new StringBuffer();
+ for (State state : node.getInStates()) {
+ String stateName = state.getName();
+ if (stateName != null && stateName.length() > 0) {
+ if (stateLabel.length() > 0) {
+ stateLabel.append(STATE_SEPARATOR);
+ }
+ stateLabel.append(stateName);
+ }
+ }
+ if (stateLabel.length() > 0) {
+ if (result.length() > 0) {
+ result.append(System.getProperty("line.separator"));
+ }
+ result.append(START_STATE_SEQUENCE).append(stateLabel).append(END_STATE_SEQUENCE);
+ }
+ }
+ return result.toString();
+ }
+
+ private void appendName(StringBuilder builder, NamedElement element) {
+ if (element == null) {
+ return;
+ }
+ String name = element.getName();
+ if (name != null && name.length() > 0) {
+ if (builder.length() > 0) {
+ builder.append(SEPARATOR);
+ }
+ builder.append(name);
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/FloatingLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/FloatingLabelHelper.java
index 05014b9ec21..2f0fdcc0bc4 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/FloatingLabelHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/FloatingLabelHelper.java
@@ -21,38 +21,38 @@ import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
-import org.eclipse.papyrus.uml.tools.utils.CollaborationUseUtil;
import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance;
-import org.eclipse.papyrus.uml.tools.utils.InstanceSpecificationUtil;
import org.eclipse.papyrus.uml.tools.utils.MultiplicityElementUtil;
import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
-import org.eclipse.papyrus.uml.tools.utils.OperationUtil;
-import org.eclipse.papyrus.uml.tools.utils.ParameterUtil;
-import org.eclipse.papyrus.uml.tools.utils.PortUtil;
-import org.eclipse.papyrus.uml.tools.utils.PropertyUtil;
import org.eclipse.papyrus.uml.tools.utils.SignalUtil;
-import org.eclipse.papyrus.uml.tools.utils.TypeUtil;
+import org.eclipse.papyrus.uml.tools.utils.TypedElementUtil;
import org.eclipse.uml2.uml.Association;
-import org.eclipse.uml2.uml.CollaborationUse;
-import org.eclipse.uml2.uml.InstanceSpecification;
import org.eclipse.uml2.uml.MultiplicityElement;
import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.Parameter;
-import org.eclipse.uml2.uml.Port;
-import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Signal;
-import org.eclipse.uml2.uml.TemplateParameter;
import org.eclipse.uml2.uml.TypedElement;
-//TODO Check for usefull property to display
-
/**
* Helper for labels displaying {@link NamedElement}.
*/
public class FloatingLabelHelper extends StereotypedElementLabelHelper {
- // Einstance
+
+ /** The Constant SLASH. */
+ private static final String SLASH = "/";//$NON-NLS-1$
+
+ /** The Constant DOUBLE_DOT. */
+ private static final String DOUBLE_DOT = ": ";//$NON-NLS-1$
+
+ /** The Constant ONE_SPACE. */
+ private static final String ONE_SPACE = " ";//$NON-NLS-1$
+
+ /** The Constant EMPTY. */
+ private static final String EMPTY = ""; //$NON-NLS-1$
+
+ /** The Constant STEREOTYPE. */
+ private static final String STEREOTYPE = "stereotype"; //$NON-NLS-1$
+
/** The label helper. */
private static FloatingLabelHelper labelHelper;
@@ -105,45 +105,17 @@ public class FloatingLabelHelper extends StereotypedElementLabelHelper {
/**
* Style constant for default value display in labels.
*/
- masks.put(ICustomAppearance.DISP_DEFAULT_VALUE, "Default Value");
-
- /**
- * Style constant for modifiers display in labels.
- */
- masks.put(ICustomAppearance.DISP_MODIFIERS, "Modifiers");
-
- /** Style constant for carriage return in labels */
- masks.put(ICustomAppearance.DISP_MULTI_LINE, "Multiline");
-
- /** Style constant for operation#parameter direction display in labels */
- masks.put(ICustomAppearance.DISP_PARAMETER_DIRECTION, "Parameters Direction");
+ masks.put(ICustomAppearance.DISP_DEFAULT_VALUE, "Default Value");
/** Style constant for direction display in labels */
masks.put(ICustomAppearance.DISP_DIRECTION, "Direction");
- /** Style constant for operation#parameter name display in labels */
- masks.put(ICustomAppearance.DISP_PARAMETER_NAME, "Parameters Name");
-
- /** Style constant for operation#parameter type display in labels */
- masks.put(ICustomAppearance.DISP_PARAMETER_TYPE, "Parameters Type");
-
- /** Style constant for operation#parameter multiplicity display in labels */
- masks.put(ICustomAppearance.DISP_PARAMETER_MULTIPLICITY, "Parameters Multiplicity");
-
- /** Style constant for operation#parameter default value display in labels */
- masks.put(ICustomAppearance.DISP_PARAMETER_DEFAULT, "Parameters Default");
-
- /** Style constant for operation#parameter modifiers display in labels */
- masks.put(ICustomAppearance.DISP_PARAMETER_MODIFIERS, "Parameters Modifiers");
-
/** Style constant for return type display in labels */
masks.put(ICustomAppearance.DISP_RT_TYPE, "returnType");
/** Style constant for return multiplicity display in labels */
masks.put(ICustomAppearance.DISP_RT_MULTIPLICITY, "Return Multiplicity");
- /** Style constant for conjugated labels */
- masks.put(ICustomAppearance.DISP_CONJUGATED, "Conjugated");
}
/**
@@ -184,12 +156,18 @@ public class FloatingLabelHelper extends StereotypedElementLabelHelper {
*/
protected String parseString(GraphicalEditPart editPart, Collection<String> displayValue) {
NamedElement namedElement = getUMLElement(editPart);
+ StringBuilder buffer = new StringBuilder();
+
+ if (displayValue.contains(STEREOTYPE)) {
+ // computes the label for the stereotype (horizontal presentation)
+ buffer.append(stereotypesToDisplay((GraphicalEditPart) editPart.getParent()));
+ }
if (namedElement != null) {
- return getCustomLabel(namedElement, displayValue);
+ buffer.append(getCustomLabel(namedElement, displayValue));
}
- return "";
+ return buffer.toString();
}
@@ -217,6 +195,15 @@ public class FloatingLabelHelper extends StereotypedElementLabelHelper {
}
/**
+ * Computes the label to be displayed for the floating label
+ */
+ @Override
+ protected String labelToDisplay(GraphicalEditPart editPart) {
+ // computes the string label to be displayed
+ return elementLabel(editPart);
+ }
+
+ /**
* return the custom label of the property, given UML2 specification and a custom style.
*
* @param namedElement
@@ -225,52 +212,21 @@ public class FloatingLabelHelper extends StereotypedElementLabelHelper {
* the mask values
* @return the string corresponding to the label of the property
*/
- public static String getCustomLabel(NamedElement namedElement, Collection<String> maskValues) {
+ public String getCustomLabel(NamedElement namedElement, Collection<String> maskValues) {
// Use of specific existing custom label
- // use CollaborationUse custom label
- if (namedElement instanceof CollaborationUse) {
- return CollaborationUseUtil.getCustomLabel((CollaborationUse) namedElement, maskValues);
- }
-
- // use InstanceSpecification custom label
- if (namedElement instanceof InstanceSpecification) {
- return InstanceSpecificationUtil.getCustomLabel((InstanceSpecification) namedElement, maskValues);
- }
-
- // use Operation custom label
- if (namedElement instanceof Operation) {
- return OperationUtil.getCustomLabel((Operation) namedElement, maskValues);
- }
-
- // use Parameter custom label
- if (namedElement instanceof Parameter) {
- return ParameterUtil.getCustomLabel((Parameter) namedElement, maskValues);
- }
-
// use Signal custom label
if (namedElement instanceof Signal) {
return SignalUtil.getCustomLabel((Signal) namedElement, maskValues);
}
- // use Port custom label
- if (namedElement instanceof Port) {
- return PortUtil.getCustomLabel((Port) namedElement, maskValues);
- }
-
- // use Property custom label
- if (namedElement instanceof Property) {
- return PropertyUtil.getCustomLabel((Property) namedElement, maskValues);
- }
- // TODO add others usefull properties
-
// default custom label
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
// visibility
if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) {
- buffer.append(" ");
+ buffer.append(ONE_SPACE);
buffer.append(NamedElementUtil.getVisibilityAsSign(namedElement));
}
@@ -278,25 +234,22 @@ public class FloatingLabelHelper extends StereotypedElementLabelHelper {
if (namedElement instanceof Association) {
if (maskValues.contains(ICustomAppearance.DISP_DERIVE)) {
if (((Association) namedElement).isDerived()) {
- buffer.append("/");
+ buffer.append(SLASH);
}
}
}
// name
if (maskValues.contains(ICustomAppearance.DISP_NAME)) {
- buffer.append(" ");
- buffer.append(namedElement.getName());
+ buffer.append(ONE_SPACE);
+ final String name = namedElement.getName();
+ buffer.append(name != null ? name : EMPTY);
}
// Type of TypedElement
if (namedElement instanceof TypedElement) {
- if (maskValues.contains(ICustomAppearance.DISP_TYPE)) {
- // type
- if (((TypedElement) namedElement).getType() != null) {
- buffer.append(": " + ((TypedElement) namedElement).getType().getName());
- } else {
- buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
- }
+ if (maskValues.contains(ICustomAppearance.DISP_RT_TYPE) || maskValues.contains(ICustomAppearance.DISP_TYPE)) {
+ buffer.append(DOUBLE_DOT);
+ buffer.append(TypedElementUtil.getTypeAsString((TypedElement) namedElement));
}
}
@@ -309,17 +262,6 @@ public class FloatingLabelHelper extends StereotypedElementLabelHelper {
}
}
- // Template Parameter(not sure of the uml element
- if (namedElement instanceof TemplateParameter) {
- if (maskValues.contains(ICustomAppearance.DISP_DEFAULT_VALUE)) {
- // default value
- if (((TemplateParameter) namedElement).getDefault() != null) {
- buffer.append(" = ");
- buffer.append(((TemplateParameter) namedElement).getDefault());
- }
- }
- }
-
return buffer.toString();
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/stereotype/AppliedStereotypeParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/stereotype/AppliedStereotypeParser.java
index 7cc25dac0a7..28ac8c419ae 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/stereotype/AppliedStereotypeParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/stereotype/AppliedStereotypeParser.java
@@ -34,6 +34,16 @@ public class AppliedStereotypeParser implements ISemanticParser {
private static final MessageFormat APPLIED_PROFILE = new MessageFormat("\u00AB{0}\u00BB"); //$NON-NLS-1$
+ private final String myDefaultPrintString;
+
+ public AppliedStereotypeParser() {
+ this(null);
+ }
+
+ public AppliedStereotypeParser(String defaultPrintString) {
+ myDefaultPrintString = defaultPrintString;
+ }
+
@Override
public boolean areSemanticElementsAffected(EObject listener, Object notification) {
if (notification instanceof Notification) {
@@ -94,7 +104,8 @@ public class AppliedStereotypeParser implements ISemanticParser {
@Override
public String getPrintString(IAdaptable element, int flags) {
String editString = getEditString(element, flags);
- return editString == null || editString.length() == 0 ? editString : APPLIED_PROFILE.format(new Object[] { editString });
+ editString = editString == null || editString.isEmpty() ? myDefaultPrintString : editString;
+ return editString == null || editString.isEmpty() ? "" : APPLIED_PROFILE.format(new Object[] { editString });
}
@Override

Back to the top