From 674b9a3a8ab3169e78f687d4da5e88a46c330447 Mon Sep 17 00:00:00 2001 From: akallio Date: Wed, 15 Jun 2011 08:10:53 +0000 Subject: [PATCH] connection fix to awt thread git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@21353 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/ui/editor/DiagramViewer.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/DiagramViewer.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/DiagramViewer.java index b0b181cf..8e412512 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/DiagramViewer.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/DiagramViewer.java @@ -65,6 +65,8 @@ import org.simantics.sysdyn.ui.elements2.connections.SysdynConnectionClass; import org.simantics.sysdyn.ui.properties.SysdynPropertyPage; import org.simantics.utils.datastructures.hints.HintContext; import org.simantics.utils.datastructures.hints.IHintContext; +import org.simantics.utils.threads.AWTThread; +import org.simantics.utils.threads.ThreadUtils; /** * @author Tuukka Lehtonen @@ -79,13 +81,24 @@ public class DiagramViewer extends org.simantics.modeling.ui.diagramEditor.Diagr public void createPartControl(Composite parent) { super.createPartControl(parent); - ElementPainter ep = canvasContext.getSingleItem(ElementPainter.class); - for(IElement e : sourceDiagram.getElements()) { - if(e.getElementClass().getId().contains("Connection")){ - ep.update(e); + + ThreadUtils.asyncExec(AWTThread.getThreadAccess(), new Runnable() { + + @Override + public void run() { + if (isDisposed()) { + return; + } else { + ElementPainter ep = canvasContext.getSingleItem(ElementPainter.class); + for(IElement e : sourceDiagram.getElements()) { + if(e.getElementClass().getId().contains("Connection")){ + ep.update(e); + } + } + scheduleZoomToFit(); + } } - } - scheduleZoomToFit(); + }); } @Override -- 2.47.1