Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2019-04-15 08:51:49 -0400
committerNicolas FAUVERGUE2019-04-17 03:43:44 -0400
commit093f64a4df811c7a941d623e100b8b8d607be6eb (patch)
treee8b7dc155ed8450819182c91481b90d7cd6beaef
parent4de7be31b8ad1677de2456a8aa1d01f75121f7d3 (diff)
downloadorg.eclipse.papyrus-093f64a4df811c7a941d623e100b8b8d607be6eb.tar.gz
org.eclipse.papyrus-093f64a4df811c7a941d623e100b8b8d607be6eb.tar.xz
org.eclipse.papyrus-093f64a4df811c7a941d623e100b8b8d607be6eb.zip
Bug 540815 - [Property view] Upper multiplicity is not correctly updated
- Remove value specification, if value corresponds to default Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr> Change-Id: Ibef2c95155561e2f8f86ff96fee052e52c435996
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/SetMultiplicityCommand.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/SetMultiplicityCommand.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/SetMultiplicityCommand.java
index 51116298e31..bf0460e3cc1 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/SetMultiplicityCommand.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/SetMultiplicityCommand.java
@@ -18,6 +18,8 @@ package org.eclipse.papyrus.uml.tools.commands;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
@@ -39,6 +41,11 @@ import org.eclipse.uml2.uml.UMLPackage;
*/
public class SetMultiplicityCommand extends CompoundCommand {
+ /**
+ * Optimize lower/upper bounds, if they correspond to the default value
+ */
+ private static final String OPTIMIZE_BOUNDS = "optimize bounds";
+
private int[] lowerUpper;
private MultiplicityElement element;
@@ -46,6 +53,10 @@ public class SetMultiplicityCommand extends CompoundCommand {
static EStructuralFeature lowerFeature = UMLPackage.eINSTANCE.getMultiplicityElement_Lower();
static EStructuralFeature upperFeature = UMLPackage.eINSTANCE.getMultiplicityElement_Upper();
+
+ static EStructuralFeature lowerFeatureVS = UMLPackage.eINSTANCE.getMultiplicityElement_LowerValue();
+
+ static EStructuralFeature upperFeatureVS = UMLPackage.eINSTANCE.getMultiplicityElement_UpperValue();
public SetMultiplicityCommand(MultiplicityElement element, String value) {
if (element == null) {
@@ -69,6 +80,8 @@ public class SetMultiplicityCommand extends CompoundCommand {
append(getSetCommand(lowerFeature, lower));
append(getSetCommand(upperFeature, upper));
+ append(getOptimizeCommand(lowerFeature, lowerFeatureVS));
+ append(getOptimizeCommand(upperFeature, upperFeatureVS));
}
private Command getSetCommand(EStructuralFeature feature, int value) {
@@ -84,6 +97,22 @@ public class SetMultiplicityCommand extends CompoundCommand {
return null;
}
+ private Command getOptimizeCommand(EStructuralFeature feature, EStructuralFeature featureVS) {
+ // can't use a SetRequest, since we need to evaluate the eIsSet after the first command has
+ // been executed
+ return new RecordingCommand(TransactionUtil.getEditingDomain(element), OPTIMIZE_BOUNDS) {
+
+ @Override
+ protected void doExecute() {
+ if (!element.eIsSet(feature)) {
+ // feature corresponds to default value, remove value specification
+ // see bug 540815
+ element.eSet(featureVS, null);
+ }
+ }
+ };
+ }
+
@Override
public boolean canExecute() {
return element != null && lowerUpper != null && lowerUpper.length == 2 && super.canExecute();

Back to the top