Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-11-24 12:49:41 +0000
committervincent lorenzo2016-11-29 11:01:26 +0000
commit3ed639ecef256da3eeff86d3b428720561f362df (patch)
treeea5d0d552c2e0b62cd9ee3cafd907ee69c0ad2e8 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src
parentb3141df23ca644573f8b2813ad8859722d418bd9 (diff)
downloadorg.eclipse.papyrus-3ed639ecef256da3eeff86d3b428720561f362df.tar.gz
org.eclipse.papyrus-3ed639ecef256da3eeff86d3b428720561f362df.tar.xz
org.eclipse.papyrus-3ed639ecef256da3eeff86d3b428720561f362df.zip
Bug 496905: [Diagram][ModelExplorer][Table][Dialog] Papyrus must integrate
the internationalization feature provided by UML. https://bugs.eclipse.org/bugs/show_bug.cgi?id=496905 Commit of UML for internationalization. Change-Id: Ia61e5ef4d537f9e9b192bcfe073f921542fe4876 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/UmlCompositeDiagramForMultiEditor.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/PropertyPartFromTypeCreateCommand.java25
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/InformationFlowCustomLabelEditPolicy.java6
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/ConnectorLabelParser.java194
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/NamedElementLabelParser.java304
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/RoleBindingRoleNameParser.java6
6 files changed, 288 insertions, 251 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/UmlCompositeDiagramForMultiEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/UmlCompositeDiagramForMultiEditor.java
index 9e57d166a9d..e1b374deafb 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/UmlCompositeDiagramForMultiEditor.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/UmlCompositeDiagramForMultiEditor.java
@@ -10,6 +10,7 @@
* Contributors:
* Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 392301
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
*
*****************************************************************************/
@@ -24,6 +25,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.papyrus.infra.core.editor.BackboneException;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization;
import org.eclipse.papyrus.uml.diagram.composite.part.UMLDiagramEditor;
import org.eclipse.papyrus.uml.diagram.composite.part.UMLDiagramEditorPlugin;
import org.eclipse.swt.graphics.Image;
@@ -78,7 +80,7 @@ public class UmlCompositeDiagramForMultiEditor extends UMLDiagramEditor {
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
super.init(site, input);
- setPartName(getDiagram().getName());
+ setPartName(LabelInternationalization.getInstance().getDiagramLabel(getDiagram()));
titleImage = DIAG_IMG_DESC.createImage();
setTitleImage(titleImage);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/PropertyPartFromTypeCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/PropertyPartFromTypeCreateCommand.java
index eac6ac42901..f3ec4ac4b93 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/PropertyPartFromTypeCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/PropertyPartFromTypeCreateCommand.java
@@ -8,7 +8,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * 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.diagram.composite.custom.edit.command;
@@ -21,7 +22,9 @@ import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.adapter.SemanticAdapter;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.StructuredClassifier;
import org.eclipse.uml2.uml.Type;
@@ -73,21 +76,37 @@ public class PropertyPartFromTypeCreateCommand extends EditElementCommand {
StructuredClassifier owner = (StructuredClassifier) getElementToEdit();
owner.getOwnedAttributes().add(newElement);
newElement.setType(type);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ semanticAdapter.setElement(newElement);
String typeName = type.getName();
String elementName = (typeName.length() == 0) ? "none" : //$NON-NLS-1$
typeName.substring(0, 1).toLowerCase() + typeName.substring(1);
+
+ String typeLabel = "";
+ String elementLabel = "";
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(type) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(type)) {
+ typeLabel = UMLLabelInternationalization.getInstance().getLabelWithoutUML(type);
+ elementLabel = (typeLabel.length() == 0) ? "none" : //$NON-NLS-1$
+ typeLabel.substring(0, 1).toLowerCase() + typeLabel.substring(1);
+ }
+
int i = 0;
String initialElementName = elementName;
+ String initialElementLabel = elementLabel;
// assure that name is unique.
while (owner.getAttribute(elementName, null) != null) {
elementName = initialElementName + String.valueOf(i);
+ if(!elementLabel.isEmpty()){
+ elementLabel = initialElementLabel + String.valueOf(i);
+ }
i++;
}
newElement.setName(elementName);
- ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ if(!elementName.isEmpty()){
+ UMLLabelInternationalization.getInstance().setLabel(newElement, elementName, null);
+ }
- semanticAdapter.setElement(newElement);
return CommandResult.newOKCommandResult(semanticAdapter);
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/InformationFlowCustomLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/InformationFlowCustomLabelEditPolicy.java
index daa5986fe91..74ec96c07e7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/InformationFlowCustomLabelEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/InformationFlowCustomLabelEditPolicy.java
@@ -8,7 +8,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
*
*****************************************************************************/
@@ -18,6 +19,7 @@ import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.InformationFlowConveyedLabelEditPart;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.InformationFlow;
@@ -134,7 +136,7 @@ public class InformationFlowCustomLabelEditPolicy extends AbstractCustomLabelEdi
if (getUMLElement() instanceof InformationFlow) {
EList<Classifier> classes = ((InformationFlow) getUMLElement()).getConveyeds();
for (int i = 0; i < classes.size(); i++) {
- name += classes.get(i).getName();
+ name += UMLLabelInternationalization.getInstance().getLabel(classes.get(i));
if (i != classes.size() - 1) {
name += ", ";
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/ConnectorLabelParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/ConnectorLabelParser.java
index e2632e3c771..216fa87a8a8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/ConnectorLabelParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/ConnectorLabelParser.java
@@ -1,96 +1,98 @@
-/*****************************************************************************
- * Copyright (c) 2009-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:
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.composite.custom.parsers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.uml2.uml.Connector;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * Semantic Parser for {@link Connector} label
- */
-public class ConnectorLabelParser extends NamedElementLabelParser {
-
- /** The String format for displaying a {@link Connector} label with its type (Association) */
- protected static final String TYPE_FORMAT = "%s: %s";
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- String result = "";
- EObject eObject = EMFHelper.getEObject(element);
-
- if ((eObject != null) && (eObject instanceof Connector)) {
-
- Connector connector = (Connector) eObject;
-
- // manage name
- if (connector.isSetName()) {
- result = connector.getName();
- }
-
- // manage type
- String type = "";
- if ((connector.getType() != null) && (connector.getType().isSetName())) {
- type = connector.getType().getName();
- result = String.format(TYPE_FORMAT, result, type);
- }
-
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
-
- if (event instanceof Notification) {
- Object feature = ((Notification) event).getFeature();
- if (feature instanceof EStructuralFeature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getConnector_Type().equals(feature);
- }
- }
-
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<EObject> getSemanticElementsBeingParsed(EObject element) {
- List<EObject> semanticElementsBeingParsed = new ArrayList<EObject>();
-
- if ((element != null) && (element instanceof Connector)) {
- Connector semElement = (Connector) element;
-
- semanticElementsBeingParsed.add(semElement);
- if (semElement.getType() != null) {
- semanticElementsBeingParsed.add(semElement.getType());
- }
- }
- return semanticElementsBeingParsed;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009-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:
+ * 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.diagram.composite.custom.parsers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.Connector;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Semantic Parser for {@link Connector} label
+ */
+public class ConnectorLabelParser extends NamedElementLabelParser {
+
+ /** The String format for displaying a {@link Connector} label with its type (Association) */
+ protected static final String TYPE_FORMAT = "%s: %s";
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ String result = "";
+ EObject eObject = EMFHelper.getEObject(element);
+
+ if ((eObject != null) && (eObject instanceof Connector)) {
+
+ Connector connector = (Connector) eObject;
+
+ // manage name
+ if (connector.isSetName()) {
+ result = UMLLabelInternationalization.getInstance().getLabel(connector);
+ }
+
+ // manage type
+ String type = "";
+ if ((connector.getType() != null) && (connector.getType().isSetName())) {
+ type = UMLLabelInternationalization.getInstance().getLabel(connector.getType());
+ result = String.format(TYPE_FORMAT, result, type);
+ }
+
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+
+ if (event instanceof Notification) {
+ Object feature = ((Notification) event).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getConnector_Type().equals(feature);
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<EObject> getSemanticElementsBeingParsed(EObject element) {
+ List<EObject> semanticElementsBeingParsed = new ArrayList<EObject>();
+
+ if ((element != null) && (element instanceof Connector)) {
+ Connector semElement = (Connector) element;
+
+ semanticElementsBeingParsed.add(semElement);
+ if (semElement.getType() != null) {
+ semanticElementsBeingParsed.add(semElement.getType());
+ }
+ }
+ return semanticElementsBeingParsed;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/NamedElementLabelParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/NamedElementLabelParser.java
index 90401f8312c..bfc9de47a96 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/NamedElementLabelParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/NamedElementLabelParser.java
@@ -1,147 +1,157 @@
-/*****************************************************************************
- * Copyright (c) 2009-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:
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.composite.custom.parsers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
-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.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
-import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * Semantic Parser for {@link NamedElement} name.
- */
-public class NamedElementLabelParser implements ISemanticParser {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getEditString(IAdaptable element, int flags) {
- String editString = "";
-
- EObject eObject = EMFHelper.getEObject(element);
- if ((eObject != null) && (eObject instanceof NamedElement)) {
- NamedElement semElement = (NamedElement) eObject;
- if (semElement.isSetName()) {
- editString = semElement.getName();
- }
- }
- return editString;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IParserEditStatus isValidEditString(IAdaptable element, String editString) {
- return ParserEditStatus.EDITABLE_STATUS;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ICommand getParseCommand(IAdaptable element, String newString, int flags) {
-
- ICommand command = UnexecutableCommand.INSTANCE;
-
- EObject objectToEdit = EMFHelper.getEObject(element);
- if (objectToEdit == null) {
- return UnexecutableCommand.INSTANCE;
- }
-
- try {
- command = ElementEditServiceUtils.getEditServiceProvider().getEditService(objectToEdit).getEditCommand(new SetRequest(objectToEdit, UMLPackage.eINSTANCE.getNamedElement_Name(), newString));
- } catch (ServiceException e) {
- Activator.log.error(e);
- }
-
- return command;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- String result = "";
- EObject eObject = EMFHelper.getEObject(element);
-
- if (eObject instanceof NamedElement) {
- return ((NamedElement) eObject).getName();
- }
-
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
-
- if (event instanceof Notification) {
- Object feature = ((Notification) event).getFeature();
- if (feature instanceof EStructuralFeature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature);
- }
- }
-
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<EObject> getSemanticElementsBeingParsed(EObject element) {
- List<EObject> semanticElementsBeingParsed = new ArrayList<EObject>();
- semanticElementsBeingParsed.add(element);
-
- return semanticElementsBeingParsed;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- return true;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2009-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:
+ * 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.diagram.composite.custom.parsers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
+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.emf.ui.services.parser.ISemanticParser;
+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.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;
+
+/**
+ * Semantic Parser for {@link NamedElement} name.
+ */
+public class NamedElementLabelParser implements ISemanticParser {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getEditString(IAdaptable element, int flags) {
+ String editString = "";
+
+ EObject eObject = EMFHelper.getEObject(element);
+ if ((eObject != null) && (eObject instanceof NamedElement)) {
+ NamedElement semElement = (NamedElement) eObject;
+ if (semElement.isSetName()) {
+ editString = UMLLabelInternationalization.getInstance().getLabel(semElement);
+ }
+ }
+ return editString;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IParserEditStatus isValidEditString(IAdaptable element, String editString) {
+ return ParserEditStatus.EDITABLE_STATUS;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ICommand getParseCommand(IAdaptable element, String newString, int flags) {
+
+ ICommand command = UnexecutableCommand.INSTANCE;
+
+ EObject objectToEdit = EMFHelper.getEObject(element);
+ if (objectToEdit == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ try {
+ 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);
+ }
+
+ return command;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ String result = "";
+ EObject eObject = EMFHelper.getEObject(element);
+
+ if (eObject instanceof NamedElement) {
+ return UMLLabelInternationalization.getInstance().getLabel((NamedElement) eObject);
+ }
+
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+
+ if (event instanceof Notification) {
+ Object feature = ((Notification) event).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature);
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<EObject> getSemanticElementsBeingParsed(EObject element) {
+ List<EObject> semanticElementsBeingParsed = new ArrayList<EObject>();
+ semanticElementsBeingParsed.add(element);
+
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ return true;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/RoleBindingRoleNameParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/RoleBindingRoleNameParser.java
index 8f8e13f8ba5..c61cace6799 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/RoleBindingRoleNameParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/parsers/RoleBindingRoleNameParser.java
@@ -8,7 +8,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * 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.diagram.composite.custom.parsers;
@@ -26,6 +27,7 @@ import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
import org.eclipse.uml2.uml.ConnectableElement;
import org.eclipse.uml2.uml.Dependency;
import org.eclipse.uml2.uml.NamedElement;
@@ -122,7 +124,7 @@ public class RoleBindingRoleNameParser implements ISemanticParser {
if (!binding.getClients().isEmpty()) {
NamedElement role = binding.getClients().get(0);
- return role.getName();
+ return UMLLabelInternationalization.getInstance().getLabel(role);
} // else
return ""; //$NON-NLS-1$
}

Back to the top