From 2562ca8a15efe3f77b77784c75df8d373deb29f4 Mon Sep 17 00:00:00 2001 From: rinoux Date: Mon, 16 Aug 2021 16:42:04 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-57209=20=E5=85=B1=E4=BA=AB=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E6=98=BE=E7=A4=BA=E9=85=8D=E7=BD=AE=E5=85=BC?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tils.java => StrategyConfigAttrUtils.java} | 21 +---------- .../data/datapane/TableDataTreePane.java | 16 ++++----- .../tabledatapane/DBTableDataPane.java | 35 ++++++++++++------- 3 files changed, 32 insertions(+), 40 deletions(-) rename designer-base/src/main/java/com/fr/design/data/{DesignerStrategyConfigUtils.java => StrategyConfigAttrUtils.java} (88%) diff --git a/designer-base/src/main/java/com/fr/design/data/DesignerStrategyConfigUtils.java b/designer-base/src/main/java/com/fr/design/data/StrategyConfigAttrUtils.java similarity index 88% rename from designer-base/src/main/java/com/fr/design/data/DesignerStrategyConfigUtils.java rename to designer-base/src/main/java/com/fr/design/data/StrategyConfigAttrUtils.java index c15b3f3ce..e2a75fc11 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignerStrategyConfigUtils.java +++ b/designer-base/src/main/java/com/fr/design/data/StrategyConfigAttrUtils.java @@ -26,7 +26,7 @@ import java.util.Set; * @version 10.0 * Created by rinoux on 2020/10/28 */ -public class DesignerStrategyConfigUtils { +public class StrategyConfigAttrUtils { /** * 获取当前编辑模版的数据集缓存配置属性 @@ -56,25 +56,6 @@ public class DesignerStrategyConfigUtils { } - /** - * 当前编辑的模版是否被批量开启 - * - * @return - */ - public static boolean isEditingTemplateRecommended() { - JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - - if (jTemplate != null) { - FILE file = jTemplate.getEditingFILE(); - if (file != null) { - String path = file.getPath(); - return StrategyConfigService.isTemplateEnabled(path); - } - } - return false; - } - - /** * 获取模版数据集配置 * diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java index b95c03ac6..493d40d79 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java @@ -11,7 +11,7 @@ import com.fr.design.constants.UIConstants; import com.fr.design.data.BasicTableDataTreePane; import com.fr.design.data.BasicTableDataUtils; import com.fr.design.data.DesignTableDataManager; -import com.fr.design.data.DesignerStrategyConfigUtils; +import com.fr.design.data.StrategyConfigAttrUtils; import com.fr.design.data.tabledata.StoreProcedureWorkerListener; import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; import com.fr.design.data.tabledata.tabledatapane.DBTableDataPane; @@ -291,10 +291,10 @@ public class TableDataTreePane extends BasicTableDataTreePane { editingConfig.setDsName(tdName); if (!ComparatorUtils.equals(oldName, tdName)) { //重命名 - DesignerStrategyConfigUtils.removeStrategyConfig(oldName); + StrategyConfigAttrUtils.removeStrategyConfig(oldName); } - DesignerStrategyConfigUtils.addStrategyConfig(editingConfig); + StrategyConfigAttrUtils.addStrategyConfig(editingConfig); } ((DBTableData) td).setDsName(tdName); } @@ -588,7 +588,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { if (wrapper.getTableData() instanceof DBTableData) { DBTableData td = (DBTableData) wrapper.getTableData(); - StrategyConfig config = DesignerStrategyConfigUtils.getStrategyConfig(wrapper.getTableDataName()); + StrategyConfig config = StrategyConfigAttrUtils.getStrategyConfig(wrapper.getTableDataName()); if (config == null) { result.put(td, td.isShare() ? ESDStatus.SINGLE_ON : ESDStatus.SINGLE_OFF); } else { @@ -632,14 +632,14 @@ public class TableDataTreePane extends BasicTableDataTreePane { StrategyConfig strategyConfig = getOrCreateStrategyConfig(dsName); strategyConfig.setEnable(true); strategyConfig.setUseGlobal(false); - DesignerStrategyConfigUtils.addStrategyConfig(strategyConfig); + StrategyConfigAttrUtils.addStrategyConfig(strategyConfig); DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); } } } private @NotNull StrategyConfig getOrCreateStrategyConfig(String dsName) { - StrategyConfig config = DesignerStrategyConfigUtils.getStrategyConfig(dsName); + StrategyConfig config = StrategyConfigAttrUtils.getStrategyConfig(dsName); if (config == null) { config = StrategyConfigHelper.createStrategyConfig(true); @@ -680,7 +680,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { StrategyConfig strategyConfig = getOrCreateStrategyConfig(dsName); strategyConfig.setEnable(false); strategyConfig.setUseGlobal(false); - DesignerStrategyConfigUtils.addStrategyConfig(strategyConfig); + StrategyConfigAttrUtils.addStrategyConfig(strategyConfig); DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); } } @@ -814,7 +814,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { checkButtonEnabled(); //删掉缓存配置 - DesignerStrategyConfigUtils.removeStrategyConfig(selectedNO.getName()); + StrategyConfigAttrUtils.removeStrategyConfig(selectedNO.getName()); // 如果一个模版是平台开启,这个数据集的配置不会存xml,预览模版时直接从全局配置copy,这样 // 导致删除的时候StrategyConfigsAttrSavedHook没有通过前后配置比较感知数据集被删除,因此不会发出事件让其失效 diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index 8f17a2a10..8b8099ab4 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -12,7 +12,7 @@ import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; -import com.fr.design.data.DesignerStrategyConfigUtils; +import com.fr.design.data.StrategyConfigAttrUtils; import com.fr.design.data.datapane.ESDStrategyConfigPane; import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane; import com.fr.design.data.datapane.preview.PreviewTablePane; @@ -106,7 +106,7 @@ public class DBTableDataPane extends AbstractTableDataPane { //配置 private StrategyConfig strategyConfig; - private StrategyConfigHandler configHandler; + private StrategyConfigHandler configHandler; public DBTableDataPane() { @@ -353,7 +353,8 @@ public class DBTableDataPane extends AbstractTableDataPane { //判断是不是模版数据集 switch (this.dbTableData.getScope()) { case TEMPLATE: - setEsdEnableStatus(DesignerStrategyConfigUtils.isEditingTemplateRecommended(), false); + String tplPath = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath(); + setEsdEnableStatus(StrategyConfigService.isTemplateEnabled(tplPath), false); break; case SERVER: //不会走到这里 @@ -706,21 +707,31 @@ public class DBTableDataPane extends AbstractTableDataPane { String dsName = getTableData().getDsName(); //这里为了之前兼容插件创建的配置,缓存配置不在DBTableData,而是从模版attr读取 - strategyConfig = DesignerStrategyConfigUtils.getStrategyConfig(dsName); - - if (strategyConfig == null || strategyConfig.isUseGlobal()) { - //模版里面没有配置,检查模版是否被开启 - boolean tplEnabled = StrategyConfigService.isTemplateEnabled(tplPath); - if (tplEnabled) { - //使用全局配置 - strategyConfig = StrategyConfigHelper.createStrategyConfig(true); - } + strategyConfig = StrategyConfigAttrUtils.getStrategyConfig(dsName); + + + if (useGlobal(getTableData(), strategyConfig, tplPath)) { + //使用全局配置 + strategyConfig = StrategyConfigHelper.createStrategyConfig(true); + } else if (getTableData().isShare()) { + //使用共享数据集兼容配置 + strategyConfig = StrategyConfigHelper.createStrategyConfig(true, false, true); } } return strategyConfig; } + private boolean useGlobal(DBTableData dbTableData, StrategyConfig strategyConfig, String tplPath) { + //非共享且配置为空或者指定使用全局配置时,检查是否全局开启 + if (!dbTableData.isShare() && (strategyConfig == null || strategyConfig.isUseGlobal())) { + //模版里面没有配置,检查模版是否被开启 + return StrategyConfigService.isTemplateEnabled(tplPath); + } + + return false; + } + @Override public void save(DBTableData saved, StrategyConfig config) {