From f44f361644f1440e819b4b33b8884f3c9df8d128 Mon Sep 17 00:00:00 2001 From: Vincent Aravantinos <aravantinos@fortiss.org> Date: Fri, 22 Apr 2016 12:57:16 +0000 Subject: [PATCH] adds setAutoCheck to ConstraintsUtils refs 2553 --- .../trunk/model/kernel.ecore | 6 +++++- .../tooling/kernel/utils/ConstraintsUtils.java | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/org.fortiss.tooling.kernel/trunk/model/kernel.ecore b/org.fortiss.tooling.kernel/trunk/model/kernel.ecore index bf75fcde0..5e6c7ee7e 100644 --- a/org.fortiss.tooling.kernel/trunk/model/kernel.ecore +++ b/org.fortiss.tooling.kernel/trunk/model/kernel.ecore @@ -136,7 +136,11 @@ upperBound="-1" eType="#//constraints/ConstrainedWithChecksum" containment="true"/> <eStructuralFeatures xsi:type="ecore:EReference" name="verificationStatus" eType="#//constraints/IConstraintVerificationStatus" containment="true"/> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="autoCheck" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="autoCheck" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"> + <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> + <details key="documentation" value="<b>Do not set this field directly!</b> Use ConstraintsUtils.setAutoCheck instead: this will trigger the check immediatly if you set <code>autocheck</code> to <code>true</code>."/> + </eAnnotations> + </eStructuralFeatures> </eClassifiers> <eClassifiers xsi:type="ecore:EClass" name="IConstraintVerificationStatus" abstract="true" interface="true"> diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/ConstraintsUtils.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/ConstraintsUtils.java index 91c2858f0..17ed3b20b 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/ConstraintsUtils.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/ConstraintsUtils.java @@ -24,6 +24,7 @@ import org.fortiss.tooling.kernel.model.constraints.IConstrained; import org.fortiss.tooling.kernel.model.constraints.IConstraint; import org.fortiss.tooling.kernel.model.constraints.OutdatedVerificationStatus; import org.fortiss.tooling.kernel.model.constraints.SuccessVerificationStatus; +import org.fortiss.tooling.kernel.service.IConstraintVerificationService; /** * Utility methods for dealing with constraints. @@ -31,7 +32,7 @@ import org.fortiss.tooling.kernel.model.constraints.SuccessVerificationStatus; * @author aravantinos * @author $Author$ * @version $Rev$ - * @ConQAT.Rating YELLOW Hash: 1325BAE0A0C28B3F093D89D912BE1AFF + * @ConQAT.Rating YELLOW Hash: 16AE39268EA05749A3262EFCF0601695 */ public class ConstraintsUtils { /** @@ -108,4 +109,19 @@ public class ConstraintsUtils { c.setVerificationStatus(status); return status; } + + /** + * @param c + * @param value + * Sets the <code>autoCheck</code> field of <code>c</code> to <code>value</code> + * <b>and triggers the verification of <code>c</code> if <code>value</code> is + * <code>true</code>.</b> + * Use this instead of directly setting <code>autocheck</code>. + */ + public static void setAutoCheck(IConstraint c, boolean value) { + c.setAutoCheck(value); + if(value) { + IConstraintVerificationService.INSTANCE.verify(c); + } + } } -- GitLab