Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2016-06-06 12:41:21 +0000
committerGerrit Code Review @ Eclipse.org2016-06-06 14:35:12 +0000
commit33ab90d0d82924112278af88930a1049d9da7067 (patch)
tree4f3b9fda34405f4e84f070623e6baa687527b89f /plugins/uml
parentc58930bcc5a0be0176df2ce296e338ec991ced26 (diff)
downloadorg.eclipse.papyrus-33ab90d0d82924112278af88930a1049d9da7067.tar.gz
org.eclipse.papyrus-33ab90d0d82924112278af88930a1049d9da7067.tar.xz
org.eclipse.papyrus-33ab90d0d82924112278af88930a1049d9da7067.zip
Bug 495280 - [XText editor] Cannot more class attributes, if multiplicity != [1]
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contributions/PropertyXtextDirectEditorConfiguration.java5
-rw-r--r--plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/MultiplicityXTextParserUtils.java53
2 files changed, 43 insertions, 15 deletions
diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contributions/PropertyXtextDirectEditorConfiguration.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contributions/PropertyXtextDirectEditorConfiguration.java
index a64cc62dcd7..0cc04c7d43c 100644
--- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contributions/PropertyXtextDirectEditorConfiguration.java
+++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.property.xtext.ui/src/org/eclipse/papyrus/uml/textedit/property/xtext/ui/contributions/PropertyXtextDirectEditorConfiguration.java
@@ -138,7 +138,10 @@ public class PropertyXtextDirectEditorConfiguration extends DefaultXtextDirectEd
if (propertyRuleObject.getMultiplicity() != null) {
// Manage the lower and the upper value specifications
- updateCommand.add(updateMultiplicityCommand(provider, property, propertyRuleObject));
+ ICommand updateMultiplicity = updateMultiplicityCommand(provider, property, propertyRuleObject);
+ if (updateMultiplicity != null) {
+ updateCommand.add(updateMultiplicity);
+ }
}
if (propertyRuleObject.getDefault() != null) {
diff --git a/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/MultiplicityXTextParserUtils.java b/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/MultiplicityXTextParserUtils.java
index 34e6079283d..7c51bc4b756 100644
--- a/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/MultiplicityXTextParserUtils.java
+++ b/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/MultiplicityXTextParserUtils.java
@@ -53,15 +53,28 @@ public class MultiplicityXTextParserUtils {
*/
public static ICommand updateOneMultiplicityCommand(final IElementEditService provider, final EObject eObject, final String bound) {
final CompositeCommand compositeCommand = new CompositeCommand("Multiplicity update");
+ CompositeCommand updateLower, updateUpper;
if (UNLIMITED_KEYWORD.equals(bound)) {
// The bound filled is the '*' character
- compositeCommand.add(updateLowerValueSpecificationMultiplicityCommand(provider, eObject, "0"));
- compositeCommand.add(updateUpperValueSpecificationMultiplicityCommand(provider, eObject, "-1"));
+ updateLower = updateLowerValueSpecificationMultiplicityCommand(provider, eObject, "0"); //$NON-NLS-1$
+ updateUpper = updateUpperValueSpecificationMultiplicityCommand(provider, eObject, "-1"); //$NON-NLS-1$
} else {
- compositeCommand.add(updateLowerValueSpecificationMultiplicityCommand(provider, eObject, bound));
- compositeCommand.add(updateUpperValueSpecificationMultiplicityCommand(provider, eObject, bound));
+ updateLower = updateLowerValueSpecificationMultiplicityCommand(provider, eObject, bound);
+ updateUpper = updateUpperValueSpecificationMultiplicityCommand(provider, eObject, bound);
+ }
+ if (!updateLower.isEmpty()) {
+ compositeCommand.add(updateLower);
+ }
+ if (!updateUpper.isEmpty()) {
+ compositeCommand.add(updateUpper);
+ }
+
+ if (compositeCommand.isEmpty()) {
+ return null;
+ }
+ else {
+ return compositeCommand.reduce();
}
- return compositeCommand;
}
/**
@@ -80,15 +93,27 @@ public class MultiplicityXTextParserUtils {
public static ICommand updateTwoMultiplicityCommand(final IElementEditService provider, final EObject eObject, final String lowerBound, final String upperBound) {
final CompositeCommand compositeCommand = new CompositeCommand("Multiplicity update");
- compositeCommand.add(updateLowerValueSpecificationMultiplicityCommand(provider, eObject, lowerBound));
+ CompositeCommand updateLower = updateLowerValueSpecificationMultiplicityCommand(provider, eObject, lowerBound);
+ if (!updateLower.isEmpty()) {
+ compositeCommand.add(updateLower);
+ }
- if (UNLIMITED_KEYWORD.equals(upperBound)) {
- // The upper bound filled is the '*' character
- compositeCommand.add(updateUpperValueSpecificationMultiplicityCommand(provider, eObject, "-1"));
- } else {
- compositeCommand.add(updateUpperValueSpecificationMultiplicityCommand(provider, eObject, upperBound));
+ // The upper bound filled is the '*' character
+ String upperBoundVal = UNLIMITED_KEYWORD.equals(upperBound) ?
+ "-1" : //$NON-NLS-1$
+ upperBound;
+
+ CompositeCommand updateUpper = updateUpperValueSpecificationMultiplicityCommand(provider, eObject, upperBoundVal);
+ if (!updateUpper.isEmpty()) {
+ compositeCommand.add(updateUpper);
+ }
+
+ if (compositeCommand.isEmpty()) {
+ return null;
+ }
+ else {
+ return compositeCommand.reduce();
}
- return compositeCommand;
}
/**
@@ -102,7 +127,7 @@ public class MultiplicityXTextParserUtils {
* The bound string representation.
* @return The command to update the lower multiplicity.
*/
- private static ICommand updateLowerValueSpecificationMultiplicityCommand(final IElementEditService provider, final EObject eObject, final String bound) {
+ private static CompositeCommand updateLowerValueSpecificationMultiplicityCommand(final IElementEditService provider, final EObject eObject, final String bound) {
final CompositeCommand compositeCommand = new CompositeCommand("Lower Multiplicity update");
ValueSpecification newLowerValueSpecification = (ValueSpecification) eObject.eGet(UMLPackage.eINSTANCE.getMultiplicityElement_LowerValue());
@@ -142,7 +167,7 @@ public class MultiplicityXTextParserUtils {
* The bound string representation.
* @return The command to update the upper multiplicity.
*/
- private static ICommand updateUpperValueSpecificationMultiplicityCommand(final IElementEditService provider, final EObject eObject, final String bound) {
+ private static CompositeCommand updateUpperValueSpecificationMultiplicityCommand(final IElementEditService provider, final EObject eObject, final String bound) {
final CompositeCommand compositeCommand = new CompositeCommand("Upper Multiplicity update");
ValueSpecification newUpperValueSpecification = (ValueSpecification) eObject.eGet(UMLPackage.eINSTANCE.getMultiplicityElement_UpperValue());

Back to the top