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

makes the verification run as a separate job

prevents verification to run when IDs are not ready

refs 2553
parent 1038545e
No related branches found
No related tags found
No related merge requests found
package org.fortiss.tooling.kernel.ui.internal;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
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.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.TreeIterator;
......@@ -14,6 +19,7 @@ import org.eclipse.emf.ecore.util.EContentAdapter;
import org.fortiss.tooling.kernel.ToolingKernelActivator;
import org.fortiss.tooling.kernel.extension.IEclipseResourcePostLoadProvider;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.model.IIdLabeled;
import org.fortiss.tooling.kernel.model.constraints.ConstrainedWithChecksum;
import org.fortiss.tooling.kernel.model.constraints.ConstraintsPackage;
import org.fortiss.tooling.kernel.model.constraints.IConstrained;
......@@ -36,7 +42,7 @@ import org.fortiss.tooling.kernel.utils.LoggingUtils;
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: CB3FC2AF2D45F99291553F698F3957B9
* @ConQAT.Rating YELLOW Hash: B1153D3AA79E3F3AC9F21E26A8BC2E99
*/
public final class ConstraintVerificationUIService extends
EObjectAwareServiceBase<IConstraintVerifierUI<IConstraint>> implements
......@@ -146,17 +152,30 @@ public final class ConstraintVerificationUIService extends
if(constraint.isAutoCheck()) {
ITopLevelElement modelContext =
IPersistencyService.INSTANCE.getTopLevelElementFor(constraint);
modelContext.runAsCommand(new Runnable() {
// IDs can be in a bad state if the notification is triggered during some
// composition
if(!checkIDs(modelContext)) {
return false;
}
(new Job("Constraint verification job") {
@Override
public void run() {
IConstraintVerificationService.INSTANCE.verify(constraint);
protected IStatus run(IProgressMonitor monitor) {
synchronized(constraint) {
modelContext.runAsCommand(new Runnable() {
@Override
public void run() {
IConstraintVerificationService.INSTANCE.verify(constraint);
}
});
}
ConstraintsUIUtils.triggerMarkersRefresh(constraint);
return Status.OK_STATUS;
}
});
}).schedule();
} else if(!(constraint.getVerificationStatus() instanceof OutdatedVerificationStatus)) {
ConstraintsUtils.createOutdatedVerificationStatus(constraint);
ConstraintsUIUtils.triggerMarkersRefresh(constraint);
}
// Update GUI markers
ConstraintsUIUtils.triggerMarkersRefresh(constraint);
return true;
}
return false;
......@@ -220,6 +239,18 @@ public final class ConstraintVerificationUIService extends
return false;
}
/** Checks whether elements necessitating IDs do have an ID. */
private static boolean checkIDs(ITopLevelElement modelContext) {
Iterator<EObject> i = modelContext.getRootModelElement().eAllContents();
while(i.hasNext()) {
EObject eo = i.next();
if(eo instanceof IIdLabeled && ((IIdLabeled)eo).getId() <= 0) {
return false;
}
}
return true;
}
/** {@inheritDoc} */
@Override
protected String getExtensionPointName() {
......
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