Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils')
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/META-INF/MANIFEST.MF3
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/CollaborationUseUtil.java176
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ExtensionPointUtil.java82
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/InstanceSpecificationUtil.java8
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/MultiplicityElementUtil.java3
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/OperationUtil.java474
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java6
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ParameterUtil.java430
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PortUtil.java208
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PropertyUtil.java722
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/SignalUtil.java160
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/TypeUtil.java144
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/TypedElementUtil.java54
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ValueSpecificationUtil.java32
14 files changed, 1277 insertions, 1225 deletions
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/META-INF/MANIFEST.MF b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/META-INF/MANIFEST.MF
index 697f7b0daec..8421fff1abb 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/META-INF/MANIFEST.MF
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/META-INF/MANIFEST.MF
@@ -3,7 +3,8 @@ Export-Package: org.eclipse.papyrus.uml.tools.utils
Require-Bundle: org.eclipse.uml2.uml;bundle-version="[5.2.0,6.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)",
org.eclipse.gmf.runtime.notation;bundle-version="[1.8.0,2.0.0)",
- org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport
+ org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.uml.internationalization.utils;bundle-version="[1.0.0,2.0.0)"
Bundle-Vendor: %pluginProvider
Bundle-ActivationPolicy: lazy
Bundle-Version: 3.0.0.qualifier
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/CollaborationUseUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/CollaborationUseUtil.java
index 345a815ef08..124e850ed11 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/CollaborationUseUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/CollaborationUseUtil.java
@@ -1,87 +1,89 @@
-/*****************************************************************************
- * Copyright (c) 2009 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:
- * Yann TANGUY (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.tools.utils;
-
-import java.util.Collection;
-
-import org.eclipse.uml2.uml.CollaborationUse;
-
-/**
- * Utility class for <code>org.eclipse.uml2.uml.CollaborationUse</code><BR>
- */
-public class CollaborationUseUtil {
-
- public final static String UNDEFINED_TYPE_NAME = "<Undefined>";
-
- /**
- * return the full label of the CollaborationUse, given UML2 specification.
- *
- * @return the string corresponding to the label of the CollaborationUse
- */
- public static String getLabel(CollaborationUse collaborationUse) {
- StringBuffer buffer = new StringBuffer();
- // visibility
- buffer.append(" ");
- buffer.append(NamedElementUtil.getVisibilityAsSign(collaborationUse));
-
- // name
- buffer.append(" ");
- buffer.append(collaborationUse.getName());
-
- // type
- if (collaborationUse.getType() != null) {
- buffer.append(": " + collaborationUse.getType().getName());
- } else {
- buffer.append(": " + UNDEFINED_TYPE_NAME);
- }
-
- return buffer.toString();
- }
-
- /**
- * return the custom label of the CollaborationUse, given UML2 specification and a custom style.
- *
- * @param style
- * the integer representing the style of the label
- *
- * @return the string corresponding to the label of the CollaborationUse
- */
- public static String getCustomLabel(CollaborationUse collaborationUse, Collection<String> maskValues) {
- StringBuffer buffer = new StringBuffer();
- // visibility
-
- buffer.append(" ");
- if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) {
- buffer.append(NamedElementUtil.getVisibilityAsSign(collaborationUse));
- }
-
- // name
- if (maskValues.contains(ICustomAppearance.DISP_NAME)) {
- buffer.append(" ");
- buffer.append(collaborationUse.getName());
- }
-
- if (maskValues.contains(ICustomAppearance.DISP_TYPE)) {
- // type
- if (collaborationUse.getType() != null) {
- buffer.append(": " + collaborationUse.getType().getName());
- } else {
- buffer.append(": " + UNDEFINED_TYPE_NAME);
- }
- }
-
- return buffer.toString();
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Yann TANGUY (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.tools.utils;
+
+import java.util.Collection;
+
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.CollaborationUse;
+
+/**
+ * Utility class for <code>org.eclipse.uml2.uml.CollaborationUse</code><BR>
+ */
+public class CollaborationUseUtil {
+
+ public final static String UNDEFINED_TYPE_NAME = "<Undefined>";
+
+ /**
+ * return the full label of the CollaborationUse, given UML2 specification.
+ *
+ * @return the string corresponding to the label of the CollaborationUse
+ */
+ public static String getLabel(CollaborationUse collaborationUse) {
+ StringBuffer buffer = new StringBuffer();
+ // visibility
+ buffer.append(" ");
+ buffer.append(NamedElementUtil.getVisibilityAsSign(collaborationUse));
+
+ // name
+ buffer.append(" ");
+ buffer.append(UMLLabelInternationalization.getInstance().getLabel(collaborationUse));
+
+ // type
+ if (collaborationUse.getType() != null) {
+ buffer.append(": " + UMLLabelInternationalization.getInstance().getLabel(collaborationUse.getType()));
+ } else {
+ buffer.append(": " + UNDEFINED_TYPE_NAME);
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ * return the custom label of the CollaborationUse, given UML2 specification and a custom style.
+ *
+ * @param style
+ * the integer representing the style of the label
+ *
+ * @return the string corresponding to the label of the CollaborationUse
+ */
+ public static String getCustomLabel(CollaborationUse collaborationUse, Collection<String> maskValues) {
+ StringBuffer buffer = new StringBuffer();
+ // visibility
+
+ buffer.append(" ");
+ if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) {
+ buffer.append(NamedElementUtil.getVisibilityAsSign(collaborationUse));
+ }
+
+ // name
+ if (maskValues.contains(ICustomAppearance.DISP_NAME)) {
+ buffer.append(" ");
+ buffer.append(UMLLabelInternationalization.getInstance().getLabel(collaborationUse));
+ }
+
+ if (maskValues.contains(ICustomAppearance.DISP_TYPE)) {
+ // type
+ if (collaborationUse.getType() != null) {
+ buffer.append(": " + UMLLabelInternationalization.getInstance().getLabel(collaborationUse.getType()));
+ } else {
+ buffer.append(": " + UNDEFINED_TYPE_NAME);
+ }
+ }
+
+ return buffer.toString();
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ExtensionPointUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ExtensionPointUtil.java
index 9bc808106a3..a5e695f9872 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ExtensionPointUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ExtensionPointUtil.java
@@ -1,40 +1,42 @@
-/*****************************************************************************
- * Copyright (c) 2008 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:
- * Remi SCHNEKENBURGER (CEA LIST) Remi.schnekenburger@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.tools.utils;
-
-import org.eclipse.uml2.uml.ExtensionPoint;
-
-/**
- * Utility class for {@link ExtensionPoint}
- */
-// @unused
-public class ExtensionPointUtil {
-
- /**
- * Returns the explanation for the extension point element
- *
- * @return the string defining explanation for the extension point element
- */
- // @unused
- public static String getExplanation(ExtensionPoint extensionPoint) {
- String explanation = "";
- final String name = ((extensionPoint.getName() != null) ? extensionPoint.getName() : "");
- int startIndexOfExplanation = name.lastIndexOf(":");
- if ((startIndexOfExplanation > 0) && (startIndexOfExplanation != name.length())) {
- explanation = name.substring(startIndexOfExplanation + 1).trim();
- }
- return explanation;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2008 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:
+ * Remi SCHNEKENBURGER (CEA LIST) Remi.schnekenburger@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.tools.utils;
+
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.ExtensionPoint;
+
+/**
+ * Utility class for {@link ExtensionPoint}
+ */
+// @unused
+public class ExtensionPointUtil {
+
+ /**
+ * Returns the explanation for the extension point element
+ *
+ * @return the string defining explanation for the extension point element
+ */
+ // @unused
+ public static String getExplanation(ExtensionPoint extensionPoint) {
+ String explanation = "";
+ final String name = ((extensionPoint.getName() != null) ? UMLLabelInternationalization.getInstance().getLabel(extensionPoint) : "");
+ int startIndexOfExplanation = name.lastIndexOf(":");
+ if ((startIndexOfExplanation > 0) && (startIndexOfExplanation != name.length())) {
+ explanation = name.substring(startIndexOfExplanation + 1).trim();
+ }
+ return explanation;
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/InstanceSpecificationUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/InstanceSpecificationUtil.java
index 505c672897f..16a8561ce1a 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/InstanceSpecificationUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/InstanceSpecificationUtil.java
@@ -9,12 +9,14 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
*/
package org.eclipse.papyrus.uml.tools.utils;
import java.util.Collection;
import java.util.Iterator;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.InstanceSpecification;
@@ -37,7 +39,11 @@ public class InstanceSpecificationUtil {
// name
if (maskValues.contains(ICustomAppearance.DISP_NAME)) {
- buffer.append(NamedElementUtil.getName(instance));
+ if(null != instance.getName()){
+ buffer.append(UMLLabelInternationalization.getInstance().getLabel(instance));
+ }else{
+ buffer.append((NamedElementUtil.getDefaultNameWithIncrement(instance)));
+ }
}
// classifier
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/MultiplicityElementUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/MultiplicityElementUtil.java
index ac868ece577..633d0ffae7d 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/MultiplicityElementUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/MultiplicityElementUtil.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Yann TANGUY (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
*
*****************************************************************************/
package org.eclipse.papyrus.uml.tools.utils;
@@ -215,7 +216,7 @@ public class MultiplicityElementUtil {
* @return The string representing the value specification
*/
private static String getStringSpecificationValue(final ValueSpecification valueSpecification, final boolean isEdition) {
- String boundStr = ValueSpecificationUtil.getSpecificationValue(valueSpecification);
+ String boundStr = ValueSpecificationUtil.getSpecificationValue(valueSpecification, true);
if (isEdition && valueSpecification instanceof LiteralString) {
final StringBuffer buffer = new StringBuffer();
buffer.append(QUOTE);
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/OperationUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/OperationUtil.java
index c0492cec2ce..2927a23d0d3 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/OperationUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/OperationUtil.java
@@ -1,236 +1,238 @@
-/*****************************************************************************
- * Copyright (c) 2009 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:
- * Yann TANGUY (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.tools.utils;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.papyrus.infra.tools.util.StringHelper;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.Parameter;
-import org.eclipse.uml2.uml.ParameterDirectionKind;
-
-/**
- * Utility class for <code>org.eclipse.uml2.uml.Operation</code><BR>
- */
-public class OperationUtil {
-
- /**
- * return the custom label of the operation, given UML2 specification and a custom style.
- *
- * @param style
- * the integer representing the style of the label
- *
- * @return the string corresponding to the label of the operation
- */
- public static String getCustomLabel(Operation operation, Collection<String> maskValues) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(" "); // adds " " first for correct display considerations
-
- // visibility
- if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) {
- buffer.append(NamedElementUtil.getVisibilityAsSign(operation));
- }
-
- // name
- if (maskValues.contains(ICustomAppearance.DISP_NAME)) {
- buffer.append(" ");
- buffer.append(operation.getName());
- }
-
- //
- // parameters : '(' parameter-list ')'
- buffer.append("(");
- buffer.append(OperationUtil.getParametersAsString(operation, maskValues));
- buffer.append(")");
-
- // return type
- if (maskValues.contains(ICustomAppearance.DISP_RT_TYPE) || maskValues.contains(ICustomAppearance.DISP_TYPE)) {
- buffer.append(OperationUtil.getReturnTypeAsString(operation, maskValues));
- }
-
- // modifiers
- if (maskValues.contains(ICustomAppearance.DISP_MODIFIERS)) {
- String modifiers = OperationUtil.getModifiersAsString(operation);
- if (!modifiers.equals("")) {
- buffer.append("{");
- buffer.append(modifiers);
- buffer.append("}");
- }
- }
- return buffer.toString();
- }
-
- /**
- * 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, Collection<String> maskValues) {
- boolean displayType = maskValues.contains(ICustomAppearance.DISP_RT_TYPE) || maskValues.contains(ICustomAppearance.DISP_TYPE);
- boolean displayMultiplicity = maskValues.contains(ICustomAppearance.DISP_RT_MULTIPLICITY) || maskValues.contains(ICustomAppearance.DISP_MULTIPLICITY);
- StringBuffer label = new StringBuffer("");
-
- // Retrieve the return parameter (assume to be unique if defined)
- Parameter returnParameter = OperationUtil.getReturnParameter(operation);
- // Create the string for the return type
- if (returnParameter == null) {
- // no-operation: label = ""
-
- } else if (!displayType && !displayMultiplicity) {
- // no-operation: label = ""
-
- } else {
- label.append(": ");
- if (displayType) {
- label.append(TypedElementUtil.getTypeAsString(returnParameter));
- }
-
- if (displayMultiplicity) {
- label.append(MultiplicityElementUtil.getMultiplicityAsString(returnParameter));
- }
- }
- return label.toString();
- }
-
- /**
- * Returns operation parameters as a string, the label is customized using a bit mask
- *
- * @return a string containing all parameters separated by commas
- */
- private static String getParametersAsString(Operation operation, Collection<String> maskValues) {
- StringBuffer paramString = new StringBuffer();
- Iterator<Parameter> paramIterator = operation.getOwnedParameters().iterator();
- boolean firstParameter = true;
- while (paramIterator.hasNext()) {
- Parameter parameter = paramIterator.next();
- // Do not include return parameters
- if (!parameter.getDirection().equals(ParameterDirectionKind.RETURN_LITERAL)) {
-
- // get the label for this parameter
- String parameterString = ParameterUtil.getCustomLabel(parameter, extractParameterMaskValues(maskValues));
- if (!parameterString.trim().equals("")) {
- if (!firstParameter) {
- paramString.append(", ");
- }
- paramString.append(parameterString);
- firstParameter = false;
- }
- }
- }
- return paramString.toString();
- }
-
- private static Collection<String> extractParameterMaskValues(Collection<String> operationMaskValues) {
- Set<String> result = new HashSet<String>();
-
- for (String maskValue : operationMaskValues) {
- if (maskValue.startsWith(ICustomAppearance.PARAMETERS_PREFIX)) {
- String newValue = StringHelper.firstToLower(maskValue.replace(ICustomAppearance.PARAMETERS_PREFIX, ""));
- result.add(newValue);
- }
- }
-
- return result;
- }
-
- /**
- * Returns operation modifiers as string, separated with comma.
- *
- * @return a string containing the modifiers
- */
- private static String getModifiersAsString(Operation operation) {
- StringBuffer buffer = new StringBuffer();
- boolean needsComma = false;
-
- // Return parameter modifiers
- Parameter returnParameter = OperationUtil.getReturnParameter(operation);
- if (returnParameter != null) {
- // non unique parameter
- if (!returnParameter.isUnique()) {
- buffer.append("nonunique");
- needsComma = true;
- }
-
- // return parameter has ordered values
- if (returnParameter.isOrdered()) {
- if (needsComma) {
- buffer.append(", ");
- }
- buffer.append("ordered");
- needsComma = true;
- }
- }
-
- // is the operation a query ?
- if (operation.isQuery()) {
- if (needsComma) {
- buffer.append(", ");
- }
- buffer.append("query");
- needsComma = true;
- }
-
- // is the operation redefining another operation ?
- Iterator<Operation> it = operation.getRedefinedOperations().iterator();
- while (it.hasNext()) {
- Operation currentOperation = it.next();
- if (needsComma) {
- buffer.append(", ");
- }
- buffer.append("redefines ");
- buffer.append(currentOperation.getName());
- needsComma = true;
- }
-
- // has the operation a constraint ?
- Iterator<Constraint> it2 = operation.getOwnedRules().iterator();
- while (it2.hasNext()) {
- Constraint constraint = it2.next();
- if (needsComma) {
- buffer.append(", ");
- }
- if (constraint.getSpecification() != null) {
- buffer.append(constraint.getSpecification().stringValue());
- }
- needsComma = true;
- }
-
- return buffer.toString();
- }
-
- /**
- * 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) {
- // Retrieve the return parameter (assume to be unique if defined)
- Parameter returnParameter = null;
-
- Iterator<Parameter> it = operation.getOwnedParameters().iterator();
- while ((returnParameter == null) && (it.hasNext())) {
- Parameter parameter = it.next();
- if (parameter.getDirection().equals(ParameterDirectionKind.RETURN_LITERAL)) {
- returnParameter = parameter;
- }
- }
- return returnParameter;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Yann TANGUY (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.utils;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.papyrus.infra.tools.util.StringHelper;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+
+/**
+ * Utility class for <code>org.eclipse.uml2.uml.Operation</code><BR>
+ */
+public class OperationUtil {
+
+ /**
+ * return the custom label of the operation, given UML2 specification and a custom style.
+ *
+ * @param style
+ * the integer representing the style of the label
+ *
+ * @return the string corresponding to the label of the operation
+ */
+ public static String getCustomLabel(Operation operation, Collection<String> maskValues) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(" "); // adds " " first for correct display considerations
+
+ // visibility
+ if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) {
+ buffer.append(NamedElementUtil.getVisibilityAsSign(operation));
+ }
+
+ // name
+ if (maskValues.contains(ICustomAppearance.DISP_NAME)) {
+ buffer.append(" ");
+ buffer.append(UMLLabelInternationalization.getInstance().getLabel(operation));
+ }
+
+ //
+ // parameters : '(' parameter-list ')'
+ buffer.append("(");
+ buffer.append(OperationUtil.getParametersAsString(operation, maskValues));
+ buffer.append(")");
+
+ // return type
+ if (maskValues.contains(ICustomAppearance.DISP_RT_TYPE) || maskValues.contains(ICustomAppearance.DISP_TYPE)) {
+ buffer.append(OperationUtil.getReturnTypeAsString(operation, maskValues));
+ }
+
+ // modifiers
+ if (maskValues.contains(ICustomAppearance.DISP_MODIFIERS)) {
+ String modifiers = OperationUtil.getModifiersAsString(operation);
+ if (!modifiers.equals("")) {
+ buffer.append("{");
+ buffer.append(modifiers);
+ buffer.append("}");
+ }
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * 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, Collection<String> maskValues) {
+ boolean displayType = maskValues.contains(ICustomAppearance.DISP_RT_TYPE) || maskValues.contains(ICustomAppearance.DISP_TYPE);
+ boolean displayMultiplicity = maskValues.contains(ICustomAppearance.DISP_RT_MULTIPLICITY) || maskValues.contains(ICustomAppearance.DISP_MULTIPLICITY);
+ StringBuffer label = new StringBuffer("");
+
+ // Retrieve the return parameter (assume to be unique if defined)
+ Parameter returnParameter = OperationUtil.getReturnParameter(operation);
+ // Create the string for the return type
+ if (returnParameter == null) {
+ // no-operation: label = ""
+
+ } else if (!displayType && !displayMultiplicity) {
+ // no-operation: label = ""
+
+ } else {
+ label.append(": ");
+ if (displayType) {
+ label.append(TypedElementUtil.getTypeAsString(returnParameter));
+ }
+
+ if (displayMultiplicity) {
+ label.append(MultiplicityElementUtil.getMultiplicityAsString(returnParameter));
+ }
+ }
+ return label.toString();
+ }
+
+ /**
+ * Returns operation parameters as a string, the label is customized using a bit mask
+ *
+ * @return a string containing all parameters separated by commas
+ */
+ private static String getParametersAsString(Operation operation, Collection<String> maskValues) {
+ StringBuffer paramString = new StringBuffer();
+ Iterator<Parameter> paramIterator = operation.getOwnedParameters().iterator();
+ boolean firstParameter = true;
+ while (paramIterator.hasNext()) {
+ Parameter parameter = paramIterator.next();
+ // Do not include return parameters
+ if (!parameter.getDirection().equals(ParameterDirectionKind.RETURN_LITERAL)) {
+
+ // get the label for this parameter
+ String parameterString = ParameterUtil.getCustomLabel(parameter, extractParameterMaskValues(maskValues));
+ if (!parameterString.trim().equals("")) {
+ if (!firstParameter) {
+ paramString.append(", ");
+ }
+ paramString.append(parameterString);
+ firstParameter = false;
+ }
+ }
+ }
+ return paramString.toString();
+ }
+
+ private static Collection<String> extractParameterMaskValues(Collection<String> operationMaskValues) {
+ Set<String> result = new HashSet<String>();
+
+ for (String maskValue : operationMaskValues) {
+ if (maskValue.startsWith(ICustomAppearance.PARAMETERS_PREFIX)) {
+ String newValue = StringHelper.firstToLower(maskValue.replace(ICustomAppearance.PARAMETERS_PREFIX, ""));
+ result.add(newValue);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns operation modifiers as string, separated with comma.
+ *
+ * @return a string containing the modifiers
+ */
+ private static String getModifiersAsString(Operation operation) {
+ StringBuffer buffer = new StringBuffer();
+ boolean needsComma = false;
+
+ // Return parameter modifiers
+ Parameter returnParameter = OperationUtil.getReturnParameter(operation);
+ if (returnParameter != null) {
+ // non unique parameter
+ if (!returnParameter.isUnique()) {
+ buffer.append("nonunique");
+ needsComma = true;
+ }
+
+ // return parameter has ordered values
+ if (returnParameter.isOrdered()) {
+ if (needsComma) {
+ buffer.append(", ");
+ }
+ buffer.append("ordered");
+ needsComma = true;
+ }
+ }
+
+ // is the operation a query ?
+ if (operation.isQuery()) {
+ if (needsComma) {
+ buffer.append(", ");
+ }
+ buffer.append("query");
+ needsComma = true;
+ }
+
+ // is the operation redefining another operation ?
+ Iterator<Operation> it = operation.getRedefinedOperations().iterator();
+ while (it.hasNext()) {
+ Operation currentOperation = it.next();
+ if (needsComma) {
+ buffer.append(", ");
+ }
+ buffer.append("redefines ");
+ buffer.append(UMLLabelInternationalization.getInstance().getLabel(currentOperation));
+ needsComma = true;
+ }
+
+ // has the operation a constraint ?
+ Iterator<Constraint> it2 = operation.getOwnedRules().iterator();
+ while (it2.hasNext()) {
+ Constraint constraint = it2.next();
+ if (needsComma) {
+ buffer.append(", ");
+ }
+ if (constraint.getSpecification() != null) {
+ buffer.append(constraint.getSpecification().stringValue());
+ }
+ needsComma = true;
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ * 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) {
+ // Retrieve the return parameter (assume to be unique if defined)
+ Parameter returnParameter = null;
+
+ Iterator<Parameter> it = operation.getOwnedParameters().iterator();
+ while ((returnParameter == null) && (it.hasNext())) {
+ Parameter parameter = it.next();
+ if (parameter.getDirection().equals(ParameterDirectionKind.RETURN_LITERAL)) {
+ returnParameter = parameter;
+ }
+ }
+ return returnParameter;
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java
index c779540538b..e81c1fdc86d 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java
@@ -11,6 +11,7 @@
* Remi SCHNEKENBURGER (CEA LIST) Remi.schnekenburger@cea.fr - Initial API and implementation
* Yann TANGUY (CEA LIST) yann.tanguy@cea.fr
* Christian W. Damus (CEA) - bug 402525
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
*
*****************************************************************************/
package org.eclipse.papyrus.uml.tools.utils;
@@ -39,6 +40,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.ui.util.ServiceUtilsForHandlers;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
import org.eclipse.uml2.uml.Collaboration;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
@@ -606,8 +608,8 @@ public class PackageUtil {
* {@inheritDoc}
*/
public int compare(Type o1, Type o2) {
- final String o1Name = ((o1.getName() != null) ? o1.getName() : ""); //$NON-NLS-1$
- final String o2Name = ((o2.getName() != null) ? o2.getName() : ""); //$NON-NLS-1$
+ final String o1Name = ((o1.getName() != null) ? UMLLabelInternationalization.getInstance().getLabel(o1) : ""); //$NON-NLS-1$
+ final String o2Name = ((o2.getName() != null) ? UMLLabelInternationalization.getInstance().getLabel(o2) : ""); //$NON-NLS-1$
return o1Name.compareTo(o2Name);
}
}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ParameterUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ParameterUtil.java
index 7717e5bd448..7b7fcf6f954 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ParameterUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ParameterUtil.java
@@ -1,214 +1,216 @@
-/*****************************************************************************
- * Copyright (c) 2009 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:
- * Yann TANGUY (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.tools.utils;
-
-import java.util.Collection;
-
-import org.eclipse.uml2.uml.Parameter;
-
-/**
- * Utility class for <code>org.eclipse.uml2.uml.Parameter</code><BR>
- */
-public class ParameterUtil {
-
- /**
- * Returns the modifier of the property, separated by a comma, as as single line if <code>multiline</code> is <code>false</code> or as a multiline
- * string if <code>multiline</code> is <code>false</code>.
- *
- * @param multiLine
- * boolean that indicates if the string should have several lines when set to <code>true</code> or only one line when set to <code>false</code>.
- *
- * @return a string giving all modifiers for the property
- */
- public static String getModifiersAsString(Parameter parameter, boolean multiLine) {
- StringBuffer buffer = new StringBuffer();
- boolean needsComma = false;
- String NL = (multiLine) ? "\n" : " ";
-
- // Return parameter modifiers
- if (parameter.isOrdered()) {
- needsComma = updateModifiersString(buffer, needsComma, NL, "ordered");
- ;
- }
- if (parameter.isUnique()) {
- needsComma = updateModifiersString(buffer, needsComma, NL, "unique");
- }
- if (parameter.isException()) {
- needsComma = updateModifiersString(buffer, needsComma, NL, "exception");
- }
- if (parameter.isStream()) {
- needsComma = updateModifiersString(buffer, needsComma, NL, "stream");
- }
-
- if (!buffer.toString().equals("")) {
- buffer.insert(0, "{");
- buffer.append("}");
- }
-
- return buffer.toString();
- }
-
- /**
- * Update the modifiers string
- *
- * @param buffer
- * the existing bufferString to append
- * @param needsComma
- * if it needs coma
- * @param NL
- * if it is multiline
- * @param message
- * the message top
- * @return true because the modifier string is no more empty
- */
- private static boolean updateModifiersString(StringBuffer buffer, boolean needsComma, String NL, String message) {
- if (needsComma) {
- buffer.append(",");
- buffer.append(NL);
- }
- buffer.append(message);
- return true;
- }
-
- /**
- * return the full label of the Parameter.
- *
- * @return the string corresponding to the label of the parameter
- */
- public static String getLabel(Parameter parameter) {
- StringBuffer buffer = new StringBuffer();
- // visibility
- buffer.append(" ");
- buffer.append(NamedElementUtil.getVisibilityAsSign(parameter));
-
- // direction
- buffer.append(" ");
- buffer.append(parameter.getDirection().getLiteral());
-
- // name
- buffer.append(" ");
- if (parameter.getName() != null) {
- buffer.append(parameter.getName());
- }
-
- // type
- if (parameter.getType() != null) {
- buffer.append(": " + parameter.getType().getName());
- } else {
- buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
- }
-
- // multiplicity -> do not display [1]
- String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(parameter);
- if (!multiplicity.trim().equals("[1]")) {
- buffer.append(multiplicity);
- }
-
- // default value
- if (parameter.getDefault() != null) {
- buffer.append(" = ");
- buffer.append(parameter.getDefault());
- }
-
- // property modifiers
- buffer.append(ParameterUtil.getModifiersAsString(parameter, false));
-
- return buffer.toString();
- }
-
- /**
- * return the custom label of the property, given UML2 specification and a custom style.
- *
- * @param style
- * the integer representing the style of the label
- *
- * @return the string corresponding to the label of the property
- */
- public static String getCustomLabel(Parameter parameter, Collection<String> maskValues) {
- StringBuffer buffer = new StringBuffer();
- // visibility
- buffer.append(" ");
- if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) {
- buffer.append(NamedElementUtil.getVisibilityAsSign(parameter));
- }
-
- // direction property
- if (maskValues.contains(ICustomAppearance.DISP_PARAMETER_DIRECTION) || maskValues.contains(ICustomAppearance.DISP_DIRECTION)) {
- buffer.append(" ");
- buffer.append(parameter.getDirection().getLiteral());
- }
-
- // name
- if (maskValues.contains(ICustomAppearance.DISP_PARAMETER_NAME) || maskValues.contains(ICustomAppearance.DISP_NAME)) {
- buffer.append(" ");
- buffer.append(parameter.getName());
- }
-
- if (maskValues.contains(ICustomAppearance.DISP_PARAMETER_TYPE) || maskValues.contains(ICustomAppearance.DISP_TYPE)) {
- // type
- if (parameter.getType() != null) {
- buffer.append(": " + parameter.getType().getName());
- } else {
- buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
- }
- }
-
- if (maskValues.contains(ICustomAppearance.DISP_PARAMETER_MULTIPLICITY) || maskValues.contains(ICustomAppearance.DISP_MULTIPLICITY)) {
- // multiplicity -> do not display [1]
- String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(parameter);
- buffer.append(multiplicity);
- }
-
- if (maskValues.contains(ICustomAppearance.DISP_PARAMETER_DEFAULT) || maskValues.contains(ICustomAppearance.DISP_DEFAULT_VALUE)) {
- // default value
- if (parameter.getDefault() != null) {
- buffer.append(" = ");
- buffer.append(parameter.getDefault());
- }
- }
-
- if (maskValues.contains(ICustomAppearance.DISP_MODIFIERS)) {
- boolean multiLine = (maskValues.contains(ICustomAppearance.DISP_MULTI_LINE));
- // property modifiers
- String modifiers = ParameterUtil.getModifiersAsString(parameter, multiLine);
- if (!modifiers.equals("")) {
- if (multiLine) {
- buffer.append("\n");
- }
- buffer.append(modifiers);
- }
- }
- return buffer.toString();
- }
-
- /**
- * Returns the default value as a String
- *
- * @param equalSign
- * boolean set to <code>true</code> if the label must have the <code>=</code> sign
- * before the default value
- * @return the default value as a String
- */
- private static String getDefaultAsString(Parameter parameter, boolean equalSign) {
- String defaultString = "";
- // default value
- if ((parameter.getDefault() != null) && !parameter.getDefault().equals("")) {
- if (equalSign) {
- defaultString += "= ";
- }
- defaultString += parameter.getDefault();
- }
- return "";
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Yann TANGUY (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.utils;
+
+import java.util.Collection;
+
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.Parameter;
+
+/**
+ * Utility class for <code>org.eclipse.uml2.uml.Parameter</code><BR>
+ */
+public class ParameterUtil {
+
+ /**
+ * Returns the modifier of the property, separated by a comma, as as single line if <code>multiline</code> is <code>false</code> or as a multiline
+ * string if <code>multiline</code> is <code>false</code>.
+ *
+ * @param multiLine
+ * boolean that indicates if the string should have several lines when set to <code>true</code> or only one line when set to <code>false</code>.
+ *
+ * @return a string giving all modifiers for the property
+ */
+ public static String getModifiersAsString(Parameter parameter, boolean multiLine) {
+ StringBuffer buffer = new StringBuffer();
+ boolean needsComma = false;
+ String NL = (multiLine) ? "\n" : " ";
+
+ // Return parameter modifiers
+ if (parameter.isOrdered()) {
+ needsComma = updateModifiersString(buffer, needsComma, NL, "ordered");
+ ;
+ }
+ if (parameter.isUnique()) {
+ needsComma = updateModifiersString(buffer, needsComma, NL, "unique");
+ }
+ if (parameter.isException()) {
+ needsComma = updateModifiersString(buffer, needsComma, NL, "exception");
+ }
+ if (parameter.isStream()) {
+ needsComma = updateModifiersString(buffer, needsComma, NL, "stream");
+ }
+
+ if (!buffer.toString().equals("")) {
+ buffer.insert(0, "{");
+ buffer.append("}");
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ * Update the modifiers string
+ *
+ * @param buffer
+ * the existing bufferString to append
+ * @param needsComma
+ * if it needs coma
+ * @param NL
+ * if it is multiline
+ * @param message
+ * the message top
+ * @return true because the modifier string is no more empty
+ */
+ private static boolean updateModifiersString(StringBuffer buffer, boolean needsComma, String NL, String message) {
+ if (needsComma) {
+ buffer.append(",");
+ buffer.append(NL);
+ }
+ buffer.append(message);
+ return true;
+ }
+
+ /**
+ * return the full label of the Parameter.
+ *
+ * @return the string corresponding to the label of the parameter
+ */
+ public static String getLabel(Parameter parameter) {
+ StringBuffer buffer = new StringBuffer();
+ // visibility
+ buffer.append(" ");
+ buffer.append(NamedElementUtil.getVisibilityAsSign(parameter));
+
+ // direction
+ buffer.append(" ");
+ buffer.append(parameter.getDirection().getLiteral());
+
+ // name
+ buffer.append(" ");
+ if (parameter.getName() != null) {
+ buffer.append(UMLLabelInternationalization.getInstance().getLabel(parameter));
+ }
+
+ // type
+ if (parameter.getType() != null) {
+ buffer.append(": " + UMLLabelInternationalization.getInstance().getLabel(parameter.getType()));
+ } else {
+ buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
+ }
+
+ // multiplicity -> do not display [1]
+ String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(parameter);
+ if (!multiplicity.trim().equals("[1]")) {
+ buffer.append(multiplicity);
+ }
+
+ // default value
+ if (parameter.getDefault() != null) {
+ buffer.append(" = ");
+ buffer.append(parameter.getDefault());
+ }
+
+ // property modifiers
+ buffer.append(ParameterUtil.getModifiersAsString(parameter, false));
+
+ return buffer.toString();
+ }
+
+ /**
+ * return the custom label of the property, given UML2 specification and a custom style.
+ *
+ * @param style
+ * the integer representing the style of the label
+ *
+ * @return the string corresponding to the label of the property
+ */
+ public static String getCustomLabel(Parameter parameter, Collection<String> maskValues) {
+ StringBuffer buffer = new StringBuffer();
+ // visibility
+ buffer.append(" ");
+ if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) {
+ buffer.append(NamedElementUtil.getVisibilityAsSign(parameter));
+ }
+
+ // direction property
+ if (maskValues.contains(ICustomAppearance.DISP_PARAMETER_DIRECTION) || maskValues.contains(ICustomAppearance.DISP_DIRECTION)) {
+ buffer.append(" ");
+ buffer.append(parameter.getDirection().getLiteral());
+ }
+
+ // name
+ if (maskValues.contains(ICustomAppearance.DISP_PARAMETER_NAME) || maskValues.contains(ICustomAppearance.DISP_NAME)) {
+ buffer.append(" ");
+ buffer.append(UMLLabelInternationalization.getInstance().getLabel(parameter));
+ }
+
+ if (maskValues.contains(ICustomAppearance.DISP_PARAMETER_TYPE) || maskValues.contains(ICustomAppearance.DISP_TYPE)) {
+ // type
+ if (parameter.getType() != null) {
+ buffer.append(": " + UMLLabelInternationalization.getInstance().getLabel(parameter.getType()));
+ } else {
+ buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
+ }
+ }
+
+ if (maskValues.contains(ICustomAppearance.DISP_PARAMETER_MULTIPLICITY) || maskValues.contains(ICustomAppearance.DISP_MULTIPLICITY)) {
+ // multiplicity -> do not display [1]
+ String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(parameter);
+ buffer.append(multiplicity);
+ }
+
+ if (maskValues.contains(ICustomAppearance.DISP_PARAMETER_DEFAULT) || maskValues.contains(ICustomAppearance.DISP_DEFAULT_VALUE)) {
+ // default value
+ if (parameter.getDefault() != null) {
+ buffer.append(" = ");
+ buffer.append(parameter.getDefault());
+ }
+ }
+
+ if (maskValues.contains(ICustomAppearance.DISP_MODIFIERS)) {
+ boolean multiLine = (maskValues.contains(ICustomAppearance.DISP_MULTI_LINE));
+ // property modifiers
+ String modifiers = ParameterUtil.getModifiersAsString(parameter, multiLine);
+ if (!modifiers.equals("")) {
+ if (multiLine) {
+ buffer.append("\n");
+ }
+ buffer.append(modifiers);
+ }
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Returns the default value as a String
+ *
+ * @param equalSign
+ * boolean set to <code>true</code> if the label must have the <code>=</code> sign
+ * before the default value
+ * @return the default value as a String
+ */
+ private static String getDefaultAsString(Parameter parameter, boolean equalSign) {
+ String defaultString = "";
+ // default value
+ if ((parameter.getDefault() != null) && !parameter.getDefault().equals("")) {
+ if (equalSign) {
+ defaultString += "= ";
+ }
+ defaultString += parameter.getDefault();
+ }
+ return "";
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PortUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PortUtil.java
index 6d30ba4b855..7e8b21d2286 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PortUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PortUtil.java
@@ -1,103 +1,105 @@
-/*****************************************************************************
- * 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:
- * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.tools.utils;
-
-import java.util.Collection;
-
-import org.eclipse.uml2.uml.Port;
-import org.eclipse.uml2.uml.Property;
-
-
-public class PortUtil extends PropertyUtil {
-
- /**
- * return the custom label of the property, given UML2 specification and a custom style.
- *
- * @param style
- * the integer representing the style of the label
- *
- * @return the string corresponding to the label of the property
- */
- public static String getCustomLabel(Property property, Collection<String> maskValues) {
- StringBuffer buffer = new StringBuffer();
- // visibility
-
- buffer.append(" ");
- if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) {
- buffer.append(NamedElementUtil.getVisibilityAsSign(property));
- }
-
- // derived property
- if (maskValues.contains(ICustomAppearance.DISP_DERIVE)) {
- if (property.isDerived()) {
- buffer.append("/");
- }
- }
- // name
- if (maskValues.contains(ICustomAppearance.DISP_NAME)) {
- buffer.append(" ");
- buffer.append(property.getName());
- }
-
- if (maskValues.contains(ICustomAppearance.DISP_TYPE)) {
- if (maskValues.contains(ICustomAppearance.DISP_CONJUGATED)) {
- if (((Port) property).isConjugated()) {
- buffer.append(": ~");
- } else {
- buffer.append(": ");
- }
- } else {
- buffer.append(": ");
- }
- // type
- if (property.getType() != null) {
- buffer.append(property.getType().getName());
- } else {
- buffer.append(TypeUtil.UNDEFINED_TYPE_NAME);
- }
- }
-
- if (maskValues.contains(ICustomAppearance.DISP_MULTIPLICITY)) {
- // multiplicity -> do not display [1]
- String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(property);
- buffer.append(multiplicity);
- }
-
- if (maskValues.contains(ICustomAppearance.DISP_DEFAULT_VALUE)) {
- // default value
- if (property.getDefaultValue() != null) {
- buffer.append(" = ");
- buffer.append(ValueSpecificationUtil.getSpecificationValue(property.getDefaultValue()));
- }
- }
-
- if (maskValues.contains(ICustomAppearance.DISP_MODIFIERS)) {
- boolean multiLine = maskValues.contains(ICustomAppearance.DISP_MULTI_LINE);
- // property modifiers
- String modifiers = PropertyUtil.getModifiersAsString(property, multiLine);
- if (!modifiers.equals("")) {
- if (multiLine) {
- buffer.append("\n");
- }
-
- if (!buffer.toString().endsWith(" ")) {
- buffer.append(" ");
- }
-
- buffer.append(modifiers);
- }
- }
- return buffer.toString();
- }
-}
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.utils;
+
+import java.util.Collection;
+
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.Property;
+
+
+public class PortUtil extends PropertyUtil {
+
+ /**
+ * return the custom label of the property, given UML2 specification and a custom style.
+ *
+ * @param style
+ * the integer representing the style of the label
+ *
+ * @return the string corresponding to the label of the property
+ */
+ public static String getCustomLabel(Property property, Collection<String> maskValues) {
+ StringBuffer buffer = new StringBuffer();
+ // visibility
+
+ buffer.append(" ");
+ if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) {
+ buffer.append(NamedElementUtil.getVisibilityAsSign(property));
+ }
+
+ // derived property
+ if (maskValues.contains(ICustomAppearance.DISP_DERIVE)) {
+ if (property.isDerived()) {
+ buffer.append("/");
+ }
+ }
+ // name
+ if (maskValues.contains(ICustomAppearance.DISP_NAME)) {
+ buffer.append(" ");
+ buffer.append(UMLLabelInternationalization.getInstance().getLabel(property));
+ }
+
+ if (maskValues.contains(ICustomAppearance.DISP_TYPE)) {
+ if (maskValues.contains(ICustomAppearance.DISP_CONJUGATED)) {
+ if (((Port) property).isConjugated()) {
+ buffer.append(": ~");
+ } else {
+ buffer.append(": ");
+ }
+ } else {
+ buffer.append(": ");
+ }
+ // type
+ if (property.getType() != null) {
+ buffer.append(UMLLabelInternationalization.getInstance().getLabel(property.getType()));
+ } else {
+ buffer.append(TypeUtil.UNDEFINED_TYPE_NAME);
+ }
+ }
+
+ if (maskValues.contains(ICustomAppearance.DISP_MULTIPLICITY)) {
+ // multiplicity -> do not display [1]
+ String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(property);
+ buffer.append(multiplicity);
+ }
+
+ if (maskValues.contains(ICustomAppearance.DISP_DEFAULT_VALUE)) {
+ // default value
+ if (property.getDefaultValue() != null) {
+ buffer.append(" = ");
+ buffer.append(ValueSpecificationUtil.getSpecificationValue(property.getDefaultValue(), true));
+ }
+ }
+
+ if (maskValues.contains(ICustomAppearance.DISP_MODIFIERS)) {
+ boolean multiLine = maskValues.contains(ICustomAppearance.DISP_MULTI_LINE);
+ // property modifiers
+ String modifiers = PropertyUtil.getModifiersAsString(property, multiLine);
+ if (!modifiers.equals("")) {
+ if (multiLine) {
+ buffer.append("\n");
+ }
+
+ if (!buffer.toString().endsWith(" ")) {
+ buffer.append(" ");
+ }
+
+ buffer.append(modifiers);
+ }
+ }
+ return buffer.toString();
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PropertyUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PropertyUtil.java
index 23458631060..01779b93138 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PropertyUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PropertyUtil.java
@@ -1,360 +1,362 @@
-/*****************************************************************************
- * Copyright (c) 2009 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:
- * Yann TANGUY (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.tools.utils;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Property;
-
-/**
- * Utility class for <code>org.eclipse.uml2.uml.Property</code><BR>
- */
-public class PropertyUtil {
-
- /**
- * Get all properties that can be subset by this {@link Property} checks the type and the
- * multiplicity.
- *
- * @param property
- * property for which the list of subsettable properties are made
- * @param noCheck
- * set this parameter to <code>true</code> if multiplicity and type check should be
- * made for the computation
- * @return all properties that can be subset
- */
- public static List<Property> getSubsettablesProperties(Property property, boolean noCheck) {
- List<Property> list = new ArrayList<Property>();
-
- // subset properties:
- Iterator<NamedElement> it = property.getClass_().getMembers().iterator();
- while (it.hasNext()) {
-
- NamedElement element = it.next();
- if (element instanceof Property) {
- boolean isValid = true;
- Property subsettableProperty = (Property) element;
-
- // check it is not itself....
- if (subsettableProperty.equals(property)) {
- isValid = false;
- }
-
- // check types conformity
- if (!noCheck) {
- if (property.getType() != null && subsettableProperty.getType() != null) {
- if (!property.getType().conformsTo(subsettableProperty.getType())) {
- isValid = false;
- }
- } else {
- isValid = false;
- }
-
- // check multiplicity (only upper bound has an OCL rule)
- if ((subsettableProperty.getUpper() != -1) && (property.getUpper() > subsettableProperty.getUpper())) {
- isValid = false;
- }
- }
-
- if (isValid) {
- list.add(subsettableProperty);
- }
- }
- }
- return list;
- }
-
- /**
- * Find a subsetted property given its name and a context to find it.
- *
- * @param name
- * the name of the property
- * @return the property found or <code>null</code> if the element was not found.
- */
- // @unused
- public static Property findSusbsettedPropertyByName(String propertyName, Property property, boolean noCheck) {
- Iterator<Property> it = PropertyUtil.getSubsettablesProperties(property, true).iterator();
- while (it.hasNext()) {
- Property tmpProperty = it.next();
- String tmpPropertyName = tmpProperty.getName();
- if (tmpPropertyName != null && propertyName.equals(tmpPropertyName.trim())) {
- return tmpProperty;
- }
- }
- return null;
- }
-
- /**
- * Get all properties that can be redefined by this {@link Property}.
- *
- * @return all properties that can be redefined
- */
- public static List<Property> getRedefinableProperties(Property property) {
- List<Property> list = new ArrayList<Property>();
-
- // redefine-able properties:
- Iterator<NamedElement> it = property.getClass_().getInheritedMembers().iterator();
- while (it.hasNext()) {
- NamedElement element = it.next();
- if (element instanceof Property) {
- list.add((Property) element);
- }
- }
-
- // adds also already redefined members. In fact, when properties are
- // redefined, they
- // disappear from the inherited members list
- Iterator<Property> it2 = property.getRedefinedProperties().iterator();
- while (it2.hasNext()) {
- Property element = it2.next();
- list.add(element);
- }
- return list;
- }
-
- /**
- * Find a redefined property given its name and a context to find it.
- *
- * @param name
- * the name of the property
- * @return the property found or <code>null</code> if the element was not found.
- */
- public static Property findRedefinedPropertyByName(String propertyName, Property property) {
- Iterator<Property> it = PropertyUtil.getRedefinableProperties(property).iterator();
- while (it.hasNext()) {
- Property tmpProperty = it.next();
- String tmpPropertyName = tmpProperty.getName();
- if (tmpPropertyName != null && propertyName.equals(tmpPropertyName.trim())) {
- return tmpProperty;
- }
- }
- return null;
- }
-
- /**
- * Get the displayed string for the derived attribute of the property.
- *
- * @param property
- * the property
- * @return If the property is derived, return "/". Otherwise return an empty String
- */
- public static String getDerived(Property property) {
- return property.isDerived() ? "/" : "";
- }
-
- /**
- * return the full label of the property, given UML2 specification.
- *
- * @return the string corresponding to the label of the property
- */
- public static String getLabel(Property property) {
- StringBuffer buffer = new StringBuffer();
- // visibility
- buffer.append(" ");
- buffer.append(getNonNullString(NamedElementUtil.getVisibilityAsSign(property)));
-
- // derived property
- buffer.append(getNonNullString(getDerived(property)));
-
- // name
- buffer.append(" ");
- buffer.append(getNonNullString(getName(property)));
-
- // type
- if (property.getType() != null) {
- buffer.append(" : " + getNonNullString(property.getType().getName()));
- } else {
- buffer.append(" : " + TypeUtil.UNDEFINED_TYPE_NAME);
- }
-
- // multiplicity -> do not display [1]
- String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(property);
- if (!multiplicity.trim().equals("[1]")) {
- buffer.append(getNonNullString(multiplicity));
- }
-
- // default value
- if (property.getDefaultValue() != null) {
- buffer.append(" = ");
- buffer.append(getNonNullString(ValueSpecificationUtil.getSpecificationValue(property.getDefaultValue())));
- }
-
- // property modifiers
- buffer.append(getNonNullString(PropertyUtil.getModifiersAsString(property, false)));
-
- return buffer.toString();
- }
-
- public static String getName(Property property) {
- if (property.getName() != null) {
- return property.getName();
- } else {
- return (NamedElementUtil.getDefaultNameWithIncrement(property));
- }
- }
-
- private static String getNonNullString(String source) {
- return source == null ? "" : source;
- }
-
- /**
- * return the custom label of the property, given UML2 specification and a custom style.
- *
- * @param style
- * the collection of label fragments to display
- *
- * @return the string corresponding to the label of the property
- */
- public static String getCustomLabel(Property property, Collection<String> style) {
- StringBuffer buffer = new StringBuffer();
- // visibility
-
- buffer.append(" ");
- if (style.contains(ICustomAppearance.DISP_VISIBILITY)) {
- buffer.append(getNonNullString(NamedElementUtil.getVisibilityAsSign(property)));
- }
-
- // derived property
- if (style.contains(ICustomAppearance.DISP_DERIVE)) {
- if (property.isDerived()) {
- buffer.append("/");
- }
- }
- // name
- if (style.contains(ICustomAppearance.DISP_NAME)) {
- buffer.append(" ");
- buffer.append(getNonNullString(property.getName()));
- }
-
- if (style.contains(ICustomAppearance.DISP_TYPE)) {
- // type
- if (property.getType() != null) {
- buffer.append(": " + getNonNullString(property.getType().getName()));
- } else {
- buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
- }
- }
-
- if (style.contains(ICustomAppearance.DISP_MULTIPLICITY)) {
- // multiplicity -> do not display [1]
- String multiplicity = getNonNullString(MultiplicityElementUtil.getMultiplicityAsString(property));
- buffer.append(multiplicity);
- } else if (style.contains(ICustomAppearance.DISP_MULTIPLICITY_NO_BRACKETS)) {
- String multiplicity = getNonNullString(MultiplicityElementUtil.formatMultiplicityNoBrackets(property));
- buffer.append(multiplicity);
- }
-
- if (style.contains(ICustomAppearance.DISP_DEFAULT_VALUE)) {
- // default value
- if (property.getDefaultValue() != null) {
- buffer.append(" = ");
- buffer.append(getNonNullString(ValueSpecificationUtil.getSpecificationValue(property.getDefaultValue())));
- }
- }
-
- if (style.contains(ICustomAppearance.DISP_MODIFIERS)) {
- boolean multiLine = style.contains(ICustomAppearance.DISP_MULTI_LINE);
- // property modifiers
- String modifiers = getNonNullString(PropertyUtil.getModifiersAsString(property, multiLine));
- if (!modifiers.equals("")) {
- if (multiLine) {
- buffer.append("\n");
- }
-
- if (!buffer.toString().endsWith(" ")) {
- buffer.append(" ");
- }
-
- buffer.append(modifiers);
- }
- }
- return buffer.toString();
- }
-
- /**
- * Returns the modifier of the property, separated by a comma, as as single line if <code>multiline</code> is <code>false</code> or as a multiline
- * string if <code>multiline</code> is <code>false</code>.
- *
- * @param multiLine
- * boolean that indicates if the string should have several lines when set to <code>true</code> or only one line when set to <code>false</code>.
- *
- * @return a string giving all modifiers for the property
- */
- public static String getModifiersAsString(Property property, boolean multiLine) {
- StringBuffer buffer = new StringBuffer();
- boolean needsComma = false;
- String NL = (multiLine) ? "\n" : " ";
-
- // Return property modifiers
- if (property.isReadOnly()) {
- buffer.append("readOnly");
- needsComma = true;
- }
- if (property.isDerivedUnion()) {
- needsComma = updateModifiersString(buffer, needsComma, NL, "union");
- }
- if (property.isOrdered()) {
- needsComma = updateModifiersString(buffer, needsComma, NL, "ordered");
- ;
- }
- if (property.isUnique()) {
- needsComma = updateModifiersString(buffer, needsComma, NL, "unique");
- }
-
- // is the property redefining another property ?
- for (Property current : property.getRedefinedProperties()) {
- needsComma = updateModifiersString(buffer, needsComma, NL, "redefines ");
- buffer.append(current.getName());
- }
-
- // is the property subsetting another property ?
- for (Property current : property.getSubsettedProperties()) {
- needsComma = updateModifiersString(buffer, needsComma, NL, "subsets ");
- buffer.append(current.getName());
- }
-
- if (!buffer.toString().equals("")) {
- buffer.insert(0, "{");
- buffer.append("}");
- }
-
- return buffer.toString();
- }
-
- /**
- * Update the modifiers string
- *
- * @param buffer
- * the existing bufferString to append
- * @param needsComma
- * if it needs coma
- * @param NL
- * if it is multiline
- * @param message
- * the message top
- * @return true because the modifier string is no more empty
- */
- private static boolean updateModifiersString(StringBuffer buffer, boolean needsComma, String NL, String message) {
- if (needsComma) {
- buffer.append(",");
- buffer.append(NL);
- }
- buffer.append(message);
- return true;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Yann TANGUY (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.tools.utils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Property;
+
+/**
+ * Utility class for <code>org.eclipse.uml2.uml.Property</code><BR>
+ */
+public class PropertyUtil {
+
+ /**
+ * Get all properties that can be subset by this {@link Property} checks the type and the
+ * multiplicity.
+ *
+ * @param property
+ * property for which the list of subsettable properties are made
+ * @param noCheck
+ * set this parameter to <code>true</code> if multiplicity and type check should be
+ * made for the computation
+ * @return all properties that can be subset
+ */
+ public static List<Property> getSubsettablesProperties(Property property, boolean noCheck) {
+ List<Property> list = new ArrayList<Property>();
+
+ // subset properties:
+ Iterator<NamedElement> it = property.getClass_().getMembers().iterator();
+ while (it.hasNext()) {
+
+ NamedElement element = it.next();
+ if (element instanceof Property) {
+ boolean isValid = true;
+ Property subsettableProperty = (Property) element;
+
+ // check it is not itself....
+ if (subsettableProperty.equals(property)) {
+ isValid = false;
+ }
+
+ // check types conformity
+ if (!noCheck) {
+ if (property.getType() != null && subsettableProperty.getType() != null) {
+ if (!property.getType().conformsTo(subsettableProperty.getType())) {
+ isValid = false;
+ }
+ } else {
+ isValid = false;
+ }
+
+ // check multiplicity (only upper bound has an OCL rule)
+ if ((subsettableProperty.getUpper() != -1) && (property.getUpper() > subsettableProperty.getUpper())) {
+ isValid = false;
+ }
+ }
+
+ if (isValid) {
+ list.add(subsettableProperty);
+ }
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Find a subsetted property given its name and a context to find it.
+ *
+ * @param name
+ * the name of the property
+ * @return the property found or <code>null</code> if the element was not found.
+ */
+ // @unused
+ public static Property findSusbsettedPropertyByName(String propertyName, Property property, boolean noCheck) {
+ Iterator<Property> it = PropertyUtil.getSubsettablesProperties(property, true).iterator();
+ while (it.hasNext()) {
+ Property tmpProperty = it.next();
+ String tmpPropertyName = tmpProperty.getName();
+ if (tmpPropertyName != null && propertyName.equals(tmpPropertyName.trim())) {
+ return tmpProperty;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get all properties that can be redefined by this {@link Property}.
+ *
+ * @return all properties that can be redefined
+ */
+ public static List<Property> getRedefinableProperties(Property property) {
+ List<Property> list = new ArrayList<Property>();
+
+ // redefine-able properties:
+ Iterator<NamedElement> it = property.getClass_().getInheritedMembers().iterator();
+ while (it.hasNext()) {
+ NamedElement element = it.next();
+ if (element instanceof Property) {
+ list.add((Property) element);
+ }
+ }
+
+ // adds also already redefined members. In fact, when properties are
+ // redefined, they
+ // disappear from the inherited members list
+ Iterator<Property> it2 = property.getRedefinedProperties().iterator();
+ while (it2.hasNext()) {
+ Property element = it2.next();
+ list.add(element);
+ }
+ return list;
+ }
+
+ /**
+ * Find a redefined property given its name and a context to find it.
+ *
+ * @param name
+ * the name of the property
+ * @return the property found or <code>null</code> if the element was not found.
+ */
+ public static Property findRedefinedPropertyByName(String propertyName, Property property) {
+ Iterator<Property> it = PropertyUtil.getRedefinableProperties(property).iterator();
+ while (it.hasNext()) {
+ Property tmpProperty = it.next();
+ String tmpPropertyName = tmpProperty.getName();
+ if (tmpPropertyName != null && propertyName.equals(tmpPropertyName.trim())) {
+ return tmpProperty;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get the displayed string for the derived attribute of the property.
+ *
+ * @param property
+ * the property
+ * @return If the property is derived, return "/". Otherwise return an empty String
+ */
+ public static String getDerived(Property property) {
+ return property.isDerived() ? "/" : "";
+ }
+
+ /**
+ * return the full label of the property, given UML2 specification.
+ *
+ * @return the string corresponding to the label of the property
+ */
+ public static String getLabel(Property property) {
+ StringBuffer buffer = new StringBuffer();
+ // visibility
+ buffer.append(" ");
+ buffer.append(getNonNullString(NamedElementUtil.getVisibilityAsSign(property)));
+
+ // derived property
+ buffer.append(getNonNullString(getDerived(property)));
+
+ // name
+ buffer.append(" ");
+ buffer.append(getNonNullString(getName(property)));
+
+ // type
+ if (property.getType() != null) {
+ buffer.append(" : " + getNonNullString(UMLLabelInternationalization.getInstance().getLabel(property.getType())));
+ } else {
+ buffer.append(" : " + TypeUtil.UNDEFINED_TYPE_NAME);
+ }
+
+ // multiplicity -> do not display [1]
+ String multiplicity = MultiplicityElementUtil.getMultiplicityAsString(property);
+ if (!multiplicity.trim().equals("[1]")) {
+ buffer.append(getNonNullString(multiplicity));
+ }
+
+ // default value
+ if (property.getDefaultValue() != null) {
+ buffer.append(" = ");
+ buffer.append(getNonNullString(ValueSpecificationUtil.getSpecificationValue(property.getDefaultValue())));
+ }
+
+ // property modifiers
+ buffer.append(getNonNullString(PropertyUtil.getModifiersAsString(property, false)));
+
+ return buffer.toString();
+ }
+
+ public static String getName(Property property) {
+ if (property.getName() != null) {
+ return UMLLabelInternationalization.getInstance().getLabel(property);
+ } else {
+ return (NamedElementUtil.getDefaultNameWithIncrement(property));
+ }
+ }
+
+ private static String getNonNullString(String source) {
+ return source == null ? "" : source;
+ }
+
+ /**
+ * return the custom label of the property, given UML2 specification and a custom style.
+ *
+ * @param style
+ * the collection of label fragments to display
+ *
+ * @return the string corresponding to the label of the property
+ */
+ public static String getCustomLabel(Property property, Collection<String> style) {
+ StringBuffer buffer = new StringBuffer();
+ // visibility
+
+ buffer.append(" ");
+ if (style.contains(ICustomAppearance.DISP_VISIBILITY)) {
+ buffer.append(getNonNullString(NamedElementUtil.getVisibilityAsSign(property)));
+ }
+
+ // derived property
+ if (style.contains(ICustomAppearance.DISP_DERIVE)) {
+ if (property.isDerived()) {
+ buffer.append("/");
+ }
+ }
+ // name
+ if (style.contains(ICustomAppearance.DISP_NAME)) {
+ buffer.append(" ");
+ buffer.append(getNonNullString(UMLLabelInternationalization.getInstance().getLabel(property)));
+ }
+
+ if (style.contains(ICustomAppearance.DISP_TYPE)) {
+ // type
+ if (property.getType() != null) {
+ buffer.append(": " + getNonNullString(UMLLabelInternationalization.getInstance().getLabel(property.getType())));
+ } else {
+ buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
+ }
+ }
+
+ if (style.contains(ICustomAppearance.DISP_MULTIPLICITY)) {
+ // multiplicity -> do not display [1]
+ String multiplicity = getNonNullString(MultiplicityElementUtil.getMultiplicityAsString(property));
+ buffer.append(multiplicity);
+ } else if (style.contains(ICustomAppearance.DISP_MULTIPLICITY_NO_BRACKETS)) {
+ String multiplicity = getNonNullString(MultiplicityElementUtil.formatMultiplicityNoBrackets(property));
+ buffer.append(multiplicity);
+ }
+
+ if (style.contains(ICustomAppearance.DISP_DEFAULT_VALUE)) {
+ // default value
+ if (property.getDefaultValue() != null) {
+ buffer.append(" = ");
+ buffer.append(getNonNullString(ValueSpecificationUtil.getSpecificationValue(property.getDefaultValue(), true)));
+ }
+ }
+
+ if (style.contains(ICustomAppearance.DISP_MODIFIERS)) {
+ boolean multiLine = style.contains(ICustomAppearance.DISP_MULTI_LINE);
+ // property modifiers
+ String modifiers = getNonNullString(PropertyUtil.getModifiersAsString(property, multiLine));
+ if (!modifiers.equals("")) {
+ if (multiLine) {
+ buffer.append("\n");
+ }
+
+ if (!buffer.toString().endsWith(" ")) {
+ buffer.append(" ");
+ }
+
+ buffer.append(modifiers);
+ }
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Returns the modifier of the property, separated by a comma, as as single line if <code>multiline</code> is <code>false</code> or as a multiline
+ * string if <code>multiline</code> is <code>false</code>.
+ *
+ * @param multiLine
+ * boolean that indicates if the string should have several lines when set to <code>true</code> or only one line when set to <code>false</code>.
+ *
+ * @return a string giving all modifiers for the property
+ */
+ public static String getModifiersAsString(Property property, boolean multiLine) {
+ StringBuffer buffer = new StringBuffer();
+ boolean needsComma = false;
+ String NL = (multiLine) ? "\n" : " ";
+
+ // Return property modifiers
+ if (property.isReadOnly()) {
+ buffer.append("readOnly");
+ needsComma = true;
+ }
+ if (property.isDerivedUnion()) {
+ needsComma = updateModifiersString(buffer, needsComma, NL, "union");
+ }
+ if (property.isOrdered()) {
+ needsComma = updateModifiersString(buffer, needsComma, NL, "ordered");
+ ;
+ }
+ if (property.isUnique()) {
+ needsComma = updateModifiersString(buffer, needsComma, NL, "unique");
+ }
+
+ // is the property redefining another property ?
+ for (Property current : property.getRedefinedProperties()) {
+ needsComma = updateModifiersString(buffer, needsComma, NL, "redefines ");
+ buffer.append(UMLLabelInternationalization.getInstance().getLabel(current));
+ }
+
+ // is the property subsetting another property ?
+ for (Property current : property.getSubsettedProperties()) {
+ needsComma = updateModifiersString(buffer, needsComma, NL, "subsets ");
+ buffer.append(UMLLabelInternationalization.getInstance().getLabel(current));
+ }
+
+ if (!buffer.toString().equals("")) {
+ buffer.insert(0, "{");
+ buffer.append("}");
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ * Update the modifiers string
+ *
+ * @param buffer
+ * the existing bufferString to append
+ * @param needsComma
+ * if it needs coma
+ * @param NL
+ * if it is multiline
+ * @param message
+ * the message top
+ * @return true because the modifier string is no more empty
+ */
+ private static boolean updateModifiersString(StringBuffer buffer, boolean needsComma, String NL, String message) {
+ if (needsComma) {
+ buffer.append(",");
+ buffer.append(NL);
+ }
+ buffer.append(message);
+ return true;
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/SignalUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/SignalUtil.java
index 3b788ce2b5d..93569ca5f8f 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/SignalUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/SignalUtil.java
@@ -1,79 +1,81 @@
-/*****************************************************************************
- * Copyright (c) 2010 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:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.tools.utils;
-
-import java.util.Collection;
-
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Signal;
-
-/**
- * Utility class for <code>org.eclipse.uml2.uml.Signal</code><BR>
- */
-public class SignalUtil {
-
- /**
- * return the custom label of the signal, given UML2 specification and a custom style.
- *
- * @param style
- * the integer representing the style of the label
- *
- * @return the string corresponding to the label of the signal
- */
- public static String getCustomLabel(Signal signal, Collection<String> maskValues) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(" "); // adds " " first for correct display considerations
-
- // visibility
- if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) {
- buffer.append(NamedElementUtil.getVisibilityAsSign(signal));
- }
-
- // name
- if (maskValues.contains(ICustomAppearance.DISP_NAME)) {
- buffer.append(" ");
- buffer.append(signal.getName());
- }
-
- //
- // parameters : '(' parameter-list ')'
- buffer.append("(");
- buffer.append(getPropertiesAsString(signal, maskValues));
- buffer.append(")");
-
- return buffer.toString();
- }
-
- /**
- * Returns signal properties as a string, the label is customized using a bit mask
- *
- * @return a string containing all properties separated by commas
- */
- private static String getPropertiesAsString(Signal signal, Collection<String> maskValues) {
- StringBuffer propertiesString = new StringBuffer();
- boolean firstProperty = true;
- for (Property property : signal.getOwnedAttributes()) {
- // get the label for this property
- String propertyString = PropertyUtil.getCustomLabel(property, maskValues);
- if (!propertyString.trim().equals("")) {
- if (!firstProperty) {
- propertiesString.append(", ");
- }
- propertiesString.append(propertyString);
- firstProperty = false;
- }
- }
- return propertiesString.toString();
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Atos Origin - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.utils;
+
+import java.util.Collection;
+
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Signal;
+
+/**
+ * Utility class for <code>org.eclipse.uml2.uml.Signal</code><BR>
+ */
+public class SignalUtil {
+
+ /**
+ * return the custom label of the signal, given UML2 specification and a custom style.
+ *
+ * @param style
+ * the integer representing the style of the label
+ *
+ * @return the string corresponding to the label of the signal
+ */
+ public static String getCustomLabel(Signal signal, Collection<String> maskValues) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(" "); // adds " " first for correct display considerations
+
+ // visibility
+ if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) {
+ buffer.append(NamedElementUtil.getVisibilityAsSign(signal));
+ }
+
+ // name
+ if (maskValues.contains(ICustomAppearance.DISP_NAME)) {
+ buffer.append(" ");
+ buffer.append(UMLLabelInternationalization.getInstance().getLabel(signal));
+ }
+
+ //
+ // parameters : '(' parameter-list ')'
+ buffer.append("(");
+ buffer.append(getPropertiesAsString(signal, maskValues));
+ buffer.append(")");
+
+ return buffer.toString();
+ }
+
+ /**
+ * Returns signal properties as a string, the label is customized using a bit mask
+ *
+ * @return a string containing all properties separated by commas
+ */
+ private static String getPropertiesAsString(Signal signal, Collection<String> maskValues) {
+ StringBuffer propertiesString = new StringBuffer();
+ boolean firstProperty = true;
+ for (Property property : signal.getOwnedAttributes()) {
+ // get the label for this property
+ String propertyString = PropertyUtil.getCustomLabel(property, maskValues);
+ if (!propertyString.trim().equals("")) {
+ if (!firstProperty) {
+ propertiesString.append(", ");
+ }
+ propertiesString.append(propertyString);
+ firstProperty = false;
+ }
+ }
+ return propertiesString.toString();
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/TypeUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/TypeUtil.java
index 86714ec6772..fae53a36979 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/TypeUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/TypeUtil.java
@@ -1,71 +1,73 @@
-/*****************************************************************************
- * Copyright (c) 2009 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:
- * Yann TANGUY (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.tools.utils;
-
-import java.util.Iterator;
-
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Namespace;
-import org.eclipse.uml2.uml.Type;
-
-/**
- * Utility class for <code>org.eclipse.uml2.uml.Type</code><BR>
- */
-public class TypeUtil {
-
- public final static String UNDEFINED_TYPE_NAME = "<Undefined>";
-
- /**
- * Get a string that displays the name of the type, and then its namespace.
- * <p>
- * For example: "String - UMLPrimitiveType"
- *
- * @return a string that displays information about the type
- */
- public static String getInfoString(Type type) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(type.getName());
- buffer.append(" - ");
- String tmp = "";
- Iterator<Namespace> it = type.allNamespaces().iterator();
- while (it.hasNext()) {
- Namespace namespace = it.next();
- if (it.hasNext()) {
- tmp = NamedElement.SEPARATOR + namespace.getName() + tmp;
- } else {
- tmp = namespace.getName() + tmp;
- }
- }
- buffer.append(tmp);
- return buffer.toString();
- }
-
- /**
- *
- *
- * @param type
- * to check
- *
- * @return true if type is metaclass, else false
- */
- @Deprecated
- // use {@link Class#isMetaclass()} Check if a type is a metaclass.
- public static boolean isMetaclass(Type type) {
- if (type instanceof Class) {
- return ((Class) type).isMetaclass();
- }
- return false;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Yann TANGUY (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.utils;
+
+import java.util.Iterator;
+
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Namespace;
+import org.eclipse.uml2.uml.Type;
+
+/**
+ * Utility class for <code>org.eclipse.uml2.uml.Type</code><BR>
+ */
+public class TypeUtil {
+
+ public final static String UNDEFINED_TYPE_NAME = "<Undefined>";
+
+ /**
+ * Get a string that displays the name of the type, and then its namespace.
+ * <p>
+ * For example: "String - UMLPrimitiveType"
+ *
+ * @return a string that displays information about the type
+ */
+ public static String getInfoString(Type type) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(UMLLabelInternationalization.getInstance().getLabel(type));
+ buffer.append(" - ");
+ String tmp = "";
+ Iterator<Namespace> it = type.allNamespaces().iterator();
+ while (it.hasNext()) {
+ Namespace namespace = it.next();
+ if (it.hasNext()) {
+ tmp = NamedElement.SEPARATOR + UMLLabelInternationalization.getInstance().getLabel(namespace) + tmp;
+ } else {
+ tmp = UMLLabelInternationalization.getInstance().getLabel(namespace) + tmp;
+ }
+ }
+ buffer.append(tmp);
+ return buffer.toString();
+ }
+
+ /**
+ *
+ *
+ * @param type
+ * to check
+ *
+ * @return true if type is metaclass, else false
+ */
+ @Deprecated
+ // use {@link Class#isMetaclass()} Check if a type is a metaclass.
+ public static boolean isMetaclass(Type type) {
+ if (type instanceof Class) {
+ return ((Class) type).isMetaclass();
+ }
+ return false;
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/TypedElementUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/TypedElementUtil.java
index cf50dfb5aca..ee227ee94a1 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/TypedElementUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/TypedElementUtil.java
@@ -1,26 +1,28 @@
-/*****************************************************************************
- * Copyright (c) 2009 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:
- * Yann TANGUY (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.tools.utils;
-
-import org.eclipse.uml2.uml.TypedElement;
-
-/**
- * Utility class for <code>org.eclipse.uml2.uml.TypedElement</code><BR>
- */
-public class TypedElementUtil {
-
- public static String getTypeAsString(TypedElement element) {
- return (element.getType() != null) ? element.getType().getName() : "<Undefined>";
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Yann TANGUY (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.tools.utils;
+
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.TypedElement;
+
+/**
+ * Utility class for <code>org.eclipse.uml2.uml.TypedElement</code><BR>
+ */
+public class TypedElementUtil {
+
+ public static String getTypeAsString(TypedElement element) {
+ return (element.getType() != null) ? UMLLabelInternationalization.getInstance().getLabel(element.getType()) : "<Undefined>";
+ }
+}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ValueSpecificationUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ValueSpecificationUtil.java
index 533941c1f97..ac4857301c8 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ValueSpecificationUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ValueSpecificationUtil.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Remi SCHNEKENBURGER (CEA LIST) Remi.schnekenburger@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
*
*****************************************************************************/
@@ -16,6 +17,7 @@ package org.eclipse.papyrus.uml.tools.utils;
import java.util.Collection;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
import org.eclipse.uml2.uml.Constraint;
import org.eclipse.uml2.uml.Duration;
import org.eclipse.uml2.uml.Expression;
@@ -49,6 +51,16 @@ public class ValueSpecificationUtil {
* @param specification
*/
public static String getSpecificationValue(ValueSpecification specification) {
+ return getSpecificationValue(specification, false);
+ }
+
+ /**
+ * Get a string representing of a ValueSpecification
+ *
+ * @param specification The Value specification.
+ * @param useInternationalization Boolean to determinate if the internationalization must be used for the string representation.
+ */
+ public static String getSpecificationValue(final ValueSpecification specification, final boolean useInternationalization) {
String value = ""; //$NON-NLS-1$
if (specification != null && specification.eClass() != null) {
switch (specification.eClass().getClassifierID()) {
@@ -75,7 +87,11 @@ public class ValueSpecificationUtil {
break;
case UMLPackage.INSTANCE_VALUE:
if (((InstanceValue) specification).getInstance() != null) {
- value = ((InstanceValue) specification).getInstance().getName();
+ if(useInternationalization){
+ value = UMLLabelInternationalization.getInstance().getLabel(((InstanceValue) specification).getInstance());
+ }else{
+ value = ((InstanceValue) specification).getInstance().getName();
+ }
}
break;
case UMLPackage.EXPRESSION:
@@ -104,7 +120,11 @@ public class ValueSpecificationUtil {
if (durationExpr.getExpr() != null) {
value = getSpecificationValue(durationExpr.getExpr());
} else if (durationExpr.getObservations().size() > 0) {
- value = durationExpr.getObservations().get(0).getName();
+ if(useInternationalization){
+ value = UMLLabelInternationalization.getInstance().getLabel(durationExpr.getObservations().get(0));
+ }else{
+ value = durationExpr.getObservations().get(0).getName();
+ }
}
break;
case UMLPackage.TIME_EXPRESSION:
@@ -112,7 +132,11 @@ public class ValueSpecificationUtil {
if (timeExpr.getExpr() != null) {
value = getSpecificationValue(timeExpr.getExpr());
} else if (timeExpr.getObservations().size() > 0) {
- value = timeExpr.getObservations().get(0).getName();
+ if(useInternationalization){
+ value = UMLLabelInternationalization.getInstance().getLabel(timeExpr.getObservations().get(0));
+ }else{
+ value = timeExpr.getObservations().get(0).getName();
+ }
}
break;
case UMLPackage.INTERVAL:
@@ -148,7 +172,7 @@ public class ValueSpecificationUtil {
if (specification != null) {
ValueSpecification spe = specification.getSpecification();
if (spe != null) {
- value = getSpecificationValue(spe);
+ value = getSpecificationValue(spe, true);
}
}
return value;

Back to the top