From d828819b5fc926823ed9b9a1d0d67a4e8e2970cd Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 14 Jun 2022 14:49:31 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-73283=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=E4=B8=AA?= =?UTF-8?q?=E5=88=ABjar=E5=BC=82=E5=B8=B8=E6=97=B6=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E8=A7=A6=E5=8F=91=E8=87=AA=E5=8A=A8=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=20=E6=94=B9=E4=B8=80=E4=B8=AA=E5=9B=BD=E9=99=85=E5=8C=96?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/env/detect/impl/JarInconsistentDetector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/env/detect/impl/JarInconsistentDetector.java b/designer-base/src/main/java/com/fr/env/detect/impl/JarInconsistentDetector.java index 8cfc988a95..2a744046a1 100644 --- a/designer-base/src/main/java/com/fr/env/detect/impl/JarInconsistentDetector.java +++ b/designer-base/src/main/java/com/fr/env/detect/impl/JarInconsistentDetector.java @@ -136,7 +136,7 @@ public class JarInconsistentDetector extends AbstractExceptionDetector { return DetectorResult.exception(type(), new ExceptionTips(new Message.Simple(tipsMessage)), new ExceptionSolution(new Message.Link(Toolkit.i18nText(type().getSolutionLocale()), DetectorConstants.JAR_HELP_LINK), null), - ExceptionLog.create(type().getLogLocale() + message)); + ExceptionLog.create(Toolkit.i18nText(type().getLogLocale()) + message)); } private Map groupBy(List localInfos) { From 0f8406f3c4442ec7b11f352163f5eefe4a0a9731 Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 14 Jun 2022 16:13:03 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-73557=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=E9=A2=84?= =?UTF-8?q?=E6=9C=9F=E5=A4=96=E7=9A=84=E5=90=AF=E5=8A=A8=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E4=B8=8E=E8=AE=BE=E8=AE=A1=E7=A8=BF=E4=B8=8D?= =?UTF-8?q?=E4=B8=80=E8=87=B4=201=E3=80=81=E4=BF=AE=E6=94=B9=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E5=AD=97=E4=BD=93=E7=9A=84=E5=AE=9E=E7=8E=B0=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E7=84=B6=E5=92=8C=E5=85=B6=E4=BB=96=E7=9A=84=E5=AD=97?= =?UTF-8?q?=E4=BD=93=E4=B8=8D=E7=BB=9F=E4=B8=80=E3=80=82=202=E3=80=81?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E4=B8=80=E4=B8=8B=20UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/env/detect/ui/DetectorErrorDialog.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/env/detect/ui/DetectorErrorDialog.java b/designer-base/src/main/java/com/fr/env/detect/ui/DetectorErrorDialog.java index 43a2f00b9d..e636524c87 100644 --- a/designer-base/src/main/java/com/fr/env/detect/ui/DetectorErrorDialog.java +++ b/designer-base/src/main/java/com/fr/env/detect/ui/DetectorErrorDialog.java @@ -7,6 +7,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.ColorUtils; +import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.env.detect.base.DetectorUtil; import com.fr.env.detect.bean.DetectorResult; @@ -14,7 +15,6 @@ import com.fr.env.detect.bean.ExceptionSolution; import com.fr.env.detect.bean.ExceptionTips; import com.fr.env.detect.bean.Message; import com.fr.exit.DesignerExiter; -import com.fr.general.FRFont; import javax.swing.BorderFactory; import javax.swing.JDialog; @@ -39,13 +39,17 @@ import java.util.List; * created by Harrison on 2022/05/29 **/ public class DetectorErrorDialog extends JDialog implements ActionListener { - + + public static final float FONT_BOLD_HEIGHT = 16f; private UIButton okButton; private UIButton restartButton; public DetectorErrorDialog(Frame parent, List results) { super(parent, true); + + // 可能是还没初始化 UI 的时候出现的问题,初始化一下 UI + DesignUtils.initLookAndFeel(); JPanel northPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel headerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); @@ -57,8 +61,9 @@ public class DetectorErrorDialog extends JDialog implements ActionListener { JPanel messagePane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); { UILabel boldHeader = new UILabel(Toolkit.i18nText("Fine-Design_Error_Start_Apology_Message")); - Font font = FRFont.getInstance(boldHeader.getFont().getFontName(), Font.PLAIN, 16); - boldHeader.setFont(font); + Font font = boldHeader.getFont(); + Font boldFont = font.deriveFont(FONT_BOLD_HEIGHT); + boldHeader.setFont(boldFont); messagePane.add(boldHeader); UILabel description = new UILabel(Toolkit.i18nText("Fine-Design_Send_Report_To_Us")); From 2d322f3ad24d3f1bc7bb04685232f0a15af0684e Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 14 Jun 2022 16:58:40 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-73586=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=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E8=BF=9E=E6=8E=A5=E5=A4=B1=E8=B4=A5=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=89=8B=E5=8A=A8=E6=A3=80=E6=B5=8B=EF=BC=8C?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E5=A4=B1=E8=B4=A5=20=E5=92=8C=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E6=B2=9F=E9=80=9A=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E5=AD=98=E5=9C=A8=E6=A3=80=E6=B5=8B=E8=BF=87=E7=A8=8B?= =?UTF-8?q?=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/env/detect/base/DetectorBridge.java | 9 +- .../fr/env/detect/bean/DetectorResult.java | 6 ++ .../fr/env/detect/bean/DetectorStatus.java | 5 ++ .../detect/thowable/ThrowableLogAppender.java | 2 + .../fr/env/detect/ui/EnvDetectorDialog.java | 82 +++++++++++-------- 5 files changed, 67 insertions(+), 37 deletions(-) diff --git a/designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java b/designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java index 50bca7fd1c..765ad1edac 100644 --- a/designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java +++ b/designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java @@ -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) { - return detectorManager.getValue().detect(type); + try { + return detectorManager.getValue().detect(type); + } catch (Exception e) { + FineLoggerFactory.getLogger().error("detect failed", e); + // 返回成功的信息, 别影响前端的展示。 + return DetectorResult.unknown(type); + } } /** diff --git a/designer-base/src/main/java/com/fr/env/detect/bean/DetectorResult.java b/designer-base/src/main/java/com/fr/env/detect/bean/DetectorResult.java index 2b45ecbc1e..aa9a007bbb 100644 --- a/designer-base/src/main/java/com/fr/env/detect/bean/DetectorResult.java +++ b/designer-base/src/main/java/com/fr/env/detect/bean/DetectorResult.java @@ -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); diff --git a/designer-base/src/main/java/com/fr/env/detect/bean/DetectorStatus.java b/designer-base/src/main/java/com/fr/env/detect/bean/DetectorStatus.java index 6a12015e91..b7e5df818c 100644 --- a/designer-base/src/main/java/com/fr/env/detect/bean/DetectorStatus.java +++ b/designer-base/src/main/java/com/fr/env/detect/bean/DetectorStatus.java @@ -14,4 +14,9 @@ public enum DetectorStatus { * 异常 */ EXCEPTION, + + /** + * 未知 + */ + UNKNOWN, } diff --git a/designer-base/src/main/java/com/fr/env/detect/thowable/ThrowableLogAppender.java b/designer-base/src/main/java/com/fr/env/detect/thowable/ThrowableLogAppender.java index bcb4736e1d..3348052f4d 100644 --- a/designer-base/src/main/java/com/fr/env/detect/thowable/ThrowableLogAppender.java +++ b/designer-base/src/main/java/com/fr/env/detect/thowable/ThrowableLogAppender.java @@ -60,6 +60,8 @@ public class ThrowableLogAppender extends AbstractAppender { public void enable() { + // 初始化一下,别出问题 + logHandler.getHandler().start(); FRLogger.getLogger().addExtendLogAppender(logHandler); } 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 25689ad202..ed03d78cc1 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 @@ -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() { @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++; } @@ -218,11 +220,16 @@ public class EnvDetectorDialog extends JDialog { @Override protected void done() { - - if (buttonStatus.isExecuting()) { - // 执行结束 - buttonStatus = EnvDetectorButtonStatus.A_NEW; - UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refreshHeaderPanel); + + try { + this.get(); + if (buttonStatus.isExecuting()) { + // 执行结束 + 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); } // 刷新一下面板-开始执行啦 - 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; @@ -360,31 +367,34 @@ public class EnvDetectorDialog extends JDialog { infoPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Exception")), BorderLayout.CENTER); } statusPanel.add(infoPanel, BorderLayout.WEST); - - 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.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent mouseEvent) { - NotificationDialogProperties properties = new NotificationDialogProperties((Frame) EnvDetectorDialog.this.getOwner(), Toolkit.i18nText("Fine-Design_Basic_Detect_Notification_Title")); - Stream results = model.getResults(); - List notificationModels = results - .filter(Objects::nonNull) - .filter((e) -> e.getStatus() == DetectorStatus.EXCEPTION) - .map(DetectorUtil::convert2Notification) - .collect(Collectors.toList()); - - NotificationDialog dialog = new NotificationDialog(properties, notificationModels); - dialog.open(); - } - }); - detailPanel.add(detailLabel, BorderLayout.CENTER); + + // 如果结果是检测出的异常,则出现详细信息。 + 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(DETAIL_FONT_COLOR); + detailLabel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseEvent) { + NotificationDialogProperties properties = new NotificationDialogProperties((Frame) EnvDetectorDialog.this.getOwner(), Toolkit.i18nText("Fine-Design_Basic_Detect_Notification_Title")); + Stream results = model.getResults(); + List notificationModels = results + .filter(Objects::nonNull) + .filter((e) -> e.getStatus() == DetectorStatus.EXCEPTION) + .map(DetectorUtil::convert2Notification) + .collect(Collectors.toList()); + + NotificationDialog dialog = new NotificationDialog(properties, notificationModels); + dialog.open(); + } + }); + detailPanel.add(detailLabel, BorderLayout.CENTER); + } + statusPanel.add(detailPanel, 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(); From 750e5ea5435f03d92996d93d298e0d8eea65c8ce Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 14 Jun 2022 17:21:33 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-73586=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=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E8=BF=9E=E6=8E=A5=E5=A4=B1=E8=B4=A5=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=89=8B=E5=8A=A8=E6=A3=80=E6=B5=8B=EF=BC=8C?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E5=A4=B1=E8=B4=A5=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/env/detect/base/DetectorBridge.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java b/designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java index 765ad1edac..798e0ae047 100644 --- a/designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java +++ b/designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java @@ -91,7 +91,7 @@ public class DetectorBridge { return detectorManager.getValue().detect(type); } catch (Exception e) { FineLoggerFactory.getLogger().error("detect failed", e); - // 返回成功的信息, 别影响前端的展示。 + // 返回未知错误信息 return DetectorResult.unknown(type); } }