Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-02-03 12:26:14 +0000
committerCamille Letavernier2014-02-03 12:27:15 +0000
commit7a4fb9607229c4f30c7691ddf56f06dcc2af21cd (patch)
tree4416f82abcca8ff6e54f568c2b4f9263fb56a6f1
parent6a9f426427ba5ffb5fec2d3cabd99860f430e0fa (diff)
downloadorg.eclipse.papyrus-7a4fb9607229c4f30c7691ddf56f06dcc2af21cd.tar.gz
org.eclipse.papyrus-7a4fb9607229c4f30c7691ddf56f06dcc2af21cd.tar.xz
org.eclipse.papyrus-7a4fb9607229c4f30c7691ddf56f06dcc2af21cd.zip
417396: [CSS] The CSS Engine shall support label visibility & mask
https://bugs.eclipse.org/bugs/show_bug.cgi?id=417396 - Fix LifelineLabel-related classes - Adapt all MaskManaged labels from Sequence diagram to the new API
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/MessageLabelHelper.java44
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageLabelEditPolicy.java28
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/MessageCustomParser.java15
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/preferences/CustomDiagramPreferenceInitializer.java3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java19
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperationUtil.java55
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SignalUtil.java36
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/TooltipUtil.java26
8 files changed, 105 insertions, 121 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/MessageLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/MessageLabelHelper.java
index 6d4857ebdde..543108af2bc 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/MessageLabelHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/MessageLabelHelper.java
@@ -1,9 +1,9 @@
package org.eclipse.papyrus.uml.diagram.sequence.edit.helpers;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
@@ -26,13 +26,15 @@ import org.eclipse.uml2.uml.ValueSpecification;
public class MessageLabelHelper extends StereotypedElementLabelHelper {
+ public static final Collection<String> DEFAULT_LABEL_DISPLAY = Arrays.asList(ICustomAppearence.DISP_NAME, ICustomAppearence.DISP_PARAMETER_NAME, ICustomAppearence.DISP_PARAMETER_TYPE, ICustomAppearence.DISP_RT_TYPE);
+
/**
* singelton instance
*/
private static MessageLabelHelper labelHelper;
/** Map for masks */
- protected final Map<Integer, String> masks = new HashMap<Integer, String>(11);
+ protected final Map<String, String> masks = new HashMap<String, String>();
protected MessageLabelHelper() {
// initialize the map
@@ -51,7 +53,7 @@ public class MessageLabelHelper extends StereotypedElementLabelHelper {
/**
* Returns the singleton instance of this class
- *
+ *
* @return the singleton instance.
*/
public static MessageLabelHelper getInstance() {
@@ -75,7 +77,7 @@ public class MessageLabelHelper extends StereotypedElementLabelHelper {
if(editPart instanceof LabelEditPart) {
editPart = (GraphicalEditPart)editPart.getParent();
}
- int displayValue = CustomMessagePreferencePage.DEFAULT_LABEL_DISPLAY;
+ Collection<String> displayValue = DEFAULT_LABEL_DISPLAY;
IMaskManagedLabelEditPolicy policy = (IMaskManagedLabelEditPolicy)editPart.getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
if(policy != null) {
displayValue = policy.getCurrentDisplayValue();
@@ -96,12 +98,12 @@ public class MessageLabelHelper extends StereotypedElementLabelHelper {
return getMessageLabel(e, displayValue);
}
- private String getMessageLabel(Message e, int style) {
+ private String getMessageLabel(Message message, Collection<String> displayValue) {
StringBuffer buffer = new StringBuffer();
- buffer.append(e.getName());
+ buffer.append(message.getName());
// parameters : '(' parameter-list ')'
- EList<ValueSpecification> arguments = e.getArguments();
- if(arguments.size() > 0 && (style & ICustomAppearence.DISP_PARAMETER_NAME) != 0 || (style & ICustomAppearence.DISP_DERIVE) != 0) {
+ EList<ValueSpecification> arguments = message.getArguments();
+ if(arguments.size() > 0 && (displayValue.contains(ICustomAppearence.DISP_PARAMETER_NAME) || displayValue.contains(ICustomAppearence.DISP_DERIVE))) {
buffer.append("(");
for(int i = 0; i < arguments.size(); i++) {
if(i > 0) {
@@ -109,7 +111,7 @@ public class MessageLabelHelper extends StereotypedElementLabelHelper {
}
ValueSpecification arg = arguments.get(i);
//type
- if((style & ICustomAppearence.DISP_PARAMETER_TYPE) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_PARAMETER_TYPE)) {
String type = TypedElementUtil.getTypeAsString(arg);
if(type != null) {
buffer.append(type);
@@ -117,7 +119,7 @@ public class MessageLabelHelper extends StereotypedElementLabelHelper {
}
boolean showEqualMark = false;
// name
- if((style & ICustomAppearence.DISP_PARAMETER_NAME) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_PARAMETER_NAME)) {
buffer.append(" ");
String name = StringHelper.trimToEmpty(arg.getName());
buffer.append(name);
@@ -126,7 +128,7 @@ public class MessageLabelHelper extends StereotypedElementLabelHelper {
}
}
// value
- if((style & ICustomAppearence.DISP_DERIVE) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_DERIVE)) {
String value = ValueSpecificationUtil.getSpecificationValue(arg);
if(value != null) {
if(showEqualMark) {
@@ -141,25 +143,11 @@ public class MessageLabelHelper extends StereotypedElementLabelHelper {
return buffer.toString();
}
- public String getMaskLabel(int value) {
- return masks.get(value);
- }
-
- public Collection<String> getMaskLabels() {
- return masks.values();
- }
-
- @Override
- public Map<Integer, String> getMasks() {
+ public Map<String, String> getMasks() {
return masks;
}
- public Set<Integer> getMaskValues() {
- return masks.keySet();
- }
-
- @Override
- public int getDefaultValue() {
- return CustomMessagePreferencePage.DEFAULT_LABEL_DISPLAY;
+ public Collection<String> getDefaultValue() {
+ return DEFAULT_LABEL_DISPLAY;
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageLabelEditPolicy.java
index cf3c9e09e66..745c7251962 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageLabelEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageLabelEditPolicy.java
@@ -46,27 +46,15 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
}
@Override
- public int getDefaultDisplayValue() {
- return CustomMessagePreferencePage.DEFAULT_LABEL_DISPLAY;
- }
-
- public String getMaskLabel(int value) {
- return MessageLabelHelper.getInstance().getMaskLabel(value);
- }
-
- public Collection<String> getMaskLabels() {
- return MessageLabelHelper.getInstance().getMaskLabels();
+ public Collection<String> getDefaultDisplayValue() {
+ return MessageLabelHelper.getInstance().getDefaultValue();
}
@Override
- public Map<Integer, String> getMasks() {
+ public Map<String, String> getMasks() {
return MessageLabelHelper.getInstance().getMasks();
}
- public Collection<Integer> getMaskValues() {
- return MessageLabelHelper.getInstance().getMaskValues();
- }
-
@Override
public Message getUMLElement() {
if(hostSemanticElement instanceof Message) {
@@ -261,7 +249,7 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
/**
* notifies that a parameter of the operation has changed.
- *
+ *
* @param parameter
* the {@link Parameter} that has changed
* @param notification
@@ -348,7 +336,7 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
/**
* notifies that a parameter of the operation has changed.
- *
+ *
* @param parameter
* the {@link Parameter} that has changed
* @param notification
@@ -370,7 +358,7 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
/**
* notifies that the the property has changed.
- *
+ *
* @param operation
* the operation that has changed
* @param notification
@@ -414,7 +402,7 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
/**
* Checks if the given object is one of the parameter type of the operation
- *
+ *
* @param object
* the object to test
* @param operation
@@ -435,7 +423,7 @@ public class MessageLabelEditPolicy extends AbstractMaskManagedEditPolicy {
/**
* Checks if the given object is one of the parameter of the operation
- *
+ *
* @param object
* the object to test
* @param operation
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/MessageCustomParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/MessageCustomParser.java
index ffdd88b0c23..80ccc7de4cd 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/MessageCustomParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/MessageCustomParser.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2009 Atos Origin.
*
- *
+ *
* 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
@@ -14,6 +14,7 @@
package org.eclipse.papyrus.uml.diagram.sequence.parser.custom;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.eclipse.core.runtime.IAdaptable;
@@ -58,14 +59,14 @@ public class MessageCustomParser extends MessageFormatParser implements ISemanti
if(signature instanceof Operation) {
Operation operation = (Operation)signature;
if(MessageSort.REPLY_LITERAL.equals(message.getMessageSort())) {
- result = OperationUtil.getCustomLabel(operation, ICustomAppearence.DISP_NAME | ICustomAppearence.DISP_RT_TYPE);
+ result = OperationUtil.getCustomLabel(operation, Arrays.asList(ICustomAppearence.DISP_NAME, ICustomAppearence.DISP_RT_TYPE));
} else if(MessageSort.SYNCH_CALL_LITERAL.equals(message.getMessageSort())) {
- result = OperationUtil.getCustomLabel(operation, ICustomAppearence.DISP_NAME | ICustomAppearence.DISP_PARAMETER_NAME | ICustomAppearence.DISP_PARAMETER_TYPE);
+ result = OperationUtil.getCustomLabel(operation, Arrays.asList(ICustomAppearence.DISP_NAME, ICustomAppearence.DISP_PARAMETER_NAME, ICustomAppearence.DISP_PARAMETER_TYPE));
} else {
- result = OperationUtil.getCustomLabel(operation, ICustomAppearence.DISP_NAME | ICustomAppearence.DISP_PARAMETER_NAME | ICustomAppearence.DISP_PARAMETER_TYPE | ICustomAppearence.DISP_RT_TYPE);
+ result = OperationUtil.getCustomLabel(operation, Arrays.asList(ICustomAppearence.DISP_NAME, ICustomAppearence.DISP_PARAMETER_NAME, ICustomAppearence.DISP_PARAMETER_TYPE, ICustomAppearence.DISP_RT_TYPE));
}
} else if(signature instanceof Signal) {
- result = SignalUtil.getCustomLabel((Signal)signature, ICustomAppearence.DISP_NAME | ICustomAppearence.DISP_TYPE);
+ result = SignalUtil.getCustomLabel((Signal)signature, Arrays.asList(ICustomAppearence.DISP_NAME, ICustomAppearence.DISP_TYPE));
} else if(signature != null) {
result = signature.getName();
}
@@ -77,11 +78,13 @@ public class MessageCustomParser extends MessageFormatParser implements ISemanti
return result;
}
+ @Override
public boolean areSemanticElementsAffected(EObject listener, Object notification) {
return true;
}
- public List getSemanticElementsBeingParsed(EObject element) {
+ @Override
+ public List<Element> getSemanticElementsBeingParsed(EObject element) {
List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
if(element instanceof Message) {
Message message = (Message)element;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/preferences/CustomDiagramPreferenceInitializer.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/preferences/CustomDiagramPreferenceInitializer.java
index 5116fa89378..000bf328be3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/preferences/CustomDiagramPreferenceInitializer.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/preferences/CustomDiagramPreferenceInitializer.java
@@ -22,7 +22,7 @@ public class CustomDiagramPreferenceInitializer extends DiagramPreferenceInitial
/**
* Add the diagram preference page to the initialization
- *
+ *
* @Override (update at each gmf change) diagram preference page
*/
@Override
@@ -55,7 +55,6 @@ public class CustomDiagramPreferenceInitializer extends DiagramPreferenceInitial
//Custom preference pages.
CustomCombinedFragmentPreferencePage.initDefaults(store);
CustomConsiderIgnoreFragmentPreferencePage.initDefaults(store);
- CustomLifelinePreferencePage.initDefaults(store);
CustomDestructionOccurrenceSpecificationPreferencePage.initDefaults(store);
CustomInteractionOperandPreferencePage.initDefaults(store);
}
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 17da7c1ebce..d2628591f4e 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
@@ -9,7 +9,6 @@ import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.helper.StereotypedElementLabelHelper;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineNameEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.preferences.CustomLifelinePreferencePage;
import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.uml2.uml.ConnectableElement;
import org.eclipse.uml2.uml.Lifeline;
@@ -34,7 +33,7 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
/**
* Returns the singleton instance of this class
- *
+ *
* @return the singleton instance.
*/
public static LifelineLabelHelper getInstance() {
@@ -60,7 +59,7 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
/**
* Returns the map of masks used to display
- *
+ *
* @return the map of masks used to display
*/
public Map<String, String> getMasks() {
@@ -96,8 +95,8 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
private String getCustomLabel(Lifeline lifeline, Collection<String> displayValue) {
StringBuilder sb = new StringBuilder();
appendName(lifeline, displayValue, sb);
- boolean displayType = displayValue.contains(CustomLifelinePreferencePage.SHOW_REPRESENT_TYPE);
- if(lifeline.getRepresents() == null || displayValue.contains(CustomLifelinePreferencePage.SHOW_LIFELINE_NAME)) {
+ boolean displayType = displayValue.contains(SHOW_REPRESENT_TYPE);
+ if(lifeline.getRepresents() == null || displayValue.contains(LifelineLabelHelper.SHOW_LIFELINE_NAME)) {
displayType = false;
}
if(displayType) {
@@ -110,16 +109,16 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
protected void appendName(Lifeline lifeline, Collection<String> displayValue, StringBuilder sb) {
ConnectableElement element = lifeline.getRepresents();
String lifelineName = lifeline.getName();
- if(element == null || displayValue.contains(CustomLifelinePreferencePage.SHOW_LIFELINE_NAME)) {
+ if(element == null || displayValue.contains(SHOW_LIFELINE_NAME)) {
appendString(sb, lifelineName, UNAMED);
return;
} else {
// represents is not null
- if(displayValue.contains(CustomLifelinePreferencePage.SHOW_REPRESENT_NAME)) {
+ if(displayValue.contains(SHOW_REPRESENT_NAME)) {
appendString(sb, element.getName(), UNAMED);
}
// if neither <1> or <2> are checked, show lifeline name (or <unnamed> when the lifeline has no name)
- else if(!displayValue.contains(CustomLifelinePreferencePage.SHOW_REPRESENT_TYPE)) {
+ else if(!displayValue.contains(SHOW_REPRESENT_TYPE)) {
appendString(sb, lifelineName, UNAMED);
}
}
@@ -131,9 +130,9 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
return;
}
Type type = element.getType();
- if(displayValue.contains(CustomLifelinePreferencePage.SHOW_REPRESENT_TYPE)) {
+ if(displayValue.contains(SHOW_REPRESENT_TYPE)) {
if(type == null) {
- if(displayValue.contains(CustomLifelinePreferencePage.SHOW_UNDEFINED_TYPE)) {
+ if(displayValue.contains(SHOW_UNDEFINED_TYPE)) {
sb.append(":").append(UNDEFINED);
}
} else {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperationUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperationUtil.java
index 33703dbfdb3..2031788ef36 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperationUtil.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperationUtil.java
@@ -1,5 +1,6 @@
package org.eclipse.papyrus.uml.diagram.sequence.util;
+import java.util.Collection;
import java.util.Iterator;
import org.eclipse.emf.common.util.EList;
@@ -20,21 +21,21 @@ import org.eclipse.uml2.uml.ValueSpecification;
public class OperationUtil {
- public static String getCustomLabel(Message e, int paramIndex, Parameter parameter, int style) {
+ public static String getCustomLabel(Message e, int paramIndex, Parameter parameter, Collection<String> displayValue) {
StringBuffer buffer = new StringBuffer();
// visibility
buffer.append(" ");
- if((style & ICustomAppearence.DISP_VISIBILITY) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_VISIBILITY)) {
buffer.append(NamedElementUtil.getVisibilityAsSign(parameter));
}
// direction property
- if((style & ICustomAppearence.DISP_PARAMETER_DIRECTION) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_PARAMETER_DIRECTION)) {
buffer.append(" ");
buffer.append(parameter.getDirection().getLiteral());
}
boolean showEqualMark = false;
// name
- if((style & ICustomAppearence.DISP_PARAMETER_NAME) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_PARAMETER_NAME)) {
buffer.append(" ");
String name = StringHelper.trimToEmpty(parameter.getName());
if(name.trim().length() > 0) {
@@ -42,7 +43,7 @@ public class OperationUtil {
}
buffer.append(name);
}
- if((style & ICustomAppearence.DISP_PARAMETER_TYPE) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_PARAMETER_TYPE)) {
// type
if(parameter.getType() != null) {
buffer.append(": " + StringHelper.trimToEmpty(parameter.getType().getName()));
@@ -51,12 +52,12 @@ public class OperationUtil {
}
showEqualMark = true;
}
- if((style & ICustomAppearence.DISP_PARAMETER_MULTIPLICITY) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_PARAMETER_MULTIPLICITY)) {
// multiplicity -> do not display [1]
String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(parameter);
buffer.append(multiplicity);
}
- if((style & ICustomAppearence.DISP_DERIVE) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_DERIVE)) {
String value = getValue(e, paramIndex, parameter);
if(value != null) {
if(showEqualMark) {
@@ -64,7 +65,7 @@ public class OperationUtil {
}
buffer.append(value);
}
- } else if((style & ICustomAppearence.DISP_PARAMETER_DEFAULT) != 0) {
+ } else if(displayValue.contains(ICustomAppearence.DISP_PARAMETER_DEFAULT)) {
// default value
if(parameter.getDefault() != null) {
if(showEqualMark) {
@@ -73,8 +74,8 @@ public class OperationUtil {
buffer.append(parameter.getDefault());
}
}
- if((style & ICustomAppearence.DISP_MOFIFIERS) != 0) {
- boolean multiLine = ((style & ICustomAppearence.DISP_MULTI_LINE) != 0);
+ if(displayValue.contains(ICustomAppearence.DISP_MODIFIERS)) {
+ boolean multiLine = displayValue.contains(ICustomAppearence.DISP_MULTI_LINE);
// property modifiers
String modifiers = ParameterUtil.getModifiersAsString(parameter, multiLine);
if(!modifiers.equals("")) {
@@ -98,29 +99,29 @@ public class OperationUtil {
return null;
}
- public static String getCustomLabel(Message e, Operation operation, int style) {
+ public static String getCustomLabel(Message message, Operation operation, Collection<String> displayValue) {
StringBuffer buffer = new StringBuffer();
buffer.append(" "); // adds " " first for correct display considerations
// visibility
- if((style & ICustomAppearence.DISP_VISIBILITY) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_VISIBILITY)) {
buffer.append(NamedElementUtil.getVisibilityAsSign(operation));
}
// name
- if((style & ICustomAppearence.DISP_NAME) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_NAME)) {
buffer.append(" ");
buffer.append(StringHelper.trimToEmpty(operation.getName()));
}
//
// parameters : '(' parameter-list ')'
buffer.append("(");
- buffer.append(getParametersAsString(e, operation, style));
+ buffer.append(getParametersAsString(message, operation, displayValue));
buffer.append(")");
// return type
- if((style & ICustomAppearence.DISP_RT_TYPE) != 0) {
- buffer.append(getReturnTypeAsString(operation, style));
+ if(displayValue.contains(ICustomAppearence.DISP_RT_TYPE)) {
+ buffer.append(getReturnTypeAsString(operation, displayValue));
}
// modifiers
- if((style & ICustomAppearence.DISP_MOFIFIERS) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_MODIFIERS)) {
String modifiers = getModifiersAsString(operation);
if(!modifiers.equals("")) {
buffer.append("{");
@@ -133,7 +134,7 @@ public class OperationUtil {
/**
* Returns operation modifiers as string, separated with comma.
- *
+ *
* @return a string containing the modifiers
*/
private static String getModifiersAsString(Operation operation) {
@@ -192,14 +193,14 @@ public class OperationUtil {
/**
* Returns return parameter label as a string, string parametrized with a style mask.
- *
+ *
* @param style
* the mask that indicates which element to display
* @return a string containing the return parameter type
*/
- private static String getReturnTypeAsString(Operation operation, int style) {
- boolean displayType = ((style & ICustomAppearence.DISP_RT_TYPE) != 0);
- boolean displayMultiplicity = ((style & ICustomAppearence.DISP_RT_MULTIPLICITY) != 0);
+ private static String getReturnTypeAsString(Operation operation, Collection<String> displayValue) {
+ boolean displayType = displayValue.contains(ICustomAppearence.DISP_RT_TYPE);
+ boolean displayMultiplicity = displayValue.contains(ICustomAppearence.DISP_RT_MULTIPLICITY);
StringBuffer label = new StringBuffer("");
// Retrieve the return parameter (assume to be unique if defined)
Parameter returnParameter = getReturnParameter(operation);
@@ -222,7 +223,7 @@ public class OperationUtil {
/**
* Gives the return parameter for this operation, or <code>null</code> if none exists.
- *
+ *
* @return the return parameter of the operation or <code>null</code>
*/
private static Parameter getReturnParameter(Operation operation) {
@@ -240,12 +241,12 @@ public class OperationUtil {
/**
* Returns operation parameters as a string, the label is customized using a bit mask
- *
+ *
* @param e
- *
+ *
* @return a string containing all parameters separated by commas
*/
- private static String getParametersAsString(Message e, Operation operation, int style) {
+ private static String getParametersAsString(Message e, Operation operation, Collection<String> displayValue) {
StringBuffer paramString = new StringBuffer();
Iterator<Parameter> paramIterator = operation.getOwnedParameters().iterator();
boolean firstParameter = true;
@@ -255,7 +256,7 @@ public class OperationUtil {
// Do not include return parameters
if(!parameter.getDirection().equals(ParameterDirectionKind.RETURN_LITERAL)) {
// get the label for this parameter
- String parameterString = getCustomLabel(e, paramIndex, parameter, style).trim();
+ String parameterString = getCustomLabel(e, paramIndex, parameter, displayValue).trim();
paramIndex++;
if(!parameterString.equals("")) {
if(!firstParameter) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SignalUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SignalUtil.java
index e0c21fd5727..d0da44e611a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SignalUtil.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SignalUtil.java
@@ -1,5 +1,7 @@
package org.eclipse.papyrus.uml.diagram.sequence.util;
+import java.util.Collection;
+
import org.eclipse.emf.common.util.EList;
import org.eclipse.papyrus.infra.tools.util.StringHelper;
import org.eclipse.papyrus.uml.tools.utils.ICustomAppearence;
@@ -15,22 +17,22 @@ import org.eclipse.uml2.uml.ValueSpecification;
public class SignalUtil {
- private static String getCustomPropertyLabel(Message e, Property property, int style) {
+ private static String getCustomPropertyLabel(Message e, Property property, Collection<String> displayValue) {
StringBuffer buffer = new StringBuffer();
// visibility
buffer.append(" ");
- if((style & ICustomAppearence.DISP_VISIBILITY) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_VISIBILITY)) {
buffer.append(NamedElementUtil.getVisibilityAsSign(property));
}
// derived property
- if((style & ICustomAppearence.DISP_DERIVE) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_DERIVE)) {
if(property.isDerived()) {
buffer.append("/");
}
}
boolean showEqualMark = false;
// name
- if((style & ICustomAppearence.DISP_PARAMETER_NAME) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_PARAMETER_NAME)) {
buffer.append(" ");
String name = StringHelper.trimToEmpty(property.getName());
if(name.trim().length() > 0) {
@@ -38,7 +40,7 @@ public class SignalUtil {
}
buffer.append(name);
}
- if((style & ICustomAppearence.DISP_PARAMETER_TYPE) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_PARAMETER_TYPE)) {
// type
if(property.getType() != null) {
buffer.append(": " + StringHelper.trimToEmpty(property.getType().getName()));
@@ -47,12 +49,12 @@ public class SignalUtil {
}
showEqualMark = true;
}
- if((style & ICustomAppearence.DISP_MULTIPLICITY) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_MULTIPLICITY)) {
// multiplicity -> do not display [1]
String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(property);
buffer.append(multiplicity);
}
- if((style & ICustomAppearence.DISP_DERIVE) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_DERIVE)) {
String value = getValue(e, property);
if(value != null) {
if(showEqualMark) {
@@ -60,7 +62,7 @@ public class SignalUtil {
}
buffer.append(value);
}
- } else if((style & ICustomAppearence.DISP_PARAMETER_DEFAULT) != 0) {
+ } else if(displayValue.contains(ICustomAppearence.DISP_PARAMETER_DEFAULT)) {
// default value
if(property.getDefault() != null) {
if(showEqualMark) {
@@ -69,8 +71,8 @@ public class SignalUtil {
buffer.append(property.getDefault());
}
}
- if((style & ICustomAppearence.DISP_MOFIFIERS) != 0) {
- boolean multiLine = ((style & ICustomAppearence.DISP_MULTI_LINE) != 0);
+ if(displayValue.contains(ICustomAppearence.DISP_MODIFIERS)) {
+ boolean multiLine = displayValue.contains(ICustomAppearence.DISP_MULTI_LINE);
// property modifiers
String modifiers = PropertyUtil.getModifiersAsString(property, multiLine);
if(!modifiers.equals("")) {
@@ -102,29 +104,29 @@ public class SignalUtil {
/**
* return the custom label of the signal, given UML2 specification and a custom style.
*
- * @param e
+ * @param message
*
* @param style
* the integer representing the style of the label
*
* @return the string corresponding to the label of the signal
*/
- public static String getCustomLabel(Message e, Signal signal, int style) {
+ public static String getCustomLabel(Message message, Signal signal, Collection<String> displayValue) {
StringBuffer buffer = new StringBuffer();
buffer.append(" "); // adds " " first for correct display considerations
// visibility
- if((style & ICustomAppearence.DISP_VISIBILITY) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_VISIBILITY)) {
buffer.append(NamedElementUtil.getVisibilityAsSign(signal));
}
// name
- if((style & ICustomAppearence.DISP_NAME) != 0) {
+ if(displayValue.contains(ICustomAppearence.DISP_NAME)) {
buffer.append(" ");
buffer.append(StringHelper.trimToEmpty(signal.getName()));
}
//
// parameters : '(' parameter-list ')'
buffer.append("(");
- buffer.append(getPropertiesAsString(e, signal, style));
+ buffer.append(getPropertiesAsString(message, signal, displayValue));
buffer.append(")");
return buffer.toString();
}
@@ -134,12 +136,12 @@ public class SignalUtil {
*
* @return a string containing all properties separated by commas
*/
- private static String getPropertiesAsString(Message e, Signal signal, int style) {
+ private static String getPropertiesAsString(Message e, Signal signal, Collection<String> displayValue) {
StringBuffer propertiesString = new StringBuffer();
boolean firstProperty = true;
for(Property property : signal.getOwnedAttributes()) {
// get the label for this property
- String propertyString = getCustomPropertyLabel(e, property, style).trim();
+ String propertyString = getCustomPropertyLabel(e, property, displayValue).trim();
if(!propertyString.equals("")) {
if(!firstProperty) {
propertiesString.append(", ");
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/TooltipUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/TooltipUtil.java
index c4167e57bec..c1bb3b8f608 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/TooltipUtil.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/TooltipUtil.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2010 CEA
*
- *
+ *
* 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
@@ -14,6 +14,7 @@
package org.eclipse.papyrus.uml.diagram.sequence.util;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import org.eclipse.core.runtime.Assert;
@@ -43,7 +44,6 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragment2Edit
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineNameEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.navigator.UMLNavigatorLabelProvider;
-import org.eclipse.papyrus.uml.diagram.sequence.preferences.CustomLifelinePreferencePage;
import org.eclipse.uml2.uml.CombinedFragment;
import org.eclipse.uml2.uml.ConnectableElement;
import org.eclipse.uml2.uml.DestructionOccurrenceSpecification;
@@ -63,7 +63,7 @@ import org.eclipse.uml2.uml.UMLPackage;
/**
* Display type name as tooltip of each node element
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=402964
- *
+ *
* @author Jin Liu (jin.liu@soyatec.com)
*/
public class TooltipUtil {
@@ -160,7 +160,7 @@ public class TooltipUtil {
/**
* Constructor.
- *
+ *
*/
public TooltipEditPolicy(TooltipUpdater updater) {
this.updater = updater;
@@ -215,9 +215,9 @@ public class TooltipUtil {
/**
* Constructor.
- *
+ *
* @param updater
- *
+ *
*/
public TooltipFigure(TooltipUpdater updater) {
this.updater = updater;
@@ -238,7 +238,7 @@ public class TooltipUtil {
/**
* @see org.eclipse.draw2d.Figure#getPreferredSize(int, int)
- *
+ *
* @param wHint
* @param hHint
* @return
@@ -297,7 +297,7 @@ public class TooltipUtil {
/**
* Constructor.
- *
+ *
*/
public EditPartTooltipUpdater(GraphicalEditPart editPart) {
Assert.isNotNull(editPart);
@@ -306,9 +306,10 @@ public class TooltipUtil {
/**
* @see org.eclipse.papyrus.uml.diagram.sequence.util.TooltipUtil.TooltipUpdater#getTooltipName()
- *
+ *
* @return
*/
+ @Override
public String getTooltipName() {
if(editPart instanceof CombinedFragment2EditPart) {
return "Co Region";
@@ -360,9 +361,10 @@ public class TooltipUtil {
/**
* @see org.eclipse.papyrus.uml.diagram.sequence.util.TooltipUtil.TooltipUpdater#getTooltipDescription()
- *
+ *
* @return
*/
+ @Override
public String getTooltipDescription() {
//CoRegion
// if(editPart instanceof CombinedFragment2EditPart) {
@@ -430,7 +432,9 @@ public class TooltipUtil {
}
}
if(semanticElement instanceof Lifeline) {
- int displayValue = CustomLifelinePreferencePage.DEFAULT_LABEL_DISPLAY;
+ //Bug 417396
+ //FIXME: Refactored the displayValue as-is (int -> Collection<String>), although it is not used anymore to configure the tooltip. Remove?
+ Collection<String> displayValue = LifelineLabelHelper.DEFAULT_LABEL_DISPLAY;
IMaskManagedLabelEditPolicy policy = null;
if(editPart instanceof LifelineEditPart) {
policy = (IMaskManagedLabelEditPolicy)editPart.getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);

Back to the top