Browse Source

REPORT-73586【设计器环境监测】远程连接失败后,触发手动检测,检测失败

和产品沟通,添加交互存在检测过程的异常
feature/x
Harrison 2 years ago
parent
commit
2d322f3ad2
  1. 7
      designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java
  2. 6
      designer-base/src/main/java/com/fr/env/detect/bean/DetectorResult.java
  3. 5
      designer-base/src/main/java/com/fr/env/detect/bean/DetectorStatus.java
  4. 2
      designer-base/src/main/java/com/fr/env/detect/thowable/ThrowableLogAppender.java
  5. 32
      designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java

7
designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java vendored

@ -10,6 +10,7 @@ import com.fr.env.detect.impl.JarInconsistentDetector;
import com.fr.env.detect.impl.JarLackDetector;
import com.fr.env.detect.thowable.ThrowableLogAppender;
import com.fr.env.detect.thowable.ThrowableStore;
import com.fr.log.FineLoggerFactory;
import com.fr.value.NotNullLazyValue;
import org.jetbrains.annotations.NotNull;
@ -86,7 +87,13 @@ public class DetectorBridge {
@NotNull
public DetectorResult detect(DetectorType type) {
try {
return detectorManager.getValue().detect(type);
} catch (Exception e) {
FineLoggerFactory.getLogger().error("detect failed", e);
// 返回成功的信息, 别影响前端的展示。
return DetectorResult.unknown(type);
}
}
/**

6
designer-base/src/main/java/com/fr/env/detect/bean/DetectorResult.java vendored

@ -31,6 +31,12 @@ public class DetectorResult {
this.log = log;
}
public static DetectorResult unknown(DetectorType type) {
DetectorResult result = new DetectorResult(type);
result.status = DetectorStatus.UNKNOWN;
return result;
}
public static DetectorResult normal(DetectorType type) {
DetectorResult result = new DetectorResult(type);

5
designer-base/src/main/java/com/fr/env/detect/bean/DetectorStatus.java vendored

@ -14,4 +14,9 @@ public enum DetectorStatus {
* 异常
*/
EXCEPTION,
/**
* 未知
*/
UNKNOWN,
}

2
designer-base/src/main/java/com/fr/env/detect/thowable/ThrowableLogAppender.java vendored

@ -60,6 +60,8 @@ public class ThrowableLogAppender extends AbstractAppender {
public void enable() {
// 初始化一下,别出问题
logHandler.getHandler().start();
FRLogger.getLogger().addExtendLogAppender(logHandler);
}

32
designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java vendored

@ -21,6 +21,7 @@ import com.fr.env.detect.base.EnvDetectorConfig;
import com.fr.env.detect.bean.DetectorResult;
import com.fr.env.detect.bean.DetectorStatus;
import com.fr.env.detect.bean.DetectorType;
import com.fr.log.FineLoggerFactory;
import org.jetbrains.annotations.NotNull;
import javax.swing.BorderFactory;
@ -55,6 +56,7 @@ public class EnvDetectorDialog extends JDialog {
private static final int TIMEOUT = 1000;
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;
@ -177,7 +179,7 @@ public class EnvDetectorDialog extends JDialog {
}
// 执行前
buttonStatus = buttonStatus.next();
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshHeaderPanel);
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshHeader);
detectWorker = new SwingWorker<Void, Void>() {
@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);
DetectorType type = item.getType();
@ -208,7 +210,7 @@ public class EnvDetectorDialog extends JDialog {
// 只有还在运行中,才会真正的刷新面板
if (buttonStatus.isExecuting()) {
// 在刷新一下面板
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refresh);
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshBody);
currentDetectIndex++;
}
@ -219,10 +221,15 @@ public class EnvDetectorDialog extends JDialog {
@Override
protected void done() {
try {
this.get();
if (buttonStatus.isExecuting()) {
// 执行结束
buttonStatus = EnvDetectorButtonStatus.A_NEW;
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshHeaderPanel);
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);
}
// 刷新一下面板-开始执行啦
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refresh);
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshBody);
}
private void stopDetecting(UIButton detectButton) {
@ -251,7 +258,7 @@ public class EnvDetectorDialog extends JDialog {
// 刷新按钮
detectButton.setText(buttonStatus.getDesc());
// 刷新面板
refresh();
refreshBody();
});
}
@ -265,7 +272,7 @@ public class EnvDetectorDialog extends JDialog {
this.resultSummaryPane.setLayout(new BorderLayout(5, 0));
Boolean success = model.getResults()
.map((e) -> {
if (e.getStatus() == DetectorStatus.NORMAL) {
if (e != null && e.getStatus() == DetectorStatus.NORMAL) {
return Boolean.TRUE;
}
return Boolean.FALSE;
@ -361,11 +368,13 @@ public class EnvDetectorDialog extends JDialog {
}
statusPanel.add(infoPanel, BorderLayout.WEST);
// 如果结果是检测出的异常,则出现详细信息。
if (result.getStatus() == DetectorStatus.EXCEPTION) {
JPanel detailPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
{
detailPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
UILabel detailLabel = new UILabel(Toolkit.i18nText("Fine_Designer_Look_Detail"));
detailLabel.setForeground(new Color(65, 155, 249));
detailLabel.setForeground(DETAIL_FONT_COLOR);
detailLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent mouseEvent) {
@ -383,9 +392,10 @@ public class EnvDetectorDialog extends JDialog {
});
detailPanel.add(detailLabel, BorderLayout.CENTER);
}
statusPanel.add(detailPanel, BorderLayout.CENTER);
}
}
return statusPanel;
}
@ -434,14 +444,14 @@ public class EnvDetectorDialog extends JDialog {
return tailPanel;
}
private void refreshHeaderPanel() {
private void refreshHeader() {
updateHeaderPanel();
pack();
repaint();
}
private void refresh() {
private void refreshBody() {
updateTable(this.tablePanel);
pack();

Loading…
Cancel
Save