From c8112ea7b21b56ef632d80765a7f4d113a7d3468 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Mon, 31 Aug 2020 14:06:16 +0300 Subject: [PATCH] Introduce DebuggerCanvasProxy to avoid compile time AWT toolkit init gitlab #593 Change-Id: Ie625f8bc7becbce47f7d035ba6f73eec0ba5566c --- .../scl/Simantics/GraphicalDebugger.scl | 2 +- .../debug/graphical/DebuggerCanvasProxy.java | 32 +++++++++++++++++++ .../debug/graphical/GraphicalDebugger.java | 4 +-- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/DebuggerCanvasProxy.java 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); } } -- 2.47.1