From b34b5e24ad2d9904131f267159eab2935fa7337e Mon Sep 17 00:00:00 2001 From: "Richard.Fang" Date: Tue, 3 Dec 2024 19:28:54 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-141296=20=E8=AE=BE=E8=AE=A1=E5=99=A8UI?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/file/PreferencePane.java | 16 ++++++++++++++-- .../com/fr/design/mainframe/DesignerFrame.java | 16 ++++++++-------- .../main/java/com/fr/design/ui/util/UIUtil.java | 12 +++++++----- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 6852392791..665bb518b9 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -952,6 +952,11 @@ public class PreferencePane extends BasicPane { previewResolutionBtnM.setEnabled(enabled); // 设计器启动选项-延迟启动云端运维模块 this.cloudAnalyticsDelayCheckBox.setSelected(designerEnvManager.isCloudAnalyticsDelay()); + // 异步加载高级配置 + loadAdvanceConfigAsync(); + } + + private void loadAdvanceConfigAsync() { List> advanceConfigLoaders = Arrays.asList( GcConfig.getInstance()::isGcEnable, ServerPreferenceConfig.getInstance()::isUseUniverseDBM, @@ -973,7 +978,9 @@ public class PreferencePane extends BasicPane { VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager(); //如果是集群并且是老版本则不可用 if (VcsHelper.getInstance().isLegacyMode() && WorkContext.getCurrent().isCluster()) { + // 保存自动生成版本 vcsEnableCheckBox.setEnabled(false); + // 模板版本控制存储优化 gcEnableCheckBox.setEnabled(false); } if (VcsHelper.getInstance().needInit()) { @@ -982,6 +989,8 @@ public class PreferencePane extends BasicPane { vcsEnableCheckBox.setEnabled(false); vcsEnableCheckBox.setSelected(false); } + autoSaveIntervalEditor.setValue(vcsConfigManager.getAutoSaveInterval()); + //版本管理-存储与清理机制 if (!vcsEnableCheckBox.isSelected()) { saveCommitCheckBox.setEnabled(false); saveIntervalEditor.setEnabled(false); @@ -990,7 +999,11 @@ public class PreferencePane extends BasicPane { saveIntervalEditor.setValue(vcsConfigManager.getSaveInterval()); saveCommitCheckBox.setSelected(vcsConfigManager.isSaveCommit()); useIntervalCheckBox.setSelected(vcsConfigManager.isUseInterval()); - //版本管理-存储与清理机制 + // 异步加载版本管理配置 + loadVersionControlConfigsAsync(); + } + + private void loadVersionControlConfigsAsync() { List> vcsConfigLoaders = Arrays.asList( VcsConfig.getInstance()::isUseV2AutoClean, VcsConfig.getInstance()::getV2CleanInterval, @@ -1002,7 +1015,6 @@ public class PreferencePane extends BasicPane { v2RetainInterval -> autoCleanRetainIntervalComboBox.setSelectedIndex(getIndex((Integer) v2RetainInterval)) ); UIUtil.loadConfigsAndUpdateUI(vcsConfigLoaders, vcsConfigUpdaters); - autoSaveIntervalEditor.setValue(vcsConfigManager.getAutoSaveInterval()); } private void updateGcConfigUI(Boolean gcEnable) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index aa80150da0..8d71ae353f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -686,18 +686,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * 设置标题 */ public void setTitle() { - StringBuilder defaultTitleSB = buildDefaultTitle(); + StringBuilder defaultTitle = buildDefaultTitle(); JTemplate editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); // 当前模板是否为有效模板 if (JTemplate.isValid(editingTemplate)) { String path = editingTemplate.getPath(); UIUtil.executeAsyncTaskAndUpdateUI(() -> editingTemplate.getEditingFILE().exists(), exists -> { String finalPath = buildFinalPath(path, exists, editingTemplate); - defaultTitleSB.append(" ").append(finalPath); - setTitle(defaultTitleSB.toString()); + defaultTitle.append(" ").append(finalPath); + setTitle(defaultTitle.toString()); }); } else { - setTitle(defaultTitleSB.toString()); + setTitle(defaultTitle.toString()); } } @@ -712,14 +712,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } private StringBuilder buildDefaultTitle() { - StringBuilder defaultTitleSB = new StringBuilder(); - defaultTitleSB.append(ProductConstants.APP_NAME).append(" ").append(GeneralUtils.getVersion()).append(" ").append(ProductConstants.BRANCH).append(" "); + StringBuilder defaultTitle = new StringBuilder(); + defaultTitle.append(ProductConstants.APP_NAME).append(" ").append(GeneralUtils.getVersion()).append(" ").append(ProductConstants.BRANCH).append(" "); // james:标识登录的用户和登录的ENV String envName = DesignerEnvManager.getEnvManager().getCurEnvName(); String username = getCurrentUsername(envName); // 拼接用户名、环境名以及工作环境描述 - defaultTitleSB.append(username).append("@").append(envName).append("[").append(WorkContext.getCurrent().getDescription()).append("]"); - return defaultTitleSB; + defaultTitle.append(username).append("@").append(envName).append("[").append(WorkContext.getCurrent().getDescription()).append("]"); + return defaultTitle; } private String getCurrentUsername(String envName) { diff --git a/designer-base/src/main/java/com/fr/design/ui/util/UIUtil.java b/designer-base/src/main/java/com/fr/design/ui/util/UIUtil.java index 12ad87fca6..b3dd08f90b 100644 --- a/designer-base/src/main/java/com/fr/design/ui/util/UIUtil.java +++ b/designer-base/src/main/java/com/fr/design/ui/util/UIUtil.java @@ -5,6 +5,7 @@ import com.fr.third.guava.base.Stopwatch; import com.fr.third.guava.base.Supplier; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ExecutionException; import java.util.function.Consumer; import org.jetbrains.annotations.NotNull; @@ -113,19 +114,20 @@ public class UIUtil { try { T result = get(); uiUpdater.accept(result); - } catch (Exception e) { - throw new RuntimeException(e); + } catch (InterruptedException | ExecutionException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } }.execute(); } /** - * 异步加载配置并在加载完成后更新 UI。 + * 异步加载配置并更新UI * * @param 配置对象的类型 * @param configLoaders 配置加载器列表,每个加载器负责加载一种配置 * @param uiUpdaters UI 更新器列表,每个更新器负责在 UI 上显示对应配置的值 + * 加载的过程是异步的,UI更新会在任务完成后执行。配置加载是顺序进行的,即一个配置加载完成后,才会加载下一个配置。 */ public static void loadConfigsAndUpdateUI(List> configLoaders, List> uiUpdaters) { new SwingWorker, Void>() { @@ -144,8 +146,8 @@ public class UIUtil { for (int i = 0; i < configResults.size(); i++) { uiUpdaters.get(i).accept(configResults.get(i)); } - } catch (Exception e) { - throw new RuntimeException(e); + } catch (InterruptedException | ExecutionException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } }.execute();