Browse Source

REPORT-75998 主要数据结构

feature/x
Destiny.Lin 2 years ago
parent
commit
31d7caf8bc
  1. 357
      designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java
  2. 72
      designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java
  3. 114
      designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java
  4. 71
      designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java
  5. 81
      designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java
  6. 217
      designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java
  7. 64
      designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java
  8. 103
      designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java
  9. 232
      designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ContentObject.java
  10. 244
      designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java

357
designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java

@ -0,0 +1,357 @@
package com.fr.design.actions.replace.info;
import com.fr.base.Formula;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Title;
import com.fr.design.actions.replace.action.ShowValue;
import com.fr.design.actions.replace.action.content.widget.FrmWidgetType;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.design.write.submit.DBManipulationPane;
import com.fr.form.ui.Widget;
import com.fr.general.GeneralUtils;
import com.fr.general.ImageWithSuffix;
import com.fr.general.data.TableDataColumn;
import com.fr.invoke.Reflect;
import com.fr.main.impl.LinkWorkBookTemplate;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.FloatElement;
import com.fr.report.cell.cellattr.core.RichChar;
import com.fr.report.cell.cellattr.core.RichText;
import com.fr.report.cell.cellattr.core.SubReport;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.cell.painter.BiasTextPainter;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
import javafx.util.Pair;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
/**
* 返回查找内容匹配词高亮模板名称所在sheet分布组件单元格位置操作
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-08-11
*/
public class CellInfo implements Info {
private ITContent content;
private int cellChartIndex = -1;
private boolean chartExist = false;
public CellInfo(ITContent content) {
this.content = content;
}
@Override
public ITContent getContent() {
return content;
}
public void setContent(ITContent content) {
this.content = content;
}
@Override
public String toString() {
return AssistUtils.toString(this);
}
/**
* 获取单元格的值不对图表进行处理如果是图表类型在展示阶段特殊处理
*
* @param o 用于替换的replaceObject
* @return
*/
@Override
public HashMap<String, String> getValue(Object... o) {
HashMap<String, String> stringHashMap = new HashMap<>();
CellElement cellElement = (((CellElement) (this.getContent().getReplaceObject())));
if (cellElement.getValue() != null && !this.isChartExist()) {
CellValueType cellValueType = CellValueType.match(cellElement.getValue().getClass().getSimpleName());
if (cellValueType != null) {
cellValueType.addValue2Map(cellElement.getValue(), stringHashMap);
} else {
stringHashMap.put("content", GeneralUtils.objectToString(cellElement.getValue()));
}
}
return stringHashMap;
}
/**
* 对不同类型的值进行设置与替换
*
* @param info 用于获取值和设置值
* @param findStr 要被替换的字符串
* @param replaceStr 用于替换的字符串
* @param operatorArray 存储内容类替换所要操作的所有位置Pair<起始位置,结束位置>
*/
@Override
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) {
CellElement cellElement = (((CellElement) (this.getContent().getReplaceObject())));
if (this.isChartExist() && this.getCellChartIndex() != -1) {
ChartCollection chartCollection = (ChartCollection) ((CellElement) this.getContent().getReplaceObject()).getValue();
Title title = chartCollection.getChart(this.getCellChartIndex()).getTitle();
if (title.getTextObject() instanceof Formula) {
Formula formula = (Formula) title.getTextObject();
updateOldStr(formula.getContent(), findStr);
formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr));
} else {
updateOldStr(GeneralUtils.objectToString(title.getTextObject()), findStr);
title.setTextObject(ShowValueUtils.replaceAll(GeneralUtils.objectToString(title.getTextObject()), findStr, replaceStr));
}
} else {
CellValueType cellValueType = CellValueType.match(cellElement.getValue().getClass().getSimpleName());
if (cellValueType != null) {
cellValueType.setValue(this, cellElement.getValue(), findStr, replaceStr);
} else {
updateOldStr(GeneralUtils.objectToString(cellElement.getValue()), findStr);
cellElement.setValue(ShowValueUtils.replaceAll(GeneralUtils.objectToString(cellElement.getValue()), findStr, replaceStr));
}
}
}
public int getCellChartIndex() {
return cellChartIndex;
}
public void setCellChartIndex(int cellChartIndex) {
this.cellChartIndex = cellChartIndex;
}
public boolean isChartExist() {
return chartExist;
}
public void setChartExist(boolean chartExist) {
this.chartExist = chartExist;
}
/**
* 复制一份CellInfo防止引用传递问题
*
* @return
*/
public CellInfo copy() {
ITContent content = this.getContent().copy();
CellInfo cellInfo = new CellInfo(content);
cellInfo.setCellChartIndex(this.getCellChartIndex());
cellInfo.setChartExist(this.isChartExist());
return cellInfo;
}
/**
* 获取展示的字符串
*
* @param info 信息
* @return
*/
@Override
public String getInfoShowStr(Info info) {
return this.getContent().getOldShowStr();
}
@Override
public Boolean checkValid() {
CellElement cellElement = (((CellElement) (this.getContent().getReplaceObject())));
String newValue;
if (this.isChartExist() && this.getCellChartIndex() != -1) {
newValue = getChartCheckValue();
} else {
CellValueType cellValueType = CellValueType.match(cellElement.getValue().getClass().getSimpleName());
if (cellValueType != null) {
newValue = cellValueType.getCheckValue(this);
} else {
newValue = GeneralUtils.objectToString(cellElement.getValue());
}
}
return StringUtils.equals(newValue, this.getContent().getOldShowStr());
}
private String getChartCheckValue() {
ChartCollection chartCollection = (ChartCollection) ((CellElement) this.getContent().getReplaceObject()).getValue();
Title title = chartCollection.getChart(this.getCellChartIndex()).getTitle();
if (title.getTextObject() instanceof Formula) {
Formula formula = (Formula) title.getTextObject();
return formula.getContent();
} else {
return GeneralUtils.objectToString(title.getTextObject());
}
}
/**
* 单元格的值的类型
*/
public enum CellValueType {
/**
* 数据列类型目前只对数据集的名称进行修改对于其中的列名暂不支持修改
*/
DS_COLUMN("DSColumn") {
@Override
public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) {
cellInfo.updateOldStr(GeneralUtils.objectToString(((DSColumn) o).getDSName()), findStr);
((DSColumn) o).setDSName(ShowValueUtils.replaceAll(((DSColumn) o).getDSName(), findStr, replaceStr));
}
@Override
public void addValue2Map(Object o, HashMap<String, String> map) {
map.put("content", ((DSColumn) o).getDSName());
}
@Override
public String getCheckValue(Info info) {
CellElement o = (CellElement) info.getContent().getReplaceObject();
return ((DSColumn) o.getValue()).getDSName();
}
},
/**
* 富文本形式
* 为了不破坏富文本的格式暂时不对样式不同的文本进行连接替换每个样式不同的文本都是一个独立的个体
*/
RICH_TEXT("RichText") {
@Override
public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) {
cellInfo.updateOldStr(GeneralUtils.objectToString(((RichText) o).getContent()), findStr);
Iterator<RichChar> it = ((RichText) o).charIterator();
while (it.hasNext()) {
RichChar richChar = it.next();
richChar.setText(ShowValueUtils.replaceAll(richChar.getText(), findStr, replaceStr));
}
}
@Override
public void addValue2Map(Object o, HashMap<String, String> map) {
map.put("content", ((RichText) o).getContent());
}
@Override
public String getCheckValue(Info info) {
CellElement o = (CellElement) info.getContent().getReplaceObject();
return ((RichText) o.getValue()).getContent();
}
},
/**
* 公式类型
*/
FORMULA("Formula") {
@Override
public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) {
cellInfo.updateOldStr(GeneralUtils.objectToString(o), findStr);
((Formula) o).setContent(ShowValueUtils.replaceAll(((Formula) o).getContent(), findStr, replaceStr));
}
@Override
public String getCheckValue(Info info) {
CellElement o = (CellElement) info.getContent().getReplaceObject();
return ((Formula) o.getValue()).getContent();
}
},
/**
* 子报表类型目前支持修改路径
*/
SUB_REPORT("SubReport") {
@Override
public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) {
LinkWorkBookTemplate workBookTemplate = (LinkWorkBookTemplate) ((SubReport) o).getPackee();
cellInfo.updateOldStr(workBookTemplate.getTemplatePath(), findStr);
workBookTemplate.setTemplatePath(ShowValueUtils.replaceAll(workBookTemplate.getTemplatePath(), findStr, replaceStr));
}
@Override
public void addValue2Map(Object o, HashMap<String, String> map) {
LinkWorkBookTemplate workBookTemplate = (LinkWorkBookTemplate) ((SubReport) o).getPackee();
map.put("content", GeneralUtils.objectToString(workBookTemplate.getTemplatePath()));
}
@Override
public String getCheckValue(Info info) {
CellElement o = (CellElement) info.getContent().getReplaceObject();
LinkWorkBookTemplate workBookTemplate = (LinkWorkBookTemplate) ((SubReport) o.getValue()).getPackee();
return GeneralUtils.objectToString(workBookTemplate.getTemplatePath());
}
},
/**
* 斜线类型
*/
BIAS_TEXT_PAINTER("BiasTextPainter") {
@Override
public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) {
cellInfo.updateOldStr(((BiasTextPainter) o).getText(), findStr);
((BiasTextPainter) o).setText(ShowValueUtils.replaceAll(((BiasTextPainter) o).getText(), findStr, replaceStr));
}
@Override
public void addValue2Map(Object o, HashMap<String, String> map) {
map.put("content", ((BiasTextPainter) o).getText());
}
@Override
public String getCheckValue(Info info) {
CellElement o = (CellElement) info.getContent().getReplaceObject();
return ((BiasTextPainter) o.getValue()).getText();
}
};
String name;
CellValueType(String name) {
this.name = name;
}
/**
* 匹配
*
* @param name
* @return
*/
@Nullable
public static CellValueType match(String name) {
CellValueType[] values = CellValueType.values();
for (CellValueType value : values) {
if (value.name.equals(name)) {
return value;
}
}
return null;
}
/**
* 设置值
*
* @param cellInfo
* @param o
* @param findStr
* @param replaceStr
*/
public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) {
}
/**
* 将值加到Map中
*
* @param o
* @param map
*/
public void addValue2Map(Object o, HashMap<String, String> map) {
map.put("content", GeneralUtils.objectToString(o));
}
public String getCheckValue(Info info) {
return StringUtils.EMPTY;
}
}
}

