From 1bf8891fa89b295f6c708ea38577146a37152ad7 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 13 Nov 2024 15:30:02 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-140290=20=E3=80=90FVS=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E6=9B=BF=E6=8D=A2=E3=80=91=E5=8D=B8=E8=BD=BD?= =?UTF-8?q?=E5=86=8D=E5=AE=89=E8=A3=85FVS=E6=8F=92=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E7=9C=8B=E6=9D=BF=E5=92=8C=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E7=9C=8B=E6=9D=BF=EF=BC=8C=E6=9B=BF=E6=8D=A2=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E6=8C=89=E9=92=AE=E7=81=B0=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/TableDataTreePane.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) 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 543886bfa9..6a02671d3e 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 @@ -92,15 +92,13 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.concurrent.ExecutionException; public class TableDataTreePane extends BasicTableDataTreePane { - private static Set extraActions = new HashSet<>(); + private static Map extraActions = new HashMap<>(); private static final TableDataTreePane singleton = new TableDataTreePane(); public static final int PLUGIN_LISTENER_PRIORITY = 1; @@ -226,7 +224,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { popupMenu.add(pasteAction.createMenuItem()); popupMenu.add(removeAction.createMenuItem()); popupMenu.addSeparator(); - for (AbstractExtraAction action : extraActions) { + for (AbstractExtraAction action : extraActions.values()) { try { popupMenu.add(action.createMenuItem()); } catch (Exception e) { @@ -275,7 +273,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { } private void initExtraAction() { - for (AbstractExtraAction action: extraActions) { + for (AbstractExtraAction action: extraActions.values()) { try { toolbarDef.addShortCut(action); } catch (Exception e) { @@ -287,19 +285,20 @@ public class TableDataTreePane extends BasicTableDataTreePane { /** * 注册ExtraAction * + * @param key 标识符 * @param extraAction TableDataTree工具栏的扩展接口Action */ - public static void registerExtraAction(AbstractExtraAction extraAction) { - extraActions.add(extraAction); + public static void registerExtraAction(String key, AbstractExtraAction extraAction) { + extraActions.put(key, extraAction); } /** * 移除ExtraAction * - * @param extraAction TableDataTree工具栏的扩展接口Action + * @param key 标识符 */ - public static void removeExtraAction(AbstractExtraAction extraAction) { - extraActions.remove(extraAction); + public static void removeExtraAction(String key) { + extraActions.remove(key); } /** @@ -729,7 +728,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { pasteAction.setEnabled(false); removeAction.setEnabled(false); previewTableDataAction.setEnabled(false); - for (AbstractExtraAction action : extraActions) { + for (AbstractExtraAction action : extraActions.values()) { action.setEnabled(false); } if (op == null || op.interceptButtonEnabled()) { @@ -766,7 +765,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { } private void checkExtraActionEnable(int dataMode, int selectioncount, boolean hasSelectedIndependentColumns) { - for (AbstractExtraAction action : extraActions) { + for (AbstractExtraAction action : extraActions.values()) { action.setEnabled(action.checkEnable(dataMode, selectioncount, hasSelectedIndependentColumns)); } } From 425c6b72a9e8a3874faa7248e3a2265e31852298 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 13 Nov 2024 15:33:58 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-140290=20=E3=80=90FVS=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E6=9B=BF=E6=8D=A2=E3=80=91=E5=8D=B8=E8=BD=BD?= =?UTF-8?q?=E5=86=8D=E5=AE=89=E8=A3=85FVS=E6=8F=92=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E7=9C=8B=E6=9D=BF=E5=92=8C=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E7=9C=8B=E6=9D=BF=EF=BC=8C=E6=9B=BF=E6=8D=A2=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E6=8C=89=E9=92=AE=E7=81=B0=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/data/datapane/TableDataTreePane.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 6a02671d3e..06e9a969d1 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 @@ -285,20 +285,19 @@ public class TableDataTreePane extends BasicTableDataTreePane { /** * 注册ExtraAction * - * @param key 标识符 * @param extraAction TableDataTree工具栏的扩展接口Action */ - public static void registerExtraAction(String key, AbstractExtraAction extraAction) { - extraActions.put(key, extraAction); + public static void registerExtraAction(AbstractExtraAction extraAction) { + extraActions.put(extraAction.getClass().getSimpleName(), extraAction); } /** * 移除ExtraAction * - * @param key 标识符 + * @param extraAction TableDataTree工具栏的扩展接口Action */ - public static void removeExtraAction(String key) { - extraActions.remove(key); + public static void removeExtraAction(AbstractExtraAction extraAction) { + extraActions.remove(extraAction.getClass().getSimpleName()); } /** From ad5d78ff92d1d220728713a62a77249caed23f7c Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 14 Nov 2024 10:19:27 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-140361=20=E3=80=90=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E6=9B=BF=E6=8D=A2=E3=80=91=E5=9B=BE=E8=A1=A8=E7=9A=84?= =?UTF-8?q?=E7=89=B9=E6=95=88-=E5=9B=BE=E8=A1=A8=E8=B6=85=E9=93=BE?= =?UTF-8?q?=E6=82=AC=E6=B5=AE=E5=9B=BE=E8=A1=A8=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?-=E6=95=B0=E6=8D=AE=E9=9B=86=EF=BC=8C=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/content/js/SearchCellJSAction.java | 13 + .../content/js/SearchChartJSAction.java | 2 - .../content/js/SearchFloatJSAction.java | 12 + .../replace/action/content/js/SearchJS.java | 12 + .../action/content/js/SearchJSManager.java | 16 ++ .../actions/replace/utils/ReplaceUtils.java | 239 +++++++++++++++++- .../actions/replace/utils/SearchJSUtils.java | 57 ++++- 7 files changed, 345 insertions(+), 6 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchCellJSAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchCellJSAction.java index cff74e9e0a..997000d06b 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchCellJSAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchCellJSAction.java @@ -9,6 +9,7 @@ import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.utils.SearchJSUtils; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JTemplate; +import com.fr.js.JavaScript; import com.fr.js.JavaScriptImpl; import com.fr.js.NameJavaScriptGroup; @@ -42,6 +43,18 @@ public class SearchCellJSAction implements SearchJS { jsInfos.addAll(CellJSInfos); } + @Override + public List getTemplateJSDependenceTables(JTemplate jTemplate) { + List scripts = new ArrayList<>(); + SearchCellAction searchCellAction = SearchCellAction.getInstance(); + searchCellAction.search4Infos(jTemplate); + for (CellInfo cellInfo : searchCellAction.getCellInfos()) { + CellElement cell = (CellElement) cellInfo.getContent().getReplaceObject(); + scripts.addAll(SearchJSUtils.getJSDependenceTables(cell)); + } + return scripts; + } + private void addJSInfos2ListFromCell(JTemplate jTemplate, List jsInfos) { SearchCellAction searchCellAction = SearchCellAction.getInstance(); searchCellAction.search4Infos(jTemplate); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java index 1d04ac2ccf..ca550066ac 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java @@ -9,7 +9,6 @@ import com.fr.design.actions.replace.utils.SearchJSUtils; import com.fr.design.i18n.Toolkit; import com.fr.js.JavaScriptImpl; import com.fr.js.NameJavaScript; - import com.fr.js.NameJavaScriptGroup; import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.plot.VanChartPlot; @@ -21,7 +20,6 @@ import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.vanchart.VanChart; import com.fr.stable.collections.combination.Pair; -import java.util.ArrayList; import java.util.List; /** diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchFloatJSAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchFloatJSAction.java index 4270d5bbca..96f589d791 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchFloatJSAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchFloatJSAction.java @@ -11,6 +11,7 @@ import com.fr.design.actions.replace.utils.SearchJSUtils; import com.fr.design.mainframe.JTemplate; +import com.fr.js.JavaScript; import com.fr.report.cell.FloatElement; @@ -37,6 +38,17 @@ public class SearchFloatJSAction implements SearchJS { jsInfos.addAll(floatJSInfos); } + @Override + public List getTemplateJSDependenceTables(JTemplate jTemplate) { + List scripts = new ArrayList<>(); + SearchFloatAction searchFloatAction = SearchFloatAction.getInstance(); + searchFloatAction.search4Infos(jTemplate); + for (FloatInfo floatInfo : searchFloatAction.getFloatInfos()) { + FloatElement floatElement = (FloatElement) floatInfo.getContent().getReplaceObject(); + scripts.addAll(SearchJSUtils.getJSDependenceTables(floatElement)); + } + return scripts; + } private void addJSInfos2ListFromFloat(JTemplate jTemplate, List jsInfos) { SearchFloatAction searchFloatAction = SearchFloatAction.getInstance(); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJS.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJS.java index d543a4c2ea..64d65abfc9 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJS.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJS.java @@ -3,7 +3,9 @@ package com.fr.design.actions.replace.action.content.js; import com.fr.design.actions.replace.action.SearchAction; import com.fr.design.actions.replace.info.JSInfo; import com.fr.design.mainframe.JTemplate; +import com.fr.js.JavaScript; +import java.util.ArrayList; import java.util.List; /** @@ -23,4 +25,14 @@ public interface SearchJS extends SearchAction { */ default void searchJSFromObject(JTemplate jTemplate, List jsInfos) { } + + /** + * 获取模板中的涉及数据集的所有超链 + * + * @param jTemplate 模板 + * @return 超链集合 + */ + default List getTemplateJSDependenceTables(JTemplate jTemplate) { + return new ArrayList<>(); + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJSManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJSManager.java index 9bd972a1f1..f2a1cc38af 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJSManager.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJSManager.java @@ -5,6 +5,7 @@ import com.fr.design.actions.replace.action.SearchManager; import com.fr.design.actions.replace.info.JSInfo; import com.fr.design.mainframe.JTemplate; +import com.fr.js.JavaScript; import java.util.ArrayList; import java.util.HashSet; @@ -45,6 +46,21 @@ public class SearchJSManager implements SearchAction, SearchManager { setJsInfos(jsInfos); } + + /** + * 查找超链 + * + * @param jTemplate 模板 + * @return 超链集合 + */ + public List getTemplateJSDependenceTables(JTemplate jTemplate) { + List javaScripts = new ArrayList<>(); + for (SearchJS searchJS : searchJSSet) { + javaScripts.addAll(searchJS.getTemplateJSDependenceTables(jTemplate)); + } + return javaScripts; + } + public List getJsInfos() { return jsInfos; } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceUtils.java index 4571dc1ad1..56a38c4f6d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceUtils.java @@ -2,12 +2,21 @@ package com.fr.design.actions.replace.utils; import com.fr.base.Formula; import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.web.ChartHyperPoplink; +import com.fr.data.SimpleDSColumn; import com.fr.data.TableReplacementEntity; +import com.fr.data.condition.CommonCondition; +import com.fr.data.condition.JoinCondition; +import com.fr.data.condition.ListCondition; +import com.fr.data.core.Compare; +import com.fr.data.impl.NameTableData; +import com.fr.data.impl.TableDataDictionary; import com.fr.design.actions.replace.action.content.cell.SearchCellAction; import com.fr.design.actions.replace.action.content.formula.SearchFormulaManager; import com.fr.design.actions.replace.action.content.formula.cell.SearchCellFormulaAction; import com.fr.design.actions.replace.action.content.formula.chart.SearchChartCollectionFormulaAction; import com.fr.design.actions.replace.action.content.formula.widget.SearchWidgetFormulaAction; +import com.fr.design.actions.replace.action.content.js.SearchJSManager; import com.fr.design.actions.replace.action.content.tabledata.TableDataFormulaType; import com.fr.design.actions.replace.action.content.tabledata.TableDataFormulaUtils; import com.fr.design.actions.replace.action.content.widget.SearchWidgetAction; @@ -17,8 +26,18 @@ import com.fr.design.actions.replace.info.WidgetInfo; import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.mainframe.JTemplate; import com.fr.form.FormElementCaseProvider; +import com.fr.form.ui.DictionaryContainer; import com.fr.form.ui.ElementCaseEditor; +import com.fr.general.ComparatorUtils; +import com.fr.general.data.Condition; +import com.fr.general.data.TableDataColumn; +import com.fr.js.JavaScript; +import com.fr.js.NameJavaScript; import com.fr.main.impl.WorkBook; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.FloatElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.elementcase.ElementCase; import com.fr.report.report.Report; import com.fr.report.utils.ElementCaseHelper; @@ -180,6 +199,8 @@ public class ReplaceUtils { List formulaInfos = new ArrayList<>(); SearchChartCollectionFormulaAction.getInstance().searchChartCollectionFormula(formulaInfos, new ITContent(), chartCollection); replaceFormulaInfos(formulaInfos, entities); + // 超链部分 + replaceChartJs(chartCollection, entities); } /** @@ -190,13 +211,16 @@ public class ReplaceUtils { */ public static void replaceElementCase(ElementCase elementCase, List entities) { // 非公式部分 - ElementCaseHelper.replaceTableDataWithOutFormula(elementCase, entities); + replaceTableDataWithOutFormula(elementCase, entities); // 公式部分——理论上就只有单元格和控件(超链那些都包含) List formulaInfos = getElementCaseFormulas(elementCase); replaceFormulaInfos(formulaInfos, entities); + // 超链部分 + replaceElementCasJs(elementCase, entities); } + /** * 替换CPT使用的数据集(包含公式里的) * @@ -206,18 +230,73 @@ public class ReplaceUtils { public static void replaceCpt(JTemplate template, List entity) { if (template.getTarget() instanceof WorkBook) { WorkBook workBook = (WorkBook) template.getTarget(); - // 非公式部分替换 replaceWorkBook(workBook, entity); // 公式部分 SearchFormulaManager.getInstance().search4Infos(template); List formulaInfos = SearchFormulaManager.getInstance().getFormulaInfos(); replaceFormulaInfos(formulaInfos, entity); + // 超链部分 + replaceTemplateJs(template, entity); // 触发响应 template.fireTargetModified(); } } + /** + * ----------------------------------------------private-------------------------------------------------- + */ + + + private static void replaceTemplateJs(JTemplate template, List entity) { + List javaScripts = SearchJSManager.getInstance().getTemplateJSDependenceTables(template); + replaceJs(javaScripts, entity); + } + + private static void replaceChartJs(ChartCollection chartCollection, List entities) { + List scripts = new ArrayList<>(); + List nameJavaScripts = SearchJSUtils.getChartJavaScript(chartCollection); + for(NameJavaScript javaScript : nameJavaScripts) { + if (javaScript.getJavaScript() instanceof ChartHyperPoplink) { + scripts.add(javaScript.getJavaScript()); + } + } + replaceJs(scripts, entities); + } + + private static void replaceElementCasJs(ElementCase elementCase, List entities) { + if (elementCase == null) { + return; + } + List javaScripts = new ArrayList<>(); + // 替换悬浮元素 + Iterator floatIterator = elementCase.floatIterator(); + while (floatIterator.hasNext()) { + FloatElement floatCell = (FloatElement) floatIterator.next(); + javaScripts.addAll(SearchJSUtils.getJSDependenceTables(floatCell)); + } + // 替换通用元素 + Iterator cellIterator = elementCase.cellIterator(); + while (cellIterator.hasNext()) { + CellElement cell = (CellElement) cellIterator.next(); + javaScripts.addAll(SearchJSUtils.getJSDependenceTables(cell)); + } + replaceJs(javaScripts, entities); + } + + + private static void replaceJs(List javaScripts, List entity) { + for (JavaScript javaScript : javaScripts) { + if (javaScript instanceof ChartHyperPoplink) { + ChartHyperPoplink chartHyperPoplink = (ChartHyperPoplink) javaScript; + if (chartHyperPoplink.getChartCollection() instanceof ChartCollection) { + replaceChart((ChartCollection) chartHyperPoplink.getChartCollection(), entity); + } + } + } + } + + private static void replaceWorkBook(WorkBook workBook, List entity) { if (acceptTableReplacement(entity)) { for (int i = 0; i < workBook.getReportCount(); i++) { @@ -226,7 +305,7 @@ public class ReplaceUtils { Iterator it = report.iteratorOfElementCase(); while (it.hasNext()) { ElementCase elementCase = (ElementCase) it.next(); - ElementCaseHelper.replaceTableDataWithOutFormula(elementCase, entity); + replaceTableDataWithOutFormula(elementCase, entity); } } } @@ -270,4 +349,158 @@ public class ReplaceUtils { } return formulaInfos; } + + + /** + * 替换数据集 + * + * @param elementCase 可以是报表块、组件、WorkBook... + * @param entity 数据集替换信息 + */ + private static void replaceTableDataWithOutFormula(ElementCase elementCase, List entity) { + if (elementCase == null) { + return; + } + + // -------非公式部分------- + // 替换悬浮元素 + replaceFloatCell(elementCase, entity); + // 替换通用元素 + replaceNormalCell(elementCase, entity); + } + + + /** + * 替换通用元素,主要是单元格的各个地方 + * + *
  • 单元格形态
  • + *
  • 单元格控件
  • + *
  • 单元格数据字典
  • + *
  • 单元格值
  • + * + * @param elementCase + * @param entity + */ + private static void replaceNormalCell(ElementCase elementCase, List entity) { + Iterator cellIterator = elementCase.cellIterator(); + + while (cellIterator.hasNext()) { + CellElement cell = (CellElement) cellIterator.next(); + // 处理【形态、控件、数据字典】 + replacePresentAndDictionary(cell, entity); + // 处理【单元格值】 + replaceCellValue(cell, entity); + } + } + + private static void replaceCellValue(CellElement cell, List entity) { + Object value = cell.getValue(); + if (value instanceof DSColumn) { + // 替换【数据列】 + replaceDSColumn( (DSColumn) value, entity); + // 替换【条件属性】 + replaceCondition(((DSColumn) value).getCondition(), entity); + } else if (value instanceof ChartCollection) { + ((ChartCollection) value).replaceTableData(entity); + replaceChartJs((ChartCollection) value, entity); + } + } + + private static void replaceCondition(Condition condition, List entity) { + if (condition != null) { + //公式条件不需要修改,里面不会涉及到,有问题再加 + //普通条件 + //1条条件 + if (condition instanceof CommonCondition) { + dealWithTableDataNameChange((CommonCondition) condition, entity); + } + //N条条件 + if (condition instanceof ListCondition) { + for (int k = 0; k < ((ListCondition) condition).getJoinConditionCount(); k++) { + JoinCondition joinCondition = ((ListCondition) condition).getJoinCondition(k); + Condition obCondition = joinCondition.getCondition(); + if (obCondition != null) { + if (obCondition instanceof CommonCondition) { + dealWithTableDataNameChange((CommonCondition) obCondition, entity); + } + } + } + } + } + } + + private static void dealWithTableDataNameChange(CommonCondition condition, List entities) { + Compare compare = condition.getCompare(); + Object ob = compare.getValue(); + if (ob instanceof SimpleDSColumn) { + for (TableReplacementEntity entity : entities) { + if (ComparatorUtils.equals(((SimpleDSColumn) ob).getDsName(), entity.getOldName())) { + ((SimpleDSColumn) ob).setDsName(entity.getNewName()); + ((SimpleDSColumn) ob).setColumn(TableDataColumn.createColumn(entity.getTargetField(TableDataColumn.getColumnName(((SimpleDSColumn) ob).getColumn())))); + } + } + + } + } + + private static void replaceDSColumn(DSColumn dsColumn, List entities) { + for (TableReplacementEntity entity : entities) { + if (ComparatorUtils.equals(dsColumn.getDSName(), entity.getOldName())) { + // 数据集替换 + dsColumn.setDSName(entity.getNewName()); + // 数据集字段替换 + dsColumn.setColumn(TableDataColumn.createColumn(entity.getTargetField(dsColumn.getColumnName()))); + } + } + } + + private static void replacePresentAndDictionary(CellElement cell, List entities) { + TemplateCellElement cellElement = (TemplateCellElement) cell; + // 处理单元格的控件 + replaceCellWidget(cellElement, entities); + // 处理形态 + ElementCaseHelper.replacePresent(cellElement.getPresent(), entities); + } + + + /** + * 处理单元格控件 + * + * @param cellElement 单元格 + * @param entities 替换信息 + */ + private static void replaceCellWidget(TemplateCellElement cellElement, List entities) { + if (cellElement.getWidget() instanceof DictionaryContainer) { + DictionaryContainer db = (DictionaryContainer) (cellElement.getWidget()); + if (db != null) { + if (db.getDictionary() instanceof TableDataDictionary) { + TableDataDictionary tdd = (TableDataDictionary) db.getDictionary(); + NameTableData ndd = (NameTableData) tdd.getTableData(); + // 控件持有的数据字典也得处理 + ElementCaseHelper.replaceTableDataDictionary(tdd, ndd, entities); + } + } + } + } + + /** + * 替换悬浮元素中的数据集 + * + * @param elementCase 组件 + * @param entities 替换信息 + */ + private static void replaceFloatCell(ElementCase elementCase, List entities) { + Iterator floatIterator = elementCase.floatIterator(); + while (floatIterator.hasNext()) { + FloatElement floatCell = (FloatElement) floatIterator.next(); + Object value = floatCell.getValue(); + if (value instanceof ChartCollection) { + ((ChartCollection) value).replaceTableData(entities); + replaceChartJs((ChartCollection) value, entities); + } + } + } + + + } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java index 2a1a4ef188..8a2d245b54 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java @@ -36,7 +36,6 @@ import com.fr.report.cell.Elem; import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; - import java.util.ArrayList; import java.util.List; @@ -379,6 +378,27 @@ public class SearchJSUtils { } + /** + * 获取图表-特效-交互属性中的JS + */ + public static List getChartJavaScript(ChartCollection chartCollection) { + ArrayList nameJavaScriptArrayList = new ArrayList<>(); + for (int i = 0; i < chartCollection.getChartCount(); i++) { + if (chartCollection.getChart(i) instanceof VanChart) { + VanChart chart = ((VanChart) chartCollection.getChart(i)); + if (chart.getPlot() != null) { + NameJavaScriptGroup nameJavaScriptGroup = chart.getPlot().getHotHyperLink(); + if (isNameJavaScriptGroupExist(nameJavaScriptGroup)) { + for (int j = 0; j < nameJavaScriptGroup.size(); j++) { + nameJavaScriptArrayList.add(nameJavaScriptGroup.getNameHyperlink(j)); + } + } + } + } + } + return nameJavaScriptArrayList; + } + /** * 处理图表的交互属性(可能存在多种地图) * @param content 存储信息的数据结构 @@ -493,6 +513,41 @@ public class SearchJSUtils { } } + + /** + * 获取涉及数据集的超链 + * + * @param elem 单元对象 + * @return 超链集合 + */ + public static List getJSDependenceTables(Elem elem) { + List scripts = new ArrayList<>(); + if (elem.getNameHyperlinkGroup() != null) { + for (int j = 0; j < elem.getNameHyperlinkGroup().size(); j++) { + NameJavaScript nameJavaScript = elem.getNameHyperlinkGroup().getNameHyperlink(j); + JavaScript javaScript = nameJavaScript.getJavaScript(); + if (isChartHyperPopLinkValid(javaScript)) { + ChartHyperPoplink chartHyperPoplink = (ChartHyperPoplink) javaScript; + scripts.add(javaScript); + dealWithChartHyperPoplink(chartHyperPoplink, scripts); + } + } + } + return scripts; + } + + private static void dealWithChartHyperPoplink(ChartHyperPoplink chartHyperPoplink, List scripts) { + if (chartHyperPoplink.getChartCollection() instanceof ChartCollection) { + List nameJavaScripts = getNameJavaScript((ChartCollection) chartHyperPoplink.getChartCollection(), new ITContent(), new ArrayList<>()); + for(NameJavaScript javaScript : nameJavaScripts) { + if (javaScript.getJavaScript() instanceof ChartHyperPoplink) { + scripts.add(javaScript.getJavaScript()); + } + } + } + } + + /** * 是否图表悬浮超链且内部图表是否可用 * From 70084fb9e44a3a3c821ffc75fea338e7f2fbff99 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 14 Nov 2024 10:26:27 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-140564=20=E3=80=90=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E6=9B=BF=E6=8D=A2=E3=80=91=E5=8F=82=E6=95=B0=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E6=89=80=E6=9C=89=E6=8E=A7=E4=BB=B6=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=AD=97=E5=85=B8=E7=9A=84=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=EF=BC=8C=E9=83=BD=E6=B2=A1=E6=9C=89=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/replace/utils/ReplaceUtils.java | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceUtils.java index 56a38c4f6d..f5445542d8 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceUtils.java @@ -28,12 +28,14 @@ import com.fr.design.mainframe.JTemplate; import com.fr.form.FormElementCaseProvider; import com.fr.form.ui.DictionaryContainer; import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.general.data.Condition; import com.fr.general.data.TableDataColumn; import com.fr.js.JavaScript; import com.fr.js.NameJavaScript; import com.fr.main.impl.WorkBook; +import com.fr.main.parameter.ReportParameterAttr; import com.fr.report.cell.CellElement; import com.fr.report.cell.FloatElement; import com.fr.report.cell.TemplateCellElement; @@ -230,7 +232,9 @@ public class ReplaceUtils { public static void replaceCpt(JTemplate template, List entity) { if (template.getTarget() instanceof WorkBook) { WorkBook workBook = (WorkBook) template.getTarget(); - // 非公式部分替换 + // 参数面板 + replaceWorkBookPara(workBook, entity); + // 主体非公式部分替换 replaceWorkBook(workBook, entity); // 公式部分 SearchFormulaManager.getInstance().search4Infos(template); @@ -246,7 +250,16 @@ public class ReplaceUtils { /** * ----------------------------------------------private-------------------------------------------------- */ + private static void replaceWorkBookPara(WorkBook workBook, List entity) { + ReportParameterAttr attr = workBook.getReportParameterAttr(); + if (attr != null && attr.getParameterUI() != null) { + Widget[] widgets = attr.getParameterUI().getAllWidgets(); + for (Widget widget : widgets) { + replaceWidget(widget, entity); + } + } + } private static void replaceTemplateJs(JTemplate template, List entity) { List javaScripts = SearchJSManager.getInstance().getTemplateJSDependenceTables(template); @@ -457,28 +470,26 @@ public class ReplaceUtils { private static void replacePresentAndDictionary(CellElement cell, List entities) { TemplateCellElement cellElement = (TemplateCellElement) cell; // 处理单元格的控件 - replaceCellWidget(cellElement, entities); + replaceWidget(cellElement.getWidget(), entities); // 处理形态 ElementCaseHelper.replacePresent(cellElement.getPresent(), entities); } /** - * 处理单元格控件 + * 处理控件 * - * @param cellElement 单元格 + * @param widget 控件 * @param entities 替换信息 */ - private static void replaceCellWidget(TemplateCellElement cellElement, List entities) { - if (cellElement.getWidget() instanceof DictionaryContainer) { - DictionaryContainer db = (DictionaryContainer) (cellElement.getWidget()); - if (db != null) { - if (db.getDictionary() instanceof TableDataDictionary) { - TableDataDictionary tdd = (TableDataDictionary) db.getDictionary(); - NameTableData ndd = (NameTableData) tdd.getTableData(); - // 控件持有的数据字典也得处理 - ElementCaseHelper.replaceTableDataDictionary(tdd, ndd, entities); - } + private static void replaceWidget(Widget widget, List entities) { + if (widget instanceof DictionaryContainer) { + DictionaryContainer db = (DictionaryContainer) widget; + if (db.getDictionary() instanceof TableDataDictionary) { + TableDataDictionary tdd = (TableDataDictionary) db.getDictionary(); + NameTableData ndd = (NameTableData) tdd.getTableData(); + // 控件持有的数据字典也得处理 + ElementCaseHelper.replaceTableDataDictionary(tdd, ndd, entities); } } }