Browse Source

REPORT-85210 && REPORT-85293

1-加载条样式优化
2-启动异常报错优化
3-给异步加载 envmanager 提供配置
newui
Harrison 2 years ago
parent
commit
9d9551b766
  1. 52
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 4
      designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java
  3. 14
      designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java
  4. 55
      designer-base/src/test/java/com/fr/design/gui/iprogressbar/ProgressDialogTest.java
  5. 6
      designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java

52
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;

4
designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java

@ -20,6 +20,10 @@ import java.awt.Frame;
/**
* 加载进度弹窗
* <em>使用注意点:</em>
* 1-需要等到 父frame 启动好之后才能启动进度条
* 2-或者到使用时再初始化不要作为属性存在
* {@link com.fr.design.gui.iprogressbar.ProgressDialogTest}
*/
public class ProgressDialog extends UIDialog {
protected static final FRFont font = DesignUtils

14
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<Void, Void> task = new SwingWorker<Void, Void>() {
@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 {

55
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<Frame>() {
@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<Frame>() {
@Override
public void accept(Frame frame) {
ProgressDialog progressDialog = new ProgressDialog(frame);
progressDialog.setVisible(true);
progressDialog.updateLoadingText("test");
}
});
}
}

6
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);

Loading…
Cancel
Save