72
designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java

@ -0,0 +1,72 @@
package com.fr.design.actions.replace.info;
import com.fr.design.actions.replace.action.content.component.ComponentType;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.form.ui.Widget;
import com.fr.stable.StringUtils;
import javafx.util.Pair;
import java.util.ArrayList;
import java.util.HashMap;
/**
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-08-29
*/
public class ComponentInfo implements Info {
private ITContent content;
public ComponentInfo(ITContent content) {
this.content = content;
}
public void setContent(ITContent content) {
this.content = content;
}
@Override
public HashMap<String, String> getValue(Object... o) {
HashMap<String, String> hashMap = new HashMap<>();
if (this.content.getReplaceObject() != null && this.content.getReplaceObject() instanceof Widget) {
hashMap.put("content", ((Widget) this.content.getReplaceObject()).getWidgetName());
}
return hashMap;
}
@Override
public ITContent getContent() {
return content;
}
/**
* 这边设置值其实就是修改组件的名称要注意的就是如果是layout的情况下有些需要对其外面封装的对象也进行名称的修改
*
* @param info 用于获取值和设置值
* @param findStr 要被替换的字符串
* @param replaceStr 用于替换的字符串
* @param operatorArray 存储内容类替换所要操作的所有位置Pair<起始位置,结束位置>
*/
@Override
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) {
ComponentType componentType = ComponentType.match(this.content.getReplaceObject().getClass().getSimpleName());
if (componentType != null) {
componentType.setValue(info, findStr, replaceStr, operatorArray);
}
}
/**
* 获取展示的信息
*
* @param info 信息
* @return
*/
@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;
}
}

