diff options
Diffstat (limited to 'plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common')
13 files changed, 218 insertions, 189 deletions
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/META-INF/MANIFEST.MF b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/META-INF/MANIFEST.MF index 1783a3e4258..20ca98c4fc9 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/META-INF/MANIFEST.MF +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/META-INF/MANIFEST.MF @@ -33,7 +33,9 @@ Require-Bundle: org.eclipse.emf;bundle-version="[2.6.0,3.0.0)", org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="[1.2.0,2.0.0)";visibility:=reexport, org.eclipse.papyrus.uml.modelexplorer.widgets;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.uml.diagram.composite;bundle-version="[3.0.0,4.0.0)";visibility:=reexport, - org.eclipse.papyrus.uml.diagram.clazz;bundle-version="[3.0.0,4.0.0)" + org.eclipse.papyrus.uml.diagram.clazz;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.uml.internationalization.edit;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.uml.internationalization.utils;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-Version: 2.0.0.qualifier diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/parser/FlowPortLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/parser/FlowPortLabelParser.java index 4fef645ef06..f332eb80329 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/parser/FlowPortLabelParser.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/parser/FlowPortLabelParser.java @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * - * CEA LIST - Initial API and implementation + * CEA LIST - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.sysml.diagram.common.parser; @@ -32,6 +32,7 @@ import org.eclipse.papyrus.sysml.portandflows.FlowPort; import org.eclipse.papyrus.sysml.portandflows.FlowSpecification; import org.eclipse.papyrus.sysml.portandflows.PortandflowsPackage; import org.eclipse.papyrus.uml.diagram.common.parser.PropertyLabelParser; +import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil; import org.eclipse.uml2.uml.InstanceValue; @@ -129,7 +130,7 @@ public class FlowPortLabelParser extends PropertyLabelParser { // manage name if ((maskValues.contains(ICustomAppearance.DISP_NAME)) && (property.isSetName())) { - String name = property.getName(); + String name = UMLLabelInternationalization.getInstance().getLabel(property); result = String.format(NAME_FORMAT, result, name); } @@ -138,7 +139,7 @@ public class FlowPortLabelParser extends PropertyLabelParser { String type = "<Undefined>"; if (property.getType() != null) { - type = property.getType().getName(); + type = UMLLabelInternationalization.getInstance().getLabel(property.getType()); } // If type is undefined only show "<Undefined>" when explicitly asked. @@ -164,7 +165,7 @@ public class FlowPortLabelParser extends PropertyLabelParser { if ((maskValues.contains(ICustomAppearance.DISP_DEFAULT_VALUE)) && ((property.getDefaultValue() != null))) { ValueSpecification valueSpecification = property.getDefaultValue(); if (valueSpecification instanceof InstanceValue) { - result = String.format(DEFAULT_VALUE_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(valueSpecification)); + result = String.format(DEFAULT_VALUE_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(valueSpecification, true)); } } @@ -186,7 +187,7 @@ public class FlowPortLabelParser extends PropertyLabelParser { EList<Property> redefinedProperties = property.getRedefinedProperties(); if (redefinedProperties != null && !redefinedProperties.isEmpty()) { for (Property p : redefinedProperties) { - sb.append(sb.length() == 0 ? p.getName() : ", redefines " + p.getName()); + sb.append(sb.length() == 0 ? UMLLabelInternationalization.getInstance().getLabel(p) : ", redefines " + UMLLabelInternationalization.getInstance().getLabel(p)); } } if (sb.length() != 0) { diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/parser/RequirementLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/parser/RequirementLabelParser.java index 548984a5c1f..c7984cb850b 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/parser/RequirementLabelParser.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/parser/RequirementLabelParser.java @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * - * CEA LIST - Initial API and implementation + * CEA LIST - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.sysml.diagram.common.parser; @@ -26,6 +26,7 @@ import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; import org.eclipse.papyrus.sysml.requirements.Requirement; import org.eclipse.papyrus.uml.diagram.common.parser.NamedElementLabelParser; +import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; import org.eclipse.uml2.uml.Class; import org.eclipse.uml2.uml.util.UMLUtil; @@ -63,7 +64,7 @@ public class RequirementLabelParser extends NamedElementLabelParser { // manage name if (maskValues.contains(ICustomAppearance.DISP_NAME)) { - String name = clazz.getName(); + String name = UMLLabelInternationalization.getInstance().getLabel(clazz); result = String.format(NAME_FORMAT, name); } diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/parser/UnitLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/parser/UnitLabelParser.java index 041a725ad39..10242f87699 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/parser/UnitLabelParser.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-sysml/org/eclipse/papyrus/sysml/diagram/common/parser/UnitLabelParser.java @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * - * CEA LIST - Initial API and implementation + * CEA LIST - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.sysml.diagram.common.parser; @@ -30,6 +30,7 @@ import org.eclipse.papyrus.sysml.blocks.Dimension; import org.eclipse.papyrus.sysml.blocks.Unit; import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; import org.eclipse.papyrus.uml.diagram.common.parser.NamedElementLabelParser; +import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; import org.eclipse.uml2.uml.InstanceSpecification; import org.eclipse.uml2.uml.util.UMLUtil; @@ -68,7 +69,7 @@ public class UnitLabelParser extends NamedElementLabelParser { // manage name if ((maskValues.contains(ICustomAppearance.DISP_NAME)) && (iSpec.isSetName())) { - String name = iSpec.getName(); + String name = UMLLabelInternationalization.getInstance().getLabel(iSpec); result = String.format(NAME_FORMAT, name); } @@ -78,7 +79,7 @@ public class UnitLabelParser extends NamedElementLabelParser { if ((unit != null) && (unit.getDimension() != null)) { Dimension dim = unit.getDimension(); if ((dim.getBase_InstanceSpecification() != null) && (dim.getBase_InstanceSpecification().isSetName())) { - dimensionName = dim.getBase_InstanceSpecification().getName(); + dimensionName = UMLLabelInternationalization.getInstance().getLabel(dim.getBase_InstanceSpecification()); } } result = String.format(DIMENSION_FORMAT, result, dimensionName); diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/AssociationEndLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/AssociationEndLabelParser.java index ac2699f927b..9cb1c33b8fd 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/AssociationEndLabelParser.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/AssociationEndLabelParser.java @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * - * CEA LIST - Initial API and implementation + * CEA LIST - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.common.parser; @@ -24,6 +24,7 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLMultiplicityElementUtil; +import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil; import org.eclipse.uml2.uml.Association; @@ -87,7 +88,7 @@ public class AssociationEndLabelParser extends PropertyLabelParser { // manage name if (maskValues.contains(ICustomAppearance.DISP_NAME) && property.isSetName()) { - String name = property.getName(); + String name = UMLLabelInternationalization.getInstance().getLabel(property); // If property is owned by Association (non navigable) only show the name when explicitly asked. @@ -101,7 +102,7 @@ public class AssociationEndLabelParser extends PropertyLabelParser { if (maskValues.contains(ICustomAppearance.DISP_TYPE)) { String type = "<Undefined>"; if (property.getType() != null) { - type = property.getType().getName(); + type = UMLLabelInternationalization.getInstance().getLabel(property.getType()); } // If type is undefined only show "<Undefined>" when explicitly asked. @@ -124,7 +125,7 @@ public class AssociationEndLabelParser extends PropertyLabelParser { // manage default value if (maskValues.contains(ICustomAppearance.DISP_DEFAULT_VALUE) && property.getDefaultValue() != null) { ValueSpecification valueSpecification = property.getDefaultValue(); - result = String.format(DEFAULT_VALUE_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(valueSpecification)); + result = String.format(DEFAULT_VALUE_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(valueSpecification, true)); } // manage modifier @@ -145,7 +146,7 @@ public class AssociationEndLabelParser extends PropertyLabelParser { EList<Property> redefinedProperties = property.getRedefinedProperties(); if (redefinedProperties != null && !redefinedProperties.isEmpty()) { for (Property p : redefinedProperties) { - sb.append(sb.length() == 0 ? p.getName() : ", redefines " + p.getName()); + sb.append(sb.length() == 0 ? UMLLabelInternationalization.getInstance().getLabel(p) : ", redefines " + UMLLabelInternationalization.getInstance().getLabel(p)); } } if (sb.length() != 0) { diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ConnectorLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ConnectorLabelParser.java index d8b67756741..dba310651f9 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ConnectorLabelParser.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ConnectorLabelParser.java @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * - * CEA LIST - Initial API and implementation + * CEA LIST - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.common.parser; @@ -26,6 +26,7 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; +import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; import org.eclipse.uml2.uml.Connector; import org.eclipse.uml2.uml.UMLPackage; @@ -62,7 +63,7 @@ public class ConnectorLabelParser extends NamedElementLabelParser { // manage name if (maskValues.contains(ICustomAppearance.DISP_NAME) && (connector.isSetName())) { - String name = connector.getName(); + String name = UMLLabelInternationalization.getInstance().getLabel(connector); result = String.format(NAME_FORMAT, name); } @@ -70,7 +71,7 @@ public class ConnectorLabelParser extends NamedElementLabelParser { if (maskValues.contains(ICustomAppearance.DISP_TYPE)) { String type = "<Undefined>"; if (connector.getType() != null) { - type = connector.getType().getName(); + type = UMLLabelInternationalization.getInstance().getLabel(connector.getType()); } // If type is undefined only show "<Undefined>" when explicitly asked. diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ConstraintLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ConstraintLabelParser.java index b6193fd946d..1dbfdd09dd4 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ConstraintLabelParser.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ConstraintLabelParser.java @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * - * CEA LIST - Initial API and implementation + * CEA LIST - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.common.parser; @@ -28,11 +28,15 @@ import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.gmf.runtime.common.core.command.ICommand; import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; +import org.eclipse.papyrus.infra.core.resource.ModelSet; import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; import org.eclipse.papyrus.uml.diagram.common.Activator; +import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil; import org.eclipse.uml2.uml.Constraint; @@ -71,7 +75,7 @@ public class ConstraintLabelParser extends NamedElementLabelParser { // edit name if ((maskValues.contains(ICustomAppearance.DISP_NAME))) { if (semElement.isSetName()) { - editString = semElement.getName(); + editString = UMLLabelInternationalization.getInstance().getLabel(semElement); } // (try to) edit constraint specification @@ -107,7 +111,7 @@ public class ConstraintLabelParser extends NamedElementLabelParser { // manage name if ((maskValues.contains(ICustomAppearance.DISP_NAME)) && (semElement.isSetName())) { - String name = semElement.getName(); + String name = UMLLabelInternationalization.getInstance().getLabel(semElement); result = String.format(NAME_FORMAT, name); } @@ -115,7 +119,7 @@ public class ConstraintLabelParser extends NamedElementLabelParser { if ((maskValues.contains(ILabelPreferenceConstants.DISP_SPECIFICATION))) { String spec = "<Undefined>"; if (semElement.getSpecification() != null) { - spec = ValueSpecificationUtil.getSpecificationValue(semElement.getSpecification()); + spec = ValueSpecificationUtil.getSpecificationValue(semElement.getSpecification(), true); if (spec == null || "".equals(spec)) { spec = "<Undefined>"; } @@ -144,8 +148,13 @@ public class ConstraintLabelParser extends NamedElementLabelParser { // prepare set name request if ((maskValues.contains(ICustomAppearance.DISP_NAME))) { - updateRequest = new SetRequest(constraint, UMLPackage.eINSTANCE.getNamedElement_Name(), newString); - updateRequest.setLabel("Update Constraint Label"); + if(InternationalizationPreferencesUtils.getInternationalizationPreference(constraint) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(constraint)){ + final ModelSet modelSet = (ModelSet)constraint.eResource().getResourceSet(); + command = new EMFtoGMFCommandWrapper(UMLLabelInternationalization.getInstance().getSetLabelCommand(modelSet.getTransactionalEditingDomain(), constraint, newString, null)); + }else{ + updateRequest = new SetRequest(constraint, UMLPackage.eINSTANCE.getNamedElement_Name(), newString); + updateRequest.setLabel("Update Constraint Label"); + } // prepare set specification request } else if ((maskValues.contains(ILabelPreferenceConstants.DISP_SPECIFICATION))) { diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/NamedElementLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/NamedElementLabelParser.java index f35c93eef23..dd5db038963 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/NamedElementLabelParser.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/NamedElementLabelParser.java @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * - * CEA LIST - Initial API and implementation + * CEA LIST - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.common.parser; @@ -31,11 +31,15 @@ import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.papyrus.infra.core.resource.ModelSet; import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.infra.gmfdiag.common.helper.MaskLabelHelper; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; import org.eclipse.papyrus.uml.diagram.common.Activator; +import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; import org.eclipse.uml2.uml.NamedElement; import org.eclipse.uml2.uml.UMLPackage; @@ -55,7 +59,7 @@ public class NamedElementLabelParser implements IMaskManagedSemanticParser { if ((eObject != null) && (eObject instanceof NamedElement)) { NamedElement semElement = (NamedElement) eObject; if (semElement.isSetName()) { - editString = semElement.getName(); + editString = UMLLabelInternationalization.getInstance().getLabel(semElement); } } return editString; @@ -83,7 +87,12 @@ public class NamedElementLabelParser implements IMaskManagedSemanticParser { } try { - command = ElementEditServiceUtils.getEditServiceProvider().getEditService(objectToEdit).getEditCommand(new SetRequest(objectToEdit, UMLPackage.eINSTANCE.getNamedElement_Name(), newString)); + if(InternationalizationPreferencesUtils.getInternationalizationPreference(objectToEdit) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML((NamedElement)objectToEdit)){ + final ModelSet modelSet = (ModelSet)objectToEdit.eResource().getResourceSet(); + command = new EMFtoGMFCommandWrapper(UMLLabelInternationalization.getInstance().getSetLabelCommand(modelSet.getTransactionalEditingDomain(), (NamedElement)objectToEdit, newString, null)); + }else{ + command = ElementEditServiceUtils.getEditServiceProvider().getEditService(objectToEdit).getEditCommand(new SetRequest(objectToEdit, UMLPackage.eINSTANCE.getNamedElement_Name(), newString)); + } } catch (ServiceException e) { Activator.log.error(e); } @@ -100,7 +109,7 @@ public class NamedElementLabelParser implements IMaskManagedSemanticParser { EObject eObject = EMFHelper.getEObject(element); if (eObject instanceof NamedElement) { - return ((NamedElement) eObject).getName(); + return UMLLabelInternationalization.getInstance().getLabel((NamedElement) eObject); } return result; diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/OperationLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/OperationLabelParser.java index 1c8aa32e973..81ef14ccf77 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/OperationLabelParser.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/OperationLabelParser.java @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * - * CEA LIST - Initial API and implementation + * CEA LIST - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.common.parser; @@ -30,6 +30,7 @@ import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.infra.tools.util.StringHelper; import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; import org.eclipse.papyrus.uml.diagram.common.utils.ParameterLabelUtil; +import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; import org.eclipse.uml2.uml.Operation; import org.eclipse.uml2.uml.Parameter; @@ -101,7 +102,7 @@ public class OperationLabelParser extends NamedElementLabelParser { // manage name and parameters if ((maskValues.contains(ICustomAppearance.DISP_NAME)) && (operation.isSetName())) { - String name = operation.getName(); + String name = UMLLabelInternationalization.getInstance().getLabel(operation); StringBuffer params = new StringBuffer(); for (Parameter parameter : operation.getOwnedParameters()) { @@ -118,7 +119,7 @@ public class OperationLabelParser extends NamedElementLabelParser { if ((maskValues.contains(ICustomAppearance.DISP_TYPE))) { String type = "<Undefined>"; if (operation.getType() != null) { - type = operation.getType().getName(); + type = UMLLabelInternationalization.getInstance().getLabel(operation.getType()); } // If type is undefined only show "<Undefined>" when explicitly asked. diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/PropertyLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/PropertyLabelParser.java index 0fd37969d94..89ea3a8e1d7 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/PropertyLabelParser.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/PropertyLabelParser.java @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * - * CEA LIST - Initial API and implementation + * CEA LIST - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.common.parser; @@ -28,6 +28,7 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLMultiplicityElementUtil; +import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil; import org.eclipse.uml2.uml.Property; @@ -113,7 +114,7 @@ public class PropertyLabelParser extends NamedElementLabelParser { // manage name if (maskValues.contains(ICustomAppearance.DISP_NAME) && (property.isSetName())) { - String name = property.getName(); + String name = UMLLabelInternationalization.getInstance().getLabel(property); result = String.format(NAME_FORMAT, result, name); } @@ -121,7 +122,7 @@ public class PropertyLabelParser extends NamedElementLabelParser { if (maskValues.contains(ICustomAppearance.DISP_TYPE)) { String type = "<Undefined>"; if (property.getType() != null) { - type = property.getType().getName(); + type = UMLLabelInternationalization.getInstance().getLabel(property.getType()); } // If type is undefined only show "<Undefined>" when explicitly asked. @@ -143,7 +144,7 @@ public class PropertyLabelParser extends NamedElementLabelParser { // manage default value if (maskValues.contains(ICustomAppearance.DISP_DEFAULT_VALUE) && property.getDefaultValue() != null) { ValueSpecification valueSpecification = property.getDefaultValue(); - result = String.format(DEFAULT_VALUE_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(valueSpecification)); + result = String.format(DEFAULT_VALUE_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(valueSpecification, true)); } // manage modifier @@ -164,7 +165,7 @@ public class PropertyLabelParser extends NamedElementLabelParser { EList<Property> redefinedProperties = property.getRedefinedProperties(); if (redefinedProperties != null && !redefinedProperties.isEmpty()) { for (Property p : redefinedProperties) { - sb.append(sb.length() == 0 ? p.getName() : ", redefines " + p.getName()); + sb.append(sb.length() == 0 ? UMLLabelInternationalization.getInstance().getLabel(p) : ", redefines " + UMLLabelInternationalization.getInstance().getLabel(p)); } } if (sb.length() != 0) { diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ReceptionLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ReceptionLabelParser.java index 7c7fe85686c..a5fbfaef55c 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ReceptionLabelParser.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ReceptionLabelParser.java @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * - * CEA LIST - Initial API and implementation + * CEA LIST - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.common.parser; @@ -26,6 +26,7 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; +import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; import org.eclipse.uml2.uml.Reception; import org.eclipse.uml2.uml.UMLPackage; @@ -65,7 +66,7 @@ public class ReceptionLabelParser extends NamedElementLabelParser implements IMa // manage name if (maskValues.contains(ICustomAppearance.DISP_NAME) && reception.isSetName()) { - String name = reception.getName(); + String name = UMLLabelInternationalization.getInstance().getLabel(reception); result = String.format(NAME_FORMAT, result, name); } @@ -73,7 +74,7 @@ public class ReceptionLabelParser extends NamedElementLabelParser implements IMa if (maskValues.contains(ILabelPreferenceConstants.DISP_SIGNAL)) { String type = "<Undefined>"; if (reception.getSignal() != null) { - type = reception.getSignal().getName(); + type = UMLLabelInternationalization.getInstance().getLabel(reception.getSignal()); } result = String.format(TYPE_FORMAT, result, type); } diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/utils/ParameterLabelUtil.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/utils/ParameterLabelUtil.java index ca346d9aecf..edb3268fffb 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/utils/ParameterLabelUtil.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/utils/ParameterLabelUtil.java @@ -1,135 +1,136 @@ -/*****************************************************************************
- * Copyright (c) 2011 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:
- *
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.utils;
-
-import java.util.Collection;
-
-import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants;
-import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLMultiplicityElementUtil;
-import org.eclipse.papyrus.uml.diagram.common.parser.IMaskManagedSemanticParser;
-import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance;
-import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil;
-import org.eclipse.uml2.uml.Parameter;
-import org.eclipse.uml2.uml.ParameterDirectionKind;
-import org.eclipse.uml2.uml.ValueSpecification;
-
-
-public class ParameterLabelUtil {
-
- /** The String format for displaying a {@link Parameter} with direction */
- protected static final String DIRECTION_FORMAT = "%s %s";
-
- /** The String format for displaying a {@link Parameter} label with its name */
- protected static final String NAME_FORMAT = "%s%s";
-
- /** The String format for displaying a {@link Parameter} label with its type */
- protected static final String TYPE_FORMAT = "%s: %s";
-
- /** The String format for displaying a {@link Parameter} label with its multiplicity */
- protected static final String MULTIPLICITY_FORMAT = "%s [%s..%s]";
-
- /** The String format for displaying a {@link Parameter} label with its default value */
- protected static final String DEFAULT_VALUE_FORMAT = "%s= %s";
-
- /** The String format for displaying a {@link Parameter} label with its modifiers */
- protected static final String MODIFIER_FORMAT = "%s{%s}";
-
- public static String getPrintString(Parameter parameter, Collection<String> displayValue) {
- if (displayValue.isEmpty()) {
- return IMaskManagedSemanticParser.MaskedLabel;
- }
-
- String result = "";
-
- if (parameter != null) {
-
- // manage direction
- if (displayValue.contains(ICustomAppearance.DISP_DIRECTION) || displayValue.contains(ICustomAppearance.DISP_PARAMETER_DIRECTION)) {
- String direction;
- switch (parameter.getDirection().getValue()) {
- case ParameterDirectionKind.IN:
- direction = "in";
- break;
- case ParameterDirectionKind.OUT:
- direction = "out";
- break;
- case ParameterDirectionKind.INOUT:
- direction = "inout";
- break;
- case ParameterDirectionKind.RETURN:
- direction = "return";
- break;
- default:
- direction = "in";
- break;
- }
- result = String.format(DIRECTION_FORMAT, direction, result);
- }
-
- // manage name
- if ((displayValue.contains(ICustomAppearance.DISP_NAME) || displayValue.contains(ICustomAppearance.DISP_PARAMETER_NAME)) && (parameter.isSetName())) {
- String name = parameter.getName();
- result = String.format(NAME_FORMAT, result, name);
- }
-
- // manage type
- if (displayValue.contains(ICustomAppearance.DISP_TYPE) || displayValue.contains(ICustomAppearance.DISP_PARAMETER_TYPE)) {
- String type = "<Undefined>";
- if (parameter.getType() != null) {
- type = parameter.getType().getName();
- }
-
- // If type is undefined only show "<Undefined>" when explicitly asked.
- if (displayValue.contains(ILabelPreferenceConstants.DISP_UNDEFINED_TYPE) || (!"<Undefined>".equals(type))) {
- result = String.format(TYPE_FORMAT, result, type);
- }
- }
-
- // manage multiplicity
- String multiplicity = SysMLMultiplicityElementUtil.formatMultiplicity(parameter, displayValue);
- if (multiplicity != null && !multiplicity.isEmpty()) {
- result += " " + multiplicity;
- }
-
- // manage default value
- if ((displayValue.contains(ICustomAppearance.DISP_PARAMETER_DEFAULT) || displayValue.contains(ICustomAppearance.DISP_DEFAULT_VALUE)) && ((parameter.getDefaultValue() != null))) {
- ValueSpecification valueSpecification = parameter.getDefaultValue();
- result = String.format(DEFAULT_VALUE_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(valueSpecification));
- }
-
- // manage modifier
- if (displayValue.contains(ICustomAppearance.DISP_PARAMETER_MODIFIERS) || displayValue.contains(ICustomAppearance.DISP_MODIFIERS)) {
- StringBuffer sb = new StringBuffer();
- if (parameter.isOrdered()) {
- sb.append(sb.length() == 0 ? "ordered" : ", ordered");
- }
- if (parameter.isUnique()) {
- sb.append(sb.length() == 0 ? "unique" : ", unique");
- }
- if (parameter.isStream()) {
- sb.append(sb.length() == 0 ? "stream" : ", stream");
- }
- if (parameter.isException()) {
- sb.append(sb.length() == 0 ? "exception" : ", exception");
- }
- if (sb.length() != 0) {
- result = String.format(MODIFIER_FORMAT, result, sb.toString());
- }
- }
-
- }
- return result;
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2011 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: + * CEA LIST - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.utils; + +import java.util.Collection; + +import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; +import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLMultiplicityElementUtil; +import org.eclipse.papyrus.uml.diagram.common.parser.IMaskManagedSemanticParser; +import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; +import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; +import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil; +import org.eclipse.uml2.uml.Parameter; +import org.eclipse.uml2.uml.ParameterDirectionKind; +import org.eclipse.uml2.uml.ValueSpecification; + + +public class ParameterLabelUtil { + + /** The String format for displaying a {@link Parameter} with direction */ + protected static final String DIRECTION_FORMAT = "%s %s"; + + /** The String format for displaying a {@link Parameter} label with its name */ + protected static final String NAME_FORMAT = "%s%s"; + + /** The String format for displaying a {@link Parameter} label with its type */ + protected static final String TYPE_FORMAT = "%s: %s"; + + /** The String format for displaying a {@link Parameter} label with its multiplicity */ + protected static final String MULTIPLICITY_FORMAT = "%s [%s..%s]"; + + /** The String format for displaying a {@link Parameter} label with its default value */ + protected static final String DEFAULT_VALUE_FORMAT = "%s= %s"; + + /** The String format for displaying a {@link Parameter} label with its modifiers */ + protected static final String MODIFIER_FORMAT = "%s{%s}"; + + public static String getPrintString(Parameter parameter, Collection<String> displayValue) { + if (displayValue.isEmpty()) { + return IMaskManagedSemanticParser.MaskedLabel; + } + + String result = ""; + + if (parameter != null) { + + // manage direction + if (displayValue.contains(ICustomAppearance.DISP_DIRECTION) || displayValue.contains(ICustomAppearance.DISP_PARAMETER_DIRECTION)) { + String direction; + switch (parameter.getDirection().getValue()) { + case ParameterDirectionKind.IN: + direction = "in"; + break; + case ParameterDirectionKind.OUT: + direction = "out"; + break; + case ParameterDirectionKind.INOUT: + direction = "inout"; + break; + case ParameterDirectionKind.RETURN: + direction = "return"; + break; + default: + direction = "in"; + break; + } + result = String.format(DIRECTION_FORMAT, direction, result); + } + + // manage name + if ((displayValue.contains(ICustomAppearance.DISP_NAME) || displayValue.contains(ICustomAppearance.DISP_PARAMETER_NAME)) && (parameter.isSetName())) { + String name = UMLLabelInternationalization.getInstance().getLabel(parameter); + result = String.format(NAME_FORMAT, result, name); + } + + // manage type + if (displayValue.contains(ICustomAppearance.DISP_TYPE) || displayValue.contains(ICustomAppearance.DISP_PARAMETER_TYPE)) { + String type = "<Undefined>"; + if (parameter.getType() != null) { + type = UMLLabelInternationalization.getInstance().getLabel(parameter.getType()); + } + + // If type is undefined only show "<Undefined>" when explicitly asked. + if (displayValue.contains(ILabelPreferenceConstants.DISP_UNDEFINED_TYPE) || (!"<Undefined>".equals(type))) { + result = String.format(TYPE_FORMAT, result, type); + } + } + + // manage multiplicity + String multiplicity = SysMLMultiplicityElementUtil.formatMultiplicity(parameter, displayValue); + if (multiplicity != null && !multiplicity.isEmpty()) { + result += " " + multiplicity; + } + + // manage default value + if ((displayValue.contains(ICustomAppearance.DISP_PARAMETER_DEFAULT) || displayValue.contains(ICustomAppearance.DISP_DEFAULT_VALUE)) && ((parameter.getDefaultValue() != null))) { + ValueSpecification valueSpecification = parameter.getDefaultValue(); + result = String.format(DEFAULT_VALUE_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(valueSpecification, true)); + } + + // manage modifier + if (displayValue.contains(ICustomAppearance.DISP_PARAMETER_MODIFIERS) || displayValue.contains(ICustomAppearance.DISP_MODIFIERS)) { + StringBuffer sb = new StringBuffer(); + if (parameter.isOrdered()) { + sb.append(sb.length() == 0 ? "ordered" : ", ordered"); + } + if (parameter.isUnique()) { + sb.append(sb.length() == 0 ? "unique" : ", unique"); + } + if (parameter.isStream()) { + sb.append(sb.length() == 0 ? "stream" : ", stream"); + } + if (parameter.isException()) { + sb.append(sb.length() == 0 ? "exception" : ", exception"); + } + if (sb.length() != 0) { + result = String.format(MODIFIER_FORMAT, result, sb.toString()); + } + } + + } + return result; + } + +} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/Activator.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/Activator.java index 957f7ddf5d5..4437e9f5e9c 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/Activator.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src/org/eclipse/papyrus/sysml/diagram/common/Activator.java @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * - * CEA LIST - Initial API and implementation + * CEA LIST - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.sysml.diagram.common; @@ -33,10 +33,10 @@ import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.papyrus.infra.core.log.LogHelper; import org.eclipse.papyrus.sysml.portandflows.FlowDirection; import org.eclipse.papyrus.sysml.portandflows.FlowPort; +import org.eclipse.papyrus.uml.internationalization.edit.providers.InternationalizationUMLItemProviderAdapterFactory; import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.uml2.uml.edit.providers.UMLItemProviderAdapterFactory; import org.osgi.framework.BundleContext; //import org.eclipse.papyrus.sysml.activities.provider.ActivitiesItemProviderAdapterFactory; //import org.eclipse.papyrus.sysml.allocations.provider.AllocationsItemProviderAdapterFactory; @@ -285,7 +285,7 @@ public class Activator extends AbstractUIPlugin { // factories.add(new PortandflowsItemProviderAdapterFactory()); // factories.add(new RequirementsItemProviderAdapterFactory()); // Add UML adapter - factories.add(new UMLItemProviderAdapterFactory()); + factories.add(new InternationalizationUMLItemProviderAdapterFactory()); // Other adapters factories.add(new EcoreItemProviderAdapterFactory()); |