Browse Source

REPORT-114392 FR-FBP版本本地设计适配 优化部分卡顿逻辑

fbp-1.0
Destiny.Lin 5 months ago
parent
commit
5f51bbdece
  1. 56
      designer-base/src/main/java/com/fr/design/cache/DesignCacheManager.java
  2. 9
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  3. 3
      designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java
  4. 3
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

56
designer-base/src/main/java/com/fr/design/cache/DesignCacheManager.java vendored

@ -0,0 +1,56 @@
package com.fr.design.cache;
import com.fr.base.TableData;
import com.fr.design.data.tabledata.wrapper.TableDataFactory;
import java.util.Map;
/**
* 设计器缓存管理
*
* @author Destiny.Lin
* @since 11.0
* Created on 2024/8/11
*/
public class DesignCacheManager {
public static ThreadLocal<Map<String, TableData>> cacheTableData = new ThreadLocal<>();
/**
* 处理任务使用数据集缓存
*/
public static void processByCacheTableData(Task task) {
try {
cacheTableData.set(TableDataFactory.getTableDatas());
task.process();
} finally {
cacheTableData.remove();
}
}
/**
* 是否使用数据集的缓存
*/
public static boolean useDataCache() {
return cacheTableData.get() != null;
}
public static ThreadLocal<Map<String, TableData>> getCacheTableData() {
return cacheTableData;
}
public static void setCacheTableData(ThreadLocal<Map<String, TableData>> cacheTableData) {
DesignCacheManager.cacheTableData = cacheTableData;
}
/**
* 任务
*/
public interface Task {
/**
* 处理
*/
void process();
}
}

9
designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java

@ -17,6 +17,7 @@ import com.fr.data.impl.storeproc.StoreProcedureConstants;
import com.fr.data.impl.storeproc.StoreProcedureHelper; import com.fr.data.impl.storeproc.StoreProcedureHelper;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.cache.DesignCacheManager;
import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.data.tabledata.wrapper.MultiResultTableDataNameWrapper; import com.fr.design.data.tabledata.wrapper.MultiResultTableDataNameWrapper;
import com.fr.design.data.tabledata.wrapper.MultiResultTableDataWrapper; import com.fr.design.data.tabledata.wrapper.MultiResultTableDataWrapper;
@ -446,7 +447,13 @@ public abstract class DesignTableDataManager {
} }
private static void addServerData(java.util.Map<String, TableDataWrapper> resMap) { private static void addServerData(java.util.Map<String, TableDataWrapper> resMap) {
Map<String, TableData> tableDataMap = TableDataFactory.getTableDatas(); Map<String, TableData> tableDataMap;
if (DesignCacheManager.useDataCache()) {
FineLoggerFactory.getLogger().debug("use cache Table data wrapper.");
tableDataMap = DesignCacheManager.getCacheTableData().get();
} else {
tableDataMap = TableDataFactory.getTableDatas();
}
for (Entry<String, TableData> entry : tableDataMap.entrySet()) { for (Entry<String, TableData> entry : tableDataMap.entrySet()) {
if (globalDsCache.containsKey(entry.getKey())) { if (globalDsCache.containsKey(entry.getKey())) {
resMap.put(entry.getKey(), globalDsCache.get(entry.getKey())); resMap.put(entry.getKey(), globalDsCache.get(entry.getKey()));

3
designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java

@ -6,6 +6,7 @@ import com.fr.base.svg.IconUtils;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.file.LocateAction; import com.fr.design.actions.file.LocateAction;
import com.fr.design.cache.DesignCacheManager;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
@ -1296,7 +1297,7 @@ public class MultiTemplateTabPane extends JComponent {
//没有点击关闭和ListDown按钮,则切换到点击的模板处 //没有点击关闭和ListDown按钮,则切换到点击的模板处
closeIconIndex = -1; closeIconIndex = -1;
clodeMode = CLOSE; clodeMode = CLOSE;
switchJTemplate(getTemplateIndex(evtX)); DesignCacheManager.processByCacheTableData(() -> switchJTemplate(getTemplateIndex(evtX)));
isShowList = false; isShowList = false;
} }
MultiTemplateTabPane.this.repaint(); MultiTemplateTabPane.this.repaint();

3
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -5,6 +5,7 @@ package com.fr.design.file;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.cache.DesignCacheManager;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fun.TemplateTreeDefineProcessor; import com.fr.design.fun.TemplateTreeDefineProcessor;
import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.gui.itree.filetree.TemplateFileTree;
@ -112,7 +113,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
@Override @Override
public void mousePressed(MouseEvent evt) { public void mousePressed(MouseEvent evt) {
if (reportletsTree.getPathForLocation(evt.getX(), evt.getY()) != null && evt.getClickCount() == 2) { if (reportletsTree.getPathForLocation(evt.getX(), evt.getY()) != null && evt.getClickCount() == 2) {
openFile(); DesignCacheManager.processByCacheTableData(() -> openFile());
} }
} }

Loading…
Cancel
Save