From: Tuukka Lehtonen Date: Mon, 31 Aug 2020 11:06:16 +0000 (+0300) Subject: Introduce DebuggerCanvasProxy to avoid compile time AWT toolkit init X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=90506d09a405fb20380a41bb7c89fb9c510f2d42;p=simantics%2Fplatform.git Introduce DebuggerCanvasProxy to avoid compile time AWT toolkit init gitlab #593 Change-Id: Ie625f8bc7becbce47f7d035ba6f73eec0ba5566c (cherry picked from commit c8112ea7b21b56ef632d80765a7f4d113a7d3468) --- diff --git a/bundles/org.simantics.debug.graphical/scl/Simantics/GraphicalDebugger.scl b/bundles/org.simantics.debug.graphical/scl/Simantics/GraphicalDebugger.scl index 7a23274c4..0542beb1d 100644 --- a/bundles/org.simantics.debug.graphical/scl/Simantics/GraphicalDebugger.scl +++ b/bundles/org.simantics.debug.graphical/scl/Simantics/GraphicalDebugger.scl @@ -1,6 +1,6 @@ import "Simantics/DB" -importJava "org.simantics.debug.graphical.DebuggerCanvas" where +importJava "org.simantics.debug.graphical.DebuggerCanvasProxy" where data GraphDebugger setStatementFilter :: GraphDebugger -> (Statement -> Boolean) -> () diff --git a/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/DebuggerCanvasProxy.java b/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/DebuggerCanvasProxy.java new file mode 100644 index 000000000..bf7a73887 --- /dev/null +++ b/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/DebuggerCanvasProxy.java @@ -0,0 +1,32 @@ +package org.simantics.debug.graphical; + +import org.simantics.db.Resource; +import org.simantics.scl.runtime.function.Function; + +/** + * Simantics/GraphicalDebugger SCL API to avoid undesired AWT + * toolkit initialization. + * + * @author Tuukka Lehtonen + */ +public class DebuggerCanvasProxy { + + DebuggerCanvas canvas; + + public void setStatementFilter(@SuppressWarnings("rawtypes") Function statementFilter) { + canvas.setStatementFilter(statementFilter); + } + + public void removeStatementFilter() { + canvas.removeStatementFilter(); + } + + public void addResource(Resource resource) { + canvas.addResource(resource); + } + + public DebuggerCanvasProxy(DebuggerCanvas canvas) { + this.canvas = canvas; + } + +} diff --git a/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/GraphicalDebugger.java b/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/GraphicalDebugger.java index 9091a27f9..81844e4ae 100644 --- a/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/GraphicalDebugger.java +++ b/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/GraphicalDebugger.java @@ -11,7 +11,7 @@ import javax.swing.JFrame; public class GraphicalDebugger { - public static DebuggerCanvas newGraphDebugger() { + public static DebuggerCanvasProxy newGraphDebugger() { final JFrame frame = new JFrame(); frame.setTitle("Graph debugger"); Toolkit tk = Toolkit.getDefaultToolkit(); @@ -53,7 +53,7 @@ public class GraphicalDebugger { }); frame.setVisible(true); - return canvas; + return new DebuggerCanvasProxy(canvas); } }