114
designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java

@ -0,0 +1,114 @@
package com.fr.design.actions.replace.info;
import com.fr.base.Formula;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Title;
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.FloatElement;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
import javafx.util.Pair;
import java.util.ArrayList;
import java.util.HashMap;
/**
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-08-15
*/
public class FloatInfo implements Info {
private ITContent content;
private int floatChartIndex = -1;
private boolean chartExist = false;
public FloatInfo(ITContent content) {
this.content = content;
}
@Override
public ITContent getContent() {
return content;
}
public void setContent(ITContent content) {
this.content = content;
}
@Override
public String toString() {
return AssistUtils.toString(this);
}
public int getFloatChartIndex() {
return floatChartIndex;
}
public void setFloatChartIndex(int charIndex) {
this.floatChartIndex = charIndex;
}
public boolean isChartExist() {
return chartExist;
}
public void setChartExist(boolean chartExist) {
this.chartExist = chartExist;
}
@Override
public HashMap<String, String> getValue(Object... o) {
HashMap<String, String> hashMap = new HashMap<>();
FloatElement floatElement = (((FloatElement) (this.getContent().getReplaceObject())));
if (!this.isChartExist()) {
hashMap.put("content", GeneralUtils.objectToString(floatElement.getValue()));
}
return hashMap;
}
@Override
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) {
if (this.isChartExist() && this.getFloatChartIndex() != -1) {
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();
updateOldStr(formula.getContent(), findStr);
formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr));
} else {
updateOldStr(GeneralUtils.objectToString(title.getTextObject()), findStr);
title.setTextObject(ShowValueUtils.replaceAll(GeneralUtils.objectToString(title.getTextObject()), findStr, replaceStr));
}
} else {
FloatElement floatElement = ((FloatElement) this.getContent().getReplaceObject());
if (floatElement.getValue() instanceof Formula) {
Formula formula = (Formula) floatElement.getValue();
updateOldStr(formula.getContent(), findStr);
formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr));
} else {
updateOldStr(GeneralUtils.objectToString(floatElement.getValue()), findStr);
floatElement.setValue(ShowValueUtils.replaceAll(GeneralUtils.objectToString(floatElement.getValue()), findStr, replaceStr));
}
}
}
@Override
public String getInfoShowStr(Info info) {
return this.getContent().getOldShowStr();
}
/**
* 复制
* @return
*/
public FloatInfo copy() {
ITContent content = this.getContent().copy();
FloatInfo floatInfo = new FloatInfo(content);
floatInfo.setFloatChartIndex(this.getFloatChartIndex());
floatInfo.setChartExist(this.isChartExist());
return floatInfo;
}
}

