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.activity/custom-src/org/eclipse/papyrus
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.activity/custom-src/org/eclipse/papyrus')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/UmlActivityDiagramForMultiEditor.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallBehaviorActionPinUpdater.java187
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallOperationActionPinUpdater.java267
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/SendSignalActionPinUpdater.java338
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/handlers/SynchronizePinsParametersHandler.java6
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/helper/PinLabelHelper.java19
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AcceptEventActionParser.java282
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AcceptTimeEventActionParser.java284
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ActivityEdgeWeightParser.java381
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ActivityParameterNodeParser.java350
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AssociatedBehaviorParser.java390
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/CallBehaviorActionParser.java300
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/CallOperationActionParser.java338
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/EdgeGuardParser.java381
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ExceptionHandlerTypeParser.java292
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ObjectNodeParser.java350
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ParameterParser.java300
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PinParser.java344
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PinValueParser.java496
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PostConditionConstraintLabelParser.java302
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PreConditionConstraintLabelParser.java302
21 files changed, 3010 insertions, 2903 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/UmlActivityDiagramForMultiEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/UmlActivityDiagramForMultiEditor.java
index 77447b27327..ea4bf393c1d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/UmlActivityDiagramForMultiEditor.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/UmlActivityDiagramForMultiEditor.java
@@ -10,6 +10,7 @@
* Contributors:
* Atos Origin - Initial API and implementation
* Christian W. Damus (CEA) - bug 392301
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.activity;
@@ -30,6 +31,7 @@ import org.eclipse.jface.util.LocalSelectionTransfer;
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.activity.part.UMLDiagramEditor;
import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin;
import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes;
@@ -85,7 +87,7 @@ public class UmlActivityDiagramForMultiEditor 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.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallBehaviorActionPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallBehaviorActionPinUpdater.java
index 616d142be1c..5d8730951c5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallBehaviorActionPinUpdater.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallBehaviorActionPinUpdater.java
@@ -1,86 +1,101 @@
-/*****************************************************************************
- * Copyright (c) 2016 CEA LIST and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jérémie TATIBOUET (CEA LIST) - Initial API and implementation
- * Sébastien REVOL (CEA LIST) - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.uml2.uml.CallBehaviorAction;
-import org.eclipse.uml2.uml.InputPin;
-import org.eclipse.uml2.uml.OutputPin;
-import org.eclipse.uml2.uml.Parameter;
-import org.eclipse.uml2.uml.ParameterDirectionKind;
-import org.eclipse.uml2.uml.UMLFactory;
-
-public class CallBehaviorActionPinUpdater extends AbstractCallActionPinUpdater<CallBehaviorAction> {
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractCallActionPinUpdater#deriveResults()
- *
- * @return
- */
- @Override
- public List<OutputPin> deriveResults(CallBehaviorAction node) {
- List<OutputPin> derivedOutputPins = new ArrayList<OutputPin>();
- if (node.getBehavior() != null) {
- for (Parameter parameter : node.getBehavior().getOwnedParameters()) {
- if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
- || parameter.getDirection() == ParameterDirectionKind.RETURN_LITERAL
- || parameter.getDirection() == ParameterDirectionKind.OUT_LITERAL) {
- OutputPin derivedPin = UMLFactory.eINSTANCE.createOutputPin();
- derivedPin.setType(parameter.getType());
- derivedPin.setLower(parameter.getLower());
- derivedPin.setUpper(parameter.getUpper());
- if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
- derivedPin.setName("[out] " + parameter.getName());
- } else {
- derivedPin.setName(parameter.getName());
- }
- derivedOutputPins.add(derivedPin);
- }
- }
- }
- return derivedOutputPins;
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#deriveArguments()
- *
- * @return
- */
- @Override
- public List<InputPin> deriveArguments(CallBehaviorAction node) {
- List<InputPin> derivedInputPins = new ArrayList<InputPin>();
- if (node.getBehavior() != null) {
- for (Parameter parameter : node.getBehavior().getOwnedParameters()) {
- if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
- || parameter.getDirection() == ParameterDirectionKind.IN_LITERAL) {
- InputPin derivedPin = UMLFactory.eINSTANCE.createInputPin();
- derivedPin.setType(parameter.getType());
- derivedPin.setLower(parameter.getLower());
- derivedPin.setUpper(parameter.getUpper());
- if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
- derivedPin.setName("[in] " + parameter.getName());
- } else {
- derivedPin.setName(parameter.getName());
- }
- derivedInputPins.add(derivedPin);
- }
- }
- }
- return derivedInputPins;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * J�r�mie TATIBOUET (CEA LIST) - Initial API and implementation
+ * S�bastien REVOL (CEA LIST) - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.CallBehaviorAction;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+import org.eclipse.uml2.uml.UMLFactory;
+
+public class CallBehaviorActionPinUpdater extends AbstractCallActionPinUpdater<CallBehaviorAction> {
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractCallActionPinUpdater#deriveResults()
+ *
+ * @return
+ */
+ @Override
+ public List<OutputPin> deriveResults(CallBehaviorAction node) {
+ List<OutputPin> derivedOutputPins = new ArrayList<OutputPin>();
+ if (node.getBehavior() != null) {
+ for (Parameter parameter : node.getBehavior().getOwnedParameters()) {
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.RETURN_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.OUT_LITERAL) {
+ OutputPin derivedPin = UMLFactory.eINSTANCE.createOutputPin();
+ derivedOutputPins.add(derivedPin);
+ derivedPin.setType(parameter.getType());
+ derivedPin.setLower(parameter.getLower());
+ derivedPin.setUpper(parameter.getUpper());
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
+ derivedPin.setName("[out] " + parameter.getName());
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(parameter) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter)) {
+ UMLLabelInternationalization.getInstance().setLabel(derivedPin, "[out] " + UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter), null);
+ }
+ } else {
+ derivedPin.setName(parameter.getName());
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(parameter) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter)) {
+ UMLLabelInternationalization.getInstance().setLabel(derivedPin, UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter), null);
+ }
+ }
+ }
+ }
+ }
+ return derivedOutputPins;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#deriveArguments()
+ *
+ * @return
+ */
+ @Override
+ public List<InputPin> deriveArguments(CallBehaviorAction node) {
+ List<InputPin> derivedInputPins = new ArrayList<InputPin>();
+ if (node.getBehavior() != null) {
+ for (Parameter parameter : node.getBehavior().getOwnedParameters()) {
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.IN_LITERAL) {
+ InputPin derivedPin = UMLFactory.eINSTANCE.createInputPin();
+ derivedInputPins.add(derivedPin);
+ derivedPin.setType(parameter.getType());
+ derivedPin.setLower(parameter.getLower());
+ derivedPin.setUpper(parameter.getUpper());
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
+ derivedPin.setName("[in] " + parameter.getName());
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(parameter) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter)) {
+ UMLLabelInternationalization.getInstance().setLabel(derivedPin, "[in] " + UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter), null);
+ }
+ } else {
+ derivedPin.setName(parameter.getName());
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(parameter) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter)) {
+ UMLLabelInternationalization.getInstance().setLabel(derivedPin, UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter), null);
+ }
+ }
+ }
+ }
+ }
+ return derivedInputPins;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallOperationActionPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallOperationActionPinUpdater.java
index 740970dd592..29404da2dee 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallOperationActionPinUpdater.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallOperationActionPinUpdater.java
@@ -1,126 +1,141 @@
-/*****************************************************************************
- * Copyright (c) 2016 CEA LIST and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jérémie TATIBOUET (CEA LIST) - Initial API and implementation
- * Sébastien REVOL (CEA LIST) - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.uml2.uml.CallOperationAction;
-import org.eclipse.uml2.uml.InputPin;
-import org.eclipse.uml2.uml.OutputPin;
-import org.eclipse.uml2.uml.Parameter;
-import org.eclipse.uml2.uml.ParameterDirectionKind;
-import org.eclipse.uml2.uml.UMLFactory;
-
-public class CallOperationActionPinUpdater extends AbstractCallActionPinUpdater<CallOperationAction> {
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractCallActionPinUpdater#updatePins(org.eclipse.uml2.uml.CallAction)
- *
- * @param node
- */
- @Override
- public void updatePins(CallOperationAction node) {
- // Update both arguments and results
- super.updatePins(node);
- // Ensure a target is set for this operation call
- InputPin targetPin = this.deriveTarget(node);
- if (node.getTarget() == null) {
- node.setTarget(targetPin);
- } else {
- update(node.getTarget(), targetPin);
- }
- }
-
- /**
- *
- * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#deriveTarget(org.eclipse.uml2.uml.InvocationAction)
- *
- * @param node
- * @return
- */
- @Override
- public InputPin deriveTarget(CallOperationAction node) {
- InputPin pinTarget = UMLFactory.eINSTANCE.createInputPin();
- pinTarget.setLower(1);
- pinTarget.setUpper(1);
- pinTarget.setName(TARGET_NAME);
- if (node.getOperation() != null) {
- pinTarget.setType(node.getOperation().getClass_());
- }
- return pinTarget;
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#deriveArguments(org.eclipse.uml2.uml.InvocationAction)
- *
- * @param node
- * @return
- */
- @Override
- public List<InputPin> deriveArguments(CallOperationAction node) {
- List<InputPin> derivedInputPins = new ArrayList<InputPin>();
- if (node.getOperation() != null) {
- for (Parameter parameter : node.getOperation().getOwnedParameters()) {
- if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
- || parameter.getDirection() == ParameterDirectionKind.IN_LITERAL) {
- InputPin derivedPin = UMLFactory.eINSTANCE.createInputPin();
- derivedPin.setType(parameter.getType());
- derivedPin.setLower(parameter.getLower());
- derivedPin.setUpper(parameter.getUpper());
- if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
- derivedPin.setName("[in] " + parameter.getName());
- } else {
- derivedPin.setName(parameter.getName());
- }
- derivedInputPins.add(derivedPin);
- }
- }
- }
- return derivedInputPins;
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractCallActionPinUpdater#deriveResults(org.eclipse.uml2.uml.CallAction)
- *
- * @param node
- * @return
- */
- @Override
- public List<OutputPin> deriveResults(CallOperationAction node) {
- List<OutputPin> derivedOutputPins = new ArrayList<OutputPin>();
- if (node.getOperation() != null) {
- for (Parameter parameter : node.getOperation().getOwnedParameters()) {
- if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
- || parameter.getDirection() == ParameterDirectionKind.RETURN_LITERAL
- || parameter.getDirection() == ParameterDirectionKind.OUT_LITERAL) {
- OutputPin derivedPin = UMLFactory.eINSTANCE.createOutputPin();
- derivedPin.setType(parameter.getType());
- derivedPin.setLower(parameter.getLower());
- derivedPin.setUpper(parameter.getUpper());
- if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
- derivedPin.setName("[out] " + parameter.getName());
- } else {
- derivedPin.setName(parameter.getName());
- }
- derivedOutputPins.add(derivedPin);
- }
- }
- }
- return derivedOutputPins;
- }
-
-
-}
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * J�r�mie TATIBOUET (CEA LIST) - Initial API and implementation
+ * S�bastien REVOL (CEA LIST) - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.CallOperationAction;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+import org.eclipse.uml2.uml.UMLFactory;
+
+public class CallOperationActionPinUpdater extends AbstractCallActionPinUpdater<CallOperationAction> {
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractCallActionPinUpdater#updatePins(org.eclipse.uml2.uml.CallAction)
+ *
+ * @param node
+ */
+ @Override
+ public void updatePins(CallOperationAction node) {
+ // Update both arguments and results
+ super.updatePins(node);
+ // Ensure a target is set for this operation call
+ InputPin targetPin = this.deriveTarget(node);
+ if (node.getTarget() == null) {
+ node.setTarget(targetPin);
+ } else {
+ update(node.getTarget(), targetPin);
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#deriveTarget(org.eclipse.uml2.uml.InvocationAction)
+ *
+ * @param node
+ * @return
+ */
+ @Override
+ public InputPin deriveTarget(CallOperationAction node) {
+ InputPin pinTarget = UMLFactory.eINSTANCE.createInputPin();
+ pinTarget.setLower(1);
+ pinTarget.setUpper(1);
+ pinTarget.setName(TARGET_NAME);
+ if (node.getOperation() != null) {
+ pinTarget.setType(node.getOperation().getClass_());
+ }
+ return pinTarget;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#deriveArguments(org.eclipse.uml2.uml.InvocationAction)
+ *
+ * @param node
+ * @return
+ */
+ @Override
+ public List<InputPin> deriveArguments(CallOperationAction node) {
+ List<InputPin> derivedInputPins = new ArrayList<InputPin>();
+ if (node.getOperation() != null) {
+ for (Parameter parameter : node.getOperation().getOwnedParameters()) {
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.IN_LITERAL) {
+ InputPin derivedPin = UMLFactory.eINSTANCE.createInputPin();
+ derivedInputPins.add(derivedPin);
+ derivedPin.setType(parameter.getType());
+ derivedPin.setLower(parameter.getLower());
+ derivedPin.setUpper(parameter.getUpper());
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
+ derivedPin.setName("[in] " + parameter.getName());
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(parameter) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter)) {
+ UMLLabelInternationalization.getInstance().setLabel(derivedPin, "[in] " + UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter), null);
+ }
+ } else {
+ derivedPin.setName(parameter.getName());
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(parameter) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter)) {
+ UMLLabelInternationalization.getInstance().setLabel(derivedPin, UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter), null);
+ }
+ }
+ }
+ }
+ }
+ return derivedInputPins;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractCallActionPinUpdater#deriveResults(org.eclipse.uml2.uml.CallAction)
+ *
+ * @param node
+ * @return
+ */
+ @Override
+ public List<OutputPin> deriveResults(CallOperationAction node) {
+ List<OutputPin> derivedOutputPins = new ArrayList<OutputPin>();
+ if (node.getOperation() != null) {
+ for (Parameter parameter : node.getOperation().getOwnedParameters()) {
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.RETURN_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.OUT_LITERAL) {
+ OutputPin derivedPin = UMLFactory.eINSTANCE.createOutputPin();
+ derivedOutputPins.add(derivedPin);
+ derivedPin.setType(parameter.getType());
+ derivedPin.setLower(parameter.getLower());
+ derivedPin.setUpper(parameter.getUpper());
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
+ derivedPin.setName("[out] " + parameter.getName());
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(parameter) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter)) {
+ UMLLabelInternationalization.getInstance().setLabel(derivedPin, "[out] " + UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter), null);
+ }
+ } else {
+ derivedPin.setName(parameter.getName());
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(parameter) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter)) {
+ UMLLabelInternationalization.getInstance().setLabel(derivedPin, UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter), null);
+ }
+ }
+ }
+ }
+ }
+ return derivedOutputPins;
+ }
+
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/SendSignalActionPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/SendSignalActionPinUpdater.java
index 890f4b7933a..2ffb0b58e16 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/SendSignalActionPinUpdater.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/SendSignalActionPinUpdater.java
@@ -1,166 +1,172 @@
-/*****************************************************************************
- * Copyright (c) 2016 CEA LIST and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jérémie TATIBOUET (CEA LIST) - Initial API and implementation
- * Sébastien REVOL (CEA LIST) - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog;
-import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
-import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.InputPin;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Reception;
-import org.eclipse.uml2.uml.SendSignalAction;
-import org.eclipse.uml2.uml.Signal;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.UMLFactory;
-import org.eclipse.uml2.uml.UMLPackage;
-
-public class SendSignalActionPinUpdater extends AbstractInvocationActionPinUpdater<SendSignalAction> {
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#updatePins(org.eclipse.uml2.uml.InvocationAction)
- *
- * @param node
- */
- @Override
- public void updatePins(SendSignalAction node) {
- // Update arguments
- super.updatePins(node);
- // Update target
- InputPin targetPin = this.deriveTarget(node);
- if (node.getTarget() == null) {
- node.setTarget(targetPin);
- } else {
- update(node.getTarget(), targetPin);
- }
- }
-
- private static boolean canReceive(Class clazz, Signal signal) {
- Reception matchingReception = null;
- Iterator<Reception> receptionsIterator = clazz.getOwnedReceptions().iterator();
- while (matchingReception == null && receptionsIterator.hasNext()) {
- Reception currentReception = receptionsIterator.next();
- if (currentReception.getSignal() != null) {
- matchingReception = currentReception.getSignal().conformsTo(signal) ? currentReception : null;
- }
- }
- return matchingReception != null;
- }
-
- /**
- * Derive the type of the target in the context of a SendSignalAction. Three cases are supported:
- *
- * 1] A port is specified to send the signal. In the theory, this port must be owned the class realizing the sending. Hence
- * the type chosen for the target is the class owning the port.
- *
- * 2] The node already has a typed target pin. Make sure this type is still correct. This is evaluated by checking if
- * the type has a reception for chosen signal. If it is the case the type is reused, otherwise the only remaining solution
- * is to propose to the user all classes having a reception on the signal referenced by the action.
- *
- * @param node
- * the send signal action for which the target type is derived
- *
- * @return the derived type or null
- */
- private Type deriveTargetType(SendSignalAction node) {
- Type targetPinType = null;
- if (node.getOnPort() != null) {
- // If a port is specified it is possible to propose a type for the target pin. The type
- // is the type of class owning the port. This proposal might not be always right however it
- // if the signal is sent through a port it reasonable to think that the target used for the
- // send is of the type of the port owner.
- targetPinType = node.getOnPort().getClass_();
- } else {
- if (node.getTarget() != null) {
- Type currentTargetPinType = node.getTarget().getType();
- if (currentTargetPinType instanceof Class && canReceive((Class) currentTargetPinType, node.getSignal())) {
- targetPinType = currentTargetPinType;
- }
- }
- if (targetPinType == null && Display.getCurrent() !=null) {
- // In this case there is no automated derivation possible. Indeed at most we can only propose
- // to the user to choose among a list of type being able to accept the arrival of the signal
- // specified for the given action.
- //
- // Note: This can only be realized if this code is called from UI thread
- InputPin currentTargetPin = node.getTarget();
- if (currentTargetPin == null) {
- node.setTarget(UMLFactory.eINSTANCE.createInputPin());
- }
- UMLContentProvider provider = new UMLContentProvider(node.getTarget(), UMLPackage.eINSTANCE.getTypedElement_Type());
- TreeSelectorDialog dialog = new TreeSelectorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
- dialog.setTitle("Select type");
- dialog.setDescription("Select type for target input pin");
- dialog.setContentProvider(provider);
- dialog.setLabelProvider(new UMLLabelProvider());
- int userResponse = dialog.open();
- if (userResponse == Window.OK) {
- Object[] result = dialog.getResult();
- if (result != null && result.length > 0 && result[0] instanceof Type) {
- targetPinType = (Type) result[0];
- }
- }
- node.setTarget(currentTargetPin);
- }
- }
- return targetPinType;
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#deriveTarget(org.eclipse.uml2.uml.InvocationAction)
- *
- * @param node
- * @return
- */
- @Override
- public InputPin deriveTarget(SendSignalAction node) {
- InputPin targetPin = UMLFactory.eINSTANCE.createInputPin();
- targetPin.setLower(1);
- targetPin.setUpper(1);
- targetPin.setName(TARGET_NAME);
- targetPin.setType(this.deriveTargetType(node));
- return targetPin;
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#deriveArguments(org.eclipse.uml2.uml.InvocationAction)
- *
- * @param node
- * @return
- */
- @Override
- public List<InputPin> deriveArguments(SendSignalAction node) {
- List<InputPin> derivedInputPins = new ArrayList<InputPin>();
- if (node.getSignal() != null) {
- for (Property property : node.getSignal().getAllAttributes()) {
- InputPin derivedPin = UMLFactory.eINSTANCE.createInputPin();
- derivedPin.setLower(property.getLower());
- derivedPin.setUpper(property.getUpper());
- derivedPin.setType(property.getType());
- derivedPin.setName(property.getName());
- derivedInputPins.add(derivedPin);
- }
- }
- return derivedInputPins;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * J�r�mie TATIBOUET (CEA LIST) - Initial API and implementation
+ * S�bastien REVOL (CEA LIST) - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils;
+import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
+import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Reception;
+import org.eclipse.uml2.uml.SendSignalAction;
+import org.eclipse.uml2.uml.Signal;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+public class SendSignalActionPinUpdater extends AbstractInvocationActionPinUpdater<SendSignalAction> {
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#updatePins(org.eclipse.uml2.uml.InvocationAction)
+ *
+ * @param node
+ */
+ @Override
+ public void updatePins(SendSignalAction node) {
+ // Update arguments
+ super.updatePins(node);
+ // Update target
+ InputPin targetPin = this.deriveTarget(node);
+ if (node.getTarget() == null) {
+ node.setTarget(targetPin);
+ } else {
+ update(node.getTarget(), targetPin);
+ }
+ }
+
+ private static boolean canReceive(Class clazz, Signal signal) {
+ Reception matchingReception = null;
+ Iterator<Reception> receptionsIterator = clazz.getOwnedReceptions().iterator();
+ while (matchingReception == null && receptionsIterator.hasNext()) {
+ Reception currentReception = receptionsIterator.next();
+ if (currentReception.getSignal() != null) {
+ matchingReception = currentReception.getSignal().conformsTo(signal) ? currentReception : null;
+ }
+ }
+ return matchingReception != null;
+ }
+
+ /**
+ * Derive the type of the target in the context of a SendSignalAction. Three cases are supported:
+ *
+ * 1] A port is specified to send the signal. In the theory, this port must be owned the class realizing the sending. Hence
+ * the type chosen for the target is the class owning the port.
+ *
+ * 2] The node already has a typed target pin. Make sure this type is still correct. This is evaluated by checking if
+ * the type has a reception for chosen signal. If it is the case the type is reused, otherwise the only remaining solution
+ * is to propose to the user all classes having a reception on the signal referenced by the action.
+ *
+ * @param node
+ * the send signal action for which the target type is derived
+ *
+ * @return the derived type or null
+ */
+ private Type deriveTargetType(SendSignalAction node) {
+ Type targetPinType = null;
+ if (node.getOnPort() != null) {
+ // If a port is specified it is possible to propose a type for the target pin. The type
+ // is the type of class owning the port. This proposal might not be always right however it
+ // if the signal is sent through a port it reasonable to think that the target used for the
+ // send is of the type of the port owner.
+ targetPinType = node.getOnPort().getClass_();
+ } else {
+ if (node.getTarget() != null) {
+ Type currentTargetPinType = node.getTarget().getType();
+ if (currentTargetPinType instanceof Class && canReceive((Class) currentTargetPinType, node.getSignal())) {
+ targetPinType = currentTargetPinType;
+ }
+ }
+ if (targetPinType == null && Display.getCurrent() !=null) {
+ // In this case there is no automated derivation possible. Indeed at most we can only propose
+ // to the user to choose among a list of type being able to accept the arrival of the signal
+ // specified for the given action.
+ //
+ // Note: This can only be realized if this code is called from UI thread
+ InputPin currentTargetPin = node.getTarget();
+ if (currentTargetPin == null) {
+ node.setTarget(UMLFactory.eINSTANCE.createInputPin());
+ }
+ UMLContentProvider provider = new UMLContentProvider(node.getTarget(), UMLPackage.eINSTANCE.getTypedElement_Type());
+ TreeSelectorDialog dialog = new TreeSelectorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
+ dialog.setTitle("Select type");
+ dialog.setDescription("Select type for target input pin");
+ dialog.setContentProvider(provider);
+ dialog.setLabelProvider(new UMLLabelProvider());
+ int userResponse = dialog.open();
+ if (userResponse == Window.OK) {
+ Object[] result = dialog.getResult();
+ if (result != null && result.length > 0 && result[0] instanceof Type) {
+ targetPinType = (Type) result[0];
+ }
+ }
+ node.setTarget(currentTargetPin);
+ }
+ }
+ return targetPinType;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#deriveTarget(org.eclipse.uml2.uml.InvocationAction)
+ *
+ * @param node
+ * @return
+ */
+ @Override
+ public InputPin deriveTarget(SendSignalAction node) {
+ InputPin targetPin = UMLFactory.eINSTANCE.createInputPin();
+ targetPin.setLower(1);
+ targetPin.setUpper(1);
+ targetPin.setName(TARGET_NAME);
+ targetPin.setType(this.deriveTargetType(node));
+ return targetPin;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#deriveArguments(org.eclipse.uml2.uml.InvocationAction)
+ *
+ * @param node
+ * @return
+ */
+ @Override
+ public List<InputPin> deriveArguments(SendSignalAction node) {
+ List<InputPin> derivedInputPins = new ArrayList<InputPin>();
+ if (node.getSignal() != null) {
+ for (Property property : node.getSignal().getAllAttributes()) {
+ InputPin derivedPin = UMLFactory.eINSTANCE.createInputPin();
+ derivedInputPins.add(derivedPin);
+ derivedPin.setLower(property.getLower());
+ derivedPin.setUpper(property.getUpper());
+ derivedPin.setType(property.getType());
+ derivedPin.setName(property.getName());
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(property) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(property)) {
+ UMLLabelInternationalization.getInstance().setLabel(derivedPin, UMLLabelInternationalization.getInstance().getLabelWithoutUML(property), null);
+ }
+ }
+ }
+ return derivedInputPins;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/handlers/SynchronizePinsParametersHandler.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/handlers/SynchronizePinsParametersHandler.java
index 832cc9fc19b..768440c420f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/handlers/SynchronizePinsParametersHandler.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/handlers/SynchronizePinsParametersHandler.java
@@ -11,6 +11,7 @@
* Arthur Daussy (Atos) - Initial API and implementation
* Arthur Daussy - 371712 : [Activitydiagram] Papyrus should provide a way to manually resynchronize pins and parameters on Call Actions
* Olivier Mélois (Atos) : olivier.melois@atos.net - 371712
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.activity.handlers;
@@ -65,6 +66,7 @@ import org.eclipse.papyrus.uml.diagram.activity.helper.IPinToParameterLinkComman
import org.eclipse.papyrus.uml.diagram.activity.helper.PinAndParameterSynchronizer;
import org.eclipse.papyrus.uml.diagram.activity.helper.datastructure.LinkPinToParameter;
import org.eclipse.papyrus.uml.diagram.activity.providers.UMLMarkerNavigationProvider;
+import org.eclipse.papyrus.uml.internationalization.edit.providers.InternationalizationUMLItemProviderAdapterFactory;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
@@ -378,7 +380,7 @@ public class SynchronizePinsParametersHandler extends AbstractSynchronizePinsAnd
for (ActivityEdge activityEdge : dialog.getEgdesToDelete()) {
// Create a marker for all deleted edges
if (!newHashSet.isEmpty()) {
- UMLItemProviderAdapterFactory umlAdapterFactory = new UMLItemProviderAdapterFactory();
+ InternationalizationUMLItemProviderAdapterFactory umlAdapterFactory = new InternationalizationUMLItemProviderAdapterFactory();
IItemLabelProvider edgeLabelProvider = (IItemLabelProvider) umlAdapterFactory.adapt(activityEdge, IItemLabelProvider.class);
IItemLabelProvider callActionLabelProvider = (IItemLabelProvider) umlAdapterFactory.adapt(invocationAction, IItemLabelProvider.class);
UMLMarkerNavigationProvider.addMarker(target, activityEdge.eResource().getURIFragment(activityEdge), EMFCoreUtil.getQualifiedName(invocationAction, true), "The edge " + edgeLabelProvider.getText(activityEdge)
@@ -635,7 +637,7 @@ public class SynchronizePinsParametersHandler extends AbstractSynchronizePinsAnd
}
private String getEdgeListString() {
- UMLItemProviderAdapterFactory t = new UMLItemProviderAdapterFactory();
+ InternationalizationUMLItemProviderAdapterFactory t = new InternationalizationUMLItemProviderAdapterFactory();
IItemLabelProvider provider = (IItemLabelProvider) t.adapt(callAction, IItemLabelProvider.class);
StringBuilder builder = new StringBuilder("If you synchronize " + provider.getText(callAction) + " the following edges will be deleted : \n ");//$NON-NLS-1$ //$NON-NLS-2$
for (ActivityEdge e : egdes) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/helper/PinLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/helper/PinLabelHelper.java
index 3067cc6e2c1..04625899f3d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/helper/PinLabelHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/helper/PinLabelHelper.java
@@ -1,3 +1,16 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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.activity.helper;
import java.util.Collection;
@@ -10,6 +23,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEd
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.Messages;
import org.eclipse.papyrus.uml.diagram.common.helper.StereotypedElementLabelHelper;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance;
import org.eclipse.papyrus.uml.tools.utils.TypeUtil;
import org.eclipse.uml2.uml.Element;
@@ -65,12 +79,13 @@ public class PinLabelHelper extends StereotypedElementLabelHelper {
StringBuffer buffer = new StringBuffer();
if (maskValues.contains(ICustomAppearance.DISP_NAME)) {
buffer.append(" ");
- buffer.append(namedElement.getName()== null ? "" : namedElement.getName());
+ String name = UMLLabelInternationalization.getInstance().getLabel(namedElement);
+ buffer.append(null == name ? "" : name);
}
if (namedElement instanceof TypedElement) {
if (maskValues.contains(ICustomAppearance.DISP_TYPE)) {
if (((TypedElement) namedElement).getType() != null) {
- buffer.append(": " + ((TypedElement) namedElement).getType().getName());
+ buffer.append(": " + UMLLabelInternationalization.getInstance().getLabel(((TypedElement) namedElement).getType()));
} else {
buffer.append(": " + TypeUtil.UNDEFINED_TYPE_NAME);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AcceptEventActionParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AcceptEventActionParser.java
index 9a19b2cfbbb..54e73b7ad69 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AcceptEventActionParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AcceptEventActionParser.java
@@ -1,140 +1,142 @@
-/*****************************************************************************
- * Copyright (c) 2010 Atos Origin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-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.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
-import org.eclipse.uml2.uml.AcceptEventAction;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Trigger;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * A specific parser for displaying the label of an AcceptEventAction (not in
- * AcceptTimeEventAction mode). This parser refreshes the text displayed for the
- * Action.
- */
-public class AcceptEventActionParser extends MessageFormatParser implements ISemanticParser {
-
- public AcceptEventActionParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- public AcceptEventActionParser(EAttribute[] features) {
- super(features);
- }
-
- public AcceptEventActionParser() {
- super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if (notification instanceof Notification) {
- Object feature = ((Notification) notification).getFeature();
- if (feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature) feature;
- }
- }
- return featureImpl;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
- * (java.lang.Object , int)
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
- * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- Object obj = element.getAdapter(EObject.class);
- if (obj instanceof AcceptEventAction) {
- AcceptEventAction action = (AcceptEventAction) obj;
- String name = action.getName();
- if (name != null) {// && !CustomAcceptEventActionEditHelper.isAcceptTimeEventAction(action)) {
- return name;
- }
- }
- return "";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
- * java.lang.Object)
- */
- @Override
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
- */
- @Override
- public List<?> getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if (element instanceof AcceptEventAction) {
- AcceptEventAction action = (AcceptEventAction) element;
- semanticElementsBeingParsed.add(action);
- if (action.getTriggers() != null) {
- for (Trigger trigger : action.getTriggers()) {
- if (trigger != null) {
- semanticElementsBeingParsed.add(trigger);
- }
- }
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this
- * parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getAcceptEventAction_Trigger().equals(feature) || UMLPackage.eINSTANCE.getTrigger_Event().equals(feature);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * 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.diagram.activity.parser.custom;
+
+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.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.AcceptEventAction;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Trigger;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * A specific parser for displaying the label of an AcceptEventAction (not in
+ * AcceptTimeEventAction mode). This parser refreshes the text displayed for the
+ * Action.
+ */
+public class AcceptEventActionParser extends MessageFormatParser implements ISemanticParser {
+
+ public AcceptEventActionParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ public AcceptEventActionParser(EAttribute[] features) {
+ super(features);
+ }
+
+ public AcceptEventActionParser() {
+ super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
+ }
+
+ protected EStructuralFeature getEStructuralFeature(Object notification) {
+ EStructuralFeature featureImpl = null;
+ if (notification instanceof Notification) {
+ Object feature = ((Notification) notification).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ featureImpl = (EStructuralFeature) feature;
+ }
+ }
+ return featureImpl;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
+ * (java.lang.Object , int)
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ EStructuralFeature feature = getEStructuralFeature(event);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
+ * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ Object obj = element.getAdapter(EObject.class);
+ if (obj instanceof AcceptEventAction) {
+ AcceptEventAction action = (AcceptEventAction) obj;
+ String name = UMLLabelInternationalization.getInstance().getLabel(action);
+ if (name != null) {// && !CustomAcceptEventActionEditHelper.isAcceptTimeEventAction(action)) {
+ return name;
+ }
+ }
+ return "";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
+ * java.lang.Object)
+ */
+ @Override
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ EStructuralFeature feature = getEStructuralFeature(notification);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
+ */
+ @Override
+ public List<?> getSemanticElementsBeingParsed(EObject element) {
+ List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
+ if (element instanceof AcceptEventAction) {
+ AcceptEventAction action = (AcceptEventAction) element;
+ semanticElementsBeingParsed.add(action);
+ if (action.getTriggers() != null) {
+ for (Trigger trigger : action.getTriggers()) {
+ if (trigger != null) {
+ semanticElementsBeingParsed.add(trigger);
+ }
+ }
+ }
+ }
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * Determines if the given feature has to be taken into account in this
+ * parser
+ *
+ * @param feature
+ * the feature to test
+ * @return true if is valid, false otherwise
+ */
+ private boolean isValidFeature(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getAcceptEventAction_Trigger().equals(feature) || UMLPackage.eINSTANCE.getTrigger_Event().equals(feature);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AcceptTimeEventActionParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AcceptTimeEventActionParser.java
index ea0f9234178..d1dee402d6d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AcceptTimeEventActionParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AcceptTimeEventActionParser.java
@@ -1,141 +1,143 @@
-/*****************************************************************************
- * Copyright (c) 2010 Atos Origin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-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.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.activity.helper.CustomAcceptEventActionEditHelper;
-import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
-import org.eclipse.uml2.uml.AcceptEventAction;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Trigger;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * A specific parser for displaying the label of an AcceptEventAction (only in
- * AcceptTimeEventAction mode). This parser refreshes the text displayed for the
- * Action.
- */
-public class AcceptTimeEventActionParser extends MessageFormatParser implements ISemanticParser {
-
- public AcceptTimeEventActionParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- public AcceptTimeEventActionParser(EAttribute[] features) {
- super(features);
- }
-
- public AcceptTimeEventActionParser() {
- super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if (notification instanceof Notification) {
- Object feature = ((Notification) notification).getFeature();
- if (feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature) feature;
- }
- }
- return featureImpl;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
- * (java.lang.Object , int)
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
- * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- Object obj = element.getAdapter(EObject.class);
- if (obj instanceof AcceptEventAction) {
- AcceptEventAction action = (AcceptEventAction) obj;
- String name = action.getName();
- if (name != null && CustomAcceptEventActionEditHelper.isAcceptTimeEventAction(action)) {
- return name;
- }
- }
- return "";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
- * java.lang.Object)
- */
- @Override
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
- */
- @Override
- public List<?> getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if (element instanceof AcceptEventAction) {
- AcceptEventAction action = (AcceptEventAction) element;
- semanticElementsBeingParsed.add(action);
- if (action.getTriggers() != null) {
- for (Trigger trigger : action.getTriggers()) {
- if (trigger != null) {
- semanticElementsBeingParsed.add(trigger);
- }
- }
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this
- * parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getAcceptEventAction_Trigger().equals(feature) || UMLPackage.eINSTANCE.getTrigger_Event().equals(feature);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * 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.diagram.activity.parser.custom;
+
+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.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.papyrus.uml.diagram.activity.helper.CustomAcceptEventActionEditHelper;
+import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.AcceptEventAction;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Trigger;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * A specific parser for displaying the label of an AcceptEventAction (only in
+ * AcceptTimeEventAction mode). This parser refreshes the text displayed for the
+ * Action.
+ */
+public class AcceptTimeEventActionParser extends MessageFormatParser implements ISemanticParser {
+
+ public AcceptTimeEventActionParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ public AcceptTimeEventActionParser(EAttribute[] features) {
+ super(features);
+ }
+
+ public AcceptTimeEventActionParser() {
+ super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
+ }
+
+ protected EStructuralFeature getEStructuralFeature(Object notification) {
+ EStructuralFeature featureImpl = null;
+ if (notification instanceof Notification) {
+ Object feature = ((Notification) notification).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ featureImpl = (EStructuralFeature) feature;
+ }
+ }
+ return featureImpl;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
+ * (java.lang.Object , int)
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ EStructuralFeature feature = getEStructuralFeature(event);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
+ * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ Object obj = element.getAdapter(EObject.class);
+ if (obj instanceof AcceptEventAction) {
+ AcceptEventAction action = (AcceptEventAction) obj;
+ String name = UMLLabelInternationalization.getInstance().getLabel(action);
+ if (name != null && CustomAcceptEventActionEditHelper.isAcceptTimeEventAction(action)) {
+ return name;
+ }
+ }
+ return "";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
+ * java.lang.Object)
+ */
+ @Override
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ EStructuralFeature feature = getEStructuralFeature(notification);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
+ */
+ @Override
+ public List<?> getSemanticElementsBeingParsed(EObject element) {
+ List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
+ if (element instanceof AcceptEventAction) {
+ AcceptEventAction action = (AcceptEventAction) element;
+ semanticElementsBeingParsed.add(action);
+ if (action.getTriggers() != null) {
+ for (Trigger trigger : action.getTriggers()) {
+ if (trigger != null) {
+ semanticElementsBeingParsed.add(trigger);
+ }
+ }
+ }
+ }
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * Determines if the given feature has to be taken into account in this
+ * parser
+ *
+ * @param feature
+ * the feature to test
+ * @return true if is valid, false otherwise
+ */
+ private boolean isValidFeature(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getAcceptEventAction_Trigger().equals(feature) || UMLPackage.eINSTANCE.getTrigger_Event().equals(feature);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ActivityEdgeWeightParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ActivityEdgeWeightParser.java
index 13b0ee35d03..687df7a28cf 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ActivityEdgeWeightParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ActivityEdgeWeightParser.java
@@ -1,190 +1,191 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-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.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
-import org.eclipse.papyrus.uml.diagram.common.commands.SetValueSpecificationValueCommand;
-import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil;
-import org.eclipse.uml2.uml.ActivityEdge;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.ValueSpecification;
-
-/**
- * A specific parser for displaying the weight of an Activity Edge. This parser
- * refreshes the text displayed for the weight.
- */
-public class ActivityEdgeWeightParser extends MessageFormatParser implements ISemanticParser {
-
- /** The format string for displaying the weight */
- private static final String WEIGHT_FORMAT = "{weight=%s}";
-
- public ActivityEdgeWeightParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- public ActivityEdgeWeightParser(EAttribute[] features) {
- super(features);
- }
-
- public ActivityEdgeWeightParser() {
- super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if (notification instanceof Notification) {
- Object feature = ((Notification) notification).getFeature();
- if (feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature) feature;
- }
- }
- return featureImpl;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
- * (java.lang.Object , int)
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- @Override
- public String getEditString(IAdaptable adapter, int flags) {
- String value = getValueString(adapter, flags);
- if (value != null) {
- return value;
- }
- return "";
- }
-
- @Override
- public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) {
- Object obj = adapter.getAdapter(EObject.class);
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(obj);
- if (editingDomain == null) {
- return UnexecutableCommand.INSTANCE;
- }
- if (obj instanceof ActivityEdge) {
- ActivityEdge edge = (ActivityEdge) obj;
- ValueSpecification valueSpec = edge.getWeight();
- if (valueSpec != null) {
- CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); //$NON-NLS-1$
- command.compose(new CommandProxy(new SetValueSpecificationValueCommand(valueSpec, newString)));
- return command;
- }
- }
- return UnexecutableCommand.INSTANCE;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
- * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- String label = getValueString(element, flags);
- if (label == null || label.length() == 0) {
- label = " ";
- } else {
- label = String.format(WEIGHT_FORMAT, label);
- }
- return label;
- }
-
- /**
- * Get the unformatted registered string value which shall be displayed
- */
- private String getValueString(IAdaptable element, int flags) {
- Object obj = element.getAdapter(EObject.class);
- if (obj instanceof ActivityEdge) {
- ActivityEdge edge = (ActivityEdge) obj;
- ValueSpecification valueSpec = edge.getWeight();
- if (valueSpec != null) {
- String value = ValueSpecificationUtil.getSpecificationValue(valueSpec);
- if (value != null) {
- return value;
- }
- }
- }
- return "";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
- * java.lang.Object)
- */
- @Override
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
- */
- @Override
- public List<?> getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if (element instanceof ActivityEdge) {
- ActivityEdge edge = (ActivityEdge) element;
- semanticElementsBeingParsed.add(edge);
- if (edge.getWeight() != null) {
- semanticElementsBeingParsed.add(edge.getWeight());
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this
- * parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getActivityEdge_Weight().equals(feature) || ValueSpecification.class.isAssignableFrom(feature.getContainerClass());
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * 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.diagram.activity.parser.custom;
+
+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.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.diagram.common.commands.SetValueSpecificationValueCommand;
+import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil;
+import org.eclipse.uml2.uml.ActivityEdge;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+/**
+ * A specific parser for displaying the weight of an Activity Edge. This parser
+ * refreshes the text displayed for the weight.
+ */
+public class ActivityEdgeWeightParser extends MessageFormatParser implements ISemanticParser {
+
+ /** The format string for displaying the weight */
+ private static final String WEIGHT_FORMAT = "{weight=%s}";
+
+ public ActivityEdgeWeightParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ public ActivityEdgeWeightParser(EAttribute[] features) {
+ super(features);
+ }
+
+ public ActivityEdgeWeightParser() {
+ super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
+ }
+
+ protected EStructuralFeature getEStructuralFeature(Object notification) {
+ EStructuralFeature featureImpl = null;
+ if (notification instanceof Notification) {
+ Object feature = ((Notification) notification).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ featureImpl = (EStructuralFeature) feature;
+ }
+ }
+ return featureImpl;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
+ * (java.lang.Object , int)
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ EStructuralFeature feature = getEStructuralFeature(event);
+ return isValidFeature(feature);
+ }
+
+ @Override
+ public String getEditString(IAdaptable adapter, int flags) {
+ String value = getValueString(adapter, flags, false);
+ if (value != null) {
+ return value;
+ }
+ return "";
+ }
+
+ @Override
+ public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) {
+ Object obj = adapter.getAdapter(EObject.class);
+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(obj);
+ if (editingDomain == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ if (obj instanceof ActivityEdge) {
+ ActivityEdge edge = (ActivityEdge) obj;
+ ValueSpecification valueSpec = edge.getWeight();
+ if (valueSpec != null) {
+ CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); //$NON-NLS-1$
+ command.compose(new CommandProxy(new SetValueSpecificationValueCommand(valueSpec, newString)));
+ return command;
+ }
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
+ * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ String label = getValueString(element, flags, true);
+ if (label == null || label.length() == 0) {
+ label = " ";
+ } else {
+ label = String.format(WEIGHT_FORMAT, label);
+ }
+ return label;
+ }
+
+ /**
+ * Get the unformatted registered string value which shall be displayed
+ */
+ private String getValueString(IAdaptable element, int flags, final boolean useInternationalizayion) {
+ Object obj = element.getAdapter(EObject.class);
+ if (obj instanceof ActivityEdge) {
+ ActivityEdge edge = (ActivityEdge) obj;
+ ValueSpecification valueSpec = edge.getWeight();
+ if (valueSpec != null) {
+ String value = ValueSpecificationUtil.getSpecificationValue(valueSpec, useInternationalizayion);
+ if (value != null) {
+ return value;
+ }
+ }
+ }
+ return "";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
+ * java.lang.Object)
+ */
+ @Override
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ EStructuralFeature feature = getEStructuralFeature(notification);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
+ */
+ @Override
+ public List<?> getSemanticElementsBeingParsed(EObject element) {
+ List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
+ if (element instanceof ActivityEdge) {
+ ActivityEdge edge = (ActivityEdge) element;
+ semanticElementsBeingParsed.add(edge);
+ if (edge.getWeight() != null) {
+ semanticElementsBeingParsed.add(edge.getWeight());
+ }
+ }
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * Determines if the given feature has to be taken into account in this
+ * parser
+ *
+ * @param feature
+ * the feature to test
+ * @return true if is valid, false otherwise
+ */
+ private boolean isValidFeature(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getActivityEdge_Weight().equals(feature) || ValueSpecification.class.isAssignableFrom(feature.getContainerClass());
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ActivityParameterNodeParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ActivityParameterNodeParser.java
index be936cd9027..f7ed4961cd0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ActivityParameterNodeParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ActivityParameterNodeParser.java
@@ -1,174 +1,176 @@
-/*****************************************************************************
- * Copyright (c) 2010 Atos Origin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-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.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
-import org.eclipse.uml2.uml.ActivityParameterNode;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.State;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * The Class ActivityParameterNodeParser.
- */
-public class ActivityParameterNodeParser extends MessageFormatParser implements ISemanticParser {
-
- /**
- * The String format for displaying an ActivityParameterNodeParser with no
- * type
- */
- private static final String UNTYPED_PARAMETER_FORMAT = "%s";
-
- /**
- * The String format for displaying an ActivityParameterNodeParser with its
- * type
- */
- private static final String TYPED_PARAMETER_FORMAT = "%s: %s";
-
- /**
- * The String format for displaying an ActivityParameterNodeParser with in
- * State property
- */
- private static final String STATE_FORMAT = System.getProperty("line.separator").concat("[%s]");
-
- /** The String for separating states */
- private static final String STATE_SEPARATOR = ", ";
-
- public ActivityParameterNodeParser() {
- super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- public ActivityParameterNodeParser(EAttribute[] features) {
- super(features);
- }
-
- public ActivityParameterNodeParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- /**
- * Gets the e structural feature.
- *
- * @param notification
- * @return the structural feature
- */
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if (notification instanceof Notification) {
- Object feature = ((Notification) notification).getFeature();
- if (feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature) feature;
- }
- }
- return featureImpl;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- String result = "";
- ActivityParameterNode parameterNode = null;
- Object adapter = element.getAdapter(EObject.class);
- if (adapter instanceof ActivityParameterNode) {
- parameterNode = (ActivityParameterNode) adapter;
- String name = parameterNode.getName();
- result = String.format(UNTYPED_PARAMETER_FORMAT, name);
- // manage type
- if (parameterNode.getType() != null) {
- String type = parameterNode.getType().getName();
- result = String.format(TYPED_PARAMETER_FORMAT, name, type);
- }
- // manage states
- StringBuffer stateLabel = new StringBuffer();
- for (State state : parameterNode.getInStates()) {
- String stateName = state.getName();
- if (stateName == null) {
- stateName = "";
- }
- if (!"".equals(stateName)) {
- if (stateLabel.length() > 0) {
- stateLabel.append(STATE_SEPARATOR);
- }
- stateLabel.append(stateName);
- }
- }
- if (stateLabel.length() > 0) {
- result += String.format(STATE_FORMAT, stateLabel.toString());
- }
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- @SuppressWarnings("unchecked")
- public List getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- ActivityParameterNode parameterNode = null;
- if (element instanceof ActivityParameterNode) {
- parameterNode = (ActivityParameterNode) element;
- semanticElementsBeingParsed.add(parameterNode);
- if (parameterNode.getType() != null) {
- semanticElementsBeingParsed.add(parameterNode.getType());
- }
- if (parameterNode.getInStates() != null && !parameterNode.getInStates().isEmpty()) {
- semanticElementsBeingParsed.addAll(parameterNode.getInStates());
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this
- * parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getTypedElement_Type().equals(feature) || UMLPackage.eINSTANCE.getObjectNode_InState().equals(feature);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
+
+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.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.ActivityParameterNode;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.State;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * The Class ActivityParameterNodeParser.
+ */
+public class ActivityParameterNodeParser extends MessageFormatParser implements ISemanticParser {
+
+ /**
+ * The String format for displaying an ActivityParameterNodeParser with no
+ * type
+ */
+ private static final String UNTYPED_PARAMETER_FORMAT = "%s";
+
+ /**
+ * The String format for displaying an ActivityParameterNodeParser with its
+ * type
+ */
+ private static final String TYPED_PARAMETER_FORMAT = "%s: %s";
+
+ /**
+ * The String format for displaying an ActivityParameterNodeParser with in
+ * State property
+ */
+ private static final String STATE_FORMAT = System.getProperty("line.separator").concat("[%s]");
+
+ /** The String for separating states */
+ private static final String STATE_SEPARATOR = ", ";
+
+ public ActivityParameterNodeParser() {
+ super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
+ }
+
+ public ActivityParameterNodeParser(EAttribute[] features) {
+ super(features);
+ }
+
+ public ActivityParameterNodeParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ /**
+ * Gets the e structural feature.
+ *
+ * @param notification
+ * @return the structural feature
+ */
+ protected EStructuralFeature getEStructuralFeature(Object notification) {
+ EStructuralFeature featureImpl = null;
+ if (notification instanceof Notification) {
+ Object feature = ((Notification) notification).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ featureImpl = (EStructuralFeature) feature;
+ }
+ }
+ return featureImpl;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ EStructuralFeature feature = getEStructuralFeature(event);
+ return isValidFeature(feature);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ String result = "";
+ ActivityParameterNode parameterNode = null;
+ Object adapter = element.getAdapter(EObject.class);
+ if (adapter instanceof ActivityParameterNode) {
+ parameterNode = (ActivityParameterNode) adapter;
+ String name = UMLLabelInternationalization.getInstance().getLabel(parameterNode);
+ result = String.format(UNTYPED_PARAMETER_FORMAT, name);
+ // manage type
+ if (parameterNode.getType() != null) {
+ String type = UMLLabelInternationalization.getInstance().getLabel(parameterNode.getType());
+ result = String.format(TYPED_PARAMETER_FORMAT, name, type);
+ }
+ // manage states
+ StringBuffer stateLabel = new StringBuffer();
+ for (State state : parameterNode.getInStates()) {
+ String stateName = UMLLabelInternationalization.getInstance().getLabel(state);
+ if (stateName == null) {
+ stateName = "";
+ }
+ if (!"".equals(stateName)) {
+ if (stateLabel.length() > 0) {
+ stateLabel.append(STATE_SEPARATOR);
+ }
+ stateLabel.append(stateName);
+ }
+ }
+ if (stateLabel.length() > 0) {
+ result += String.format(STATE_FORMAT, stateLabel.toString());
+ }
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ EStructuralFeature feature = getEStructuralFeature(notification);
+ return isValidFeature(feature);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public List getSemanticElementsBeingParsed(EObject element) {
+ List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
+ ActivityParameterNode parameterNode = null;
+ if (element instanceof ActivityParameterNode) {
+ parameterNode = (ActivityParameterNode) element;
+ semanticElementsBeingParsed.add(parameterNode);
+ if (parameterNode.getType() != null) {
+ semanticElementsBeingParsed.add(parameterNode.getType());
+ }
+ if (parameterNode.getInStates() != null && !parameterNode.getInStates().isEmpty()) {
+ semanticElementsBeingParsed.addAll(parameterNode.getInStates());
+ }
+ }
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * Determines if the given feature has to be taken into account in this
+ * parser
+ *
+ * @param feature
+ * the feature to test
+ * @return true if is valid, false otherwise
+ */
+ private boolean isValidFeature(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getTypedElement_Type().equals(feature) || UMLPackage.eINSTANCE.getObjectNode_InState().equals(feature);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AssociatedBehaviorParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AssociatedBehaviorParser.java
index 445a050add0..c7c4d34fa53 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AssociatedBehaviorParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/AssociatedBehaviorParser.java
@@ -1,192 +1,198 @@
-/*****************************************************************************
- * Copyright (c) 2010 Atos Origin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-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.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
-import org.eclipse.uml2.uml.Behavior;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * A specific parser for displaying a behavior which is associated to an
- * element. This parser refreshes the text displayed for the behavior.
- */
-public abstract class AssociatedBehaviorParser extends MessageFormatParser implements ISemanticParser {
-
- public AssociatedBehaviorParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- public AssociatedBehaviorParser(EAttribute[] features) {
- super(features);
- }
-
- public AssociatedBehaviorParser() {
- super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if (notification instanceof Notification) {
- Object feature = ((Notification) notification).getFeature();
- if (feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature) feature;
- }
- }
- return featureImpl;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
- * (java.lang.Object , int)
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- @Override
- public String getEditString(IAdaptable adapter, int flags) {
- String value = getValueString(adapter, flags);
- if (value != null) {
- return value;
- }
- return "";
- }
-
- @Override
- public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) {
- Object obj = adapter.getAdapter(EObject.class);
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(obj);
- if (editingDomain == null) {
- return UnexecutableCommand.INSTANCE;
- }
- if (getReferenceFeature().getContainerClass().isInstance(obj)) {
- Object behavior = ((EObject) obj).eGet(getReferenceFeature());
- if (behavior instanceof Behavior) {
- return getModificationCommand((EObject) behavior, UMLPackage.eINSTANCE.getNamedElement_Name(), newString);
- }
- }
- return UnexecutableCommand.INSTANCE;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
- * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- String label = getValueString(element, flags);
- if (label == null || label.length() == 0) {
- label = "";
- } else {
- label = String.format(getFormatString(), label);
- }
- return label;
- }
-
- /**
- * Get the string format for formatting the text value. This String must
- * contain a single "%s" occurrence where to place the value.
- *
- * @return the format string
- */
- protected abstract String getFormatString();
-
- /**
- * Get the unformatted registered string value which shall be displayed
- */
- private String getValueString(IAdaptable element, int flags) {
- Object obj = element.getAdapter(EObject.class);
- if (getReferenceFeature().getContainerClass().isInstance(obj)) {
- Object behavior = ((EObject) obj).eGet(getReferenceFeature());
- if (behavior instanceof Behavior) {
- return ((Behavior) behavior).getName();
- }
- }
- return "";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
- * java.lang.Object)
- */
- @Override
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
- */
- @Override
- public List<?> getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if (getReferenceFeature().getContainerClass().isInstance(element)) {
- semanticElementsBeingParsed.add((Element) element);
- Object behavior = element.eGet(getReferenceFeature());
- if (behavior instanceof Behavior) {
- semanticElementsBeingParsed.add((Element) behavior);
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this
- * parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return getReferenceFeature().equals(feature) || UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature);
- }
-
- /**
- * Get the feature by which the property behavior is linked. This method
- * must be implemented by subclasses and the returned feature must reference
- * a Behavior.
- *
- * @return reference feature
- */
- protected abstract EStructuralFeature getReferenceFeature();
-}
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * 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.diagram.activity.parser.custom;
+
+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.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * A specific parser for displaying a behavior which is associated to an
+ * element. This parser refreshes the text displayed for the behavior.
+ */
+public abstract class AssociatedBehaviorParser extends MessageFormatParser implements ISemanticParser {
+
+ public AssociatedBehaviorParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ public AssociatedBehaviorParser(EAttribute[] features) {
+ super(features);
+ }
+
+ public AssociatedBehaviorParser() {
+ super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
+ }
+
+ protected EStructuralFeature getEStructuralFeature(Object notification) {
+ EStructuralFeature featureImpl = null;
+ if (notification instanceof Notification) {
+ Object feature = ((Notification) notification).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ featureImpl = (EStructuralFeature) feature;
+ }
+ }
+ return featureImpl;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
+ * (java.lang.Object , int)
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ EStructuralFeature feature = getEStructuralFeature(event);
+ return isValidFeature(feature);
+ }
+
+ @Override
+ public String getEditString(IAdaptable adapter, int flags) {
+ String value = getValueString(adapter, flags, false);
+ if (value != null) {
+ return value;
+ }
+ return "";
+ }
+
+ @Override
+ public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) {
+ Object obj = adapter.getAdapter(EObject.class);
+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(obj);
+ if (editingDomain == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ if (getReferenceFeature().getContainerClass().isInstance(obj)) {
+ Object behavior = ((EObject) obj).eGet(getReferenceFeature());
+ if (behavior instanceof Behavior) {
+ return getModificationCommand((EObject) behavior, UMLPackage.eINSTANCE.getNamedElement_Name(), newString);
+ }
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
+ * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ String label = getValueString(element, flags, true);
+ if (label == null || label.length() == 0) {
+ label = "";
+ } else {
+ label = String.format(getFormatString(), label);
+ }
+ return label;
+ }
+
+ /**
+ * Get the string format for formatting the text value. This String must
+ * contain a single "%s" occurrence where to place the value.
+ *
+ * @return the format string
+ */
+ protected abstract String getFormatString();
+
+ /**
+ * Get the unformatted registered string value which shall be displayed
+ */
+ private String getValueString(final IAdaptable element, final int flags, final boolean useInternationalization) {
+ Object obj = element.getAdapter(EObject.class);
+ if (getReferenceFeature().getContainerClass().isInstance(obj)) {
+ Object behavior = ((EObject) obj).eGet(getReferenceFeature());
+ if (behavior instanceof Behavior) {
+ if(useInternationalization){
+ return UMLLabelInternationalization.getInstance().getLabel((Behavior)behavior);
+ }else{
+ return ((Behavior) behavior).getName();
+ }
+ }
+ }
+ return "";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
+ * java.lang.Object)
+ */
+ @Override
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ EStructuralFeature feature = getEStructuralFeature(notification);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
+ */
+ @Override
+ public List<?> getSemanticElementsBeingParsed(EObject element) {
+ List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
+ if (getReferenceFeature().getContainerClass().isInstance(element)) {
+ semanticElementsBeingParsed.add((Element) element);
+ Object behavior = element.eGet(getReferenceFeature());
+ if (behavior instanceof Behavior) {
+ semanticElementsBeingParsed.add((Element) behavior);
+ }
+ }
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * Determines if the given feature has to be taken into account in this
+ * parser
+ *
+ * @param feature
+ * the feature to test
+ * @return true if is valid, false otherwise
+ */
+ private boolean isValidFeature(EStructuralFeature feature) {
+ return getReferenceFeature().equals(feature) || UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature);
+ }
+
+ /**
+ * Get the feature by which the property behavior is linked. This method
+ * must be implemented by subclasses and the returned feature must reference
+ * a Behavior.
+ *
+ * @return reference feature
+ */
+ protected abstract EStructuralFeature getReferenceFeature();
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/CallBehaviorActionParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/CallBehaviorActionParser.java
index 165b0e223d3..7abe6c40c5a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/CallBehaviorActionParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/CallBehaviorActionParser.java
@@ -1,149 +1,151 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-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.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
-import org.eclipse.uml2.uml.Behavior;
-import org.eclipse.uml2.uml.CallBehaviorAction;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * A specific parser for displaying the label of a CallBehaviorAction. This
- * parser refreshes the text displayed for the CallBehaviorAction.
- */
-public class CallBehaviorActionParser extends MessageFormatParser implements ISemanticParser {
-
- /** the format for CallBehaviorAction label */
- private static final String CALLBEHAVIORACTION_LABEL_FORMAT = "%s : %s";
-
- public CallBehaviorActionParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- public CallBehaviorActionParser(EAttribute[] features) {
- super(features);
- }
-
- public CallBehaviorActionParser() {
- super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if (notification instanceof Notification) {
- Object feature = ((Notification) notification).getFeature();
- if (feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature) feature;
- }
- }
- return featureImpl;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
- * (java.lang.Object , int)
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
- * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- Object obj = element.getAdapter(EObject.class);
- if (obj instanceof CallBehaviorAction) {
- CallBehaviorAction action = (CallBehaviorAction) obj;
- String actionName = "";
- if (action.getName() != null) {
- actionName = action.getName();
- }
- String behaviorName = "";
- if (action.getBehavior() != null && action.getBehavior().getName() != null) {
- behaviorName = action.getBehavior().getName();
- }
- // display behavior name alone if name is not specified differently
- if ("".equals(actionName) || actionName.equals(behaviorName)) {
- return behaviorName;
- } else {
- return String.format(CALLBEHAVIORACTION_LABEL_FORMAT, actionName, behaviorName);
- }
- }
- return " ";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
- * java.lang.Object)
- */
- @Override
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
- */
- @Override
- public List<?> getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if (element instanceof CallBehaviorAction) {
- CallBehaviorAction action = (CallBehaviorAction) element;
- semanticElementsBeingParsed.add(action);
- Behavior behavior = action.getBehavior();
- if (behavior != null) {
- semanticElementsBeingParsed.add(behavior);
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this
- * parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getCallBehaviorAction_Behavior().equals(feature);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * 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.diagram.activity.parser.custom;
+
+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.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.CallBehaviorAction;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * A specific parser for displaying the label of a CallBehaviorAction. This
+ * parser refreshes the text displayed for the CallBehaviorAction.
+ */
+public class CallBehaviorActionParser extends MessageFormatParser implements ISemanticParser {
+
+ /** the format for CallBehaviorAction label */
+ private static final String CALLBEHAVIORACTION_LABEL_FORMAT = "%s : %s";
+
+ public CallBehaviorActionParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ public CallBehaviorActionParser(EAttribute[] features) {
+ super(features);
+ }
+
+ public CallBehaviorActionParser() {
+ super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
+ }
+
+ protected EStructuralFeature getEStructuralFeature(Object notification) {
+ EStructuralFeature featureImpl = null;
+ if (notification instanceof Notification) {
+ Object feature = ((Notification) notification).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ featureImpl = (EStructuralFeature) feature;
+ }
+ }
+ return featureImpl;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
+ * (java.lang.Object , int)
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ EStructuralFeature feature = getEStructuralFeature(event);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
+ * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ Object obj = element.getAdapter(EObject.class);
+ if (obj instanceof CallBehaviorAction) {
+ CallBehaviorAction action = (CallBehaviorAction) obj;
+ String actionName = "";
+ if (action.getName() != null) {
+ actionName = UMLLabelInternationalization.getInstance().getLabel(action);
+ }
+ String behaviorName = "";
+ if (action.getBehavior() != null && action.getBehavior().getName() != null) {
+ behaviorName = UMLLabelInternationalization.getInstance().getLabel(action.getBehavior());
+ }
+ // display behavior name alone if name is not specified differently
+ if ("".equals(actionName) || actionName.equals(behaviorName)) {
+ return behaviorName;
+ } else {
+ return String.format(CALLBEHAVIORACTION_LABEL_FORMAT, actionName, behaviorName);
+ }
+ }
+ return " ";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
+ * java.lang.Object)
+ */
+ @Override
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ EStructuralFeature feature = getEStructuralFeature(notification);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
+ */
+ @Override
+ public List<?> getSemanticElementsBeingParsed(EObject element) {
+ List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
+ if (element instanceof CallBehaviorAction) {
+ CallBehaviorAction action = (CallBehaviorAction) element;
+ semanticElementsBeingParsed.add(action);
+ Behavior behavior = action.getBehavior();
+ if (behavior != null) {
+ semanticElementsBeingParsed.add(behavior);
+ }
+ }
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * Determines if the given feature has to be taken into account in this
+ * parser
+ *
+ * @param feature
+ * the feature to test
+ * @return true if is valid, false otherwise
+ */
+ private boolean isValidFeature(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getCallBehaviorAction_Behavior().equals(feature);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/CallOperationActionParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/CallOperationActionParser.java
index 159c9348ecb..f303d465fb4 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/CallOperationActionParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/CallOperationActionParser.java
@@ -1,168 +1,170 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-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.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
-import org.eclipse.uml2.uml.CallOperationAction;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * A specific parser for displaying the label of a CallOperationAction. This
- * parser refreshes the text displayed for the CallOperationAction.
- */
-public class CallOperationActionParser extends MessageFormatParser implements ISemanticParser {
-
- private static final UMLPackage eUML = UMLPackage.eINSTANCE;
-
- public CallOperationActionParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- public CallOperationActionParser(EAttribute[] features) {
- super(features);
- }
-
- public CallOperationActionParser() {
- super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if (notification instanceof Notification) {
- Object feature = ((Notification) notification).getFeature();
- if (feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature) feature;
- }
- }
- return featureImpl;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
- * (java.lang.Object , int)
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isAffectingFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
- * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- Object obj = element.getAdapter(EObject.class);
- if (obj instanceof CallOperationAction) {
- CallOperationAction action = (CallOperationAction) obj;
- String name = action.getName();
- String operation = "";
- if (name == null) {
- name = "";
- }
- if (action.getOperation() != null) {
- operation = action.getOperation().getName();
- if (operation == null) {
- operation = "";
- }
- }
- // name, operation and className are initialized with non null
- // values
- return getPrintString(name, operation);
- }
- return " ";
- }
-
- /**
- * Get the string to print with the given elements
- *
- * @param name
- * the name of the node or ""
- * @param operation
- * the name of the operation or ""
- * @param className
- * the name of the operation class or ""
- * @return the string to print
- */
- private String getPrintString(String name, String operation) {
- return isEmpty(name) ? operation : name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
- * java.lang.Object)
- */
- @Override
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isAffectingFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
- */
- @Override
- public List<?> getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if (element instanceof CallOperationAction) {
- CallOperationAction action = (CallOperationAction) element;
- semanticElementsBeingParsed.add(action);
- Operation operation = action.getOperation();
- if (operation != null) {
- semanticElementsBeingParsed.add(operation);
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this
- * parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isAffectingFeature(EStructuralFeature feature) {
- return eUML.getNamedElement_Name().equals(feature) || //
- eUML.getCallOperationAction_Operation().equals(feature);
- }
-
- private static boolean isEmpty(String text) {
- return text == null || text.length() == 0;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * 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.diagram.activity.parser.custom;
+
+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.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.CallOperationAction;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * A specific parser for displaying the label of a CallOperationAction. This
+ * parser refreshes the text displayed for the CallOperationAction.
+ */
+public class CallOperationActionParser extends MessageFormatParser implements ISemanticParser {
+
+ private static final UMLPackage eUML = UMLPackage.eINSTANCE;
+
+ public CallOperationActionParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ public CallOperationActionParser(EAttribute[] features) {
+ super(features);
+ }
+
+ public CallOperationActionParser() {
+ super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
+ }
+
+ protected EStructuralFeature getEStructuralFeature(Object notification) {
+ EStructuralFeature featureImpl = null;
+ if (notification instanceof Notification) {
+ Object feature = ((Notification) notification).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ featureImpl = (EStructuralFeature) feature;
+ }
+ }
+ return featureImpl;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
+ * (java.lang.Object , int)
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ EStructuralFeature feature = getEStructuralFeature(event);
+ return isAffectingFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
+ * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ Object obj = element.getAdapter(EObject.class);
+ if (obj instanceof CallOperationAction) {
+ CallOperationAction action = (CallOperationAction) obj;
+ String name = UMLLabelInternationalization.getInstance().getLabel(action);
+ String operation = "";
+ if (name == null) {
+ name = "";
+ }
+ if (action.getOperation() != null) {
+ operation = UMLLabelInternationalization.getInstance().getLabel(action.getOperation());
+ if (operation == null) {
+ operation = "";
+ }
+ }
+ // name, operation and className are initialized with non null
+ // values
+ return getPrintString(name, operation);
+ }
+ return " ";
+ }
+
+ /**
+ * Get the string to print with the given elements
+ *
+ * @param name
+ * the name of the node or ""
+ * @param operation
+ * the name of the operation or ""
+ * @param className
+ * the name of the operation class or ""
+ * @return the string to print
+ */
+ private String getPrintString(String name, String operation) {
+ return isEmpty(name) ? operation : name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
+ * java.lang.Object)
+ */
+ @Override
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ EStructuralFeature feature = getEStructuralFeature(notification);
+ return isAffectingFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
+ */
+ @Override
+ public List<?> getSemanticElementsBeingParsed(EObject element) {
+ List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
+ if (element instanceof CallOperationAction) {
+ CallOperationAction action = (CallOperationAction) element;
+ semanticElementsBeingParsed.add(action);
+ Operation operation = action.getOperation();
+ if (operation != null) {
+ semanticElementsBeingParsed.add(operation);
+ }
+ }
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * Determines if the given feature has to be taken into account in this
+ * parser
+ *
+ * @param feature
+ * the feature to test
+ * @return true if is valid, false otherwise
+ */
+ private boolean isAffectingFeature(EStructuralFeature feature) {
+ return eUML.getNamedElement_Name().equals(feature) || //
+ eUML.getCallOperationAction_Operation().equals(feature);
+ }
+
+ private static boolean isEmpty(String text) {
+ return text == null || text.length() == 0;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/EdgeGuardParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/EdgeGuardParser.java
index 7e56890ea05..2626e8832d0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/EdgeGuardParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/EdgeGuardParser.java
@@ -1,190 +1,191 @@
-/*****************************************************************************
- * Copyright (c) 2010 Atos Origin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-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.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
-import org.eclipse.papyrus.uml.diagram.common.commands.SetValueSpecificationValueCommand;
-import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil;
-import org.eclipse.uml2.uml.ActivityEdge;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.ValueSpecification;
-
-/**
- * A specific parser for displaying the guard of an Activity Edge. This parser
- * refreshes the text displayed for the guard.
- */
-public class EdgeGuardParser extends MessageFormatParser implements ISemanticParser {
-
- /** The format string for displaying the guard */
- private static final String GUARD_FORMAT = "[%s]";
-
- public EdgeGuardParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- public EdgeGuardParser(EAttribute[] features) {
- super(features);
- }
-
- public EdgeGuardParser() {
- super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if (notification instanceof Notification) {
- Object feature = ((Notification) notification).getFeature();
- if (feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature) feature;
- }
- }
- return featureImpl;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
- * (java.lang.Object , int)
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- @Override
- public String getEditString(IAdaptable adapter, int flags) {
- String value = getValueString(adapter, flags);
- if (value != null) {
- return value;
- }
- return "";
- }
-
- @Override
- public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) {
- Object obj = adapter.getAdapter(EObject.class);
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(obj);
- if (editingDomain == null) {
- return UnexecutableCommand.INSTANCE;
- }
- if (obj instanceof ActivityEdge) {
- ActivityEdge edge = (ActivityEdge) obj;
- ValueSpecification valueSpec = edge.getGuard();
- if (valueSpec != null) {
- CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); //$NON-NLS-1$
- command.compose(new CommandProxy(new SetValueSpecificationValueCommand(valueSpec, newString)));
- return command;
- }
- }
- return UnexecutableCommand.INSTANCE;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
- * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- String label = getValueString(element, flags);
- if (label == null || label.length() == 0) {
- label = " ";
- } else {
- label = String.format(GUARD_FORMAT, label);
- }
- return label;
- }
-
- /**
- * Get the unformatted registered string value which shall be displayed
- */
- private String getValueString(IAdaptable element, int flags) {
- Object obj = element.getAdapter(EObject.class);
- if (obj instanceof ActivityEdge) {
- ActivityEdge edge = (ActivityEdge) obj;
- ValueSpecification valueSpec = edge.getGuard();
- if (valueSpec != null) {
- String value = ValueSpecificationUtil.getSpecificationValue(valueSpec);
- if (value != null) {
- return value;
- }
- }
- }
- return "";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
- * java.lang.Object)
- */
- @Override
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
- */
- @Override
- public List<?> getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if (element instanceof ActivityEdge) {
- ActivityEdge edge = (ActivityEdge) element;
- semanticElementsBeingParsed.add(edge);
- if (edge.getGuard() != null) {
- semanticElementsBeingParsed.add(edge.getGuard());
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this
- * parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getActivityEdge_Guard().equals(feature) || ValueSpecification.class.isAssignableFrom(feature.getContainerClass());
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * 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.diagram.activity.parser.custom;
+
+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.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.diagram.common.commands.SetValueSpecificationValueCommand;
+import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil;
+import org.eclipse.uml2.uml.ActivityEdge;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.ValueSpecification;
+
+/**
+ * A specific parser for displaying the guard of an Activity Edge. This parser
+ * refreshes the text displayed for the guard.
+ */
+public class EdgeGuardParser extends MessageFormatParser implements ISemanticParser {
+
+ /** The format string for displaying the guard */
+ private static final String GUARD_FORMAT = "[%s]";
+
+ public EdgeGuardParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ public EdgeGuardParser(EAttribute[] features) {
+ super(features);
+ }
+
+ public EdgeGuardParser() {
+ super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
+ }
+
+ protected EStructuralFeature getEStructuralFeature(Object notification) {
+ EStructuralFeature featureImpl = null;
+ if (notification instanceof Notification) {
+ Object feature = ((Notification) notification).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ featureImpl = (EStructuralFeature) feature;
+ }
+ }
+ return featureImpl;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
+ * (java.lang.Object , int)
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ EStructuralFeature feature = getEStructuralFeature(event);
+ return isValidFeature(feature);
+ }
+
+ @Override
+ public String getEditString(IAdaptable adapter, int flags) {
+ String value = getValueString(adapter, flags, false);
+ if (value != null) {
+ return value;
+ }
+ return "";
+ }
+
+ @Override
+ public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) {
+ Object obj = adapter.getAdapter(EObject.class);
+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(obj);
+ if (editingDomain == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ if (obj instanceof ActivityEdge) {
+ ActivityEdge edge = (ActivityEdge) obj;
+ ValueSpecification valueSpec = edge.getGuard();
+ if (valueSpec != null) {
+ CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); //$NON-NLS-1$
+ command.compose(new CommandProxy(new SetValueSpecificationValueCommand(valueSpec, newString)));
+ return command;
+ }
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
+ * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ String label = getValueString(element, flags, true);
+ if (label == null || label.length() == 0) {
+ label = " ";
+ } else {
+ label = String.format(GUARD_FORMAT, label);
+ }
+ return label;
+ }
+
+ /**
+ * Get the unformatted registered string value which shall be displayed
+ */
+ private String getValueString(IAdaptable element, int flags, final boolean useInternationalizayion) {
+ Object obj = element.getAdapter(EObject.class);
+ if (obj instanceof ActivityEdge) {
+ ActivityEdge edge = (ActivityEdge) obj;
+ ValueSpecification valueSpec = edge.getGuard();
+ if (valueSpec != null) {
+ String value = ValueSpecificationUtil.getSpecificationValue(valueSpec, useInternationalizayion);
+ if (value != null) {
+ return value;
+ }
+ }
+ }
+ return "";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
+ * java.lang.Object)
+ */
+ @Override
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ EStructuralFeature feature = getEStructuralFeature(notification);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
+ */
+ @Override
+ public List<?> getSemanticElementsBeingParsed(EObject element) {
+ List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
+ if (element instanceof ActivityEdge) {
+ ActivityEdge edge = (ActivityEdge) element;
+ semanticElementsBeingParsed.add(edge);
+ if (edge.getGuard() != null) {
+ semanticElementsBeingParsed.add(edge.getGuard());
+ }
+ }
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * Determines if the given feature has to be taken into account in this
+ * parser
+ *
+ * @param feature
+ * the feature to test
+ * @return true if is valid, false otherwise
+ */
+ private boolean isValidFeature(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getActivityEdge_Guard().equals(feature) || ValueSpecification.class.isAssignableFrom(feature.getContainerClass());
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ExceptionHandlerTypeParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ExceptionHandlerTypeParser.java
index ddf0f06e821..6b0559f9bd8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ExceptionHandlerTypeParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ExceptionHandlerTypeParser.java
@@ -1,145 +1,147 @@
-/*****************************************************************************
- * Copyright (c) 2010 Atos Origin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-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.common.util.EList;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.ExceptionHandler;
-import org.eclipse.uml2.uml.StructuredActivityNode;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * A specific parser for displaying the type label of an ExceptionHandler. This
- * parser refreshes the text displayed for the ExceptionHandler.
- */
-public class ExceptionHandlerTypeParser extends MessageFormatParser implements ISemanticParser {
-
- /** The line break */
- private static final String LINE_BREAK = System.getProperty("line.separator");
-
- public ExceptionHandlerTypeParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- public ExceptionHandlerTypeParser(EAttribute[] features) {
- super(features);
- }
-
- public ExceptionHandlerTypeParser() {
- super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if (notification instanceof Notification) {
- Object feature = ((Notification) notification).getFeature();
- if (feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature) feature;
- }
- }
- return featureImpl;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
- * (java.lang.Object , int)
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
- * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- StringBuffer label = new StringBuffer();
- Object obj = element.getAdapter(EObject.class);
- if (obj instanceof ExceptionHandler) {
- EList<Classifier> excTypes = ((ExceptionHandler) obj).getExceptionTypes();
- for (Classifier type : excTypes) {
- if (type != null && !"".equals(type.getName()) && type.getName() != null) {
- if (label.length() > 0) {
- label.append(LINE_BREAK);
- }
- label.append(type.getName());
- }
- }
- }
- return label.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
- * java.lang.Object)
- */
- @Override
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
- */
- @Override
- public List<?> getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if (element instanceof StructuredActivityNode) {
- semanticElementsBeingParsed.add((ExceptionHandler) element);
- EList<Classifier> excTypes = ((ExceptionHandler) element).getExceptionTypes();
- for (Classifier type : excTypes) {
- semanticElementsBeingParsed.add(type);
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this
- * parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getExceptionHandler_ExceptionType().equals(feature);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * 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.diagram.activity.parser.custom;
+
+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.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.ExceptionHandler;
+import org.eclipse.uml2.uml.StructuredActivityNode;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * A specific parser for displaying the type label of an ExceptionHandler. This
+ * parser refreshes the text displayed for the ExceptionHandler.
+ */
+public class ExceptionHandlerTypeParser extends MessageFormatParser implements ISemanticParser {
+
+ /** The line break */
+ private static final String LINE_BREAK = System.getProperty("line.separator");
+
+ public ExceptionHandlerTypeParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ public ExceptionHandlerTypeParser(EAttribute[] features) {
+ super(features);
+ }
+
+ public ExceptionHandlerTypeParser() {
+ super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
+ }
+
+ protected EStructuralFeature getEStructuralFeature(Object notification) {
+ EStructuralFeature featureImpl = null;
+ if (notification instanceof Notification) {
+ Object feature = ((Notification) notification).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ featureImpl = (EStructuralFeature) feature;
+ }
+ }
+ return featureImpl;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
+ * (java.lang.Object , int)
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ EStructuralFeature feature = getEStructuralFeature(event);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
+ * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ StringBuffer label = new StringBuffer();
+ Object obj = element.getAdapter(EObject.class);
+ if (obj instanceof ExceptionHandler) {
+ EList<Classifier> excTypes = ((ExceptionHandler) obj).getExceptionTypes();
+ for (Classifier type : excTypes) {
+ if (type != null && !"".equals(type.getName()) && type.getName() != null) {
+ if (label.length() > 0) {
+ label.append(LINE_BREAK);
+ }
+ label.append(UMLLabelInternationalization.getInstance().getLabel(type));
+ }
+ }
+ }
+ return label.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
+ * java.lang.Object)
+ */
+ @Override
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ EStructuralFeature feature = getEStructuralFeature(notification);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
+ */
+ @Override
+ public List<?> getSemanticElementsBeingParsed(EObject element) {
+ List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
+ if (element instanceof StructuredActivityNode) {
+ semanticElementsBeingParsed.add((ExceptionHandler) element);
+ EList<Classifier> excTypes = ((ExceptionHandler) element).getExceptionTypes();
+ for (Classifier type : excTypes) {
+ semanticElementsBeingParsed.add(type);
+ }
+ }
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * Determines if the given feature has to be taken into account in this
+ * parser
+ *
+ * @param feature
+ * the feature to test
+ * @return true if is valid, false otherwise
+ */
+ private boolean isValidFeature(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getExceptionHandler_ExceptionType().equals(feature);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ObjectNodeParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ObjectNodeParser.java
index 3ba8d2cebca..1e76256f0a9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ObjectNodeParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ObjectNodeParser.java
@@ -1,174 +1,176 @@
-/*****************************************************************************
- * Copyright (c) 2010 Atos Origin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-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.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.ObjectNode;
-import org.eclipse.uml2.uml.State;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * The Class ObjectNodeParser. This parser handle labels for Object Nodes
- */
-public class ObjectNodeParser extends MessageFormatParser implements ISemanticParser {
-
- /**
- * The String format for displaying an ActivityParameterNodeParser with no
- * type
- */
- private static final String UNTYPED_PARAMETER_FORMAT = "%s";
-
- /**
- * The String format for displaying an ActivityParameterNodeParser with its
- * type
- */
- private static final String TYPED_PARAMETER_FORMAT = "%s: %s";
-
- /**
- * The String format for displaying an ActivityParameterNodeParser with in
- * State property
- */
- private static final String STATE_FORMAT = System.getProperty("line.separator").concat("[%s]");
-
- /** The String for separating states */
- private static final String STATE_SEPARATOR = ", ";
-
- public ObjectNodeParser() {
- super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- public ObjectNodeParser(EAttribute[] features) {
- super(features);
- }
-
- public ObjectNodeParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- /**
- * Gets the e structural feature.
- *
- * @param notification
- * @return the structural feature
- */
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if (notification instanceof Notification) {
- Object feature = ((Notification) notification).getFeature();
- if (feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature) feature;
- }
- }
- return featureImpl;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- StringBuffer result = new StringBuffer();
- Object adapter = element.getAdapter(EObject.class);
- if (adapter instanceof ObjectNode) {
- ObjectNode objectNode = (ObjectNode) adapter;
- String name = objectNode.getName();
- // manage type
- if (objectNode.getType() != null) {
- String type = objectNode.getType().getName();
- result.append(String.format(TYPED_PARAMETER_FORMAT, name, type));
- } else {
- result.append(String.format(UNTYPED_PARAMETER_FORMAT, name));
- }
- // manage states
- StringBuffer stateLabel = new StringBuffer();
- for (State state : objectNode.getInStates()) {
- String stateName = state.getName();
- if (stateName == null) {
- stateName = "";
- }
- if (!"".equals(stateName)) {
- if (stateLabel.length() > 0) {
- stateLabel.append(STATE_SEPARATOR);
- }
- stateLabel.append(stateName);
- }
- }
- if (stateLabel.length() > 0) {
- result.append(String.format(STATE_FORMAT, stateLabel.toString()));
- }
- }
- return result.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- @SuppressWarnings("unchecked")
- public List getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- ObjectNode objectNode = null;
- if (element instanceof ObjectNode) {
- objectNode = (ObjectNode) element;
- semanticElementsBeingParsed.add(objectNode);
- if (objectNode.getType() != null) {
- semanticElementsBeingParsed.add(objectNode.getType());
- }
- if (objectNode.getInStates() != null && !objectNode.getInStates().isEmpty()) {
- semanticElementsBeingParsed.addAll(objectNode.getInStates());
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this
- * parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getTypedElement_Type().equals(feature) || UMLPackage.eINSTANCE.getObjectNode_InState().equals(feature);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * 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.diagram.activity.parser.custom;
+
+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.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.ObjectNode;
+import org.eclipse.uml2.uml.State;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * The Class ObjectNodeParser. This parser handle labels for Object Nodes
+ */
+public class ObjectNodeParser extends MessageFormatParser implements ISemanticParser {
+
+ /**
+ * The String format for displaying an ActivityParameterNodeParser with no
+ * type
+ */
+ private static final String UNTYPED_PARAMETER_FORMAT = "%s";
+
+ /**
+ * The String format for displaying an ActivityParameterNodeParser with its
+ * type
+ */
+ private static final String TYPED_PARAMETER_FORMAT = "%s: %s";
+
+ /**
+ * The String format for displaying an ActivityParameterNodeParser with in
+ * State property
+ */
+ private static final String STATE_FORMAT = System.getProperty("line.separator").concat("[%s]");
+
+ /** The String for separating states */
+ private static final String STATE_SEPARATOR = ", ";
+
+ public ObjectNodeParser() {
+ super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
+ }
+
+ public ObjectNodeParser(EAttribute[] features) {
+ super(features);
+ }
+
+ public ObjectNodeParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ /**
+ * Gets the e structural feature.
+ *
+ * @param notification
+ * @return the structural feature
+ */
+ protected EStructuralFeature getEStructuralFeature(Object notification) {
+ EStructuralFeature featureImpl = null;
+ if (notification instanceof Notification) {
+ Object feature = ((Notification) notification).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ featureImpl = (EStructuralFeature) feature;
+ }
+ }
+ return featureImpl;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ EStructuralFeature feature = getEStructuralFeature(event);
+ return isValidFeature(feature);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ StringBuffer result = new StringBuffer();
+ Object adapter = element.getAdapter(EObject.class);
+ if (adapter instanceof ObjectNode) {
+ ObjectNode objectNode = (ObjectNode) adapter;
+ String name = UMLLabelInternationalization.getInstance().getLabel(objectNode);
+ // manage type
+ if (objectNode.getType() != null) {
+ String type = UMLLabelInternationalization.getInstance().getLabel(objectNode.getType());
+ result.append(String.format(TYPED_PARAMETER_FORMAT, name, type));
+ } else {
+ result.append(String.format(UNTYPED_PARAMETER_FORMAT, name));
+ }
+ // manage states
+ StringBuffer stateLabel = new StringBuffer();
+ for (State state : objectNode.getInStates()) {
+ String stateName = UMLLabelInternationalization.getInstance().getLabel(state);
+ if (stateName == null) {
+ stateName = "";
+ }
+ if (!"".equals(stateName)) {
+ if (stateLabel.length() > 0) {
+ stateLabel.append(STATE_SEPARATOR);
+ }
+ stateLabel.append(stateName);
+ }
+ }
+ if (stateLabel.length() > 0) {
+ result.append(String.format(STATE_FORMAT, stateLabel.toString()));
+ }
+ }
+ return result.toString();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ EStructuralFeature feature = getEStructuralFeature(notification);
+ return isValidFeature(feature);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public List getSemanticElementsBeingParsed(EObject element) {
+ List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
+ ObjectNode objectNode = null;
+ if (element instanceof ObjectNode) {
+ objectNode = (ObjectNode) element;
+ semanticElementsBeingParsed.add(objectNode);
+ if (objectNode.getType() != null) {
+ semanticElementsBeingParsed.add(objectNode.getType());
+ }
+ if (objectNode.getInStates() != null && !objectNode.getInStates().isEmpty()) {
+ semanticElementsBeingParsed.addAll(objectNode.getInStates());
+ }
+ }
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * Determines if the given feature has to be taken into account in this
+ * parser
+ *
+ * @param feature
+ * the feature to test
+ * @return true if is valid, false otherwise
+ */
+ private boolean isValidFeature(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getTypedElement_Type().equals(feature) || UMLPackage.eINSTANCE.getObjectNode_InState().equals(feature);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ParameterParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ParameterParser.java
index f40958ec85c..7825dca6af7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ParameterParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/ParameterParser.java
@@ -1,149 +1,151 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-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.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Parameter;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * A specific parser for displaying an Activity's Parameter. This parser
- * refreshes the text displayed for the Parameter.
- */
-public class ParameterParser extends MessageFormatParser implements ISemanticParser {
-
- /** The String format for displaying a parameter with its type */
- private static final String TYPED_PARAMETER_FORMAT = "%s: %s";
-
- /** The String format for displaying a parameter with no type */
- private static final String UNTYPED_PARAMETER_FORMAT = "%s";
-
- public ParameterParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- public ParameterParser(EAttribute[] features) {
- super(features);
- }
-
- public ParameterParser() {
- super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if (notification instanceof Notification) {
- Object feature = ((Notification) notification).getFeature();
- if (feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature) feature;
- }
- }
- return featureImpl;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
- * (java.lang.Object , int)
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
- * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- Object obj = element.getAdapter(EObject.class);
- if (obj instanceof Parameter) {
- Parameter parameter = (Parameter) obj;
- String name = parameter.getName();
- if (name == null) {
- name = " ";
- }
- if (parameter.getType() != null) {
- String type = parameter.getType().getName();
- if (type == null) {
- type = "";
- }
- return String.format(TYPED_PARAMETER_FORMAT, name, type);
- } else {
- return String.format(UNTYPED_PARAMETER_FORMAT, name);
- }
- }
- return " ";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
- * java.lang.Object)
- */
- @Override
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
- */
- @Override
- public List<?> getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if (element instanceof Parameter) {
- Parameter parameter = (Parameter) element;
- semanticElementsBeingParsed.add(parameter);
- if (parameter.getType() != null) {
- semanticElementsBeingParsed.add(parameter.getType());
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this
- * parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getTypedElement_Type().equals(feature);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * 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.diagram.activity.parser.custom;
+
+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.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * A specific parser for displaying an Activity's Parameter. This parser
+ * refreshes the text displayed for the Parameter.
+ */
+public class ParameterParser extends MessageFormatParser implements ISemanticParser {
+
+ /** The String format for displaying a parameter with its type */
+ private static final String TYPED_PARAMETER_FORMAT = "%s: %s";
+
+ /** The String format for displaying a parameter with no type */
+ private static final String UNTYPED_PARAMETER_FORMAT = "%s";
+
+ public ParameterParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ public ParameterParser(EAttribute[] features) {
+ super(features);
+ }
+
+ public ParameterParser() {
+ super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
+ }
+
+ protected EStructuralFeature getEStructuralFeature(Object notification) {
+ EStructuralFeature featureImpl = null;
+ if (notification instanceof Notification) {
+ Object feature = ((Notification) notification).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ featureImpl = (EStructuralFeature) feature;
+ }
+ }
+ return featureImpl;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
+ * (java.lang.Object , int)
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ EStructuralFeature feature = getEStructuralFeature(event);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
+ * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ Object obj = element.getAdapter(EObject.class);
+ if (obj instanceof Parameter) {
+ Parameter parameter = (Parameter) obj;
+ String name = UMLLabelInternationalization.getInstance().getLabel(parameter);
+ if (name == null) {
+ name = " ";
+ }
+ if (parameter.getType() != null) {
+ String type = UMLLabelInternationalization.getInstance().getLabel(parameter.getType());
+ if (type == null) {
+ type = "";
+ }
+ return String.format(TYPED_PARAMETER_FORMAT, name, type);
+ } else {
+ return String.format(UNTYPED_PARAMETER_FORMAT, name);
+ }
+ }
+ return " ";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
+ * java.lang.Object)
+ */
+ @Override
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ EStructuralFeature feature = getEStructuralFeature(notification);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
+ */
+ @Override
+ public List<?> getSemanticElementsBeingParsed(EObject element) {
+ List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
+ if (element instanceof Parameter) {
+ Parameter parameter = (Parameter) element;
+ semanticElementsBeingParsed.add(parameter);
+ if (parameter.getType() != null) {
+ semanticElementsBeingParsed.add(parameter.getType());
+ }
+ }
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * Determines if the given feature has to be taken into account in this
+ * parser
+ *
+ * @param feature
+ * the feature to test
+ * @return true if is valid, false otherwise
+ */
+ private boolean isValidFeature(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getTypedElement_Type().equals(feature);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PinParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PinParser.java
index 07b8a2abe05..6d96e37e971 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PinParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PinParser.java
@@ -1,171 +1,173 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-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.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Pin;
-import org.eclipse.uml2.uml.State;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * A specific parser for displaying the label of a Pin. This parser refreshes
- * the text displayed for the Pin.
- */
-public class PinParser extends MessageFormatParser implements ISemanticParser {
-
- /** The String format for displaying in State property */
- private static final String STATE_DISPLAY = System.getProperty("line.separator").concat("[%s]");
-
- /** The String for separating states */
- private static final String STATE_SEPARATOR = ", ";
-
- public PinParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- public PinParser(EAttribute[] features) {
- super(features);
- }
-
- public PinParser() {
- super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if (notification instanceof Notification) {
- Object feature = ((Notification) notification).getFeature();
- if (feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature) feature;
- }
- }
- return featureImpl;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
- * (java.lang.Object , int)
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
- * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- StringBuffer label = new StringBuffer();
- Object obj = element.getAdapter(EObject.class);
- if (obj instanceof Pin) {
- Pin pin = (Pin) obj;
- String name = pin.getName();
- if (name == null) {
- name = "";
- }
- label.append(name);
- if (pin.getInStates() != null) {
- // manage states
- StringBuffer stateLabel = new StringBuffer();
- for (State state : pin.getInStates()) {
- if (state != null) {
- String stateName = state.getName();
- if (stateName == null) {
- stateName = "";
- }
- if (!"".equals(stateName)) {
- if (stateLabel.length() > 0) {
- stateLabel.append(STATE_SEPARATOR);
- }
- stateLabel.append(stateName);
- }
- }
- }
- if (stateLabel.length() > 0) {
- label.append(String.format(STATE_DISPLAY, stateLabel.toString()));
- }
- }
- }
- if (label.length() == 0) {
- label.append(" ");
- }
- return label.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
- * java.lang.Object)
- */
- @Override
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
- */
- @Override
- public List<?> getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if (element instanceof Pin) {
- Pin pin = (Pin) element;
- semanticElementsBeingParsed.add(pin);
- if (pin.getInStates() != null) {
- for (State state : pin.getInStates()) {
- if (state != null) {
- semanticElementsBeingParsed.add(state);
- }
- }
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this
- * parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getObjectNode_InState().equals(feature);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * 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.diagram.activity.parser.custom;
+
+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.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Pin;
+import org.eclipse.uml2.uml.State;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * A specific parser for displaying the label of a Pin. This parser refreshes
+ * the text displayed for the Pin.
+ */
+public class PinParser extends MessageFormatParser implements ISemanticParser {
+
+ /** The String format for displaying in State property */
+ private static final String STATE_DISPLAY = System.getProperty("line.separator").concat("[%s]");
+
+ /** The String for separating states */
+ private static final String STATE_SEPARATOR = ", ";
+
+ public PinParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ public PinParser(EAttribute[] features) {
+ super(features);
+ }
+
+ public PinParser() {
+ super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
+ }
+
+ protected EStructuralFeature getEStructuralFeature(Object notification) {
+ EStructuralFeature featureImpl = null;
+ if (notification instanceof Notification) {
+ Object feature = ((Notification) notification).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ featureImpl = (EStructuralFeature) feature;
+ }
+ }
+ return featureImpl;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
+ * (java.lang.Object , int)
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ EStructuralFeature feature = getEStructuralFeature(event);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
+ * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ StringBuffer label = new StringBuffer();
+ Object obj = element.getAdapter(EObject.class);
+ if (obj instanceof Pin) {
+ Pin pin = (Pin) obj;
+ String name = UMLLabelInternationalization.getInstance().getLabel(pin);
+ if (name == null) {
+ name = "";
+ }
+ label.append(name);
+ if (pin.getInStates() != null) {
+ // manage states
+ StringBuffer stateLabel = new StringBuffer();
+ for (State state : pin.getInStates()) {
+ if (state != null) {
+ String stateName = UMLLabelInternationalization.getInstance().getLabel(state);
+ if (stateName == null) {
+ stateName = "";
+ }
+ if (!"".equals(stateName)) {
+ if (stateLabel.length() > 0) {
+ stateLabel.append(STATE_SEPARATOR);
+ }
+ stateLabel.append(stateName);
+ }
+ }
+ }
+ if (stateLabel.length() > 0) {
+ label.append(String.format(STATE_DISPLAY, stateLabel.toString()));
+ }
+ }
+ }
+ if (label.length() == 0) {
+ label.append(" ");
+ }
+ return label.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
+ * java.lang.Object)
+ */
+ @Override
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ EStructuralFeature feature = getEStructuralFeature(notification);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
+ */
+ @Override
+ public List<?> getSemanticElementsBeingParsed(EObject element) {
+ List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
+ if (element instanceof Pin) {
+ Pin pin = (Pin) element;
+ semanticElementsBeingParsed.add(pin);
+ if (pin.getInStates() != null) {
+ for (State state : pin.getInStates()) {
+ if (state != null) {
+ semanticElementsBeingParsed.add(state);
+ }
+ }
+ }
+ }
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * Determines if the given feature has to be taken into account in this
+ * parser
+ *
+ * @param feature
+ * the feature to test
+ * @return true if is valid, false otherwise
+ */
+ private boolean isValidFeature(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getObjectNode_InState().equals(feature);
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PinValueParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PinValueParser.java
index 2a97593d358..203bce96dd2 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PinValueParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PinValueParser.java
@@ -1,247 +1,249 @@
-/*****************************************************************************
- * Copyright (c) 2009 Atos Origin.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Atos Origin - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-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.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
-import org.eclipse.papyrus.uml.diagram.common.commands.SetValueSpecificationValueCommand;
-import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil;
-import org.eclipse.uml2.uml.Action;
-import org.eclipse.uml2.uml.ActionInputPin;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Pin;
-import org.eclipse.uml2.uml.ReadSelfAction;
-import org.eclipse.uml2.uml.ReadVariableAction;
-import org.eclipse.uml2.uml.UMLPackage;
-import org.eclipse.uml2.uml.ValuePin;
-import org.eclipse.uml2.uml.ValueSpecification;
-import org.eclipse.uml2.uml.ValueSpecificationAction;
-import org.eclipse.uml2.uml.Variable;
-
-/**
- * A specific parser for displaying the label of a Pin. This parser refreshes
- * the text displayed for the Pin.
- */
-public class PinValueParser extends MessageFormatParser implements ISemanticParser {
-
- /** The keyword for indication a ReadSelfAction input pin */
- private static final String SELF_KEYWORD = "self";
-
- public PinValueParser(EAttribute[] features, EAttribute[] editableFeatures) {
- super(features, editableFeatures);
- }
-
- public PinValueParser(EAttribute[] features) {
- super(features);
- }
-
- public PinValueParser() {
- super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
- }
-
- protected EStructuralFeature getEStructuralFeature(Object notification) {
- EStructuralFeature featureImpl = null;
- if (notification instanceof Notification) {
- Object feature = ((Notification) notification).getFeature();
- if (feature instanceof EStructuralFeature) {
- featureImpl = (EStructuralFeature) feature;
- }
- }
- return featureImpl;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
- * (java.lang.Object , int)
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- EStructuralFeature feature = getEStructuralFeature(event);
- return isValidFeature(feature);
- }
-
- @Override
- public String getEditString(IAdaptable adapter, int flags) {
- return getPrintString(adapter, flags);
- }
-
- @Override
- public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) {
- Object obj = adapter.getAdapter(EObject.class);
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(obj);
- if (editingDomain == null) {
- return UnexecutableCommand.INSTANCE;
- }
- if (obj instanceof ValuePin) {
- ValuePin pin = (ValuePin) obj;
- ValueSpecification valueSpec = pin.getValue();
- if (valueSpec != null) {
- CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); //$NON-NLS-1$
- command.compose(new CommandProxy(new SetValueSpecificationValueCommand(valueSpec, newString)));
- return command;
- }
- } else if (obj instanceof ActionInputPin) {
- ActionInputPin pin = (ActionInputPin) obj;
- Action action = pin.getFromAction();
- if (action instanceof ReadVariableAction) {
- Variable variable = ((ReadVariableAction) action).getVariable();
- if (variable != null) {
- CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); //$NON-NLS-1$
- command.compose(getModificationCommand(variable, UMLPackage.eINSTANCE.getNamedElement_Name(), newString));
- return command;
- }
- } else if (action instanceof ReadSelfAction) {
- return UnexecutableCommand.INSTANCE;
- } else if (action instanceof ValueSpecificationAction) {
- ValueSpecification valueSpec = ((ValueSpecificationAction) action).getValue();
- if (valueSpec != null) {
- CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); //$NON-NLS-1$
- command.compose(new CommandProxy(new SetValueSpecificationValueCommand(valueSpec, newString)));
- return command;
- }
- }
- }
- return UnexecutableCommand.INSTANCE;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
- * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- // ensure valueLabel is never null
- String valueLabel = " ";
- Object obj = element.getAdapter(EObject.class);
- if (obj instanceof ValuePin) {
- ValuePin pin = (ValuePin) obj;
- ValueSpecification valueSpec = pin.getValue();
- if (valueSpec != null) {
- String value = ValueSpecificationUtil.getSpecificationValue(valueSpec);
- if (value != null) {
- valueLabel = value;
- }
- }
- } else if (obj instanceof ActionInputPin) {
- ActionInputPin pin = (ActionInputPin) obj;
- Action action = pin.getFromAction();
- if (action instanceof ReadVariableAction) {
- Variable variable = ((ReadVariableAction) action).getVariable();
- if (variable != null) {
- String value = variable.getName();
- if (value != null) {
- valueLabel = value;
- }
- }
- } else if (action instanceof ReadSelfAction) {
- valueLabel = SELF_KEYWORD;
- } else if (action instanceof ValueSpecificationAction) {
- ValueSpecification valueSpec = ((ValueSpecificationAction) action).getValue();
- if (valueSpec != null) {
- String value = ValueSpecificationUtil.getSpecificationValue(valueSpec);
- if (value != null) {
- valueLabel = value;
- }
- }
- }
- }
- if (valueLabel.length() == 0) {
- valueLabel = " ";
- }
- return valueLabel;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
- * java.lang.Object)
- */
- @Override
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- EStructuralFeature feature = getEStructuralFeature(notification);
- return isValidFeature(feature);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
- * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
- */
- @Override
- public List<?> getSemanticElementsBeingParsed(EObject element) {
- List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
- if (element instanceof Pin) {
- Pin pin = (Pin) element;
- semanticElementsBeingParsed.add(pin);
- if (pin instanceof ValuePin) {
- ValueSpecification valueSpec = ((ValuePin) pin).getValue();
- if (valueSpec != null) {
- semanticElementsBeingParsed.add(valueSpec);
- }
- } else if (pin instanceof ActionInputPin) {
- Action action = ((ActionInputPin) pin).getFromAction();
- if (action != null) {
- semanticElementsBeingParsed.add(action);
- }
- if (action instanceof ReadVariableAction) {
- Variable variable = ((ReadVariableAction) action).getVariable();
- if (variable != null) {
- semanticElementsBeingParsed.add(variable);
- }
- } else if (action instanceof ValueSpecificationAction) {
- ValueSpecification valueSpec = ((ValueSpecificationAction) action).getValue();
- if (valueSpec != null) {
- semanticElementsBeingParsed.add(valueSpec);
- }
- }
- }
- }
- return semanticElementsBeingParsed;
- }
-
- /**
- * Determines if the given feature has to be taken into account in this
- * parser
- *
- * @param feature
- * the feature to test
- * @return true if is valid, false otherwise
- */
- private boolean isValidFeature(EStructuralFeature feature) {
- return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getValuePin_Value().equals(feature) || UMLPackage.eINSTANCE.getActionInputPin_FromAction().equals(feature)
- || UMLPackage.eINSTANCE.getVariableAction_Variable().equals(feature) || UMLPackage.eINSTANCE.getValueSpecificationAction_Value().equals(feature) || ValueSpecification.class.isAssignableFrom(feature.getContainerClass());
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * 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.diagram.activity.parser.custom;
+
+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.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.papyrus.uml.diagram.activity.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.diagram.common.commands.SetValueSpecificationValueCommand;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil;
+import org.eclipse.uml2.uml.Action;
+import org.eclipse.uml2.uml.ActionInputPin;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Pin;
+import org.eclipse.uml2.uml.ReadSelfAction;
+import org.eclipse.uml2.uml.ReadVariableAction;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.ValuePin;
+import org.eclipse.uml2.uml.ValueSpecification;
+import org.eclipse.uml2.uml.ValueSpecificationAction;
+import org.eclipse.uml2.uml.Variable;
+
+/**
+ * A specific parser for displaying the label of a Pin. This parser refreshes
+ * the text displayed for the Pin.
+ */
+public class PinValueParser extends MessageFormatParser implements ISemanticParser {
+
+ /** The keyword for indication a ReadSelfAction input pin */
+ private static final String SELF_KEYWORD = "self";
+
+ public PinValueParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ }
+
+ public PinValueParser(EAttribute[] features) {
+ super(features);
+ }
+
+ public PinValueParser() {
+ super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
+ }
+
+ protected EStructuralFeature getEStructuralFeature(Object notification) {
+ EStructuralFeature featureImpl = null;
+ if (notification instanceof Notification) {
+ Object feature = ((Notification) notification).getFeature();
+ if (feature instanceof EStructuralFeature) {
+ featureImpl = (EStructuralFeature) feature;
+ }
+ }
+ return featureImpl;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.papyrus.uml.diagram.sequence.parsers.AbstractParser#isAffectingEvent
+ * (java.lang.Object , int)
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ EStructuralFeature feature = getEStructuralFeature(event);
+ return isValidFeature(feature);
+ }
+
+ @Override
+ public String getEditString(IAdaptable adapter, int flags) {
+ return getPrintString(adapter, flags);
+ }
+
+ @Override
+ public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) {
+ Object obj = adapter.getAdapter(EObject.class);
+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(obj);
+ if (editingDomain == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ if (obj instanceof ValuePin) {
+ ValuePin pin = (ValuePin) obj;
+ ValueSpecification valueSpec = pin.getValue();
+ if (valueSpec != null) {
+ CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); //$NON-NLS-1$
+ command.compose(new CommandProxy(new SetValueSpecificationValueCommand(valueSpec, newString)));
+ return command;
+ }
+ } else if (obj instanceof ActionInputPin) {
+ ActionInputPin pin = (ActionInputPin) obj;
+ Action action = pin.getFromAction();
+ if (action instanceof ReadVariableAction) {
+ Variable variable = ((ReadVariableAction) action).getVariable();
+ if (variable != null) {
+ CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); //$NON-NLS-1$
+ command.compose(getModificationCommand(variable, UMLPackage.eINSTANCE.getNamedElement_Name(), newString));
+ return command;
+ }
+ } else if (action instanceof ReadSelfAction) {
+ return UnexecutableCommand.INSTANCE;
+ } else if (action instanceof ValueSpecificationAction) {
+ ValueSpecification valueSpec = ((ValueSpecificationAction) action).getValue();
+ if (valueSpec != null) {
+ CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); //$NON-NLS-1$
+ command.compose(new CommandProxy(new SetValueSpecificationValueCommand(valueSpec, newString)));
+ return command;
+ }
+ }
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser#
+ * getPrintString(org.eclipse .core.runtime.IAdaptable, int)
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ // ensure valueLabel is never null
+ String valueLabel = " ";
+ Object obj = element.getAdapter(EObject.class);
+ if (obj instanceof ValuePin) {
+ ValuePin pin = (ValuePin) obj;
+ ValueSpecification valueSpec = pin.getValue();
+ if (valueSpec != null) {
+ String value = ValueSpecificationUtil.getSpecificationValue(valueSpec, true);
+ if (value != null) {
+ valueLabel = value;
+ }
+ }
+ } else if (obj instanceof ActionInputPin) {
+ ActionInputPin pin = (ActionInputPin) obj;
+ Action action = pin.getFromAction();
+ if (action instanceof ReadVariableAction) {
+ Variable variable = ((ReadVariableAction) action).getVariable();
+ if (variable != null) {
+ String value = UMLLabelInternationalization.getInstance().getLabel(variable);
+ if (value != null) {
+ valueLabel = value;
+ }
+ }
+ } else if (action instanceof ReadSelfAction) {
+ valueLabel = SELF_KEYWORD;
+ } else if (action instanceof ValueSpecificationAction) {
+ ValueSpecification valueSpec = ((ValueSpecificationAction) action).getValue();
+ if (valueSpec != null) {
+ String value = ValueSpecificationUtil.getSpecificationValue(valueSpec);
+ if (value != null) {
+ valueLabel = value;
+ }
+ }
+ }
+ }
+ if (valueLabel.length() == 0) {
+ valueLabel = " ";
+ }
+ return valueLabel;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * areSemanticElementsAffected (org.eclipse.emf.ecore.EObject,
+ * java.lang.Object)
+ */
+ @Override
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ EStructuralFeature feature = getEStructuralFeature(notification);
+ return isValidFeature(feature);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser#
+ * getSemanticElementsBeingParsed (org.eclipse.emf.ecore.EObject)
+ */
+ @Override
+ public List<?> getSemanticElementsBeingParsed(EObject element) {
+ List<Element> semanticElementsBeingParsed = new ArrayList<Element>();
+ if (element instanceof Pin) {
+ Pin pin = (Pin) element;
+ semanticElementsBeingParsed.add(pin);
+ if (pin instanceof ValuePin) {
+ ValueSpecification valueSpec = ((ValuePin) pin).getValue();
+ if (valueSpec != null) {
+ semanticElementsBeingParsed.add(valueSpec);
+ }
+ } else if (pin instanceof ActionInputPin) {
+ Action action = ((ActionInputPin) pin).getFromAction();
+ if (action != null) {
+ semanticElementsBeingParsed.add(action);
+ }
+ if (action instanceof ReadVariableAction) {
+ Variable variable = ((ReadVariableAction) action).getVariable();
+ if (variable != null) {
+ semanticElementsBeingParsed.add(variable);
+ }
+ } else if (action instanceof ValueSpecificationAction) {
+ ValueSpecification valueSpec = ((ValueSpecificationAction) action).getValue();
+ if (valueSpec != null) {
+ semanticElementsBeingParsed.add(valueSpec);
+ }
+ }
+ }
+ }
+ return semanticElementsBeingParsed;
+ }
+
+ /**
+ * Determines if the given feature has to be taken into account in this
+ * parser
+ *
+ * @param feature
+ * the feature to test
+ * @return true if is valid, false otherwise
+ */
+ private boolean isValidFeature(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getValuePin_Value().equals(feature) || UMLPackage.eINSTANCE.getActionInputPin_FromAction().equals(feature)
+ || UMLPackage.eINSTANCE.getVariableAction_Variable().equals(feature) || UMLPackage.eINSTANCE.getValueSpecificationAction_Value().equals(feature) || ValueSpecification.class.isAssignableFrom(feature.getContainerClass());
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PostConditionConstraintLabelParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PostConditionConstraintLabelParser.java
index 0e78513fd0b..5e9a898c5ad 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PostConditionConstraintLabelParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PostConditionConstraintLabelParser.java
@@ -1,145 +1,157 @@
-/*****************************************************************************
- * 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:
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-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.IParser;
-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.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * Specific Parser for the comment, in case they have a html format.
- */
-public class PostConditionConstraintLabelParser implements IParser {
-
- private static final String CHEVRON = String.valueOf("\u00AB") + "PostCondition" + String.valueOf("\u00BB");
-
- /**
- * {@inheritDoc}
- */
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public List getSemanticElementsBeingParsed(EObject element) {
- List list = new ArrayList();
- list.add(element);
- return list;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getEditString(IAdaptable element, int flags) {
- Constraint constraint = doAdapt(element);
- if (constraint == null) {
- return "<NULL CONSTRAINT>"; //$NON-NLS-1$
- }
- return constraint.getName();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ICommand getParseCommand(IAdaptable element, String newString, int flags) {
- Constraint constraint = doAdapt(element);
- if (constraint == null) {
- return UnexecutableCommand.INSTANCE;
- }
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(constraint);
- if (editingDomain == null) {
- return UnexecutableCommand.INSTANCE;
- }
- CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Name"); //$NON-NLS-1$
- SetRequest request = new SetRequest(constraint, UMLPackage.eINSTANCE.getNamedElement_Name(), newString);
- command.compose(new SetValueCommand(request));
- return command;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- Constraint constraint = doAdapt(element);
- if (constraint == null) {
- return "<NULL CONSTRAINT>"; //$NON-NLS-1$
- }
- return CHEVRON + constraint.getName();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- if (event instanceof org.eclipse.emf.common.notify.Notification) {
- Object source = ((org.eclipse.emf.common.notify.Notification) event).getFeature();
- if (UMLPackage.eINSTANCE.getNamedElement_Name().equals(source)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IParserEditStatus isValidEditString(IAdaptable element, String editString) {
- return ParserEditStatus.EDITABLE_STATUS;
- }
-
- /**
- * Get the property associated with the given IAdaptable and the
- * memberEndIndex .
- *
- * @param element
- * the given IAdaptable
- * @return the property associated or null if it can't be found.
- */
- protected Constraint doAdapt(IAdaptable element) {
- Object obj = element.getAdapter(EObject.class);
- if (obj instanceof Constraint) {
- return (Constraint) obj;
- }
- return null;
- }
-}
+/*****************************************************************************
+ * 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:
+ * 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.diagram.activity.parser.custom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+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.IParser;
+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.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Specific Parser for the comment, in case they have a html format.
+ */
+public class PostConditionConstraintLabelParser implements IParser {
+
+ private static final String CHEVRON = String.valueOf("\u00AB") + "PostCondition" + String.valueOf("\u00BB");
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getSemanticElementsBeingParsed(EObject element) {
+ List list = new ArrayList();
+ list.add(element);
+ return list;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getEditString(IAdaptable element, int flags) {
+ Constraint constraint = doAdapt(element);
+ if (constraint == null) {
+ return "<NULL CONSTRAINT>"; //$NON-NLS-1$
+ }
+ return UMLLabelInternationalization.getInstance().getLabel(constraint);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ICommand getParseCommand(IAdaptable element, String newString, int flags) {
+ Constraint constraint = doAdapt(element);
+ if (constraint == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(constraint);
+ if (editingDomain == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ ICommand command = null;
+ 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 {
+ command = new CompositeTransactionalCommand(editingDomain, "Set Name"); //$NON-NLS-1$
+ SetRequest request = new SetRequest(constraint, UMLPackage.eINSTANCE.getNamedElement_Name(), newString);
+ command.compose(new SetValueCommand(request));
+ }
+ return command;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ Constraint constraint = doAdapt(element);
+ if (constraint == null) {
+ return "<NULL CONSTRAINT>"; //$NON-NLS-1$
+ }
+ return CHEVRON + UMLLabelInternationalization.getInstance().getLabel(constraint);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ if (event instanceof org.eclipse.emf.common.notify.Notification) {
+ Object source = ((org.eclipse.emf.common.notify.Notification) event).getFeature();
+ if (UMLPackage.eINSTANCE.getNamedElement_Name().equals(source)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IParserEditStatus isValidEditString(IAdaptable element, String editString) {
+ return ParserEditStatus.EDITABLE_STATUS;
+ }
+
+ /**
+ * Get the property associated with the given IAdaptable and the
+ * memberEndIndex .
+ *
+ * @param element
+ * the given IAdaptable
+ * @return the property associated or null if it can't be found.
+ */
+ protected Constraint doAdapt(IAdaptable element) {
+ Object obj = element.getAdapter(EObject.class);
+ if (obj instanceof Constraint) {
+ return (Constraint) obj;
+ }
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PreConditionConstraintLabelParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PreConditionConstraintLabelParser.java
index 4dec17afced..ed62ad9e95e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PreConditionConstraintLabelParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/parser/custom/PreConditionConstraintLabelParser.java
@@ -1,145 +1,157 @@
-/*****************************************************************************
- * 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:
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.parser.custom;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-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.IParser;
-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.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * Specific Parser for the comment, in case they have a html format.
- */
-public class PreConditionConstraintLabelParser implements IParser {
-
- private static final String CHEVRON = String.valueOf("\u00AB") + "PreCondition" + String.valueOf("\u00BB");
-
- /**
- * {@inheritDoc}
- */
- public boolean areSemanticElementsAffected(EObject listener, Object notification) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public List getSemanticElementsBeingParsed(EObject element) {
- List list = new ArrayList();
- list.add(element);
- return list;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getEditString(IAdaptable element, int flags) {
- Constraint constraint = doAdapt(element);
- if (constraint == null) {
- return "<NULL CONSTRAINT>"; //$NON-NLS-1$
- }
- return constraint.getName();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ICommand getParseCommand(IAdaptable element, String newString, int flags) {
- Constraint constraint = doAdapt(element);
- if (constraint == null) {
- return UnexecutableCommand.INSTANCE;
- }
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(constraint);
- if (editingDomain == null) {
- return UnexecutableCommand.INSTANCE;
- }
- CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Name"); //$NON-NLS-1$
- SetRequest request = new SetRequest(constraint, UMLPackage.eINSTANCE.getNamedElement_Name(), newString);
- command.compose(new SetValueCommand(request));
- return command;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPrintString(IAdaptable element, int flags) {
- Constraint constraint = doAdapt(element);
- if (constraint == null) {
- return "<NULL CONSTRAINT>"; //$NON-NLS-1$
- }
- return CHEVRON + constraint.getName();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isAffectingEvent(Object event, int flags) {
- if (event instanceof org.eclipse.emf.common.notify.Notification) {
- Object source = ((org.eclipse.emf.common.notify.Notification) event).getFeature();
- if (UMLPackage.eINSTANCE.getNamedElement_Name().equals(source)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IParserEditStatus isValidEditString(IAdaptable element, String editString) {
- return ParserEditStatus.EDITABLE_STATUS;
- }
-
- /**
- * Get the property associated with the given IAdaptable and the
- * memberEndIndex .
- *
- * @param element
- * the given IAdaptable
- * @return the property associated or null if it can't be found.
- */
- protected Constraint doAdapt(IAdaptable element) {
- Object obj = element.getAdapter(EObject.class);
- if (obj instanceof Constraint) {
- return (Constraint) obj;
- }
- return null;
- }
-}
+/*****************************************************************************
+ * 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:
+ * 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.diagram.activity.parser.custom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+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.IParser;
+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.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Specific Parser for the comment, in case they have a html format.
+ */
+public class PreConditionConstraintLabelParser implements IParser {
+
+ private static final String CHEVRON = String.valueOf("\u00AB") + "PreCondition" + String.valueOf("\u00BB");
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean areSemanticElementsAffected(EObject listener, Object notification) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getSemanticElementsBeingParsed(EObject element) {
+ List list = new ArrayList();
+ list.add(element);
+ return list;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getEditString(IAdaptable element, int flags) {
+ Constraint constraint = doAdapt(element);
+ if (constraint == null) {
+ return "<NULL CONSTRAINT>"; //$NON-NLS-1$
+ }
+ return UMLLabelInternationalization.getInstance().getLabel(constraint);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ICommand getParseCommand(IAdaptable element, String newString, int flags) {
+ Constraint constraint = doAdapt(element);
+ if (constraint == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(constraint);
+ if (editingDomain == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ ICommand command = null;
+ 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 {
+ command = new CompositeTransactionalCommand(editingDomain, "Set Name"); //$NON-NLS-1$
+ SetRequest request = new SetRequest(constraint, UMLPackage.eINSTANCE.getNamedElement_Name(), newString);
+ command.compose(new SetValueCommand(request));
+ }
+ return command;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getPrintString(IAdaptable element, int flags) {
+ Constraint constraint = doAdapt(element);
+ if (constraint == null) {
+ return "<NULL CONSTRAINT>"; //$NON-NLS-1$
+ }
+ return CHEVRON + UMLLabelInternationalization.getInstance().getLabel(constraint);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ if (event instanceof org.eclipse.emf.common.notify.Notification) {
+ Object source = ((org.eclipse.emf.common.notify.Notification) event).getFeature();
+ if (UMLPackage.eINSTANCE.getNamedElement_Name().equals(source)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IParserEditStatus isValidEditString(IAdaptable element, String editString) {
+ return ParserEditStatus.EDITABLE_STATUS;
+ }
+
+ /**
+ * Get the property associated with the given IAdaptable and the
+ * memberEndIndex .
+ *
+ * @param element
+ * the given IAdaptable
+ * @return the property associated or null if it can't be found.
+ */
+ protected Constraint doAdapt(IAdaptable element) {
+ Object obj = element.getAdapter(EObject.class);
+ if (obj instanceof Constraint) {
+ return (Constraint) obj;
+ }
+ return null;
+ }
+}

Back to the top