|
|
@ -54,9 +54,11 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
private static final ImageIcon LOADING_ICON = getLoadingIcon(); |
|
|
|
private static final ImageIcon LOADING_ICON = getLoadingIcon(); |
|
|
|
public static final int TIMEOUT = 1000; |
|
|
|
public static final int TIMEOUT = 1000; |
|
|
|
|
|
|
|
|
|
|
|
private JPanel body; |
|
|
|
private final JPanel body; |
|
|
|
|
|
|
|
|
|
|
|
private final JPanel headerPanel; |
|
|
|
private final JPanel headerPanel; |
|
|
|
|
|
|
|
private UIButton detectButton; |
|
|
|
|
|
|
|
private JPanel resultSummaryPane; |
|
|
|
|
|
|
|
|
|
|
|
private final TablePanel tablePanel; |
|
|
|
private final TablePanel tablePanel; |
|
|
|
|
|
|
|
|
|
|
@ -128,7 +130,7 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
|
|
|
|
|
|
|
|
JPanel headerPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
JPanel headerPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
headerPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 12, 0)); |
|
|
|
headerPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 12, 0)); |
|
|
|
UIButton detectButton = new UIButton(buttonStatus.getDesc()) { |
|
|
|
this.detectButton = new UIButton(buttonStatus.getDesc()) { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public ButtonUI getUI() { |
|
|
|
public ButtonUI getUI() { |
|
|
|
|
|
|
|
|
|
|
@ -152,7 +154,7 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
detectButton.setForeground(Color.WHITE); |
|
|
|
detectButton.setForeground(Color.WHITE); |
|
|
|
detectButton.addActionListener(event -> { |
|
|
|
detectButton.addActionListener(event -> { |
|
|
|
if (buttonStatus.isNotExecuting()) { |
|
|
|
if (buttonStatus.isNotExecuting()) { |
|
|
|
startDetecting(detectButton); |
|
|
|
startDetecting(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
stopDetecting(detectButton); |
|
|
|
stopDetecting(detectButton); |
|
|
|
} |
|
|
|
} |
|
|
@ -165,7 +167,7 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
return headerPanel; |
|
|
|
return headerPanel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void startDetecting(UIButton detectButton) { |
|
|
|
private void startDetecting() { |
|
|
|
|
|
|
|
|
|
|
|
// 重新检测的时候需要处理一些逻辑
|
|
|
|
// 重新检测的时候需要处理一些逻辑
|
|
|
|
if (buttonStatus == EnvDetectorButtonStatus.A_NEW) { |
|
|
|
if (buttonStatus == EnvDetectorButtonStatus.A_NEW) { |
|
|
@ -173,7 +175,7 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
} |
|
|
|
} |
|
|
|
// 执行前
|
|
|
|
// 执行前
|
|
|
|
buttonStatus = buttonStatus.next(); |
|
|
|
buttonStatus = buttonStatus.next(); |
|
|
|
UIUtil.invokeLaterIfNeeded(() -> detectButton.setText(buttonStatus.getDesc())); |
|
|
|
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshHeaderPanel); |
|
|
|
detectWorker = new SwingWorker<Void, Void>() { |
|
|
|
detectWorker = new SwingWorker<Void, Void>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -218,7 +220,7 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
if (buttonStatus.isExecuting()) { |
|
|
|
if (buttonStatus.isExecuting()) { |
|
|
|
// 执行结束
|
|
|
|
// 执行结束
|
|
|
|
buttonStatus = EnvDetectorButtonStatus.A_NEW; |
|
|
|
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 */ |
|
|
|
/* table */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -394,6 +432,13 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
return tailPanel; |
|
|
|
return tailPanel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void refreshHeaderPanel() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateHeaderPanel(); |
|
|
|
|
|
|
|
pack(); |
|
|
|
|
|
|
|
repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void refresh() { |
|
|
|
private void refresh() { |
|
|
|
|
|
|
|
|
|
|
|
updateTable(this.tablePanel); |
|
|
|
updateTable(this.tablePanel); |
|
|
@ -504,4 +549,9 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
|
|
|
|
|
|
|
|
public abstract EnvDetectorButtonStatus next(); |
|
|
|
public abstract EnvDetectorButtonStatus next(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class EnvDetectorHeaderPanel extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|