From a119a7b16e6a5e712c2f9331d42f1d6a01cd3c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Thu, 10 Jun 2021 09:07:01 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-7934=20win10=E5=AF=8C=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E7=9A=84jxbrowser=E7=BB=84=E4=BB=B6=E4=BD=BF=E7=94=A8LIGHTWEIG?= =?UTF-8?q?HT=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/ui/ModernUIPane.java | 29 ++++++++++++------- .../richText/VanChartRichEditorPane.java | 5 +++- .../richText/VanChartRichTextDialog.java | 2 +- .../richText/VanChartRichTextPane.java | 2 +- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java b/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java index 0afe2ccd31..084820a13e 100644 --- a/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java +++ b/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java @@ -8,6 +8,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.web.struct.AssembleComponent; import com.teamdev.jxbrowser.chromium.Browser; +import com.teamdev.jxbrowser.chromium.BrowserType; import com.teamdev.jxbrowser.chromium.JSValue; import com.teamdev.jxbrowser.chromium.events.LoadListener; import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; @@ -18,11 +19,11 @@ import com.teamdev.jxbrowser.chromium.swing.BrowserView; import javax.swing.JDialog; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; +import java.util.Map; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.Map; /** * @author richie @@ -37,11 +38,11 @@ public class ModernUIPane extends BasicPane { private String variable = "data"; private String expression = "update()"; - private ModernUIPane() { - initialize(); + private ModernUIPane(BrowserType browserType) { + initialize(browserType); } - private void initialize() { + private void initialize(BrowserType browserType) { if (browser == null) { setLayout(new BorderLayout()); Assistant.addChromiumSwitches("--disable-google-traffic"); @@ -76,10 +77,10 @@ public class ModernUIPane extends BasicPane { } }); Assistant.addChromiumSwitches("--remote-debugging-port=9222"); - initializeBrowser(); + initializeBrowser(browserType); add(new BrowserView(browser), BorderLayout.CENTER); } else { - initializeBrowser(); + initializeBrowser(browserType); add(new BrowserView(browser), BorderLayout.CENTER); } } @@ -97,8 +98,8 @@ public class ModernUIPane extends BasicPane { debugger.loadURL(browser.getRemoteDebuggingURL()); } - private void initializeBrowser() { - browser = new Browser(); + private void initializeBrowser(BrowserType browserType) { + browser = new Browser(browserType); // 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的 browser.addScriptContextListener(new ScriptContextAdapter() { @Override @@ -145,14 +146,22 @@ public class ModernUIPane extends BasicPane { public T update() { JSValue jsValue = browser.executeJavaScriptAndReturnValue("window." + namespace + "." + expression); if (jsValue.isObject()) { - return (T)jsValue.asJavaObject(); + return (T) jsValue.asJavaObject(); } return null; } public static class Builder { - private ModernUIPane pane = new ModernUIPane<>(); + private ModernUIPane pane; + + public Builder() { + this(BrowserType.HEAVYWEIGHT); + } + + public Builder(BrowserType browserType) { + this.pane = new ModernUIPane<>(browserType); + } public Builder prepare(ScriptContextListener contextListener) { pane.browser.addScriptContextListener(contextListener); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java index 312c24e84b..f1d7bfcbf6 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java @@ -20,8 +20,10 @@ import com.fr.plugin.chart.custom.CustomDefinition; import com.fr.plugin.chart.custom.type.CustomPlotType; import com.fr.plugin.chart.type.TextAlign; import com.fr.stable.StringUtils; +import com.fr.third.org.apache.commons.lang3.SystemUtils; import com.fr.van.chart.designer.PlotFactory; import com.teamdev.jxbrowser.chromium.Browser; +import com.teamdev.jxbrowser.chromium.BrowserType; import com.teamdev.jxbrowser.chromium.JSValue; import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; @@ -152,7 +154,8 @@ public class VanChartRichEditorPane { } public static ModernUIPane initPane(VanChartRichEditorModel model) { - return new ModernUIPane.Builder() + BrowserType type = SystemUtils.IS_OS_WINDOWS_10 ? BrowserType.LIGHTWEIGHT : BrowserType.HEAVYWEIGHT; + return new ModernUIPane.Builder(type) .prepare(new ScriptContextAdapter() { public void onScriptContextCreated(ScriptContextEvent event) { browser = event.getBrowser(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextDialog.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextDialog.java index 993c4bc2ea..509055842a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextDialog.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextDialog.java @@ -10,7 +10,7 @@ import java.awt.Frame; public class VanChartRichTextDialog extends BasicDialog { - public static final Dimension DEFAULT = new Dimension(960, 800); + public static final Dimension DEFAULT = new Dimension(960, 700); public VanChartRichTextDialog(Frame parent, BasicPane pane) { super(parent, pane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java index b6bce1145f..8b3d063960 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java @@ -20,7 +20,7 @@ public class VanChartRichTextPane extends BasicBeanPane { private static final int FIELD_PANE_H = 270; private static final int RICH_EDITOR_W = 940; - private static final int RICH_EDITOR_H = 460; + private static final int RICH_EDITOR_H = 400; private VanChartFieldListPane fieldListPane; private VanChartFieldAttrPane fieldAttrPane;