From 8561268d74d5934248b9095310f9ed8d39f760b3 Mon Sep 17 00:00:00 2001 From: Harrison Date: Fri, 10 Jun 2022 14:13:56 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-73335=E3=80=90=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E7=8E=AF=E5=A2=83=E7=9B=91=E6=B5=8B=E3=80=91=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E6=A3=80=E6=B5=8B=E5=AE=8C=E6=88=90=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E6=96=87=E5=AD=97=E6=8F=90=E7=A4=BA=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1=20=E5=92=8C=E4=BA=A7=E5=93=81=E6=B2=9F=E9=80=9A?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E4=BA=A4=E4=BA=92=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/env/detect/ui/EnvDetectorDialog.java | 62 +++++++++++++++++-- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java b/designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java index 96120e317..2cde3dd89 100644 --- a/designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java +++ b/designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java @@ -54,9 +54,11 @@ public class EnvDetectorDialog extends JDialog { private static final ImageIcon LOADING_ICON = getLoadingIcon(); public static final int TIMEOUT = 1000; - private JPanel body; + private final JPanel body; private final JPanel headerPanel; + private UIButton detectButton; + private JPanel resultSummaryPane; private final TablePanel tablePanel; @@ -128,7 +130,7 @@ public class EnvDetectorDialog extends JDialog { JPanel headerPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); headerPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 12, 0)); - UIButton detectButton = new UIButton(buttonStatus.getDesc()) { + this.detectButton = new UIButton(buttonStatus.getDesc()) { @Override public ButtonUI getUI() { @@ -152,7 +154,7 @@ public class EnvDetectorDialog extends JDialog { detectButton.setForeground(Color.WHITE); detectButton.addActionListener(event -> { if (buttonStatus.isNotExecuting()) { - startDetecting(detectButton); + startDetecting(); } else { stopDetecting(detectButton); } @@ -165,7 +167,7 @@ public class EnvDetectorDialog extends JDialog { return headerPanel; } - private void startDetecting(UIButton detectButton) { + private void startDetecting() { // 重新检测的时候需要处理一些逻辑 if (buttonStatus == EnvDetectorButtonStatus.A_NEW) { @@ -173,7 +175,7 @@ public class EnvDetectorDialog extends JDialog { } // 执行前 buttonStatus = buttonStatus.next(); - UIUtil.invokeLaterIfNeeded(() -> detectButton.setText(buttonStatus.getDesc())); + UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshHeaderPanel); detectWorker = new SwingWorker() { @Override @@ -218,7 +220,7 @@ public class EnvDetectorDialog extends JDialog { if (buttonStatus.isExecuting()) { // 执行结束 buttonStatus = EnvDetectorButtonStatus.A_NEW; - UIUtil.invokeLaterIfNeeded(() -> detectButton.setText(buttonStatus.getDesc())); + UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshHeaderPanel); } } }; @@ -251,6 +253,42 @@ public class EnvDetectorDialog extends JDialog { }); } + private void updateHeaderPanel() { + + // 刷新按钮 + detectButton.setText(buttonStatus.getDesc()); + if (buttonStatus == EnvDetectorButtonStatus.A_NEW) { + this.resultSummaryPane = new JPanel(); + this.resultSummaryPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + this.resultSummaryPane.setLayout(new BorderLayout(5, 0)); + Boolean success = model.getResults() + .map((e) -> { + if (e.getStatus() == DetectorStatus.NORMAL) { + return Boolean.TRUE; + } + return Boolean.FALSE; + }).reduce((a, b) -> a && b) + .orElse(Boolean.FALSE); + + if (success) { + resultSummaryPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Detect_Result_Label")), BorderLayout.WEST); + UILabel successLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Detect_Result_Success")); + successLabel.setForeground(Color.GREEN); + resultSummaryPane.add(successLabel, BorderLayout.CENTER); + } else { + resultSummaryPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Exception")), BorderLayout.WEST); + UILabel resultLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Detect_Result_Error")); + resultLabel.setForeground(Color.RED); + resultSummaryPane.add(resultLabel, BorderLayout.CENTER); + } + this.headerPanel.add(BorderLayout.CENTER, resultSummaryPane); + } else { + if (resultSummaryPane != null) { + this.headerPanel.remove(resultSummaryPane); + } + } + } + /* table */ @@ -394,6 +432,13 @@ public class EnvDetectorDialog extends JDialog { return tailPanel; } + private void refreshHeaderPanel() { + + updateHeaderPanel(); + pack(); + repaint(); + } + private void refresh() { updateTable(this.tablePanel); @@ -504,4 +549,9 @@ public class EnvDetectorDialog extends JDialog { public abstract EnvDetectorButtonStatus next(); } + + private class EnvDetectorHeaderPanel extends JPanel { + + + } }