Browse Source

Merge pull request #803 in DESIGN/design from ~RICHIE/design:release/10.0 to release/10.0

* commit '61f08810a96dcf12cf3cc78812b615476108cfec':
  KERNEL-445 调试窗口独立出来+增加重载资源文件的按钮
bugfix/10.0
richie 6 years ago
parent
commit
754f128997
  1. 48
      designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java

48
designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java

@ -2,6 +2,10 @@ package com.fr.design.ui;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.web.struct.AssembleComponent; import com.fr.web.struct.AssembleComponent;
import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.BrowserPreferences; import com.teamdev.jxbrowser.chromium.BrowserPreferences;
@ -16,6 +20,8 @@ import com.teamdev.jxbrowser.chromium.swing.BrowserView;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/** /**
* @author richie * @author richie
@ -39,17 +45,29 @@ public class ModernUIPane<T> extends BasicPane {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
BrowserPreferences.setChromiumSwitches("--disable-google-traffic"); BrowserPreferences.setChromiumSwitches("--disable-google-traffic");
if (DesignerEnvManager.getEnvManager().isOpenDebug()) { if (DesignerEnvManager.getEnvManager().isOpenDebug()) {
JSplitPane splitPane = new JSplitPane(); UIToolbar toolbar = new UIToolbar();
add(splitPane, BorderLayout.CENTER); add(toolbar, BorderLayout.NORTH);
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); UIButton openDebugButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Open_Debug_Window"));
splitPane.setDividerLocation(500); toolbar.add(openDebugButton);
UIButton reloadButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Reload"));
toolbar.add(reloadButton);
openDebugButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showDebuggerDialog();
}
});
reloadButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
browser.reloadIgnoringCache();
}
});
BrowserPreferences.setChromiumSwitches("--remote-debugging-port=9222"); BrowserPreferences.setChromiumSwitches("--remote-debugging-port=9222");
initializeBrowser(); initializeBrowser();
splitPane.setLeftComponent(new BrowserView(browser)); add(new BrowserView(browser), BorderLayout.CENTER);
Browser debugger = new Browser();
debugger.loadURL(browser.getRemoteDebuggingURL());
BrowserView debuggerView = new BrowserView(debugger);
splitPane.setRightComponent(debuggerView);
} else { } else {
initializeBrowser(); initializeBrowser();
add(new BrowserView(browser), BorderLayout.CENTER); add(new BrowserView(browser), BorderLayout.CENTER);
@ -57,6 +75,18 @@ public class ModernUIPane<T> extends BasicPane {
} }
} }
private void showDebuggerDialog() {
JDialog dialog = new JDialog(SwingUtilities.getWindowAncestor(this));
Browser debugger = new Browser();
BrowserView debuggerView = new BrowserView(debugger);
dialog.add(debuggerView, BorderLayout.CENTER);
dialog.setSize(new Dimension(800, 400));
GUICoreUtils.centerWindow(dialog);
dialog.setVisible(true);
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
debugger.loadURL(browser.getRemoteDebuggingURL());
}
private void initializeBrowser() { private void initializeBrowser() {
browser = new Browser(); browser = new Browser();
// 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的 // 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的

Loading…
Cancel
Save