71
designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java

@ -0,0 +1,71 @@
package com.fr.design.actions.replace.info;
import com.fr.data.impl.FormulaDictionary;
import com.fr.design.actions.replace.action.content.formula.FormulaReplaceObject;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.stable.StringUtils;
import javafx.util.Pair;
import java.util.ArrayList;
import java.util.HashMap;
/**
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-08-17
*/
public class FormulaInfo implements Info{
private ITContent content;
public FormulaInfo(ITContent content) {
this.content = content;
}
@Override
public ITContent getContent() {
return content;
}
public void setContent(ITContent content) {
this.content = content;
}
@Override
public HashMap<String,String> getValue(Object... o){
HashMap<String,String> map = new HashMap<>();
//这边比较特殊,存的都是FormulaDictionary ,特殊判断一下
if (this.content.getOtherPos().contains("数据字典-公式类型-显示值")){
map.put("content",((FormulaDictionary)this.getContent().getReplaceObject()).getExcuteFormula());
} else if (this.content.getOtherPos().contains("数据字典-公式类型-实际值")){
map.put("content",((FormulaDictionary)this.getContent().getReplaceObject()).getProduceFormula());
} else {
map = getCommonValue();
}
return map;
}
@Override
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) {
FormulaReplaceObject formulaReplaceObject = FormulaReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName());
if (formulaReplaceObject != null){
formulaReplaceObject.setValue(this , findStr , replaceStr, operatorArray);
}
}
@Override
public String getInfoShowStr(Info info) {
FormulaReplaceObject formulaReplaceObject = FormulaReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName());
if (formulaReplaceObject != null){
return formulaReplaceObject.getInfoShowStr(info);
}
return StringUtils.EMPTY;
}
private HashMap<String,String> getCommonValue(){
FormulaReplaceObject o = FormulaReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName());
if(o != null){
return o.getValue(this.content.getReplaceObject());
}
return new HashMap<>();
}
}

81
designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java

@ -0,0 +1,81 @@
package com.fr.design.actions.replace.info;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
import javafx.util.Pair;
import java.util.ArrayList;
import java.util.HashMap;
/**
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-08-11
*/
public class JSInfo implements Info {
private ITContent content;
private boolean contentFlag = true;
public JSInfo(ITContent content) {
this.content = content;
}
@Override
public ITContent getContent() {
return content;
}
public void setContent(ITContent content) {
this.content = content;
}
@Override
public HashMap<String, String> getValue(Object... object) {
ReplaceObject o = ReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName());
if (o != null) {
return o.getValue(this.content.getReplaceObject());
}
return new HashMap<>();
}
@Override
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) {
ReplaceObject o = ReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName());
if (o != null) {
o.setValue(this, findStr, replaceStr, this.getContent().getOperatorArray());
}
}
@Override
public String getInfoShowStr(Info info) {
return info.getContent().getOldShowStr();
}
@Override
public String toString() {
return AssistUtils.toString(this);
}
public JSInfo copy() {
ITContent content = this.getContent().copy();
JSInfo jsInfo = new JSInfo(content);
jsInfo.setContentFlag(this.isContent());
return jsInfo;
}
public boolean isContent() {
return contentFlag;
}
public void setContentFlag(boolean contentFlag) {
this.contentFlag = contentFlag;
}
}

217
designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java

