Browse Source

REPORT-75998 添加一部分校验

feature/x
Destiny.Lin 2 years ago
parent
commit
cdfe210da6
  1. 2
      designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java
  2. 15
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java
  3. 141
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java
  4. 4
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java
  5. 2
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchDateEditorFormulaAction.java
  6. 20
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchTreeEditorFormulaAction.java
  7. 25
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaAction.java
  8. 2
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaManager.java
  9. 14
      designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java
  10. 25
      designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java
  11. 9
      designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java
  12. 9
      designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java
  13. 45
      designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java
  14. 45
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java
  15. 12
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java
  16. 12
      designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java

2
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<String, String> map, List<JSInfo> 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();

15
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;
}
}

141
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<Pair<Integer, Integer>> 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) {

4
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));
}
}

2
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;

20
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<FormulaInfo> 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);
}
}
}
}

25
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<FormulaInfo> formulaInfos) {
if (isReplaceObjectExist(info)) {
@ -69,13 +76,23 @@ public class SearchWidgetFormulaAction extends AbstractSearchWidgetFormulaAction
private void searchFormulaFromWidgetValue(Info info, List<FormulaInfo> 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<String, SearchWidgetFormula> widgetType = SearchWidgetFormulaManager.getInstance().getWidgetType();

2
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());
/**
* 日期类型

14
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();
}
}

25
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();

9
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<String, String> getCommonValue() {
Map<String, String> map = new HashMap();
FormulaReplaceObject o = FormulaReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName());

9
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
*

45
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());
}
}
},
/**
* ListenerJS
@ -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());
}
}
},
/**
* VanChartHtmlLabelJS
@ -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;
}
},
/**
* JavaScriptImplJS
@ -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());
}
},
/**
* DBTableDataSQL
*/
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<String, String> getValue(Object... o) {
HashMap<String, String> map = new HashMap<>();
@ -215,4 +257,5 @@ public enum ReplaceObject implements DealWithInfoValue {
}
abstract boolean check(Info info);
}

45
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<? extends Info> 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<? extends Info> 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
}

12
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"));

12
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);
}
}

Loading…
Cancel
Save