diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
index 6b681699be..199834fb77 100644
--- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
+++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
@@ -4,6 +4,7 @@
package com.fr.design;
import com.fr.base.BaseXMLUtils;
+import com.fr.base.OptimizeUtil;
import com.fr.base.Utils;
import com.fr.collections.api.Callback;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
@@ -95,6 +96,7 @@ import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicBoolean;
/**
* The manager of Designer GUI.
@@ -263,19 +265,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter, AsyncXmlReada
designerEnvManager = new DesignerEnvManager();
//REPORT-15332有一个国际化调用比较早,需要在这边就设置好locale,由于后台GeneralContext默认是China
GeneralContext.setLocale(designerEnvManager.getLanguage());
- try {
- designerEnvManager.initElements(designerEnvManager.getDesignerEnvFile());
- } catch (Exception retryEx) {
- FineLoggerFactory.getLogger().debug("try async init DesignerEnvManager failed", retryEx);
-
- try {
- XMLTools.readFileXML(designerEnvManager, designerEnvManager.getDesignerEnvFile());
- } catch (FileNotFoundException e) {
- FineLoggerFactory.getLogger().error(e.getMessage(), e);
- XmlHandler.Self.handle(e);
- } catch (Exception e) {
- FineLoggerFactory.getLogger().error(e.getMessage(), e);
- }
+
+ if (!asyncInitEnvManager()) {
+ // 如果异步读取失败, 则恢复原来的逻辑
+ compatibleInitEnvManager();
}
// james:如果没有env定义,要设置一个默认的
@@ -292,6 +285,39 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter, AsyncXmlReada
return designerEnvManager;
}
+
+ private static void compatibleInitEnvManager() {
+
+ try {
+ XMLTools.readFileXML(designerEnvManager, designerEnvManager.getDesignerEnvFile());
+ } catch (FileNotFoundException e) {
+ FineLoggerFactory.getLogger().error(e.getMessage(), e);
+ XmlHandler.Self.handle(e);
+ } catch (Exception e) {
+ FineLoggerFactory.getLogger().error(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * 异步初始化环境管理, 提供配置, 帮助处理预期外的问题
+ * 1-当优化开启时,才走异步逻辑
+ * 2-如果异步执行中出错,则返回异常 false, 否则返回 true
+ *
+ * @return 是/否
+ */
+ private static boolean asyncInitEnvManager() {
+
+ AtomicBoolean noEx = new AtomicBoolean(false);
+ OptimizeUtil.open(DesignerEnvManager.class.getSimpleName().toLowerCase(), OptimizeUtil.Module.COMMON, () -> {
+ try {
+ designerEnvManager.initElements(designerEnvManager.getDesignerEnvFile());
+ noEx.set(true);
+ } catch (Throwable retryEx) {
+ FineLoggerFactory.getLogger().debug("try async init DesignerEnvManager failed", retryEx);
+ }
+ });
+ return noEx.get();
+ }
public ColorSelectConfigManager getColorConfigManager() {
return this.configManager;
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 2c1e6abf56..10ece3d3ab 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
@@ -20,6 +20,10 @@ import java.awt.Frame;
/**
* 加载进度弹窗
+ * 使用注意点:
+ * 1-需要等到 父frame 启动好之后,才能启动进度条。
+ * 2-或者到使用时再初始化,不要作为属性存在
+ * 见 {@link com.fr.design.gui.iprogressbar.ProgressDialogTest}
*/
public class ProgressDialog extends UIDialog {
protected static final FRFont font = DesignUtils
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 0b57247ac0..8905d6004c 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
@@ -91,8 +91,6 @@ public class StartupPageWindow extends JFrame {
initCenter(pageModel);
- loadingPanel = new StartupLoadingPanel(this);
-
// Workspace-detail
setSize(SCREEN_SIZE);
setDefaultTitle();
@@ -103,7 +101,10 @@ public class StartupPageWindow extends JFrame {
revalidate();
setFullScreen();
-
+
+ // 必须放最后
+ // 见 https://work.fineres.com/browse/REPORT-85293
+ loadingPanel = new StartupLoadingPanel(this);
}
private void initCenter(StartupPageModel pageModel) {
@@ -230,7 +231,11 @@ public class StartupPageWindow extends JFrame {
private void enterWorkspace(Runnable action) {
- loadingPanel.show();
+ UIUtil.invokeAndWaitIfNeeded(() -> {
+ loadingPanel.show();
+ setEnabled(false);
+ });
+
SwingWorker task = new SwingWorker() {
@Override
protected Void doInBackground() throws Exception {
@@ -257,6 +262,7 @@ public class StartupPageWindow extends JFrame {
.modal(false)
.build()
.setVisible(true);
+ setEnabled(true);
});
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
diff --git a/designer-base/src/test/java/com/fr/design/gui/iprogressbar/ProgressDialogTest.java b/designer-base/src/test/java/com/fr/design/gui/iprogressbar/ProgressDialogTest.java
new file mode 100644
index 0000000000..336850f26b
--- /dev/null
+++ b/designer-base/src/test/java/com/fr/design/gui/iprogressbar/ProgressDialogTest.java
@@ -0,0 +1,55 @@
+package com.fr.design.gui.iprogressbar;
+
+import com.fr.design.utils.DevUtils;
+
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.util.function.Consumer;
+
+/**
+ * @author Harrison
+ * @version 11.0
+ * Created by Harrison on 2022/11/23
+ */
+public class ProgressDialogTest {
+
+ public static void main(String[] args) {
+
+ mockInitSize();
+ }
+
+ /**
+ * 模拟 frame 的大小未初始化好的情况
+ */
+ private static void mockNotInitSize() {
+
+ DevUtils.show(new Consumer() {
+ @Override
+ public void accept(Frame frame) {
+
+ Dimension origin = frame.getSize();
+ frame.setSize(0, 0);
+ ProgressDialog progressDialog = new ProgressDialog(frame);
+ progressDialog.setVisible(true);
+ progressDialog.updateLoadingText("test");
+ frame.setSize(origin);
+ }
+ });
+ }
+
+ /**
+ * 模拟 frame 的大小初始化好的情况
+ */
+ private static void mockInitSize() {
+
+ DevUtils.show(new Consumer() {
+ @Override
+ public void accept(Frame frame) {
+
+ ProgressDialog progressDialog = new ProgressDialog(frame);
+ progressDialog.setVisible(true);
+ progressDialog.updateLoadingText("test");
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java
index 87f84c9d60..d861fa052a 100644
--- a/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java
+++ b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java
@@ -149,7 +149,11 @@ public class DesignerStartupPageActivator extends Activator {
StopWatch stopWatch = StopWatch.createStarted();
try {
- DesignerStartupContext.getRecorder().resume();
+
+ StopWatch recorder = DesignerStartupContext.getRecorder();
+ if (recorder.isSuspended()) {
+ recorder.resume();
+ }
// 等待中切换
DesignerStartupContext.getInstance().setOnWaiting(false);