From 5f51bbdecedae446e732f5522e33a9333efe3ecf Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Sun, 11 Aug 2024 23:20:24 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-114392=20FR-FBP=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=AE=BE=E8=AE=A1=E9=80=82=E9=85=8D=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E5=8D=A1=E9=A1=BF=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/cache/DesignCacheManager.java | 56 +++++++++++++++++++ .../design/data/DesignTableDataManager.java | 9 ++- .../fr/design/file/MultiTemplateTabPane.java | 3 +- .../com/fr/design/file/TemplateTreePane.java | 3 +- 4 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/cache/DesignCacheManager.java diff --git a/designer-base/src/main/java/com/fr/design/cache/DesignCacheManager.java b/designer-base/src/main/java/com/fr/design/cache/DesignCacheManager.java new file mode 100644 index 0000000000..80b8c56aab --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/cache/DesignCacheManager.java @@ -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> 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> getCacheTableData() { + return cacheTableData; + } + + public static void setCacheTableData(ThreadLocal> cacheTableData) { + DesignCacheManager.cacheTableData = cacheTableData; + } + + /** + * 任务 + */ + public interface Task { + /** + * 处理 + */ + void process(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index 1727edf26e..46e0c4de84 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/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.operator.DataOperator; import com.fr.design.DesignModelAdapter; +import com.fr.design.cache.DesignCacheManager; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.tabledata.wrapper.MultiResultTableDataNameWrapper; import com.fr.design.data.tabledata.wrapper.MultiResultTableDataWrapper; @@ -446,7 +447,13 @@ public abstract class DesignTableDataManager { } private static void addServerData(java.util.Map resMap) { - Map tableDataMap = TableDataFactory.getTableDatas(); + Map tableDataMap; + if (DesignCacheManager.useDataCache()) { + FineLoggerFactory.getLogger().debug("use cache Table data wrapper."); + tableDataMap = DesignCacheManager.getCacheTableData().get(); + } else { + tableDataMap = TableDataFactory.getTableDatas(); + } for (Entry entry : tableDataMap.entrySet()) { if (globalDsCache.containsKey(entry.getKey())) { resMap.put(entry.getKey(), globalDsCache.get(entry.getKey())); diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java index 8f2783a3ca..1a1ab51b2f 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java +++ b/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.design.actions.UpdateAction; import com.fr.design.actions.file.LocateAction; +import com.fr.design.cache.DesignCacheManager; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.imenu.UIMenuItem; @@ -1296,7 +1297,7 @@ public class MultiTemplateTabPane extends JComponent { //没有点击关闭和ListDown按钮,则切换到点击的模板处 closeIconIndex = -1; clodeMode = CLOSE; - switchJTemplate(getTemplateIndex(evtX)); + DesignCacheManager.processByCacheTableData(() -> switchJTemplate(getTemplateIndex(evtX))); isShowList = false; } MultiTemplateTabPane.this.repaint(); diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index b91ac522d0..db63112647 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/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.design.ExtraDesignClassManager; +import com.fr.design.cache.DesignCacheManager; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.fun.TemplateTreeDefineProcessor; import com.fr.design.gui.itree.filetree.TemplateFileTree; @@ -112,7 +113,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { @Override public void mousePressed(MouseEvent evt) { if (reportletsTree.getPathForLocation(evt.getX(), evt.getY()) != null && evt.getClickCount() == 2) { - openFile(); + DesignCacheManager.processByCacheTableData(() -> openFile()); } }