Browse Source

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

fbp/feature
Richard.Fang 3 weeks ago
parent
commit
7aa284f10f
  1. 2
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 2
      designer-base/src/main/java/com/fr/design/actions/file/PreferenceAction.java
  3. 155
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  4. 19
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  5. 72
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  6. 17
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeGridControlPane.java
  7. 63
      designer-base/src/main/java/com/fr/design/ui/util/UIUtil.java
  8. 2
      designer-realize/src/main/java/com/fr/design/cell/editor/FormulaCellEditor.java

2
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -515,7 +515,7 @@ public class EnvChangeEntrance {
final EnvListPane envListPane = new EnvListPane();
final BasicDialog envListDialog = envListPane.showWindow(DesignerContext.getDesignerFrame());
dialog = envListDialog;
envListPane.populateEnvManager(envName);
SwingUtilities.invokeLater(() -> envListPane.populateEnvManager(envName));
envListDialog.addDialogActionListener(new DialogActionAdapter() {
@Override

2
designer-base/src/main/java/com/fr/design/actions/file/PreferenceAction.java

@ -31,8 +31,8 @@ public class PreferenceAction extends UpdateAction {
*/
public void actionPerformed(ActionEvent e) {
final DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
final PreferencePane preferencePane = new PreferencePane();
// 将当前环境配置填充到PreferencePane中
preferencePane.populate(DesignerEnvManager.getEnvManager());
BasicDialog basicDialog = preferencePane.showWindow(designerFrame);

155
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -42,6 +42,7 @@ import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.mainframe.vcs.ui.UIPositiveIntEditor;
import com.fr.design.mainframe.vcs.ui.VcsMovePanel;
import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.unit.UnitConvertUtil;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.widget.FRWidgetFactory;
@ -55,6 +56,7 @@ import com.fr.log.FineLoggerFactory;
import com.fr.report.ReportConfigManager;
import com.fr.stable.Constants;
import com.fr.third.apache.logging.log4j.Level;
import com.fr.third.guava.base.Supplier;
import com.fr.third.guava.collect.BiMap;
import com.fr.third.guava.collect.HashBiMap;
import com.fr.transaction.Configurations;
@ -67,6 +69,9 @@ import com.fr.workspace.server.vcs.VcsConfig;
import com.fr.workspace.server.vcs.git.config.GcConfig;
import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoCleanSchedule;
import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoCleanService;
import java.util.Arrays;
import java.util.function.Consumer;
import java.util.List;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@ -869,23 +874,33 @@ public class PreferencePane extends BasicPane {
if (designerEnvManager == null) {
return;
}
// 常用
loadCommonSettings(designerEnvManager);
// 版本管理
loadVersionControlSettings(designerEnvManager);
// 高级
loadAdvanceSettings(designerEnvManager);
}
/**
* 选项-常用
* @param designerEnvManager
*/
private void loadCommonSettings(DesignerEnvManager designerEnvManager) {
// 功能设置
supportUndoCheckBox.setSelected(designerEnvManager.isSupportUndo());
if (designerEnvManager.isSupportUndo()) {
maxUndoLimit.setSelectedIndex(chooseCase(designerEnvManager.getUndoLimit()));
} else {
maxUndoLimit.setEnabled(false);
}
supportDefaultParentCalculateCheckBox.setSelected(designerEnvManager.isSupportDefaultParentCalculate());
showTemplateMissingPlugin.setSelected(designerEnvManager.isShowTemplateMissingPlugin());
this.startWithEmptyFile.setSelected(designerEnvManager.isStartWithEmptyFile());
// 编辑器设置
supportStringToFormulaBox.setSelected(designerEnvManager.isSupportStringToFormula());
shortCutLabel.setText(getDisplayShortCut(designerEnvManager.getAutoCompleteShortcuts()));
shortCutKeyStore = convert2KeyStroke(designerEnvManager.getAutoCompleteShortcuts());
if (supportStringToFormulaBox.isSelected()) {
defaultStringToFormulaBox.setEnabled(true);
defaultStringToFormulaBox.setSelected(designerEnvManager.isDefaultStringToFormula());
@ -893,13 +908,74 @@ public class PreferencePane extends BasicPane {
defaultStringToFormulaBox.setEnabled(false);
defaultStringToFormulaBox.setSelected(false);
}
// 颜色设置
gridLineColorTBButton.setColor(designerEnvManager.getGridLineColor());
paginationLineColorTBButton.setColor(designerEnvManager.getPaginationLineColor());
// 语言选择
this.languageComboBox.setSelectedItem(designerEnvManager.getLanguage());
// 启动页配置
this.startupPageEnabledCheckBox.setSelected(designerEnvManager.isStartupPageEnabled());
}
/**
* 高级
* @param designerEnvManager
*/
private void loadAdvanceSettings(DesignerEnvManager designerEnvManager) {
// Log导出配置
this.logExportDirectoryField.setText(designerEnvManager.getLogLocation());
this.logLevelComboBox.setSelectedItem(Log4jConfig.getInstance().getRootLevel());
// 标尺单位配置
this.pageLengthComboBox.setSelectedIndex(designerEnvManager.getPageLengthUnit());
this.reportLengthComboBox.setSelectedIndex(designerEnvManager.getReportLengthUnit());
// 端口设置
this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort()));
// 插件管理器选项
if (useOptimizedUPMCheckbox != null) {
useOptimizedUPMCheckbox.setSelected(true);
}
// 显示oracle所有表
this.oracleSpace.setSelected(designerEnvManager.isOracleSystemSpace());
// 模板内存优化
this.cachingTemplateSpinner.setValue(designerEnvManager.getCachingTemplateLimit());
// 产品改良
this.joinProductImproveCheckBox.setSelected(designerEnvManager.isJoinProductImprove());
if (this.autoPushUpdateCheckBox != null) {
this.autoPushUpdateCheckBox.setSelected(designerEnvManager.isAutoPushUpdateEnabled());
}
// 模板预览性能
this.imageCompressPanelCheckBox.setSelected(designerEnvManager.isImageCompress());
boolean enabled = WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot();
previewRenderSpeed.setEnabled(enabled);
previewRenderQuality.setEnabled(enabled);
previewResolutionBtnS.setEnabled(enabled);
previewResolutionBtnM.setEnabled(enabled);
// 设计器启动选项-延迟启动云端运维模块
this.cloudAnalyticsDelayCheckBox.setSelected(designerEnvManager.isCloudAnalyticsDelay());
List<Supplier<Object>> advanceConfigLoaders = Arrays.asList(
GcConfig.getInstance()::isGcEnable,
ServerPreferenceConfig.getInstance()::isUseUniverseDBM,
ReportConfigManager.getProviderInstance()::getImageExportAttr
);
List<Consumer<Object>> advanceConfigUpdaters = Arrays.asList(
gcEnable -> updateGcConfigUI((Boolean) gcEnable),
useUniverseDBM -> useUniverseDBMCheckbox.setSelected((Boolean) useUniverseDBM),
imageExportAttr -> updateImageExportUI((ImageExportAttr) imageExportAttr)
);
UIUtil.loadConfigsAndUpdateUI(advanceConfigLoaders, advanceConfigUpdaters);
}
/**
* 选项-版本管理
* @param designerEnvManager
*/
private void loadVersionControlSettings(DesignerEnvManager designerEnvManager) {
VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager();
//如果是集群并且是老版本则不可用
if (VcsHelper.getInstance().isLegacyMode() && WorkContext.getCurrent().isCluster()) {
vcsEnableCheckBox.setEnabled(false);
gcEnableCheckBox.setEnabled(false);
}
if (VcsHelper.getInstance().needInit()) {
vcsEnableCheckBox.setSelected(vcsConfigManager.isVcsEnable());
} else {
@ -911,71 +987,40 @@ public class PreferencePane extends BasicPane {
saveIntervalEditor.setEnabled(false);
useIntervalCheckBox.setEnabled(false);
}
saveIntervalEditor.setValue(vcsConfigManager.getSaveInterval());
saveCommitCheckBox.setSelected(vcsConfigManager.isSaveCommit());
useIntervalCheckBox.setSelected(vcsConfigManager.isUseInterval());
gcEnableCheckBox.setSelected(GcConfig.getInstance().isGcEnable());
gcButton.setEnabled(gcEnableCheckBox.isSelected());
useVcsAutoSaveScheduleCheckBox.setSelected(vcsConfigManager.isUseAutoSave());
useVcsAutoCleanScheduleCheckBox.setSelected(VcsConfig.getInstance().isUseV2AutoClean());
//版本管理-存储与清理机制
List<Supplier<Object>> vcsConfigLoaders = Arrays.asList(
VcsConfig.getInstance()::isUseV2AutoClean,
VcsConfig.getInstance()::getV2CleanInterval,
VcsConfig.getInstance()::getV2RetainInterval
);
List<Consumer<Object>> vcsConfigUpdaters = Arrays.asList(
useV2AutoClean -> useVcsAutoSaveScheduleCheckBox.setSelected((Boolean) useV2AutoClean),
v2CleanInterval -> autoCleanIntervalComboBox.setSelectedIndex(getIndex((Integer) v2CleanInterval)),
v2RetainInterval -> autoCleanRetainIntervalComboBox.setSelectedIndex(getIndex((Integer) v2RetainInterval))
);
UIUtil.loadConfigsAndUpdateUI(vcsConfigLoaders, vcsConfigUpdaters);
autoSaveIntervalEditor.setValue(vcsConfigManager.getAutoSaveInterval());
autoCleanIntervalComboBox.setSelectedIndex(getIndex(VcsConfig.getInstance().getV2CleanInterval()));
autoCleanRetainIntervalComboBox.setSelectedIndex(getIndex(VcsConfig.getInstance().getV2RetainInterval()));
gridLineColorTBButton.setColor(designerEnvManager.getGridLineColor());
paginationLineColorTBButton.setColor(designerEnvManager.getPaginationLineColor());
this.logExportDirectoryField.setText(designerEnvManager.getLogLocation());
this.logLevelComboBox.setSelectedItem(Log4jConfig.getInstance().getRootLevel());
this.languageComboBox.setSelectedItem(designerEnvManager.getLanguage());
this.pageLengthComboBox.setSelectedIndex(designerEnvManager.getPageLengthUnit());
this.reportLengthComboBox.setSelectedIndex(designerEnvManager.getReportLengthUnit());
this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort()));
if (useOptimizedUPMCheckbox != null) {
useOptimizedUPMCheckbox.setSelected(true);
}
useUniverseDBMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseUniverseDBM());
this.oracleSpace.setSelected(designerEnvManager.isOracleSystemSpace());
this.cachingTemplateSpinner.setValue(designerEnvManager.getCachingTemplateLimit());
this.joinProductImproveCheckBox.setSelected(designerEnvManager.isJoinProductImprove());
if (this.autoPushUpdateCheckBox != null) {
this.autoPushUpdateCheckBox.setSelected(designerEnvManager.isAutoPushUpdateEnabled());
}
this.startWithEmptyFile.setSelected(designerEnvManager.isStartWithEmptyFile());
}
this.imageCompressPanelCheckBox.setSelected(designerEnvManager.isImageCompress());
private void updateGcConfigUI(Boolean gcEnable) {
gcEnableCheckBox.setSelected(gcEnable);
gcButton.setEnabled(gcEnable);
}
ImageExportAttr attr = ReportConfigManager.getProviderInstance().getImageExportAttr();
private void updateImageExportUI(ImageExportAttr attr) {
if (attr.getPreviewRenderQuality() == ImageExportAttr.RENDER_SPEED) {
previewRenderSpeed.setSelected(true);
} else {
previewRenderQuality.setSelected(true);
}
if (attr.getPreviewResolutionScale() == DPI_SCALE_S) {
previewResolutionBtnS.setSelected(true);
} else {
previewResolutionBtnM.setSelected(true);
}
boolean enabled = WorkContext.getCurrent().isLocal() || WorkContext.getCurrent().isRoot();
previewRenderSpeed.setEnabled(enabled);
previewRenderQuality.setEnabled(enabled);
previewResolutionBtnS.setEnabled(enabled);
previewResolutionBtnM.setEnabled(enabled);
this.cloudAnalyticsDelayCheckBox.setSelected(designerEnvManager.isCloudAnalyticsDelay());
this.startupPageEnabledCheckBox.setSelected(designerEnvManager.isStartupPageEnabled());
}
private int chooseCase(int sign) {

19
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java

@ -46,6 +46,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.SeparatorDef;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.ParameterUtils;
import com.fr.esd.core.strategy.config.StrategyConfig;
import com.fr.esd.core.strategy.config.StrategyConfigHelper;
@ -67,7 +68,6 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import org.jetbrains.annotations.NotNull;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
@ -80,7 +80,6 @@ import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -226,6 +225,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> implemen
addConnectionTableProcedurePaneListener();
}
private void addConnectionTableProcedurePaneListener() {
this.connectionTableProcedurePane.addDoubleClickListener(new ConnectionTableProcedurePane.DoubleClickSelectedNodeOnTreeListener() {
@Override
@ -511,22 +511,23 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> implemen
}
private void populateESDComponents() {
//查找映射的配置
this.strategyConfig = configHandler.find();
UIUtil.executeAsyncTaskAndUpdateUI(configHandler::find, this::updateESDComponents);
}
private void updateESDComponents(StrategyConfig strategyConfig) {
this.strategyConfig = strategyConfig;
boolean shouldEnable = false;
StrategyConfigFrom from = StrategyConfigFrom.GLOBAL;
if (this.strategyConfig != null) {
if (this.strategyConfig.enabled()) {
if (strategyConfig != null) {
if (strategyConfig.enabled()) {
shouldEnable = true;
}
if (!this.strategyConfig.isUseGlobal()) {
if (!strategyConfig.isUseGlobal()) {
from = StrategyConfigFrom.INDIVIDUAL;
}
}
//服务器数据集不允许设置来源,只能单独配置
// 服务器数据集不允许设置来源,只能单独配置
if (dbTableData.getScope() != StrategicTableData.Scope.TEMPLATE) {
from = StrategyConfigFrom.INDIVIDUAL;
this.esdConfigOption.setEnabled(false);

72
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -39,6 +39,7 @@ import com.fr.design.mainframe.vcs.ui.VcsMovingExitOption;
import com.fr.design.menu.ShortCut;
import com.fr.design.os.impl.MacOsAddListenerAction;
import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.TemplateUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.event.EventDispatcher;
@ -63,7 +64,6 @@ import com.fr.stable.project.ProjectConstants;
import com.fr.start.OemHandler;
import com.fr.start.common.DesignerOpenEmptyPanel;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import javax.swing.Icon;
@ -315,7 +315,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
public void resizeFrame() {
JTemplate<?, ?> currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (currentEditingTemplate != null) {
currentEditingTemplate.setComposite();
@ -686,37 +686,50 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 设置标题
*/
public void setTitle() {
StringBuilder defaultTitleSB = 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());
});
} else {
setTitle(defaultTitleSB.toString());
}
}
private String buildFinalPath(String path, boolean exists, JTemplate<?, ?> editingTemplate) {
String finalPath = path;
if (!exists) {
finalPath = FILEFactory.MEM_PREFIX + path;
} else if (finalPath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
finalPath = WorkContext.getCurrent().getPath() + File.separator + TemplateUtils.createLockeTemplatedName(editingTemplate, path);
}
return finalPath;
}
private StringBuilder buildDefaultTitle() {
StringBuilder defaultTitleSB = new StringBuilder();
defaultTitleSB.append(ProductConstants.APP_NAME);
defaultTitleSB.append(" ");
defaultTitleSB.append(GeneralUtils.getVersion());
defaultTitleSB.append(" ");
defaultTitleSB.append(ProductConstants.BRANCH);
defaultTitleSB.append(" ");
defaultTitleSB.append(ProductConstants.APP_NAME).append(" ").append(GeneralUtils.getVersion()).append(" ").append(ProductConstants.BRANCH).append(" ");
// james:标识登录的用户和登录的ENV
String envName = DesignerEnvManager.getEnvManager().getCurEnvName();
Workspace workspace = WorkContext.getCurrent();
DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName);
String username = getCurrentUsername(envName);
// 拼接用户名、环境名以及工作环境描述
defaultTitleSB.append(username).append("@").append(envName).append("[").append(WorkContext.getCurrent().getDescription()).append("]");
return defaultTitleSB;
}
private String getCurrentUsername(String envName) {
String username = null;
DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName);
if (info != null) {
WorkspaceConnectionInfo connection = info.getConnection();
username = connection == null ? StringUtils.EMPTY : connection.getUserName();
}
defaultTitleSB.append(username).append("@").append(envName).append("[").append(workspace.getDescription()).append("]");
if (JTemplate.isValid(editingTemplate)) {
String path = editingTemplate.getPath();
if (!editingTemplate.getEditingFILE().exists()) {
path = FILEFactory.MEM_PREFIX + path;
} else if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) {
path = workspace.getPath() + File.separator + TemplateUtils.createLockeTemplatedName(editingTemplate, path);
}
defaultTitleSB.append(" ").append(path);
}
setTitle(defaultTitleSB.toString());
return username;
}
/**
@ -817,22 +830,22 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
}
}
public void showEmptyJTemplate() {
DesignerOpenEmptyPanel designerOpenEmptyPanel = new DesignerOpenEmptyPanel();
BorderLayout layout = (BorderLayout) basePane.getLayout();
basePane.remove(layout.getLayoutComponent(BorderLayout.CENTER));
basePane.remove(layout.getLayoutComponent(BorderLayout.EAST));
basePane.add(designerOpenEmptyPanel, BorderLayout.CENTER);
resetToolkitByPlus(ToolBarMenuDock.NULLAVOID);
// 这里挺恶心的,是为了保证对插件的兼容性适配
// 不然的话,插件就会 npe
// 见 https://work.fineres.com/browse/REPORT-76091
HistoryTemplateListCache.getInstance().setCurrentEditingTemplate(JNullTemplate.NULL);
layeredPane.repaint();
}
@ -932,6 +945,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/**
* 根据模板路径获取模板名称
*
* @param templatePath 模板路径 template.getPath()
* @return 模板名
*/
@ -950,7 +964,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*
* @return 是否停用失败
*/
private boolean currentTemplateDeactivateFail(JTemplate jt) {
private boolean currentTemplateDeactivateFail(JTemplate jt) {
JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
return currentEditingTemplate != null && !currentEditingTemplate.deactivateTemplate(jt);
}

17
designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeGridControlPane.java

@ -19,11 +19,16 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.ui.util.UIUtil;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.third.guava.base.Supplier;
import com.fr.third.javax.annotation.Nullable;
import com.fr.transaction.CallBackAdaptor;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
@ -211,9 +216,15 @@ public class TemplateThemeGridControlPane<T extends TemplateTheme> extends Basic
MenuDef menuDef = new MenuDef(Toolkit.i18nText("Fine-Design_Basic_Action_Add"));
menuDef.setIcon(new LazyIcon("add_popup"));
menuDef.setRePaint(true);
menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Light_Theme"), config.getDefaultLightThemeName()));
menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Dark_Theme"), config.getDefaultDarkThemeName()));
List<Supplier<String>> configLoaders = Arrays.asList(
config::getDefaultLightThemeName,
config::getDefaultDarkThemeName
);
List<Consumer<String>> configUpdaters = Arrays.asList(
lightThemeName -> menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Light_Theme"), lightThemeName)),
darkThemeName -> menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Dark_Theme"), darkThemeName))
);
UIUtil.loadConfigsAndUpdateUI(configLoaders, configUpdaters);
return menuDef;
}

63
designer-base/src/main/java/com/fr/design/ui/util/UIUtil.java

@ -3,9 +3,13 @@ package com.fr.design.ui.util;
import com.fr.log.FineLoggerFactory;
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.function.Consumer;
import org.jetbrains.annotations.NotNull;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import java.awt.Color;
import java.util.concurrent.TimeUnit;
@ -87,4 +91,63 @@ public class UIUtil {
public static Color getPanelBackageColor() {
return UIManager.getColor("Panel.background");
}
/**
* 执行异步任务并在任务完成后更新UI
* <p>
* 该方法将执行一个耗时的后台任务并在任务完成后将结果传递给一个回调函数来更新UI
* 使用 SwingWorker 来处理后台任务确保在任务完成后回到 EDT事件分发线程 更新 UI
*
* @param <T> 任务结果的类型
* @param task 需要在后台执行的任务该任务的执行过程由 Supplier 提供返回任务的结果
* @param uiUpdater 在任务完成后执行的回调函数用来处理结果并更新UI
*/
public static <T> void executeAsyncTaskAndUpdateUI(Supplier<T> task, Consumer<T> uiUpdater) {
new SwingWorker<T, Void>() {
@Override
protected T doInBackground() throws Exception {
return task.get();
}
@Override
protected void done() {
try {
T result = get();
uiUpdater.accept(result);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}.execute();
}
/**
* 异步加载配置并在加载完成后更新 UI
*
* @param <T> 配置对象的类型
* @param configLoaders 配置加载器列表每个加载器负责加载一种配置
* @param uiUpdaters UI 更新器列表每个更新器负责在 UI 上显示对应配置的值
*/
public static <T> void loadConfigsAndUpdateUI(List<Supplier<T>> configLoaders, List<Consumer<T>> uiUpdaters) {
new SwingWorker<List<T>, Void>() {
@Override
protected List<T> doInBackground() throws Exception {
List<T> results = new ArrayList<>();
for (Supplier<T> configLoader : configLoaders) {
results.add(configLoader.get());
}
return results;
}
@Override
protected void done() {
try {
List<T> configResults = get();
for (int i = 0; i < configResults.size(); i++) {
uiUpdaters.get(i).accept(configResults.get(i));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}.execute();
}
}

2
designer-realize/src/main/java/com/fr/design/cell/editor/FormulaCellEditor.java

@ -6,6 +6,7 @@ package com.fr.design.cell.editor;
import com.fr.base.BaseFormula;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.FunctionConstants;
import com.fr.design.formula.UIFormula;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.Grid;
@ -27,6 +28,7 @@ public class FormulaCellEditor extends com.fr.design.cell.editor.AbstractCellEdi
*/
public FormulaCellEditor(ElementCasePane<? extends TemplateElementCase> ePane) {
super(ePane);
SwingUtilities.invokeLater(() -> FunctionConstants.PLUGIN.getGroupName());
}
/**

Loading…
Cancel
Save