From: jsimomaa Date: Fri, 7 Dec 2018 06:53:37 +0000 (+0200) Subject: Update SCL-editor annotations asynchronously X-Git-Tag: v1.43.0~136^2~244 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=2ece1c391a481d1ee1f2285189fc41ebad248a2d;p=simantics%2Fplatform.git Update SCL-editor annotations asynchronously gitlab #225 Change-Id: Iec9fce3432b701b540526b1bd95ada331252951a --- diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLAnnotationModel.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLAnnotationModel.java index 43e4a80a0..1a0e7bcc7 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLAnnotationModel.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/SCLAnnotationModel.java @@ -3,6 +3,7 @@ package org.simantics.scl.ui.editor2; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.concurrent.ForkJoinPool; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.Position; @@ -38,15 +39,19 @@ public class SCLAnnotationModel extends AnnotationModel { }; private void updateAnnotations() { - Failable result = repository.getModule(input.getModuleName(), updateListener); - if(result instanceof Failure) { - Failure failure = (Failure)result; - setAnnotations(Arrays.asList(failure.errors)); - } - else if(result == DoesNotExist.INSTANCE) - setAnnotations(Collections.emptyList()); - else - setAnnotations(Arrays.asList(result.getResult().getWarnings())); + ForkJoinPool.commonPool().submit(() -> { + if (!connected) + return; + Failable result = repository.getModule(input.getModuleName(), updateListener); + if(result instanceof Failure) { + Failure failure = (Failure)result; + setAnnotations(Arrays.asList(failure.errors)); + } + else if(result == DoesNotExist.INSTANCE) + setAnnotations(Collections.emptyList()); + else + setAnnotations(Arrays.asList(result.getResult().getWarnings())); + }); } protected void setAnnotations(List errors) {