Browse Source

Pull request #14913: REPORT-135687 修复框体大小&添加清理

Merge in DESIGN/design from ~VITO/c-design:fbp/release to fbp/release

* commit 'cd67e9b355f7b3cb2137d21abca23efc482efb43':
  无jira任务 代码质量
  REPORT-135687 修复框体大小&添加清理
fbp/release
vito-刘恒霖 2 months ago
parent
commit
d4ab9a8d7b
  1. 23
      designer-base/src/main/java/com/fr/design/remote/ui/debug/RemoteDesignNetWorkAction.java
  2. 80
      designer-base/src/main/java/com/fr/design/remote/ui/debug/RemoteDesignNetWorkTablePane.java

23
designer-base/src/main/java/com/fr/design/remote/ui/debug/RemoteDesignNetWorkAction.java

@ -1,7 +1,7 @@
package com.fr.design.remote.ui.debug; package com.fr.design.remote.ui.debug;
import com.fine.theme.utils.FineUIScale;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
@ -10,6 +10,11 @@ import com.fr.workspace.WorkContext;
import javax.swing.JDialog; import javax.swing.JDialog;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import static com.fine.theme.utils.FineUIScale.createScaleDimension;
import static com.fine.theme.utils.FineUIScale.unscale;
/** /**
* 远程设计网络调试 * 远程设计网络调试
@ -28,19 +33,29 @@ public class RemoteDesignNetWorkAction extends UpdateAction {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (WorkContext.getCurrent().isLocal()) { if (WorkContext.getCurrent().isLocal()) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
"Remote Design NetWork can't show on local environment.");
return; return;
} }
JDialog jDialog = new JDialog(DesignerContext.getDesignerFrame(), TITLE); JDialog jDialog = new JDialog(DesignerContext.getDesignerFrame(), TITLE);
jDialog.setSize(calculatePaneDimension()); jDialog.setSize(calculatePaneDimension());
jDialog.add(new RemoteDesignNetWorkTablePane()); RemoteDesignNetWorkTablePane netWorkPane = new RemoteDesignNetWorkTablePane();
jDialog.add(netWorkPane);
jDialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
netWorkPane.clear();
super.windowClosing(e);
}
});
GUICoreUtils.centerWindow(jDialog); GUICoreUtils.centerWindow(jDialog);
jDialog.setVisible(true); jDialog.setVisible(true);
} }
private static Dimension calculatePaneDimension() { private static Dimension calculatePaneDimension() {
DesignerFrame parent = DesignerContext.getDesignerFrame(); DesignerFrame parent = DesignerContext.getDesignerFrame();
return new Dimension((int) (FineUIScale.unscale(parent.getWidth()) * 0.8), return createScaleDimension((int) (unscale(parent.getWidth()) * 0.8),
(int) (FineUIScale.unscale(parent.getHeight()) * 0.6)); (int) (unscale(parent.getHeight()) * 0.6));
} }
} }

80
designer-base/src/main/java/com/fr/design/remote/ui/debug/RemoteDesignNetWorkTablePane.java

@ -1,7 +1,9 @@
package com.fr.design.remote.ui.debug; package com.fr.design.remote.ui.debug;
import com.fanruan.workplace.http.debug.RequestInfo; import com.fanruan.workplace.http.debug.RequestInfo;
import com.fine.theme.icon.LazyIcon;
import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.formdev.flatlaf.util.ScaledEmptyBorder;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
@ -10,6 +12,8 @@ import com.fr.workspace.WorkContext;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.JToolBar;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel; import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer; import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn; import javax.swing.table.TableColumn;
@ -34,14 +38,36 @@ public class RemoteDesignNetWorkTablePane extends JPanel {
private JTable uiTable; private JTable uiTable;
private DefaultTableModel model; private DefaultTableModel model;
private final Listener<RequestInfo> remoteDesignDebugListener = new Listener<RequestInfo>() {
@Override
public void on(Event event, RequestInfo requestInfo) {
model.addRow(new Object[]{
requestInfo.getStatus(),
dateFormat(requestInfo.getDate()),
requestInfo.getPath().substring(WorkContext.getCurrent().getPath().length() - 1),
requestInfo.getConsume() + "ms",
simpleSize(requestInfo.getRequestSize()),
simpleSize(requestInfo.getResponseSize()),
requestInfo.getSendBody(),
requestInfo.getReturnBody(),
});
adjustColumnWidths(uiTable);
}
};
public RemoteDesignNetWorkTablePane() { public RemoteDesignNetWorkTablePane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBorder(new ScaledEmptyBorder(10, 10, 10, 10)); setBorder(new ScaledEmptyBorder(10, 10, 10, 10));
initComponent(); initComponent();
initListener(); addListener();
} }
private void initComponent() { private void initComponent() {
initTable();
initToolBar();
}
private void initTable() {
model = new DefaultTableModel(); model = new DefaultTableModel();
model.addColumn("status"); model.addColumn("status");
model.addColumn("time"); model.addColumn("time");
@ -55,23 +81,43 @@ public class RemoteDesignNetWorkTablePane extends JPanel {
add(new JScrollPane(uiTable), BorderLayout.CENTER); add(new JScrollPane(uiTable), BorderLayout.CENTER);
} }
private void initListener() { private void initToolBar() {
EventDispatcher.listen(REMOTE_HTTP_REQUEST, new Listener<RequestInfo>() { JToolBar jToolBar = new JToolBar();
@Override jToolBar.setBorder(new EmptyBorder(5, 0, 10, 0));
public void on(Event event, RequestInfo requestInfo) { UIButton run = new UIButton(new LazyIcon("run"));
model.addRow(new Object[]{ UIButton forbid = new UIButton(new LazyIcon("forbid"));
requestInfo.getStatus(), UIButton refresh = new UIButton(new LazyIcon("remove"));
dateFormat(requestInfo.getDate()), run.setEnabled(false);
requestInfo.getPath().substring(WorkContext.getCurrent().getPath().length() - 1), run.setToolTipText("Start Record");
requestInfo.getConsume() + "ms", run.addActionListener(e -> {
simpleSize(requestInfo.getRequestSize()), addListener();
simpleSize(requestInfo.getResponseSize()), run.setEnabled(false);
requestInfo.getSendBody(), forbid.setEnabled(true);
requestInfo.getReturnBody(), });
}); forbid.setToolTipText("Stop Record");
adjustColumnWidths(uiTable); forbid.addActionListener(e -> {
} EventDispatcher.stopListen(remoteDesignDebugListener);
run.setEnabled(true);
forbid.setEnabled(false);
}); });
refresh.setToolTipText("Clear Records");
refresh.addActionListener(e -> model.setRowCount(0));
jToolBar.add(run);
jToolBar.add(forbid);
jToolBar.add(refresh);
add(jToolBar, BorderLayout.NORTH);
}
/**
* 清理监听
*/
public void clear() {
EventDispatcher.stopListen(remoteDesignDebugListener);
}
private void addListener() {
EventDispatcher.listen(REMOTE_HTTP_REQUEST, remoteDesignDebugListener);
} }
private static void adjustColumnWidths(JTable table) { private static void adjustColumnWidths(JTable table) {

Loading…
Cancel
Save