Browse Source

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

Merge in DESIGN/design from ~HARRISON/design:feature/x to feature/x

* commit '750e5ea5435f03d92996d93d298e0d8eea65c8ce':
  REPORT-73586【设计器环境监测】远程连接失败后,触发手动检测,检测失败 更新注释
  REPORT-73586【设计器环境监测】远程连接失败后,触发手动检测,检测失败 和产品沟通,添加交互存在检测过程的异常
feature/x
Harrison 2 years ago
parent
commit
5c82cb8a1f
  1. 9
      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. 78
      designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java

9
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.impl.JarLackDetector;
import com.fr.env.detect.thowable.ThrowableLogAppender; import com.fr.env.detect.thowable.ThrowableLogAppender;
import com.fr.env.detect.thowable.ThrowableStore; import com.fr.env.detect.thowable.ThrowableStore;
import com.fr.log.FineLoggerFactory;
import com.fr.value.NotNullLazyValue; import com.fr.value.NotNullLazyValue;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -86,7 +87,13 @@ public class DetectorBridge {
@NotNull @NotNull
public DetectorResult detect(DetectorType type) { public DetectorResult detect(DetectorType type) {
return detectorManager.getValue().detect(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; 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) { public static DetectorResult normal(DetectorType type) {
DetectorResult result = new DetectorResult(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, 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() { public void enable() {
// 初始化一下,别出问题
logHandler.getHandler().start();
FRLogger.getLogger().addExtendLogAppender(logHandler); FRLogger.getLogger().addExtendLogAppender(logHandler);
} }

78
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.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();

Loading…
Cancel
Save