diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/ConstraintCheckerService.java b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/ConstraintCheckerService.java index 2684b145c04498586a6b6c5399bd6c1ab7abf29b..cba04d76db03f2b7a0280e7628164b07a0806de9 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/ConstraintCheckerService.java +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/ConstraintCheckerService.java @@ -19,6 +19,7 @@ import static java.util.Collections.emptyList; import static java.util.Collections.unmodifiableMap; import static org.conqat.lib.commons.reflect.ReflectionUtils.performNearestClassLookup; import static org.eclipse.core.runtime.Status.OK_STATUS; +import static org.eclipse.core.runtime.jobs.Job.RUNNING; import java.util.ArrayList; import java.util.Collections; @@ -39,6 +40,7 @@ import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem; import org.fortiss.tooling.kernel.introspection.IIntrospectionItem; import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService; import org.fortiss.tooling.kernel.introspection.items.ConstraintCheckerKISSDetailsItem; +import org.fortiss.tooling.kernel.model.INamedElement; import org.fortiss.tooling.kernel.service.IConstraintCheckerService; import org.fortiss.tooling.kernel.service.IKernelIntrospectionSystemService; import org.fortiss.tooling.kernel.service.base.EObjectAwareServiceBase; @@ -57,9 +59,12 @@ public class ConstraintCheckerService extends EObjectAwareServiceBase<IConstrain Map<Class<?>, List<IConstraintChecker<EObject>>> asynchronousConstraintCheckers = new HashMap<Class<?>, List<IConstraintChecker<EObject>>>(); + Map<IConstraintChecker<? extends EObject>, String> asynchronousCheckIdentifiers = + new HashMap<IConstraintChecker<? extends EObject>, String>(); + /** Maps all constraint checkers to the last started Job, each. */ - Map<IConstraintChecker<? extends EObject>, Job> asynchronousChecks = - new HashMap<IConstraintChecker<? extends EObject>, Job>(); + Map<IConstraintChecker<? extends EObject>, Map<EObject, Job>> asynchronousCheckerJobs = + new HashMap<IConstraintChecker<? extends EObject>, Map<EObject, Job>>(); /** Returns singleton instance of the service. */ public static ConstraintCheckerService getInstance() { @@ -169,12 +174,27 @@ public class ConstraintCheckerService extends EObjectAwareServiceBase<IConstrain } for(IConstraintChecker<EObject> checker : asyncHandlers) { - Job checkerJob = asynchronousChecks.get(checker); - if(checkerJob != null && checkerJob.getThread().isAlive()) { + Map<EObject, Job> jobs = asynchronousCheckerJobs.get(checker); + if(jobs == null) { + jobs = new HashMap<EObject, Job>(); + asynchronousCheckerJobs.put(checker, jobs); + } + Job checkerJob = jobs.get(modelElement); + if(checkerJob != null && checkerJob.getState() == RUNNING) { checkerJob.cancel(); } - checkerJob = new Job("Product Line Analysis") { + String checkerIdentifier = asynchronousCheckIdentifiers.get(checker); + if(checkerIdentifier == null) { + checkerIdentifier = "Asynchronous Model Constraint Check"; + } + + String modelIdentifier = ""; + if(modelElement instanceof INamedElement) { + modelIdentifier = " on " + ((INamedElement)modelElement).getName(); + } + + checkerJob = new Job(checkerIdentifier + modelIdentifier) { @Override protected IStatus run(IProgressMonitor monitor) { @@ -187,7 +207,7 @@ public class ConstraintCheckerService extends EObjectAwareServiceBase<IConstrain return OK_STATUS; } }; - asynchronousChecks.put(checker, checkerJob); + jobs.put(modelElement, checkerJob); checkerJob.setUser(false); checkerJob.schedule(); @@ -248,7 +268,7 @@ public class ConstraintCheckerService extends EObjectAwareServiceBase<IConstrain @SuppressWarnings("unchecked") @Override public <T extends EObject> void registerAsynchronousConstraintChecker( - IConstraintChecker<T> checker, Class<T> modelElementClass) { + IConstraintChecker<T> checker, Class<T> modelElementClass, String checkerName) { if(checker == null) { return; } @@ -262,5 +282,7 @@ public class ConstraintCheckerService extends EObjectAwareServiceBase<IConstrain } checkers.add((IConstraintChecker<EObject>)checker); + + asynchronousCheckIdentifiers.put(checker, checkerName); } } diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/service/IConstraintCheckerService.java b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/service/IConstraintCheckerService.java index ef0f6fe43e3858b145ea10da6566fd0e3b00a48f..14d9302795ad4979af606b9981b83c5ab023d4b2 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/service/IConstraintCheckerService.java +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/service/IConstraintCheckerService.java @@ -92,5 +92,5 @@ public interface IConstraintCheckerService { /** Registers the given checker to be run asynchronously in the service. */ <T extends EObject> void registerAsynchronousConstraintChecker(IConstraintChecker<T> checker, - Class<T> modelElementClass); + Class<T> modelElementClass, String checkerName); }