@ -0,0 +1,217 @@
package com.fr.design.actions.replace.info;
import com.fr.data.impl.DBTableData;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.form.event.Listener;
import com.fr.js.JavaScriptImpl;
import com.fr.js.NameJavaScript;
import com.fr.plugin.chart.base.VanChartHtmlLabel;
import com.fr.stable.StringUtils;
import javafx.util.Pair;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.HashMap;
/**
* 处理所存储的不同类型的对象(除了Formula外的其他对象)
* 此处对象是ITContent中用于直接查找内容与替换内容的操作对象
* Formula要处理的对象太多而且会和其他类型有重叠所以单独开一个类放
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-08-23
*/
public enum ReplaceObject implements DealWithInfoValue {
/**
* NameJavaScriptJS
*/
NAME_JAVA_SCRIPT("NameJavaScript") {
@Override
public HashMap<String, String> getValue(Object... o) {
HashMap<String, String> map = new HashMap<>();
if (!StringUtils.isEmpty(((NameJavaScript) o[0]).getName())) {
map.put("name", ((NameJavaScript) o[0]).getName());
}
if (!StringUtils.isEmpty(((JavaScriptImpl) (((NameJavaScript) o[0]).getJavaScript())).getContent())) {
map.put("content", ((JavaScriptImpl) (((NameJavaScript) o[0]).getJavaScript())).getContent());
}
return map;
}
@Override
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) {
if (((JSInfo) info).isContent()) {
JavaScriptImpl javaScript = (JavaScriptImpl) ((NameJavaScript) (info.getContent().getReplaceObject())).getJavaScript();
info.updateOldStr(javaScript.getContent(), findStr);
javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr));
} else {
NameJavaScript javaScript = ((NameJavaScript) (info.getContent().getReplaceObject()));
info.updateOldStr(javaScript.getName(), findStr);
javaScript.setName(javaScript.getName().replaceAll(findStr, replaceStr));
}
}
@Override
public String getInfoShowStr(Info info) {
if (((JSInfo) info).isContent()) {
JavaScriptImpl javaScript = (JavaScriptImpl) ((NameJavaScript) (info.getContent().getReplaceObject())).getJavaScript();
return javaScript.getContent();
} else {
NameJavaScript javaScript = ((NameJavaScript) (info.getContent().getReplaceObject()));
return javaScript.getName();
}
}
},
/**
* ListenerJS
*/
LISTENER("Listener") {
@Override
public HashMap<String, String> getValue(Object... o) {
HashMap<String, String> map = new HashMap<>();
if (!StringUtils.isEmpty(((Listener) o[0]).getName())) {
map.put("name", ((Listener) o[0]).getName());
}
if (!StringUtils.isEmpty(((JavaScriptImpl) (((Listener) o[0]).getAction())).getContent())) {
map.put("content", ((JavaScriptImpl) (((Listener) o[0]).getAction())).getContent());
}
return map;
}
@Override
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) {
if (((JSInfo) info).isContent()) {
if (operatorArray.size() > 0) {
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())));
listener.setName(listener.getName().replaceAll(findStr, replaceStr));
}
}
@Override
public String getInfoShowStr(Info info) {
if (((JSInfo) info).isContent()) {
JavaScriptImpl javaScript = (JavaScriptImpl) ((Listener) (info.getContent().getReplaceObject())).getAction();
return javaScript.getContent();
} else {
Listener listener = ((Listener) (info.getContent().getReplaceObject()));
return listener.getName();
}
}
},
/**
* VanChartHtmlLabelJS
*/
VAN_CHART_HTML_LABEL("VanChartHtmlLabel") {
@Override
public HashMap<String, String> getValue(Object... o) {
HashMap<String, String> map = new HashMap<>();
if (!StringUtils.isEmpty(((VanChartHtmlLabel) o[0]).getCustomText())) {
map.put("content", ((VanChartHtmlLabel) o[0]).getCustomText());
}
return map;
}
@Override
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) {
if (((JSInfo) info).isContent()) {
if (operatorArray.size() > 0) {
VanChartHtmlLabel htmlLabel = ((VanChartHtmlLabel) (info.getContent().getReplaceObject()));
StringBuilder stringBuilder = new StringBuilder(htmlLabel.getCustomText());
info.updateOldStr(htmlLabel.getCustomText(), findStr);
htmlLabel.setCustomText(ShowValueUtils.replaceAll(htmlLabel.getCustomText(), findStr, replaceStr));
}
}
}
@Override
public String getInfoShowStr(Info info) {
VanChartHtmlLabel htmlLabel = ((VanChartHtmlLabel) (info.getContent().getReplaceObject()));
return htmlLabel.getCustomText();
}
},
/**
* JavaScriptImplJS
*/
JAVA_SCRIPT_IMPL("JavaScriptImpl") {
@Override
public HashMap<String, String> getValue(Object... o) {
HashMap<String, String> map = new HashMap<>();
if (!StringUtils.isEmpty(((JavaScriptImpl) o[0]).getContent())) {
map.put("content", ((JavaScriptImpl) o[0]).getContent());
}
return map;
}
@Override
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) {
JavaScriptImpl javaScript = (JavaScriptImpl) (info.getContent().getReplaceObject());
info.updateOldStr(javaScript.getContent(), findStr);
javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr));
}
@Override
public String getInfoShowStr(Info info) {
JavaScriptImpl javaScript = (JavaScriptImpl) (info.getContent().getReplaceObject());
return javaScript.getContent();
}
},
/**
* DBTableDataSQL
*/
DB_TABLE_DATA("DBTableData") {
@Override
public HashMap<String, String> getValue(Object... o) {
HashMap<String, String> map = new HashMap<>();
if (!StringUtils.isEmpty(((DBTableData) o[0]).getQuery())) {
map.put("content", ((DBTableData) o[0]).getQuery());
}
return map;
}
@Override
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) {
DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject();
info.updateOldStr(dbTableData.getQuery(), findStr);
dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr));
}
@Override
public String getInfoShowStr(Info info) {
return info.getInfoShowStr(info);
}
};
String name;
ReplaceObject(String name) {
this.name = name;
}
/**
* 匹配
*
* @param name
* @return
*/
@Nullable
public static ReplaceObject match(String name) {
ReplaceObject[] values = ReplaceObject.values();
for (ReplaceObject value : values) {
if (value.name.equals(name)) {
return value;
}
}
return null;
}
}

64
designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java

