From 05bc512fbcd44cb276885db5e1298bbf2a6d6898 Mon Sep 17 00:00:00 2001 From: Vincent Aravantinos <aravantinos@fortiss.org> Date: Tue, 31 May 2016 15:10:10 +0000 Subject: [PATCH] moves autocheck setting to UI to be able to trigger refresh right after refs 2558 --- .../kernel/ui/util/ConstraintsUIUtils.java | 41 ++++++++++++++++++- .../kernel/utils/ConstraintsUtils.java | 18 +------- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/ConstraintsUIUtils.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/ConstraintsUIUtils.java index b862a0af3..8c392a9e3 100644 --- a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/ConstraintsUIUtils.java +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/ConstraintsUIUtils.java @@ -23,6 +23,10 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Function; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.emf.ecore.EObject; import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.swt.SWT; @@ -38,6 +42,7 @@ import org.fortiss.tooling.kernel.model.constraints.IConstraint; import org.fortiss.tooling.kernel.model.constraints.IConstraintVerificationStatus; import org.fortiss.tooling.kernel.model.constraints.OutdatedVerificationStatus; import org.fortiss.tooling.kernel.model.constraints.SuccessVerificationStatus; +import org.fortiss.tooling.kernel.service.IConstraintVerificationService; import org.fortiss.tooling.kernel.ui.service.IConstraintVerificationUIService; import org.fortiss.tooling.kernel.utils.EcoreUtils; @@ -47,7 +52,7 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils; * @author aravantinos * @author $Author$ * @version $Rev$ - * @ConQAT.Rating YELLOW Hash: 78F01666E8A80F35348F431EC6DA2895 + * @ConQAT.Rating YELLOW Hash: BC06655274768325481A442F27DF78E6 */ public class ConstraintsUIUtils { @@ -153,9 +158,15 @@ public class ConstraintsUIUtils { * trigger a refresh of the marker decorations. */ public static void triggerMarkersRefresh(IConstraint c) { + List<IConstrained> constraineds = new ArrayList<IConstrained>(); + // We first collect separately the constrained objects because - unfortunately for some + // unknown reason - the following notification seems to trigger a change of the list of + // constrained objects. for(ConstrainedWithChecksum cwc : c.getConstrainedsWithChecksum()) { - EcoreUtils.postRefreshNotification(cwc.getConstrained()); + constraineds.add(cwc.getConstrained()); } + constraineds.stream().forEach( + constrained -> EcoreUtils.postRefreshNotification(constrained)); } /** @@ -254,4 +265,30 @@ public class ConstraintsUIUtils { return ConstraintsUIUtils.getColor(cstr); } } + + /** + * @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) { + Display display = Display.getDefault(); + Job job = new Job("Constraint verification job") { + @Override + protected IStatus run(IProgressMonitor monitor) { + synchronized(c) { + IConstraintVerificationService.INSTANCE.verify(c); + } + display.asyncExec(() -> ConstraintsUIUtils.triggerMarkersRefresh(c)); + return Status.OK_STATUS; + } + }; + job.schedule(); + } + } } 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 53128546c..6221d2251 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 @@ -25,7 +25,6 @@ import org.fortiss.tooling.kernel.model.constraints.IConstraint; import org.fortiss.tooling.kernel.model.constraints.IConstraintVerificationStatus; 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. @@ -33,7 +32,7 @@ import org.fortiss.tooling.kernel.service.IConstraintVerificationService; * @author aravantinos * @author $Author$ * @version $Rev$ - * @ConQAT.Rating YELLOW Hash: 27D40FEDD5231775D755E9781D21C0C9 + * @ConQAT.Rating YELLOW Hash: BE54EACBF815B71F4C67D93ACFB3DA97 */ public class ConstraintsUtils { /** @@ -125,19 +124,4 @@ public class ConstraintsUtils { setVerificationStatus(c, 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