Skip to content
Snippets Groups Projects
Commit 05bc512f authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

moves autocheck setting to UI to be able to trigger refresh right after

refs 2558
parent ac167663
No related branches found
No related tags found
No related merge requests found
......@@ -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();
}
}
}
......@@ -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);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment