From 295d9a8c411fce8f4ba0486de3ce25faebcea422 Mon Sep 17 00:00:00 2001 From: Harrison Date: Thu, 24 Nov 2022 11:09:02 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-85293=E3=80=90=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E3=80=91=E8=B5=B7=E5=A7=8B=E9=A1=B5=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BD=BD=E8=BF=9B=E5=BA=A6=E6=9D=A1=E8=A7=86?= =?UTF-8?q?=E8=A7=89=E6=95=88=E6=9E=9C=E7=A1=AE=E8=AE=A4=20ProgressDialog?= =?UTF-8?q?=20=E7=94=A8=E9=94=99=E4=BA=86=EF=BC=8C=E8=BF=99=E4=B8=AA?= =?UTF-8?q?=E5=8F=AA=E8=83=BD=E6=98=AF=E4=BD=BF=E7=94=A8=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E6=89=8D=E5=88=9B=E5=BB=BA=20=E4=B8=8D=E7=84=B6?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E6=9C=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/iprogressbar/ProgressDialog.java | 4 +- .../com/fr/startup/ui/StartupPageWindow.java | 79 +++++++++---------- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java index 10ece3d3ab..44e697d043 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java +++ b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java @@ -21,8 +21,8 @@ import java.awt.Frame; /** * 加载进度弹窗 * 使用注意点: - * 1-需要等到 父frame 启动好之后,才能启动进度条。 - * 2-或者到使用时再初始化,不要作为属性存在 + * 必须到使用时再初始化,不要作为属性存在 + * 因为涉及到 大小/位置 相对于 parent 的相对判断 * 见 {@link com.fr.design.gui.iprogressbar.ProgressDialogTest} */ public class ProgressDialog extends UIDialog { diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java index 8905d6004c..6c2f4ba91f 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java @@ -81,8 +81,6 @@ public class StartupPageWindow extends JFrame { private JPanel body; - private StartupLoadingPanel loadingPanel; - public StartupPageWindow(StartupPageModel pageModel) { patchUIAction(pageModel); @@ -102,9 +100,6 @@ public class StartupPageWindow extends JFrame { setFullScreen(); - // 必须放最后 - // 见 https://work.fineres.com/browse/REPORT-85293 - loadingPanel = new StartupLoadingPanel(this); } private void initCenter(StartupPageModel pageModel) { @@ -232,45 +227,49 @@ public class StartupPageWindow extends JFrame { private void enterWorkspace(Runnable action) { UIUtil.invokeAndWaitIfNeeded(() -> { + + // 必须直接初始化 + // 见 https://work.fineres.com/browse/REPORT-85293 + StartupLoadingPanel loadingPanel = new StartupLoadingPanel(this); loadingPanel.show(); setEnabled(false); - }); - - SwingWorker task = new SwingWorker() { - @Override - protected Void doInBackground() throws Exception { - action.run(); - return null; - } - @Override - protected void done() { - - try { - Void result = get(); - setVisible(false); - } catch (Exception e) { - // 处理错误 - UIUtil.invokeLaterIfNeeded(() -> { - UIExpandDialog.Builder() - .owner(StartupPageWindow.this) - .title(Toolkit.i18nText("Fine-Design_Basic_Remote_Env_Try")) - .message(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed")) - .messageType(UIExpandDialog.WARNING_MESSAGE) - .detail(e.getMessage()) - .expand(true) - .modal(false) - .build() - .setVisible(true); - setEnabled(true); - }); - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } finally { - loadingPanel.hide(); + SwingWorker task = new SwingWorker() { + @Override + protected Void doInBackground() throws Exception { + action.run(); + return null; } - } - }; - task.execute(); + + @Override + protected void done() { + + try { + Void result = get(); + setVisible(false); + } catch (Exception e) { + // 处理错误 + UIUtil.invokeLaterIfNeeded(() -> { + UIExpandDialog.Builder() + .owner(StartupPageWindow.this) + .title(Toolkit.i18nText("Fine-Design_Basic_Remote_Env_Try")) + .message(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed")) + .messageType(UIExpandDialog.WARNING_MESSAGE) + .detail(e.getMessage()) + .expand(true) + .modal(false) + .build() + .setVisible(true); + setEnabled(true); + }); + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } finally { + loadingPanel.hide(); + } + } + }; + task.execute(); + }); } private JPanel generateRecentOpenPanel(StartupPageModel pageModel) {