From cdfe210da6f17586f87003b0f4126d77f1c3196d Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 20 Sep 2022 09:41:30 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-75998=20=E6=B7=BB=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/ShowSearchResultAction.java | 2 +- .../content/component/ComponentType.java | 15 ++ .../content/formula/FormulaReplaceObject.java | 141 +++++++++++++++++- .../template/SearchTemplateFormulaAction.java | 4 +- .../widget/SearchDateEditorFormulaAction.java | 2 +- .../widget/SearchTreeEditorFormulaAction.java | 20 +-- .../widget/SearchWidgetFormulaAction.java | 25 +++- .../widget/SearchWidgetFormulaManager.java | 2 + .../actions/replace/info/ComponentInfo.java | 14 +- .../actions/replace/info/FloatInfo.java | 25 ++++ .../actions/replace/info/FormulaInfo.java | 9 ++ .../design/actions/replace/info/JSInfo.java | 9 ++ .../actions/replace/info/ReplaceObject.java | 45 +++++- .../replace/ui/ITReplaceMainDialog.java | 45 +++--- .../replace/ui/ITReplaceNorthPanel.java | 12 ++ .../actions/replace/utils/ShowValueUtils.java | 12 +- 16 files changed, 339 insertions(+), 43 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java index 0ec4377a41..2f44137c78 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java @@ -135,7 +135,7 @@ public enum ShowSearchResultAction implements ShowValue { } private void searchMap4JS(Map map, List jsInfos, JSInfo info, String str) { - if (map.containsKey(objectNameKey) && !StringUtils.isEmpty(map.get(objectNameKey))) { + if (map.containsKey(objectNameKey) && StringUtils.isNotEmpty(map.get(objectNameKey))) { String name = map.get(objectNameKey); if (name.contains(str)) { JSInfo nameJSInfo = info.copy(); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java index db7c63f17a..bb6e190f69 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java @@ -347,4 +347,19 @@ public enum ComponentType implements DealWithInfoValue { } + /** + * 校验是否被修改 + * + * @param info + * @return + */ + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof Widget) { + Widget widget = (Widget) info.getContent().getReplaceObject(); + return StringUtils.equals(widget.getWidgetName(), info.getContent().getOldShowStr()); + } + return false; + } + + } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java index 7a1c199af9..3aaea18b33 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java @@ -4,14 +4,19 @@ import com.fr.base.BaseFormula; import com.fr.base.Formula; import com.fr.base.Parameter; import com.fr.base.StoreProcedureParameter; +import com.fr.base.core.KV; import com.fr.base.iofile.attr.WatermarkAttr; import com.fr.base.present.FormulaPresent; +import com.fr.base.present.Present; import com.fr.data.condition.FormulaCondition; import com.fr.data.core.Compare; import com.fr.design.actions.replace.info.DealWithInfoValue; import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.file.HistoryTemplateListCache; +import com.fr.form.main.Form; +import com.fr.function.IF; +import com.fr.general.GeneralUtils; import com.fr.js.SingleJavaScript; import com.fr.main.impl.WorkBook; import com.fr.report.cell.cellattr.CellInsertPolicyAttr; @@ -54,6 +59,15 @@ public enum FormulaReplaceObject implements DealWithInfoValue { info.updateOldStr(((Formula) replaceObject).getContent(), findStr); ((Formula) replaceObject).setContent(ShowValueUtils.replaceAll(((Formula) replaceObject).getContent(), findStr, replaceStr)); } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof Formula){ + Formula formula = (Formula) info.getContent().getReplaceObject(); + return StringUtils.equals(formula.getContent(), info.getContent().getOldShowStr()); + } + return false; + } }, /** * FormulaCondition @@ -77,6 +91,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { ((FormulaCondition) replaceObject).setFormula(ShowValueUtils.replaceAll(((FormulaCondition) replaceObject).getFormula(), findStr, replaceStr)); } + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof FormulaCondition){ + FormulaCondition condition = (FormulaCondition) info.getContent().getReplaceObject(); + return StringUtils.equals(condition.getFormula(), info.getContent().getOldShowStr()); + } + return false; + } }, /** * Compare @@ -102,6 +124,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { } } + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof Compare){ + Compare compare = (Compare) info.getContent().getReplaceObject(); + return StringUtils.equals(GeneralUtils.objectToString(compare.getValue()), info.getContent().getOldShowStr()); + } + return false; + } }, /** * 富文本 @@ -128,6 +158,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { } } + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof RichChar){ + RichChar richChar = (RichChar) info.getContent().getReplaceObject(); + return StringUtils.equals(richChar.getText(), info.getContent().getOldShowStr()); + } + return false; + } }, /** * KV @@ -150,6 +188,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { ((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).setContent(ShowValueUtils.replaceAll(((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).getContent(), findStr, replaceStr)); } + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof com.fr.base.core.KV){ + com.fr.base.core.KV kv = (com.fr.base.core.KV) info.getContent().getReplaceObject(); + return StringUtils.equals(GeneralUtils.objectToString(kv.getValue()), info.getContent().getOldShowStr()); + } + return false; + } }, /** * 插入策略 @@ -171,6 +217,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { ((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).getContent(), findStr, replaceStr)); } + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof CellInsertPolicyAttr){ + CellInsertPolicyAttr policyAttr = (CellInsertPolicyAttr) info.getContent().getReplaceObject(); + return StringUtils.equals(GeneralUtils.objectToString(policyAttr.getDefaultInsertValue()), info.getContent().getOldShowStr()); + } + return false; + } }, /** * present @@ -193,6 +247,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { ((FormulaPresent) replaceObject).setFormulaContent(ShowValueUtils.replaceAll(((FormulaPresent) replaceObject).getFormulaContent(), findStr, replaceStr)); } + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof FormulaPresent){ + FormulaPresent present = (FormulaPresent) info.getContent().getReplaceObject(); + return StringUtils.equals(present.getFormulaContent(), info.getContent().getOldShowStr()); + } + return false; + } }, /** * SingleJavaScript @@ -211,10 +273,17 @@ public enum FormulaReplaceObject implements DealWithInfoValue { public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { Object replaceObject = info.getContent().getReplaceObject(); info.updateOldStr(((SingleJavaScript) replaceObject).getFileName(), findStr); - ((SingleJavaScript) replaceObject).setFileName(ShowValueUtils.replaceAll(((SingleJavaScript) replaceObject).getFileName(), findStr, replaceStr)); } + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof SingleJavaScript){ + SingleJavaScript javaScript = (SingleJavaScript) info.getContent().getReplaceObject(); + return StringUtils.equals(javaScript.getFileName(), info.getContent().getOldShowStr()); + } + return false; + } }, /** * 参数 @@ -237,6 +306,16 @@ public enum FormulaReplaceObject implements DealWithInfoValue { ((Formula) (((ParameterProvider) replaceObject).getValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((ParameterProvider) replaceObject).getValue())).getContent(), findStr, replaceStr)); } + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof ParameterProvider){ + ParameterProvider provider = (ParameterProvider) info.getContent().getReplaceObject(); + if (provider.getValue() instanceof Formula){ + return StringUtils.equals(GeneralUtils.objectToString(provider.getValue()), info.getContent().getOldShowStr()); + } + } + return false; + } }, /** * FormulaProvider @@ -259,6 +338,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { ((FormulaProvider) replaceObject).setContent(ShowValueUtils.replaceAll(((FormulaProvider) replaceObject).getContent(), findStr, replaceStr)); } + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof FormulaProvider){ + FormulaProvider provider = (FormulaProvider) info.getContent().getReplaceObject(); + return StringUtils.equals(provider.getContent(), info.getContent().getOldShowStr()); + } + return false; + } }, /** * 参数 @@ -281,6 +368,16 @@ public enum FormulaReplaceObject implements DealWithInfoValue { ((Formula) (((Parameter) replaceObject).getValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((Parameter) replaceObject).getValue())).getContent(), findStr, replaceStr)); } + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof Parameter){ + Parameter parameter = (Parameter) info.getContent().getReplaceObject(); + if (parameter.getValue() instanceof Formula){ + return StringUtils.equals(((Formula) parameter.getValue()).getContent(), info.getContent().getOldShowStr()); + } + } + return false; + } }, /** * 数据列 @@ -303,6 +400,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { ((DSColumn) replaceObject).setResult(ShowValueUtils.replaceAll(((DSColumn) replaceObject).getResult(), findStr, replaceStr)); } + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof DSColumn){ + DSColumn column = (DSColumn) info.getContent().getReplaceObject(); + return StringUtils.equals(column.getResult(), info.getContent().getOldShowStr()); + } + return false; + } }, /** * 公式类型 @@ -325,6 +430,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue { ((BaseFormula) replaceObject).setContent(ShowValueUtils.replaceAll(((BaseFormula) replaceObject).getContent(), findStr, replaceStr)); } + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof BaseFormula){ + BaseFormula formula = (BaseFormula) info.getContent().getReplaceObject(); + return StringUtils.equals(formula.getContent(), info.getContent().getOldShowStr()); + } + return false; + } }, /** * 存储过程的参数 @@ -347,6 +460,17 @@ public enum FormulaReplaceObject implements DealWithInfoValue { ((Formula) ((StoreProcedureParameter) replaceObject).getValue()).setContent(ShowValueUtils.replaceAll(((Formula) ((StoreProcedureParameter) replaceObject).getValue()).getContent(), findStr, replaceStr)); } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof StoreProcedureParameter){ + StoreProcedureParameter procedureParameter = (StoreProcedureParameter) info.getContent().getReplaceObject(); + if (procedureParameter.getValue() instanceof Formula){ + return StringUtils.equals(GeneralUtils.objectToString(procedureParameter.getValue()), info.getContent().getOldShowStr()); + } + } + return false; + } }, /** * WatermarkAttr水印 @@ -369,6 +493,15 @@ public enum FormulaReplaceObject implements DealWithInfoValue { watermarkAttr.setText(ShowValueUtils.replaceAll(watermarkAttr.getText(), findStr, replaceStr)); workBook.addAttrMark(watermarkAttr); } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof WatermarkAttr){ + WatermarkAttr watermarkAttr = ((WatermarkAttr) info.getContent().getReplaceObject()); + return StringUtils.equals(watermarkAttr.getText(), info.getContent().getOldShowStr()); + } + return false; + } }; @@ -395,6 +528,12 @@ public enum FormulaReplaceObject implements DealWithInfoValue { return null; } + /** + * 校验内容 + * @param info + * @return + */ + abstract public boolean check(Info info); @Override public String getInfoShowStr(Info info) { 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 977de5a333..309fed1808 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 @@ -54,7 +54,7 @@ public class SearchTemplateFormulaAction implements SearchTemplateFormula { if (parameter.getValue() instanceof Formula) { ITContent paraContent = ITContent.copy(content); paraContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Template_Parameter")); - paraContent.setReplaceObject(parameter.getValue()); + paraContent.setReplaceObject(parameter); formulaInfos.add(new FormulaInfo(paraContent)); } } @@ -64,7 +64,7 @@ public class SearchTemplateFormulaAction implements SearchTemplateFormula { if (parameter.getValue() instanceof Formula) { ITContent paraContent = ITContent.copy(content); paraContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Parameter_Source_Type_Server")); - paraContent.setReplaceObject(parameter.getValue()); + paraContent.setReplaceObject(parameter); formulaInfos.add(new FormulaInfo(paraContent)); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchDateEditorFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchDateEditorFormulaAction.java index d7e81a1d6e..67548b4157 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchDateEditorFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchDateEditorFormulaAction.java @@ -4,7 +4,7 @@ import com.fr.design.actions.replace.info.FormulaInfo; import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.i18n.Toolkit; import com.fr.form.ui.DateEditor; -import org.gradle.internal.impldep.org.apache.commons.lang.StringUtils; +import com.fr.stable.StringUtils; import java.util.List; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchTreeEditorFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchTreeEditorFormulaAction.java index 81987a1db4..d1251c5b8c 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchTreeEditorFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchTreeEditorFormulaAction.java @@ -33,15 +33,17 @@ public class SearchTreeEditorFormulaAction extends AbstractSearchWidgetFormulaAc } private void SearchFormulaFromModelConfig(ITContent content, List formulaInfos) { - if (((TreeEditor) content.getReplaceObject()).getBuildModelConfig() != null) { - //LayerConfig[] 急速分层构建 - //TreeNodeWrapper 普通分层构建 - if (((TreeEditor) content.getReplaceObject()).getBuildModelConfig() instanceof LayerConfig[]) { - LayerConfig[] layerConfigs = (LayerConfig[]) ((TreeEditor) content.getReplaceObject()).getBuildModelConfig(); - dealWithLayerConfigs(layerConfigs, content, formulaInfos); - } else if (((TreeEditor) content.getReplaceObject()).getBuildModelConfig() instanceof TreeNodeWrapper) { - TreeNodeWrapper wrapper = (TreeNodeWrapper) ((TreeEditor) content.getReplaceObject()).getBuildModelConfig(); - dealWithTreeNodeWrapper(wrapper, content, formulaInfos); + if (content.getReplaceObject() instanceof TreeEditor) { + if (((TreeEditor) content.getReplaceObject()).getBuildModelConfig() != null) { + //LayerConfig[] 急速分层构建 + //TreeNodeWrapper 普通分层构建 + if (((TreeEditor) content.getReplaceObject()).getBuildModelConfig() instanceof LayerConfig[]) { + LayerConfig[] layerConfigs = (LayerConfig[]) ((TreeEditor) content.getReplaceObject()).getBuildModelConfig(); + dealWithLayerConfigs(layerConfigs, content, formulaInfos); + } else if (((TreeEditor) content.getReplaceObject()).getBuildModelConfig() instanceof TreeNodeWrapper) { + TreeNodeWrapper wrapper = (TreeNodeWrapper) ((TreeEditor) content.getReplaceObject()).getBuildModelConfig(); + dealWithTreeNodeWrapper(wrapper, content, formulaInfos); + } } } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaAction.java index f1f214f648..b82076a3d3 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaAction.java @@ -1,5 +1,7 @@ package com.fr.design.actions.replace.action.content.formula.widget; +import com.fr.base.BaseFormula; +import com.fr.base.Formula; import com.fr.chart.chartattr.ChartCollection; import com.fr.design.actions.replace.action.content.component.SearchComponentAction; import com.fr.design.actions.replace.action.content.formula.chart.SearchChartCollectionFormulaAction; @@ -11,14 +13,20 @@ import com.fr.design.actions.replace.info.WidgetInfo; import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.chart.gui.ChangeConfigPane; import com.fr.form.main.Form; import com.fr.form.ui.ChartEditor; +import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.Label; import com.fr.form.ui.Widget; +import com.fr.form.ui.WidgetTitle; +import com.fr.form.ui.concept.data.ValueInitializer; import com.fr.form.ui.container.WScaleLayout; import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.main.impl.WorkBook; +import com.fr.report.worksheet.FormElementCase; import java.util.ArrayList; import java.util.List; @@ -59,7 +67,6 @@ public class SearchWidgetFormulaAction extends AbstractSearchWidgetFormulaAction formulaInfos.addAll(result); } - @Override public void searchFormulaFromWidgetInfos(Info info, List formulaInfos) { if (isReplaceObjectExist(info)) { @@ -69,13 +76,23 @@ public class SearchWidgetFormulaAction extends AbstractSearchWidgetFormulaAction private void searchFormulaFromWidgetValue(Info info, List formulaInfos) { Widget widget = (Widget) info.getContent().getReplaceObject(); + if (widget instanceof WScaleLayout) { widget = ((CRBoundsWidget) ((WScaleLayout) widget).getWidget(0)).getWidget(); + info.getContent().setReplaceObject(widget); } if (widget instanceof WTitleLayout) { - widget = ((CRBoundsWidget) ((WTitleLayout) widget).getWidget(0)).getWidget(); - if (widget instanceof ChartEditor && ((ChartEditor) widget).getChartCollection() instanceof ChartCollection) { - SearchChartCollectionFormulaAction.getInstance().searchChartCollectionFormula(formulaInfos, info.getContent(), (ChartCollection) ((ChartEditor) widget).getChartCollection()); + if (((WTitleLayout) widget).getTitleBoundsWidget() != null){ + CRBoundsWidget boundsWidget = ((WTitleLayout) widget).getTitleBoundsWidget(); + if (boundsWidget.getWidget() instanceof Label){ + ITContent titleContent = ITContent.copy(info.getContent()); + titleContent.setReplaceObject(((Label) boundsWidget.getWidget()).getWidgetValue().getValue()); + formulaInfos.add(new FormulaInfo(titleContent)); + } + } + Widget tempWidget = (((WTitleLayout) widget).getBodyBoundsWidget()).getWidget(); + if (tempWidget instanceof ChartEditor && ((ChartEditor) tempWidget).getChartCollection() instanceof ChartCollection) { + SearchChartCollectionFormulaAction.getInstance().searchChartCollectionFormula(formulaInfos, info.getContent(), (ChartCollection) ((ChartEditor) tempWidget).getChartCollection()); } } Map widgetType = SearchWidgetFormulaManager.getInstance().getWidgetType(); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaManager.java index 6ddb7eae72..719f49f003 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaManager.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaManager.java @@ -32,6 +32,7 @@ public class SearchWidgetFormulaManager implements SearchManager { private static final String PAGE_FIXED_ROW_COMBOBOX = "PageFixedRowComboBox"; private static final String TREE_COMBO_BOX_EDITOR = "TreeComboBoxEditor"; private static final String TREE_EDITOR = "TreeEditor"; + private static final String W_TITLE_LAYOUT = "WTitleLayout"; private SearchWidgetFormulaManager() { /** @@ -46,6 +47,7 @@ public class SearchWidgetFormulaManager implements SearchManager { register(FREE_BUTTON, SearchCommonWidgetFormulaAction.getInstance()); register(NUMBER_EDITOR, SearchCommonWidgetFormulaAction.getInstance()); register(TEXT_EDITOR, SearchCommonWidgetFormulaAction.getInstance()); + register(W_TITLE_LAYOUT, SearchCommonWidgetFormulaAction.getInstance()); /** * 日期类型 diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java index cb84837f48..b302376fb6 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java @@ -44,6 +44,15 @@ public class ComponentInfo implements Info { } + @Override + public Boolean checkValid() { + ComponentType componentType = ComponentType.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (componentType != null) { + return componentType.check(this); + } + return false; + } + /** * 这边设置值其实就是修改组件的名称,要注意的就是如果是layout的情况下有些需要对其外面封装的对象也进行名称的修改 * @@ -68,9 +77,6 @@ public class ComponentInfo implements Info { */ @Override public String getInfoShowStr(Info info) { - if (this.content.getReplaceObject() != null && this.content.getReplaceObject() instanceof Widget) { - return ((Widget) this.content.getReplaceObject()).getWidgetName(); - } - return StringUtils.EMPTY; + return this.getContent().getOldShowStr(); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java index ec8cb28ddc..2bf794ab80 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java @@ -7,8 +7,10 @@ import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.general.GeneralUtils; +import com.fr.report.cell.CellElement; import com.fr.report.cell.FloatElement; import com.fr.stable.AssistUtils; +import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; @@ -108,6 +110,29 @@ public class FloatInfo implements Info { } } + @Override + public Boolean checkValid() { + FloatElement floatElement = (((FloatElement) (this.getContent().getReplaceObject()))); + String newValue; + if (this.isChartExist() && this.getFloatChartIndex() != -1) { + newValue = getChartCheckValue(); + } else { + newValue = GeneralUtils.objectToString(floatElement.getValue()); + } + return StringUtils.equals(newValue, this.getContent().getOldShowStr()); + } + + private String getChartCheckValue() { + ChartCollection chartCollection = (ChartCollection) ((FloatElement) this.getContent().getReplaceObject()).getValue(); + Title title = chartCollection.getChart(this.getFloatChartIndex()).getTitle(); + if (title.getTextObject() instanceof Formula) { + Formula formula = (Formula) title.getTextObject(); + return formula.getContent(); + } else { + return GeneralUtils.objectToString(title.getTextObject()); + } + } + @Override public String getInfoShowStr(Info info) { return this.getContent().getOldShowStr(); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java index 8dae97110f..73a0750cb8 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java @@ -68,6 +68,15 @@ public class FormulaInfo implements Info { return StringUtils.EMPTY; } + @Override + public Boolean checkValid() { + FormulaReplaceObject formulaReplaceObject = FormulaReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (formulaReplaceObject != null) { + return formulaReplaceObject.check(this); + } + return false; + } + private Map getCommonValue() { Map map = new HashMap(); FormulaReplaceObject o = FormulaReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java index 4cf9de1fd8..3f0632fe84 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java @@ -60,6 +60,15 @@ public class JSInfo implements Info { } + @Override + public Boolean checkValid() { + ReplaceObject o = ReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (o != null) { + return o.check(this); + } + return false; + } + /** * toString * diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java index ea82c19295..ed78c62784 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java @@ -59,6 +59,17 @@ public enum ReplaceObject implements DealWithInfoValue { return javaScript.getName(); } } + + @Override + boolean check(Info info) { + if (((JSInfo) info).isContent()) { + JavaScriptImpl javaScript = (JavaScriptImpl) ((NameJavaScript) (info.getContent().getReplaceObject())).getJavaScript(); + return StringUtils.equals(javaScript.getContent(), info.getContent().getOldShowStr()); + } else { + NameJavaScript javaScript = ((NameJavaScript) (info.getContent().getReplaceObject())); + return StringUtils.equals(javaScript.getName(), info.getContent().getOldShowStr()); + } + } }, /** * Listener——JS @@ -79,7 +90,6 @@ public enum ReplaceObject implements DealWithInfoValue { JavaScriptImpl javaScript = (JavaScriptImpl) ((Listener) (info.getContent().getReplaceObject())).getAction(); info.updateOldStr(javaScript.getContent(), findStr); javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr)); - } } else { Listener listener = ((Listener) ((info.getContent().getReplaceObject()))); @@ -97,6 +107,17 @@ public enum ReplaceObject implements DealWithInfoValue { return listener.getName(); } } + + @Override + boolean check(Info info) { + if (((JSInfo) info).isContent()) { + JavaScriptImpl javaScript = (JavaScriptImpl) ((Listener) (info.getContent().getReplaceObject())).getAction(); + return StringUtils.equals(javaScript.getContent(), info.getContent().getOldShowStr()); + } else { + Listener listener = ((Listener) (info.getContent().getReplaceObject())); + return StringUtils.equals(listener.getName(), info.getContent().getOldShowStr()); + } + } }, /** * VanChartHtmlLabel——JS @@ -126,6 +147,15 @@ public enum ReplaceObject implements DealWithInfoValue { VanChartHtmlLabel htmlLabel = ((VanChartHtmlLabel) (info.getContent().getReplaceObject())); return htmlLabel.getCustomText(); } + + @Override + boolean check(Info info) { + if (((JSInfo) info).isContent()) { + VanChartHtmlLabel htmlLabel = ((VanChartHtmlLabel) (info.getContent().getReplaceObject())); + return StringUtils.equals(htmlLabel.getCustomText(), info.getContent().getOldShowStr()); + } + return false; + } }, /** * JavaScriptImpl——JS @@ -150,11 +180,23 @@ public enum ReplaceObject implements DealWithInfoValue { JavaScriptImpl javaScript = (JavaScriptImpl) (info.getContent().getReplaceObject()); return javaScript.getContent(); } + + @Override + boolean check(Info info) { + JavaScriptImpl javaScript = (JavaScriptImpl) (info.getContent().getReplaceObject()); + return StringUtils.equals(javaScript.getContent(), info.getContent().getOldShowStr()); + } }, /** * DBTableData——SQL */ DB_TABLE_DATA("DBTableData") { + @Override + boolean check(Info info) { + DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); + return StringUtils.equals(dbTableData.getQuery(), info.getContent().getOldShowStr()); + } + @Override public Map getValue(Object... o) { HashMap map = new HashMap<>(); @@ -215,4 +257,5 @@ public enum ReplaceObject implements DealWithInfoValue { } + abstract boolean check(Info info); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index b59499c7d5..4ac477cdc5 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -41,6 +41,7 @@ import java.util.List; public class ITReplaceMainDialog extends UIDialog { List searchResultList = new ArrayList<>(); private static boolean ITReplaceFlag = false; + private static boolean matched = false; private static volatile ITReplaceMainDialog instance = null; private static String templateID; private ITReplaceNorthPanel northPane; @@ -116,21 +117,12 @@ public class ITReplaceMainDialog extends UIDialog { northPane.getFindInputCombobox().setEditable(true); northPane.getReplaceInputCombobox().setEditable(false); - ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Search_Input")); ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Input")); ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { search(); - String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); - if (StringUtils.isNotEmpty(searchStr)) { - ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setEditable(true); - northPane.getReplaceInputCombobox().setEditable(true); - } else { - ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setEditable(false); - northPane.getReplaceInputCombobox().setEditable(false); - } } }); @@ -138,14 +130,7 @@ public class ITReplaceMainDialog extends UIDialog { @Override public void actionPerformed(ActionEvent e) { search(); - String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); - if (StringUtils.isNotEmpty(searchStr)) { - ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setEditable(true); - northPane.getReplaceInputCombobox().setEditable(true); - } else { - ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setEditable(false); - northPane.getReplaceInputCombobox().setEditable(false); - } + } }); @@ -169,6 +154,7 @@ public class ITReplaceMainDialog extends UIDialog { * 替换 */ private void replace() { + if (isITReplaceValid() && checkTemplateChanged(searchResultList)) { String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText(); @@ -183,6 +169,7 @@ public class ITReplaceMainDialog extends UIDialog { southPanel.getTableEditorPane().update(); northPane.refreshReplaceInputComboBoxItems(); ITTableEditorPane.getEditTable().repaint(); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); setSearchFlag(false); @@ -204,6 +191,8 @@ public class ITReplaceMainDialog extends UIDialog { search(); } } + + } private Boolean checkTemplateChanged(List searchResultList) { @@ -252,6 +241,19 @@ public class ITReplaceMainDialog extends UIDialog { this.searchStr = searchStr; } + /** + * 是否使用通配符 + * + * @return + */ + public static boolean isMatched() { + return matched; + } + + public static void setMatched(boolean matched) { + ITReplaceMainDialog.matched = matched; + } + /** * 设置标签 * @@ -288,6 +290,15 @@ public class ITReplaceMainDialog extends UIDialog { itTableEditor.fireTableDataChanged(); northPane.refreshFindInputComboBoxItems(); setSearchFlag(true); + + String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); + if (StringUtils.isNotEmpty(searchStr)) { + ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setEditable(true); + northPane.getReplaceInputCombobox().setEditable(true); + } else { + ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setEditable(false); + northPane.getReplaceInputCombobox().setEditable(false); + } } else { //todo } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java index c35160954e..0fea79f21e 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -13,6 +13,8 @@ import javax.swing.ComboBoxEditor; import javax.swing.JCheckBox; import javax.swing.JPanel; import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Collections; @@ -92,6 +94,16 @@ public class ITReplaceNorthPanel { } }; matchRadioButton = new JCheckBox(Toolkit.i18nText("Fine-Design_Replace_WildCard")); + matchRadioButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (matchRadioButton.isSelected()) { + ITReplaceMainDialog.setMatched(true); + } else { + ITReplaceMainDialog.setMatched(false); + } + } + }); replaceButton = new UIButton(Toolkit.i18nText("Fine-Design_Replace_Button")); searchButton = new UIButton(Toolkit.i18nText("Fine-Design_Search_Button")); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java index 6342c7e72e..6f4e7e84fa 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java @@ -3,9 +3,10 @@ package com.fr.design.actions.replace.utils; import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.ui.ITReplaceMainDialog; +import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; -import org.gradle.internal.impldep.org.apache.commons.lang.StringUtils; import java.util.ArrayList; import java.util.Collection; @@ -39,7 +40,7 @@ public class ShowValueUtils { } /** - * 可以替换括号的replaceAll + * 替换策略 * * @param str 原字符串 * @param regex 要被替换的内容 @@ -47,7 +48,12 @@ public class ShowValueUtils { * @return 替换后的字符串 */ public static String replaceAll(String str, String regex, String replacement) { - return str.replaceAll(Pattern.quote(regex), replacement); + if (ITReplaceMainDialog.isMatched()){ + return str.replaceAll(Pattern.quote(regex), replacement); + }else { + return str.replace(regex, replacement); + } + }