|
|
@ -21,6 +21,7 @@ import com.fr.env.detect.base.EnvDetectorConfig; |
|
|
|
import com.fr.env.detect.bean.DetectorResult; |
|
|
|
import com.fr.env.detect.bean.DetectorResult; |
|
|
|
import com.fr.env.detect.bean.DetectorStatus; |
|
|
|
import com.fr.env.detect.bean.DetectorStatus; |
|
|
|
import com.fr.env.detect.bean.DetectorType; |
|
|
|
import com.fr.env.detect.bean.DetectorType; |
|
|
|
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.BorderFactory; |
|
|
@ -55,6 +56,7 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
private static final int TIMEOUT = 1000; |
|
|
|
private static final int TIMEOUT = 1000; |
|
|
|
|
|
|
|
|
|
|
|
private static final Color SUCCESS_COLOR = new Color(22, 193, 83); |
|
|
|
private static final Color SUCCESS_COLOR = new Color(22, 193, 83); |
|
|
|
|
|
|
|
private static final Color DETAIL_FONT_COLOR = new Color(65, 155, 249); |
|
|
|
|
|
|
|
|
|
|
|
private final JPanel body; |
|
|
|
private final JPanel body; |
|
|
|
|
|
|
|
|
|
|
@ -177,7 +179,7 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
} |
|
|
|
} |
|
|
|
// 执行前
|
|
|
|
// 执行前
|
|
|
|
buttonStatus = buttonStatus.next(); |
|
|
|
buttonStatus = buttonStatus.next(); |
|
|
|
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshHeaderPanel); |
|
|
|
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshHeader); |
|
|
|
detectWorker = new SwingWorker<Void, Void>() { |
|
|
|
detectWorker = new SwingWorker<Void, Void>() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -192,7 +194,7 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 刷新一下面板-开始执行啦
|
|
|
|
// 刷新一下面板-开始执行啦
|
|
|
|
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refresh); |
|
|
|
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshBody); |
|
|
|
|
|
|
|
|
|
|
|
EnvDetectorItem item = items.get(i); |
|
|
|
EnvDetectorItem item = items.get(i); |
|
|
|
DetectorType type = item.getType(); |
|
|
|
DetectorType type = item.getType(); |
|
|
@ -208,7 +210,7 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
// 只有还在运行中,才会真正的刷新面板
|
|
|
|
// 只有还在运行中,才会真正的刷新面板
|
|
|
|
if (buttonStatus.isExecuting()) { |
|
|
|
if (buttonStatus.isExecuting()) { |
|
|
|
// 在刷新一下面板
|
|
|
|
// 在刷新一下面板
|
|
|
|
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refresh); |
|
|
|
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshBody); |
|
|
|
currentDetectIndex++; |
|
|
|
currentDetectIndex++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -219,10 +221,15 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void done() { |
|
|
|
protected void done() { |
|
|
|
|
|
|
|
|
|
|
|
if (buttonStatus.isExecuting()) { |
|
|
|
try { |
|
|
|
// 执行结束
|
|
|
|
this.get(); |
|
|
|
buttonStatus = EnvDetectorButtonStatus.A_NEW; |
|
|
|
if (buttonStatus.isExecuting()) { |
|
|
|
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshHeaderPanel); |
|
|
|
// 执行结束
|
|
|
|
|
|
|
|
buttonStatus = EnvDetectorButtonStatus.A_NEW; |
|
|
|
|
|
|
|
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshHeader); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().error("detect failed", e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -236,7 +243,7 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
e.setResult(null); |
|
|
|
e.setResult(null); |
|
|
|
} |
|
|
|
} |
|
|
|
// 刷新一下面板-开始执行啦
|
|
|
|
// 刷新一下面板-开始执行啦
|
|
|
|
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refresh); |
|
|
|
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshBody); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void stopDetecting(UIButton detectButton) { |
|
|
|
private void stopDetecting(UIButton detectButton) { |
|
|
@ -251,7 +258,7 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
// 刷新按钮
|
|
|
|
// 刷新按钮
|
|
|
|
detectButton.setText(buttonStatus.getDesc()); |
|
|
|
detectButton.setText(buttonStatus.getDesc()); |
|
|
|
// 刷新面板
|
|
|
|
// 刷新面板
|
|
|
|
refresh(); |
|
|
|
refreshBody(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -265,7 +272,7 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
this.resultSummaryPane.setLayout(new BorderLayout(5, 0)); |
|
|
|
this.resultSummaryPane.setLayout(new BorderLayout(5, 0)); |
|
|
|
Boolean success = model.getResults() |
|
|
|
Boolean success = model.getResults() |
|
|
|
.map((e) -> { |
|
|
|
.map((e) -> { |
|
|
|
if (e.getStatus() == DetectorStatus.NORMAL) { |
|
|
|
if (e != null && e.getStatus() == DetectorStatus.NORMAL) { |
|
|
|
return Boolean.TRUE; |
|
|
|
return Boolean.TRUE; |
|
|
|
} |
|
|
|
} |
|
|
|
return Boolean.FALSE; |
|
|
|
return Boolean.FALSE; |
|
|
@ -361,30 +368,33 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
} |
|
|
|
} |
|
|
|
statusPanel.add(infoPanel, BorderLayout.WEST); |
|
|
|
statusPanel.add(infoPanel, BorderLayout.WEST); |
|
|
|
|
|
|
|
|
|
|
|
JPanel detailPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
// 如果结果是检测出的异常,则出现详细信息。
|
|
|
|
{ |
|
|
|
if (result.getStatus() == DetectorStatus.EXCEPTION) { |
|
|
|
detailPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); |
|
|
|
JPanel detailPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
UILabel detailLabel = new UILabel(Toolkit.i18nText("Fine_Designer_Look_Detail")); |
|
|
|
{ |
|
|
|
detailLabel.setForeground(new Color(65, 155, 249)); |
|
|
|
detailPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); |
|
|
|
detailLabel.addMouseListener(new MouseAdapter() { |
|
|
|
UILabel detailLabel = new UILabel(Toolkit.i18nText("Fine_Designer_Look_Detail")); |
|
|
|
@Override |
|
|
|
detailLabel.setForeground(DETAIL_FONT_COLOR); |
|
|
|
public void mouseClicked(MouseEvent mouseEvent) { |
|
|
|
detailLabel.addMouseListener(new MouseAdapter() { |
|
|
|
NotificationDialogProperties properties = new NotificationDialogProperties((Frame) EnvDetectorDialog.this.getOwner(), Toolkit.i18nText("Fine-Design_Basic_Detect_Notification_Title")); |
|
|
|
@Override |
|
|
|
Stream<DetectorResult> results = model.getResults(); |
|
|
|
public void mouseClicked(MouseEvent mouseEvent) { |
|
|
|
List<NotificationModel> notificationModels = results |
|
|
|
NotificationDialogProperties properties = new NotificationDialogProperties((Frame) EnvDetectorDialog.this.getOwner(), Toolkit.i18nText("Fine-Design_Basic_Detect_Notification_Title")); |
|
|
|
.filter(Objects::nonNull) |
|
|
|
Stream<DetectorResult> results = model.getResults(); |
|
|
|
.filter((e) -> e.getStatus() == DetectorStatus.EXCEPTION) |
|
|
|
List<NotificationModel> notificationModels = results |
|
|
|
.map(DetectorUtil::convert2Notification) |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
.filter((e) -> e.getStatus() == DetectorStatus.EXCEPTION) |
|
|
|
|
|
|
|
.map(DetectorUtil::convert2Notification) |
|
|
|
NotificationDialog dialog = new NotificationDialog(properties, notificationModels); |
|
|
|
.collect(Collectors.toList()); |
|
|
|
dialog.open(); |
|
|
|
|
|
|
|
} |
|
|
|
NotificationDialog dialog = new NotificationDialog(properties, notificationModels); |
|
|
|
}); |
|
|
|
dialog.open(); |
|
|
|
detailPanel.add(detailLabel, BorderLayout.CENTER); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
detailPanel.add(detailLabel, BorderLayout.CENTER); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
statusPanel.add(detailPanel, BorderLayout.CENTER); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
statusPanel.add(detailPanel, BorderLayout.CENTER); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return statusPanel; |
|
|
|
return statusPanel; |
|
|
|
} |
|
|
|
} |
|
|
@ -434,14 +444,14 @@ public class EnvDetectorDialog extends JDialog { |
|
|
|
return tailPanel; |
|
|
|
return tailPanel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void refreshHeaderPanel() { |
|
|
|
private void refreshHeader() { |
|
|
|
|
|
|
|
|
|
|
|
updateHeaderPanel(); |
|
|
|
updateHeaderPanel(); |
|
|
|
pack(); |
|
|
|
pack(); |
|
|
|
repaint(); |
|
|
|
repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void refresh() { |
|
|
|
private void refreshBody() { |
|
|
|
|
|
|
|
|
|
|
|
updateTable(this.tablePanel); |
|
|
|
updateTable(this.tablePanel); |
|
|
|
pack(); |
|
|
|
pack(); |
|
|
|