Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2015-04-28 08:18:03 +0000
committerCamille Letavernier2015-04-30 14:41:43 +0000
commitd1ad71e44d97bd56fd171e36bbb1f2ef12b74958 (patch)
tree71356e711ed27ed8f13f313f30686c6868b9c772 /plugins/infra/services/org.eclipse.papyrus.infra.services.validation
parent775979d5a7b654d75153b86f96030fcb96ed4409 (diff)
downloadorg.eclipse.papyrus-d1ad71e44d97bd56fd171e36bbb1f2ef12b74958.tar.gz
org.eclipse.papyrus-d1ad71e44d97bd56fd171e36bbb1f2ef12b74958.tar.xz
org.eclipse.papyrus-d1ad71e44d97bd56fd171e36bbb1f2ef12b74958.zip
Bug 446865: lowerValue and upperValue cardinality values not accessible
through UI https://bugs.eclipse.org/bugs/show_bug.cgi?id=446865 Correction of minor issues : - The validation is still enabled for exotic multiplicities and reports warnings (e.g. when typing 2..MAX, you will get a validation warning) -> The validation correction was done on OCL validation but not on EMF -> The EMF validation is managed by a new ValisationProvider which allow to override existing validation constraint method - When typing "*" in the Upper bound, using the XText Multiplicity editor, the editor displays "null=*" (It may also happen for other values, but it doesn't seem to be consistent) -> Wrong test in Label Provider - The Simple Multiplicity Editor doesn't properly refresh its read-only state. If you switch from a Property [1..2] to a property [1..MAX], the editor remains writable. Switching in the other direction, the editor remains read-only -> Need to refresh the read-only with the value refresh -> Manage the ExtendedMultiplicityObservableValue with a support for the dispose management Change-Id: I7b12a7fe73cd8f951535c137f15b9168a33bb93a Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net> Reviewed-on: https://git.eclipse.org/r/46642 Tested-by: Hudson CI Reviewed-by: Camille Letavernier <camille.letavernier@cea.fr>
Diffstat (limited to 'plugins/infra/services/org.eclipse.papyrus.infra.services.validation')
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java
index bcea5ff98e4..a1008a63d6d 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java
@@ -9,6 +9,7 @@
* IBM - Initial API and implementation
* Christian W. Damus (CEA) - Target EObject must be the diagnostic's first data element
* Benoit Maggi (CEA LIST) - Add an unique id as source for diagnostic
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 446865
*****************************************************************************/
@@ -33,6 +34,9 @@ import org.eclipse.emf.validation.model.IModelConstraint;
import org.eclipse.emf.validation.service.IBatchValidator;
import org.eclipse.emf.validation.service.IConstraintDescriptor;
import org.eclipse.emf.validation.service.ModelValidationService;
+import org.eclipse.uml2.uml.LiteralInteger;
+import org.eclipse.uml2.uml.LiteralUnlimitedNatural;
+import org.eclipse.uml2.uml.MultiplicityElement;
import org.eclipse.uml2.uml.util.UMLValidator;
@@ -95,6 +99,7 @@ public class EValidatorAdapter
// externally). If there is no context map, then we can't
// help it
if (!hasProcessed(eObject, context)) {
+
status = batchValidator.validate(
eObject,
new NullProgressMonitor());
@@ -119,6 +124,40 @@ public class EValidatorAdapter
}
/**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.uml2.uml.util.UMLValidator#validateMultiplicityElement_validateUpperGeLower(org.eclipse.uml2.uml.MultiplicityElement, org.eclipse.emf.common.util.DiagnosticChain, java.util.Map)
+ */
+ @Override
+ public boolean validateMultiplicityElement_validateUpperGeLower(MultiplicityElement multiplicityElement, DiagnosticChain diagnostics, Map<Object, Object> context) {
+ boolean result = false;
+ if (canCompareUpperGeLower(multiplicityElement)) {
+ result = super.validateMultiplicityElement_validateUpperGeLower(multiplicityElement, diagnostics, context);
+ }
+
+ return result;
+ }
+
+ /**
+ * This allows to define if the multiplicity element can compare the lower and the upper values (depending to the type of ValueSpecifications).
+ *
+ * @param eObject
+ * The {@link EObject} to check.
+ * @return <code>true</code> if the lower and upper can be compared (or if this is not a MultiplicityElement), <code>false</code> otherwise.
+ */
+ protected boolean canCompareUpperGeLower(final EObject eObject) {
+ boolean result = true;
+ if (eObject instanceof MultiplicityElement) {
+ final MultiplicityElement multiplicityElement = (MultiplicityElement) eObject;
+ if ((!((multiplicityElement.getLowerValue() instanceof LiteralInteger || multiplicityElement.getLowerValue() instanceof LiteralUnlimitedNatural)
+ && (multiplicityElement.getUpperValue() instanceof LiteralInteger || multiplicityElement.getUpperValue() instanceof LiteralUnlimitedNatural)))) {
+ result = false;
+ }
+ }
+ return result;
+ }
+
+ /**
* If we have a context map, record this object's <code>status</code> in it
* so that we will know later that we have processed it and its sub-tree.
*

Back to the top