diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchDSColumnFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchDSColumnFormulaAction.java index 5bced089a6..89ccad3b1a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchDSColumnFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchDSColumnFormulaAction.java @@ -58,8 +58,7 @@ public class SearchDSColumnFormulaAction implements SearchCellFormula { } private void addFormulaInfos2ArrayFromResult(ITContent content, DSColumn dsColumn, List formulaInfos) { - char formulaLabel = '='; - if (dsColumn.getResult() != null && dsColumn.getResult().length() > 0 && dsColumn.getResult().charAt(0) == formulaLabel) { + if (dsColumn.getResult() != null && dsColumn.getResult().length() > 0) { ITContent newContent = ITContent.copy(content); newContent.setReplaceObject(dsColumn); //高级-显示值 diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java index e7603de567..b95a6f6be6 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java @@ -22,6 +22,7 @@ import com.fr.report.write.ReportWriteAttr; import com.fr.report.write.SubmitVisitor; import com.fr.report.write.ValueVerifier; import com.fr.report.write.WClassSubmiter; +import com.fr.report.write.WClassVerifier; import com.fr.stable.CommonUtils; import com.fr.stable.ListMap; @@ -106,16 +107,31 @@ public class SearchTemplateFormulaAction implements SearchTemplateFormula { //数据校验 for (int i = 0, len = attr.getVerifierCount(); i < len; i++) { Verifier verifier = attr.getVerifier(i); + ITContent content = ITContent.copy(sheetContent); + content.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Verify_Data_Verify")); if (verifier instanceof ValueVerifier) { - ITContent content = ITContent.copy(sheetContent); - content.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Verify_Data_Verify")); dealValueVerifier4Formula(formulaInfos, content, (ValueVerifier) verifier); + } else if (verifier instanceof WClassVerifier) { + dealWClassVerifier(formulaInfos, content, (WClassVerifier)verifier); } } } } + private void dealWClassVerifier(List formulaInfos, ITContent content, WClassVerifier verifier) { + if (verifier.getClassVerifyJob() != null) { + ListMap map = verifier.getClassVerifyJob().getPropertyMap(); + for (Object value : map.values()) { + if (value instanceof Formula) { + ITContent formulaContent = ITContent.copy(content); + formulaContent.setReplaceObject(value); + formulaInfos.add(new FormulaInfo(formulaContent)); + } + } + } + } + private void dealValueVerifier4Formula(List formulaInfos, ITContent content, ValueVerifier verifier) { ITContent verifyContent = ITContent.copy(content); verifyContent.addOtherPos(verifier.getName()); 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 f5445542d8..66791c34b2 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 @@ -11,6 +11,8 @@ 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.data.impl.TreeNodeAttr; +import com.fr.data.impl.TreeNodeWrapper; 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; @@ -26,20 +28,32 @@ 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.data.DataBinding; +import com.fr.form.ui.DataControl; import com.fr.form.ui.DictionaryContainer; import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.TreeEditor; import com.fr.form.ui.Widget; +import com.fr.form.ui.concept.data.ValueInitializer; +import com.fr.form.ui.tree.LayerConfig; 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.js.NameJavaScriptGroup; 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; import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.report.cell.cellattr.highlight.DefaultHighlight; +import com.fr.report.cell.cellattr.highlight.Highlight; +import com.fr.report.cell.cellattr.highlight.HighlightGroup; +import com.fr.report.cell.cellattr.highlight.HyperlinkHighlightAction; +import com.fr.report.cell.cellattr.highlight.PresentHighlightAction; +import com.fr.report.cell.cellattr.highlight.WidgetHighlightAction; import com.fr.report.elementcase.ElementCase; import com.fr.report.report.Report; import com.fr.report.utils.ElementCaseHelper; @@ -297,6 +311,51 @@ public class ReplaceUtils { replaceJs(javaScripts, entities); } + private static void replaceCellHighlight(CellElement cell, List entities) { + if (cell instanceof TemplateCellElement) { + HighlightGroup group = ((TemplateCellElement) cell).getHighlightGroup(); + if (group != null) { + for (int i = 0 ; i < group.size(); i++) { + Highlight highlight = group.getHighlight(i); + replaceHighlight(highlight, entities); + } + } + } + } + + private static void replaceHighlight(Highlight highlight, List entities) { + if (highlight instanceof DefaultHighlight) { + DefaultHighlight defaultHighlight = (DefaultHighlight) highlight; + for (int i = 0 ; i < defaultHighlight.actionCount() ; i++) { + if (defaultHighlight.getHighlightAction(i) instanceof PresentHighlightAction) { + PresentHighlightAction action = (PresentHighlightAction) defaultHighlight.getHighlightAction(i); + ElementCaseHelper.replacePresent(action.getPresent(), entities); + } else if (defaultHighlight.getHighlightAction(i) instanceof WidgetHighlightAction) { + WidgetHighlightAction action = (WidgetHighlightAction) defaultHighlight.getHighlightAction(i); + replaceWidget(action.getWidget(), entities); + } else if (defaultHighlight.getHighlightAction(i) instanceof HyperlinkHighlightAction) { + HyperlinkHighlightAction action = (HyperlinkHighlightAction) defaultHighlight.getHighlightAction(i); + NameJavaScriptGroup group = action.getHperlink(); + dealNameJavaScriptGroup(group, entities); + } + } + } + } + + private static void dealNameJavaScriptGroup(NameJavaScriptGroup group, List entities) { + if (group != null) { + for (int i = 0 ; i < group.size(); i++) { + NameJavaScript javaScript = group.getNameHyperlink(i); + if (javaScript.getJavaScript() instanceof ChartHyperPoplink) { + if (((ChartHyperPoplink) javaScript.getJavaScript()).getChartCollection() instanceof ChartCollection) { + replaceChart((ChartCollection) ((ChartHyperPoplink) javaScript.getJavaScript()).getChartCollection(), entities); + } + + } + } + } + } + private static void replaceJs(List javaScripts, List entity) { for (JavaScript javaScript : javaScripts) { @@ -403,6 +462,8 @@ public class ReplaceUtils { replacePresentAndDictionary(cell, entity); // 处理【单元格值】 replaceCellValue(cell, entity); + // 处理【条件属性】 + replaceCellHighlight(cell, entity); } } @@ -485,6 +546,10 @@ public class ReplaceUtils { private static void replaceWidget(Widget widget, List entities) { if (widget instanceof DictionaryContainer) { DictionaryContainer db = (DictionaryContainer) widget; + if (widget instanceof TreeEditor) { + Object config = ((TreeEditor) widget).getBuildModelConfig(); + replaceTreeConfig(config, entities); + } if (db.getDictionary() instanceof TableDataDictionary) { TableDataDictionary tdd = (TableDataDictionary) db.getDictionary(); NameTableData ndd = (NameTableData) tdd.getTableData(); @@ -492,6 +557,53 @@ public class ReplaceUtils { ElementCaseHelper.replaceTableDataDictionary(tdd, ndd, entities); } } + if (widget instanceof DataControl) { + ValueInitializer value = ((DataControl) widget).getWidgetValue(); + if (value.getValue() instanceof DataBinding) { + DataBinding binding = (DataBinding) value.getValue(); + for (TableReplacementEntity entity : entities) { + if (StringUtils.equals(entity.getOldName(), binding.getDataSourceName())) { + value.setValue(new DataBinding(entity.getNewName(), entity.getTargetField(binding.getDataBindingKey()))); + break; + } + } + } + } + } + + private static void replaceTreeConfig(Object config, List entities) { + if (config instanceof LayerConfig[]) { + LayerConfig[] layerConfigs = (LayerConfig[]) config; + dealWithLayerConfigs(layerConfigs, entities); + } else if (config instanceof TreeNodeWrapper) { + TreeNodeWrapper wrapper = (TreeNodeWrapper) config; + dealWithTreeNodeWrapper(wrapper, entities); + } else if (config instanceof TableDataDictionary) { + TableDataDictionary tableDataDictionary = (TableDataDictionary) config; + ElementCaseHelper.replaceTableDataDictionary(tableDataDictionary, (NameTableData) tableDataDictionary.getTableData(), entities); + } + } + + private static void dealWithTreeNodeWrapper(TreeNodeWrapper wrapper, List entities) { + for (TreeNodeAttr attr : wrapper.getTreeNodeAttrs()) { + if (attr.getDictionary() instanceof TableDataDictionary) { + TableDataDictionary tableDataDictionary = (TableDataDictionary) attr.getDictionary(); + ElementCaseHelper.replaceTableDataDictionary(tableDataDictionary, (NameTableData) tableDataDictionary.getTableData(), entities); + } + } + } + + private static void dealWithLayerConfigs(LayerConfig[] layerConfigs, List entities) { + for (LayerConfig layerConfig : layerConfigs) { + if (layerConfig.getDictionary() != null ) { + for (TableReplacementEntity entity : entities) { + if (layerConfig.getTableData() instanceof NameTableData && StringUtils.equals(layerConfig.getTableData().getName(), entity.getOldName())) { + layerConfig.setTableData(new NameTableData(entity.getNewName())); + } + } + ElementCaseHelper.replaceTableDataDictionary(layerConfig.getDictionary(), (NameTableData) layerConfig.getDictionary().getTableData(), entities); + } + } } /**