Browse Source

Pull request #4547: KERNEL-7934 win10富文本的jxbrowser组件使用LIGHTWEIGHT渲染

Merge in DESIGN/design from ~BJORN/design:feature/10.0 to feature/10.0

* commit 'a119a7b16e6a5e712c2f9331d42f1d6a01cd3c64':
  KERNEL-7934 win10富文本的jxbrowser组件使用LIGHTWEIGHT渲染
feature/10.0
Bjorn 4 years ago
parent
commit
43c59eb56d
  1. 29
      designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java
  2. 5
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java
  3. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextDialog.java
  4. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java

29
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<T> 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<T> 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<T> 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<T> 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<T> {
private ModernUIPane<T> pane = new ModernUIPane<>();
private ModernUIPane<T> pane;
public Builder() {
this(BrowserType.HEAVYWEIGHT);
}
public Builder(BrowserType browserType) {
this.pane = new ModernUIPane<>(browserType);
}
public Builder<T> prepare(ScriptContextListener contextListener) {
pane.browser.addScriptContextListener(contextListener);

5
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<VanChartRichEditorModel> initPane(VanChartRichEditorModel model) {
return new ModernUIPane.Builder<VanChartRichEditorModel>()
BrowserType type = SystemUtils.IS_OS_WINDOWS_10 ? BrowserType.LIGHTWEIGHT : BrowserType.HEAVYWEIGHT;
return new ModernUIPane.Builder<VanChartRichEditorModel>(type)
.prepare(new ScriptContextAdapter() {
public void onScriptContextCreated(ScriptContextEvent event) {
browser = event.getBrowser();

2
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);

2
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java

@ -20,7 +20,7 @@ public class VanChartRichTextPane extends BasicBeanPane<AttrTooltipContent> {
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;

Loading…
Cancel
Save