@ -0,0 +1,64 @@
package com.fr.design.actions.replace.info;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.stable.AssistUtils;
import javafx.util.Pair;
import java.util.ArrayList;
import java.util.HashMap;
/**
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-08-16
*/
public class SQLInfo implements Info {
private ITContent content;
public SQLInfo(ITContent content) {
this.content = content;
}
@Override
public ITContent getContent() {
return content;
}
public void setContent(ITContent content) {
this.content = content;
}
@Override
public HashMap<String, String> getValue(Object... objects) {
ReplaceObject o = ReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName());
if (o != null) {
return o.getValue(this.content.getReplaceObject());
}
return new HashMap<>();
}
public SQLInfo copy() {
ITContent content = this.getContent().copy();
return new SQLInfo(content);
}
@Override
public String toString() {
return AssistUtils.toString(this);
}
@Override
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) {
ReplaceObject o = ReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName());
if (o != null) {
o.setValue(this, findStr, replaceStr, operatorArray);
}
}
@Override
public String getInfoShowStr(Info info) {
return this.getContent().getOldShowStr();
}
}

103
designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java

@ -0,0 +1,103 @@
package com.fr.design.actions.replace.info;
import com.fr.design.actions.replace.action.content.widget.FrmWidgetType;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.form.ui.WaterMark;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WScaleLayout;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.stable.AssistUtils;
import javafx.util.Pair;
import java.util.ArrayList;
import java.util.HashMap;
/**
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-08-16
*/
public class WidgetInfo implements Info, DealWithInfoValue {
private ITContent content;
private boolean waterMarkFlag = true;
public WidgetInfo(ITContent content) {
this.content = content;
}
@Override
public ITContent getContent() {
return content;
}
public void setContent(ITContent content) {
this.content = content;
}
@Override
public HashMap<String, String> getValue(Object... o) {
HashMap<String, String> map = new HashMap<>();
Widget widget = (Widget) this.content.getReplaceObject();
if (widget instanceof WScaleLayout) {
widget = ((CRBoundsWidget) ((WScaleLayout) widget).getWidget(0)).getWidget();
}
if (widget.getWidgetName() != null) {
map.put("name", widget.getWidgetName());
}
if (widget instanceof WaterMark && (((WaterMark) widget).getWaterMark() != null)) {
map.put("waterMark", ((WaterMark) widget).getWaterMark());
}
return map;
}
@Override
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) {
Widget widget = ((Widget) (this.content.getReplaceObject()));
if (this.getContent().isFrm()) {
FrmWidgetType widgetType = FrmWidgetType.match(widget.getClass().getSimpleName());
if (widgetType != null) {
widgetType.setValue(info, findStr, replaceStr, this.getContent().getOperatorArray());
}
} else {
if (isWaterMark()) {
updateOldStr(((WaterMark) widget).getWaterMark(), findStr);
((WaterMark) widget).setWaterMark(ShowValueUtils.replaceAll(((WaterMark) widget).getWaterMark(), findStr, replaceStr));
} else {
updateOldStr(widget.getWidgetName(), findStr);
widget.setWidgetName(ShowValueUtils.replaceAll(widget.getWidgetName(), findStr, replaceStr));
}
}
}
@Override
public String getInfoShowStr(Info info) {
return this.getContent().getOldShowStr();
}
public WidgetInfo copy(WidgetInfo widgetInfo) {
ITContent content = widgetInfo.getContent().copy();
return new WidgetInfo(content);
}
public boolean isWaterMark() {
return waterMarkFlag;
}
public void setWaterMarkFlag(boolean waterMarkFlag) {
this.waterMarkFlag = waterMarkFlag;
}
public boolean isReplaceObjectExist() {
return content != null && content.getReplaceObject() != null;
}
@Override
public String toString() {
return AssistUtils.toString(this);
}
}

232
designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ContentObject.java

