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; package org.fortiss.tooling.kernel.ui.internal;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; 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.Adapter;
import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.common.util.TreeIterator;
...@@ -14,6 +19,7 @@ import org.eclipse.emf.ecore.util.EContentAdapter; ...@@ -14,6 +19,7 @@ import org.eclipse.emf.ecore.util.EContentAdapter;
import org.fortiss.tooling.kernel.ToolingKernelActivator; import org.fortiss.tooling.kernel.ToolingKernelActivator;
import org.fortiss.tooling.kernel.extension.IEclipseResourcePostLoadProvider; import org.fortiss.tooling.kernel.extension.IEclipseResourcePostLoadProvider;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; 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.ConstrainedWithChecksum;
import org.fortiss.tooling.kernel.model.constraints.ConstraintsPackage; import org.fortiss.tooling.kernel.model.constraints.ConstraintsPackage;
import org.fortiss.tooling.kernel.model.constraints.IConstrained; import org.fortiss.tooling.kernel.model.constraints.IConstrained;
...@@ -36,7 +42,7 @@ import org.fortiss.tooling.kernel.utils.LoggingUtils; ...@@ -36,7 +42,7 @@ import org.fortiss.tooling.kernel.utils.LoggingUtils;
* @author aravantinos * @author aravantinos
* @author $Author$ * @author $Author$
* @version $Rev$ * @version $Rev$
* @ConQAT.Rating YELLOW Hash: CB3FC2AF2D45F99291553F698F3957B9 * @ConQAT.Rating YELLOW Hash: B1153D3AA79E3F3AC9F21E26A8BC2E99
*/ */
public final class ConstraintVerificationUIService extends public final class ConstraintVerificationUIService extends
EObjectAwareServiceBase<IConstraintVerifierUI<IConstraint>> implements EObjectAwareServiceBase<IConstraintVerifierUI<IConstraint>> implements
...@@ -146,17 +152,30 @@ public final class ConstraintVerificationUIService extends ...@@ -146,17 +152,30 @@ public final class ConstraintVerificationUIService extends
if(constraint.isAutoCheck()) { if(constraint.isAutoCheck()) {
ITopLevelElement modelContext = ITopLevelElement modelContext =
IPersistencyService.INSTANCE.getTopLevelElementFor(constraint); IPersistencyService.INSTANCE.getTopLevelElementFor(constraint);
// 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
protected IStatus run(IProgressMonitor monitor) {
synchronized(constraint) {
modelContext.runAsCommand(new Runnable() { modelContext.runAsCommand(new Runnable() {
@Override @Override
public void run() { public void run() {
IConstraintVerificationService.INSTANCE.verify(constraint); IConstraintVerificationService.INSTANCE.verify(constraint);
} }
}); });
}
ConstraintsUIUtils.triggerMarkersRefresh(constraint);
return Status.OK_STATUS;
}
}).schedule();
} else if(!(constraint.getVerificationStatus() instanceof OutdatedVerificationStatus)) { } else if(!(constraint.getVerificationStatus() instanceof OutdatedVerificationStatus)) {
ConstraintsUtils.createOutdatedVerificationStatus(constraint); ConstraintsUtils.createOutdatedVerificationStatus(constraint);
}
// Update GUI markers
ConstraintsUIUtils.triggerMarkersRefresh(constraint); ConstraintsUIUtils.triggerMarkersRefresh(constraint);
}
return true; return true;
} }
return false; return false;
...@@ -220,6 +239,18 @@ public final class ConstraintVerificationUIService extends ...@@ -220,6 +239,18 @@ public final class ConstraintVerificationUIService extends
return false; 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} */ /** {@inheritDoc} */
@Override @Override
protected String getExtensionPointName() { protected String getExtensionPointName() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment