Browse Source

REPORT-141296 设计器UI操作性能优化

fbp/feature
Richard.Fang 3 weeks ago
parent
commit
b34b5e24ad
  1. 16
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  2. 16
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  3. 12
      designer-base/src/main/java/com/fr/design/ui/util/UIUtil.java

16
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<Supplier<Object>> 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<Supplier<Object>> 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) {

16
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) {

12
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 <T> 配置对象的类型
* @param configLoaders 配置加载器列表每个加载器负责加载一种配置
* @param uiUpdaters UI 更新器列表每个更新器负责在 UI 上显示对应配置的值
* 加载的过程是异步的UI更新会在任务完成后执行配置加载是顺序进行的即一个配置加载完成后才会加载下一个配置
*/
public static <T> void loadConfigsAndUpdateUI(List<Supplier<T>> configLoaders, List<Consumer<T>> uiUpdaters) {
new SwingWorker<List<T>, 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();

Loading…
Cancel
Save