@ -0,0 +1,232 @@
package com.fr.design.actions.replace.info.base;
import com.fr.base.Formula;
import com.fr.chartx.constant.ChartKeyCst;
import com.fr.data.impl.DBTableData;
import com.fr.form.event.Listener;
import com.fr.form.ui.Widget;
import com.fr.general.data.Condition;
import com.fr.js.JavaScript;
import com.fr.js.NameJavaScript;
import com.fr.plugin.chart.base.VanChartHtmlLabel;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.FloatElement;
import com.fr.report.core.sort.sortexpression.FormulaSortExpression;
import com.fr.report.core.sort.sortexpression.SortExpression;
import com.fr.stable.AssistUtils;
import com.teamdev.jxbrowser.deps.org.checkerframework.checker.units.qual.C;
/**
* 存储用于定位内容的对象便于定位
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-08-16
*/
public class ContentObject {
//todo 可能没用,考虑废除掉
private CellElement cell;
private JavaScript js;
private NameJavaScript nameJavaScript;
private VanChartHtmlLabel htmlLabel;
private Widget widget;
private Listener listener;
private FloatElement floatElement;
private Formula formula;
private Condition condition;
private FormulaSortExpression sortExpression;
private DBTableData dbTableData;
public ContentObject() {
this.cell = null;
this.js = null;
this.nameJavaScript = null;
this.htmlLabel = null;
this.widget = null;
this.listener = null;
this.floatElement = null;
this.formula = null;
this.condition = null;
this.sortExpression = null;
this.dbTableData = null;
}
public ContentObject newContentObject(ContentObject contentObject) {
ContentObject newContent = new ContentObject();
newContent.copyCellElement(contentObject);
newContent.copyFloatElement(contentObject);
newContent.copyHtmlLabel(contentObject);
newContent.copyJavaScript(contentObject);
newContent.copyListener(contentObject);
newContent.copyNameJavaScript(contentObject);
newContent.copyWidget(contentObject);
newContent.copyFormula(contentObject);
newContent.copyCondition(contentObject);
newContent.copySortExpression(contentObject);
newContent.copyDBTableData(contentObject);
return newContent;
}
public void copyCellElement(ContentObject contentObject) {
if (contentObject.getCell() != null) {
this.setCell(contentObject.getCell());
}
}
public void copyJavaScript(ContentObject contentObject) {
if (contentObject.getJs() != null) {
this.setJs(contentObject.getJs());
}
}
public void copyNameJavaScript(ContentObject contentObject) {
if (contentObject.getNameJavaScript() != null) {
this.setNameJavaScript(contentObject.getNameJavaScript());
}
}
public void copyHtmlLabel(ContentObject contentObject) {
if (contentObject.getHtmlLabel() != null) {
this.setHtmlLabel(contentObject.getHtmlLabel());
}
}
public void copyListener(ContentObject contentObject) {
if (contentObject.getListener() != null) {
this.setListener(contentObject.getListener());
}
}
public void copyFloatElement(ContentObject contentObject) {
if (contentObject.getFloatElement() != null) {
this.setFloatElement(contentObject.getFloatElement());
}
}
public void copyWidget(ContentObject contentObject) {
if (contentObject.getWidget() != null) {
this.setWidget(contentObject.getWidget());
}
}
public void copyFormula(ContentObject contentObject) {
if (contentObject.getFormula() != null) {
this.setFormula(contentObject.getFormula());
}
}
public void copyCondition(ContentObject contentObject) {
if (contentObject.getCondition() != null) {
this.setCondition(contentObject.getCondition());
}
}
public void copySortExpression(ContentObject contentObject) {
if (contentObject.getSortExpression() != null) {
this.setSortExpression(contentObject.getSortExpression());
}
}
public void copyDBTableData(ContentObject contentObject) {
if (contentObject.getDbTableData() != null) {
this.setDbTableData(contentObject.getDbTableData());
}
}
public DBTableData getDbTableData() {
return dbTableData;
}
public void setDbTableData(DBTableData dbTableData) {
this.dbTableData = dbTableData;
}
public FormulaSortExpression getSortExpression() {
return sortExpression;
}
public void setSortExpression(FormulaSortExpression sortExpression) {
this.sortExpression = sortExpression;
}
public Condition getCondition() {
return condition;
}
public void setCondition(Condition condition) {
this.condition = condition;
}
public Formula getFormula() {
return formula;
}
public void setFormula(Formula formula) {
this.formula = formula;
}
public CellElement getCell() {
return cell;
}
public void setCell(CellElement cell) {
this.cell = cell;
}
public JavaScript getJs() {
return js;
}
public void setJs(JavaScript js) {
this.js = js;
}
public NameJavaScript getNameJavaScript() {
return nameJavaScript;
}
public void setNameJavaScript(NameJavaScript nameJavaScript) {
this.nameJavaScript = nameJavaScript;
}
public VanChartHtmlLabel getHtmlLabel() {
return htmlLabel;
}
public void setHtmlLabel(VanChartHtmlLabel htmlLabel) {
this.htmlLabel = htmlLabel;
}
public Widget getWidget() {
return widget;
}
public void setWidget(Widget widget) {
this.widget = widget;
}
public Listener getListener() {
return listener;
}
public void setListener(Listener listener) {
this.listener = listener;
}
public FloatElement getFloatElement() {
return floatElement;
}
public void setFloatElement(FloatElement floatElement) {
this.floatElement = floatElement;
}
@Override
public String toString() {
return AssistUtils.toString(this);
}
public boolean isNameJSExist() {
return this.nameJavaScript != null;
}
}

244
designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java

@ -0,0 +1,244 @@
package com.fr.design.actions.replace.info.base;
import com.fr.design.actions.replace.info.DealWithInfoValue;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
import javafx.util.Pair;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
* 主要的存储信息的数据结构
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-08-11
*/
public class ITContent implements Cloneable {
private String sheetID;
private String sheetName;
private String templateName;
private String blockName;
//一些不好定位的位置先用字符串展示出来就好
private String otherPos;
//用于后续跳转相关的对象信息
private ContentObject contentObject;
//用于操作替换相关的对象(通过此属性获取所需的对象)
private Object replaceObject;
//用于展示给用户的位置
private Object showObject;
//用于展示内容
private String showStr;
//存储展示前的旧值
private String oldShowStr;
//存储上一次搜索的string
private String lastSearchStr;
//由于我们TRL是一次性的,这边存字符串到时候new一个即可
private String trlString;
//为操作字符串提供操作位置的定位信息,Pair中存储的是开始操作的索引以及结束操作的索引
private ArrayList<Pair<Integer, Integer>> operatorArray;
//是否是决策报表——用于判断一些决策报表的特殊操作(比如决策报表控件在设置值时要多设置几个地方,一层套一层)
private boolean frmFlag = false;
//是否被选中
private boolean selected = true;
public ITContent() {
this.sheetID = StringUtils.EMPTY;
this.sheetName = StringUtils.EMPTY;
this.blockName = StringUtils.EMPTY;
this.templateName = StringUtils.EMPTY;
this.otherPos = StringUtils.EMPTY;
this.replaceObject = StringUtils.EMPTY;
this.contentObject = new ContentObject();
this.showObject = StringUtils.EMPTY;
this.showStr = StringUtils.EMPTY;
this.oldShowStr = StringUtils.EMPTY;
this.lastSearchStr = StringUtils.EMPTY;
this.trlString = StringUtils.EMPTY;
this.operatorArray = new ArrayList<>();
}
/**
* 复制
* @return
*/
public ITContent copy() {
ITContent result = new ITContent();
result.setSheetID(this.getSheetID());
result.setSheetName(this.getSheetName());
result.setTemplateName(this.getTemplateName());
result.setBlockName(this.getBlockName());
result.addOtherPos(this.getOtherPos());
result.setReplaceObject(this.getReplaceObject());
result.setContentObject(this.getContentObject().newContentObject(getContentObject()));
result.setShowObject(this.getShowObject());
result.setTrlString(this.getTrlString());
result.setShowStr(this.getShowStr());
result.setOldShowStr(this.getOldShowStr());
result.setLastSearchStr(this.getLastSearchStr());
result.setOperatorArray(this.getOperatorArray());
result.setFrmFlag(this.isFrm());
return result;
}
public ContentObject getContentObject() {
return contentObject;
}
public void setContentObject(ContentObject contentObject) {
this.contentObject = contentObject;
}
public Object getReplaceObject() {
return replaceObject;
}
public void setReplaceObject(Object replaceObject) {
this.replaceObject = replaceObject;
}
public String getSheetID() {
return sheetID;
}
public void setSheetID(String sheetID) {
this.sheetID = sheetID;
}
public String getSheetName() {
return sheetName;
}
public void setSheetName(String sheetName) {
this.sheetName = sheetName;
}
public String getTemplateName() {
return templateName;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
public String getBlockName() {
return blockName;
}
public void setBlockName(String blockName) {
this.blockName = blockName;
}
public String getOtherPos() {
return otherPos;
}
public Object getShowObject() {
return showObject;
}
public String getShowStr() {
return showStr;
}
public void setShowStr(String showStr) {
this.showStr = showStr;
}
public String getTrlString() {
return trlString;
}
public void setTrlString(String trlString) {
this.trlString = trlString;
}
public void setShowObject(Object showObject) {
this.showObject = showObject;
}
/**
* 添加位置信息
* @param otherPoses
*/
public void addOtherPos(String... otherPoses) {
for (String otherPos : otherPoses) {
if (this.otherPos != null && !StringUtils.isEmpty(this.otherPos)) {
this.otherPos = this.otherPos + "-" + otherPos;
} else {
this.otherPos = otherPos;
}
}
}
/**
* 添加跳转路径
* @param trlString
*/
public void addTRL(String trlString) {
if (!StringUtils.isEmpty(trlString)) {
if (this.trlString != null && !StringUtils.isEmpty(this.trlString)) {
this.trlString = this.trlString + ":" + trlString;
} else {
this.trlString = trlString;
}
}
}
public ArrayList<Pair<Integer, Integer>> getOperatorArray() {
return operatorArray;
}
public void setOperatorArray(ArrayList<Pair<Integer, Integer>> operatorArray) {
this.operatorArray = operatorArray;
}
public void setOtherPos(String otherPos) {
this.otherPos = otherPos;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
public boolean isFrm() {
return frmFlag;
}
public void setFrmFlag(boolean frmFlag) {
this.frmFlag = frmFlag;
}
public String getOldShowStr() {
return oldShowStr;
}
public void setOldShowStr(String oldShowStr) {
this.oldShowStr = oldShowStr;
}
public String getLastSearchStr() {
return lastSearchStr;
}
public void setLastSearchStr(String lastSearchStr) {
this.lastSearchStr = lastSearchStr;
}
@Override
public String toString() {
return AssistUtils.toString(this);
}
}
Loading…
Cancel
Save