8 changed files with 1601 additions and 0 deletions
@ -0,0 +1,388 @@ |
|||||||
|
package com.fr.design.actions.replace.action; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.chart.chartattr.ChartCollection; |
||||||
|
import com.fr.design.actions.replace.action.content.cell.SearchCellAction; |
||||||
|
import com.fr.design.actions.replace.action.content.component.SearchComponentAction; |
||||||
|
import com.fr.design.actions.replace.action.content.floatelement.SearchFloatAction; |
||||||
|
import com.fr.design.actions.replace.action.content.formula.SearchFormulaAction; |
||||||
|
import com.fr.design.actions.replace.action.content.js.SearchJSAction; |
||||||
|
import com.fr.design.actions.replace.action.content.sql.SearchSQLAction; |
||||||
|
import com.fr.design.actions.replace.action.content.widget.SearchWidgetAction; |
||||||
|
import com.fr.design.actions.replace.info.*; |
||||||
|
import com.fr.design.actions.replace.utils.ShowValueUtils; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.general.GeneralUtils; |
||||||
|
import com.fr.report.cell.CellElement; |
||||||
|
import com.fr.report.cell.FloatElement; |
||||||
|
import com.fr.third.org.apache.poi.hssf.record.formula.functions.Int; |
||||||
|
import javafx.util.Pair; |
||||||
|
import org.gradle.internal.impldep.org.apache.commons.lang.StringUtils; |
||||||
|
import org.jetbrains.annotations.Nullable; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.HashMap; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Destiny.Lin |
||||||
|
* @version 11.0 |
||||||
|
* created by Destiny.Lin on 2022-08-22 |
||||||
|
*/ |
||||||
|
public enum ShowSearchResultAction implements ShowValue { |
||||||
|
/** |
||||||
|
* 搜索单元格 |
||||||
|
*/ |
||||||
|
CELL(Toolkit.i18nText("Fine-Design_Basic_Cell")) { |
||||||
|
@Override |
||||||
|
public ArrayList<? extends Info> showSearchValue(JTemplate jTemplate) { |
||||||
|
return new SearchCellAction(jTemplate).getCellInfos(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ArrayList<? extends Info> addMatchResult(String str, ArrayList<? extends Info> arrayList) { |
||||||
|
ArrayList<CellInfo> cellInfos = new ArrayList<>(); |
||||||
|
for (Info info : arrayList) { |
||||||
|
if (((CellInfo) info).isChartExist()) { |
||||||
|
CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); |
||||||
|
ChartCollection chartCollection = (ChartCollection) cellElement.getValue(); |
||||||
|
for (int i = 0; i < chartCollection.getChartCount(); i++) { |
||||||
|
String titleName = GeneralUtils.objectToString(chartCollection.getChart(i).getTitle().getTextObject()); |
||||||
|
if (titleName.contains(str)) { |
||||||
|
CellInfo cellInfo = ((CellInfo) info).copy(); |
||||||
|
cellInfo.setCellChartIndex(i); |
||||||
|
cellInfo.getContent().addOtherPos( |
||||||
|
Toolkit.i18nText("Fine-Design_Replace_Chart_Title"), |
||||||
|
chartCollection.getChartName(i), |
||||||
|
titleName |
||||||
|
); |
||||||
|
setShowInfo(cellInfo, titleName, str); |
||||||
|
cellInfos.add(cellInfo); |
||||||
|
} |
||||||
|
} |
||||||
|
} else { |
||||||
|
HashMap<String, String> stringHashMap = info.getValue(); |
||||||
|
String content = stringHashMap.getOrDefault("content", StringUtils.EMPTY); |
||||||
|
if (content.contains(str) && !StringUtils.isEmpty(content)) { |
||||||
|
info.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); |
||||||
|
info.getContent().setOldShowStr(content); |
||||||
|
info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); |
||||||
|
info.getContent().setSelected(true); |
||||||
|
cellInfos.add((CellInfo) info); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return cellInfos; |
||||||
|
} |
||||||
|
|
||||||
|
private void setShowInfo(CellInfo cellInfo, String titleName, String str) { |
||||||
|
cellInfo.getContent().setShowStr(ShowValueUtils.getCommonString(titleName, str)); |
||||||
|
cellInfo.getContent().setOldShowStr(titleName); |
||||||
|
cellInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(titleName, str)); |
||||||
|
cellInfo.getContent().setSelected(true); |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* 搜索JS事件 |
||||||
|
*/ |
||||||
|
JS(Toolkit.i18nText("Fine-Design_Replace_JS")) { |
||||||
|
@Override |
||||||
|
public ArrayList<? extends Info> showSearchValue(JTemplate jTemplate) { |
||||||
|
return new SearchJSAction(jTemplate).getJsInfos(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ArrayList<? extends Info> addMatchResult(String str, ArrayList<? extends Info> arrayList) { |
||||||
|
ArrayList<JSInfo> jsInfos = new ArrayList<>(); |
||||||
|
HashMap<String, String> stringHashMap = new HashMap<>(); |
||||||
|
for (Info info : arrayList) { |
||||||
|
stringHashMap = info.getValue(); |
||||||
|
if (StringUtils.isEmpty(str)) { |
||||||
|
if (!StringUtils.isEmpty(stringHashMap.getOrDefault("content", StringUtils.EMPTY))) { |
||||||
|
JSInfo contentJSInfo = ((JSInfo) info).copy(); |
||||||
|
contentJSInfo.getContent().setShowStr(stringHashMap.get("content")); |
||||||
|
contentJSInfo.getContent().setOldShowStr(stringHashMap.get("content")); |
||||||
|
contentJSInfo.getContent().setSelected(true); |
||||||
|
contentJSInfo.setContentFlag(true); |
||||||
|
jsInfos.add(contentJSInfo); |
||||||
|
} |
||||||
|
if (!StringUtils.isEmpty(stringHashMap.getOrDefault("name", StringUtils.EMPTY))) { |
||||||
|
JSInfo nameJSInfo = ((JSInfo) info).copy(); |
||||||
|
nameJSInfo.getContent().setShowStr(stringHashMap.get("name")); |
||||||
|
nameJSInfo.getContent().setOldShowStr(stringHashMap.get("name")); |
||||||
|
nameJSInfo.getContent().setSelected(true); |
||||||
|
nameJSInfo.setContentFlag(false); |
||||||
|
jsInfos.add(nameJSInfo); |
||||||
|
} |
||||||
|
} else { |
||||||
|
searchMap4JS(stringHashMap, jsInfos, ((JSInfo) info), str); |
||||||
|
//searchMap4JSContent(stringHashMap, jsInfos, ((JSInfo) info), str);
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
return jsInfos; |
||||||
|
} |
||||||
|
|
||||||
|
private void searchMap4JS(HashMap<String, String> stringHashMap, ArrayList<JSInfo> jsInfos, JSInfo info, String str) { |
||||||
|
if (stringHashMap.containsKey("name") && !StringUtils.isEmpty(stringHashMap.get("name"))) { |
||||||
|
String name = stringHashMap.get("name"); |
||||||
|
if (name.contains(str)) { |
||||||
|
JSInfo nameJSInfo = info.copy(); |
||||||
|
nameJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); |
||||||
|
nameJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(name, str)); |
||||||
|
nameJSInfo.getContent().setOldShowStr(stringHashMap.get("name")); |
||||||
|
nameJSInfo.setContentFlag(false); |
||||||
|
nameJSInfo.getContent().setSelected(true); |
||||||
|
jsInfos.add(nameJSInfo); |
||||||
|
} |
||||||
|
} |
||||||
|
if (stringHashMap.containsKey("content") && !StringUtils.isEmpty(stringHashMap.get("content"))) { |
||||||
|
String content = stringHashMap.get("content"); |
||||||
|
if (content.contains(str)) { |
||||||
|
JSInfo contentJSInfo = info.copy(); |
||||||
|
contentJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); |
||||||
|
contentJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); |
||||||
|
contentJSInfo.getContent().setOldShowStr(stringHashMap.get("content")); |
||||||
|
contentJSInfo.setContentFlag(true); |
||||||
|
contentJSInfo.getContent().setSelected(true); |
||||||
|
jsInfos.add(contentJSInfo); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* 搜索SQL |
||||||
|
*/ |
||||||
|
SQL("SQL") { |
||||||
|
@Override |
||||||
|
public ArrayList<? extends Info> showSearchValue(JTemplate jTemplate) { |
||||||
|
return new SearchSQLAction(jTemplate).getSqlInfos(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ArrayList<? extends Info> addMatchResult(String str, ArrayList<? extends Info> arrayList) { |
||||||
|
ArrayList<SQLInfo> sqlInfos = new ArrayList<>(); |
||||||
|
HashMap<String, String> stringHashMap = new HashMap<>(); |
||||||
|
for (Info info : arrayList) { |
||||||
|
stringHashMap = ((SQLInfo) info).getValue(); |
||||||
|
if (StringUtils.isEmpty(str)) { |
||||||
|
info.getContent().setShowStr(stringHashMap.get("content")); |
||||||
|
info.getContent().setOldShowStr(stringHashMap.get("content")); |
||||||
|
info.getContent().setSelected(true); |
||||||
|
sqlInfos.add((SQLInfo) info); |
||||||
|
} else { |
||||||
|
searchMap4SQLContent(stringHashMap, sqlInfos, ((SQLInfo) info), str); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
return sqlInfos; |
||||||
|
} |
||||||
|
|
||||||
|
private void searchMap4SQLContent(HashMap<String, String> stringHashMap, ArrayList<SQLInfo> sqlInfos, SQLInfo info, String str) { |
||||||
|
if (stringHashMap.containsKey("content") && !StringUtils.isEmpty(stringHashMap.get("content"))) { |
||||||
|
String content = stringHashMap.get("content"); |
||||||
|
if (content.contains(str)) { |
||||||
|
SQLInfo contentJSInfo = info.copy(); |
||||||
|
contentJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); |
||||||
|
contentJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); |
||||||
|
contentJSInfo.getContent().setOldShowStr(stringHashMap.get("content")); |
||||||
|
contentJSInfo.getContent().setSelected(true); |
||||||
|
sqlInfos.add(contentJSInfo); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void updateOperaotrArray(int index, int preLength, int strLength, SQLInfo sqlInfo) { |
||||||
|
ArrayList<Pair<Integer, Integer>> pairs = new ArrayList<>(); |
||||||
|
pairs.add(new Pair<>(index + preLength, index + preLength + strLength)); |
||||||
|
sqlInfo.getContent().setOperatorArray(pairs); |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* 搜索悬浮元素 |
||||||
|
*/ |
||||||
|
FLOAT(Toolkit.i18nText("Fine-Design_Basic_Float_Element")) { |
||||||
|
@Override |
||||||
|
public ArrayList<? extends Info> showSearchValue(JTemplate jTemplate) { |
||||||
|
return new SearchFloatAction(jTemplate).getFloatInfos(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ArrayList<? extends Info> addMatchResult(String str, ArrayList<? extends Info> arrayList) { |
||||||
|
ArrayList<FloatInfo> floatInfos = new ArrayList<>(); |
||||||
|
for (Info info : arrayList) { |
||||||
|
FloatElement floatElement = ((FloatElement) (info.getContent().getReplaceObject())); |
||||||
|
//如果存的是图表,就要特殊处理
|
||||||
|
if (((FloatInfo) info).isChartExist()) { |
||||||
|
ChartCollection chartCollection = (ChartCollection) floatElement.getValue(); |
||||||
|
for (int i = 0; i < chartCollection.getChartCount(); i++) { |
||||||
|
String titleName = GeneralUtils.objectToString(chartCollection.getChart(i).getTitle().getTextObject()); |
||||||
|
if (titleName.contains(str)) { |
||||||
|
FloatInfo floatInfo = ((FloatInfo) info).copy(); |
||||||
|
floatInfo.setFloatChartIndex(i); |
||||||
|
floatInfo.getContent().addOtherPos( |
||||||
|
Toolkit.i18nText("Fine-Design_Replace_Chart_Title"), |
||||||
|
chartCollection.getChartName(i), |
||||||
|
titleName); |
||||||
|
setShowInfo(floatInfo, titleName, str); |
||||||
|
floatInfos.add(floatInfo); |
||||||
|
} |
||||||
|
} |
||||||
|
} else { |
||||||
|
if (GeneralUtils.objectToString(floatElement.getValue()).contains(str)) { |
||||||
|
FloatInfo floatInfo = ((FloatInfo) info).copy(); |
||||||
|
setShowInfo(floatInfo, GeneralUtils.objectToString(floatElement.getValue()), str); |
||||||
|
floatInfos.add(floatInfo); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return floatInfos; |
||||||
|
} |
||||||
|
|
||||||
|
private void setShowInfo(FloatInfo floatInfo, String value, String str) { |
||||||
|
floatInfo.getContent().setOldShowStr(value); |
||||||
|
floatInfo.getContent().setShowStr(ShowValueUtils.getCommonString(value, str)); |
||||||
|
floatInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(value, str)); |
||||||
|
floatInfo.getContent().setSelected(true); |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* 搜索组件 |
||||||
|
*/ |
||||||
|
COMPONENT(Toolkit.i18nText("Fine-Design_Replace_Component")) { |
||||||
|
@Override |
||||||
|
public ArrayList<? extends Info> showSearchValue(JTemplate jTemplate) { |
||||||
|
return new SearchComponentAction(jTemplate).getComponentInfos(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ArrayList<? extends Info> addMatchResult(String str, ArrayList<? extends Info> arrayList) { |
||||||
|
ArrayList<ComponentInfo> componentInfos = new ArrayList<>(); |
||||||
|
HashMap<String, String> stringHashMap = new HashMap<>(); |
||||||
|
for (Info info : arrayList) { |
||||||
|
stringHashMap = info.getValue(info.getContent().getReplaceObject()); |
||||||
|
searchMap4Component(stringHashMap, componentInfos, ((ComponentInfo) info), str); |
||||||
|
} |
||||||
|
return componentInfos; |
||||||
|
} |
||||||
|
|
||||||
|
private void searchMap4Component(HashMap<String, String> stringHashMap, ArrayList<ComponentInfo> componentInfos, ComponentInfo info, String str) { |
||||||
|
if (stringHashMap.containsKey("content")) { |
||||||
|
String content = stringHashMap.get("content"); |
||||||
|
if (content.contains(str)) { |
||||||
|
info.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); |
||||||
|
info.getContent().setOldShowStr(stringHashMap.get("content")); |
||||||
|
info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); |
||||||
|
info.getContent().setSelected(true); |
||||||
|
componentInfos.add(info); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* 搜索控件 |
||||||
|
*/ |
||||||
|
WIDGET(Toolkit.i18nText("Fine-Design_Basic_Widget")) { |
||||||
|
@Override |
||||||
|
public ArrayList<? extends Info> showSearchValue(JTemplate jTemplate) { |
||||||
|
return new SearchWidgetAction(jTemplate).getWidgetInfos(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ArrayList<? extends Info> addMatchResult(String str, ArrayList<? extends Info> arrayList) { |
||||||
|
ArrayList<WidgetInfo> widgetInfos = new ArrayList<>(); |
||||||
|
HashMap<String, String> stringHashMap = new HashMap<>(); |
||||||
|
for (Info info : arrayList) { |
||||||
|
stringHashMap = info.getValue(); |
||||||
|
searchMap4Widget(stringHashMap, widgetInfos, ((WidgetInfo) info), str); |
||||||
|
} |
||||||
|
return widgetInfos; |
||||||
|
} |
||||||
|
|
||||||
|
private void searchMap4Widget(HashMap<String, String> stringHashMap, ArrayList<WidgetInfo> widgetInfos, WidgetInfo info, String str) { |
||||||
|
if (stringHashMap.containsKey("name")) { |
||||||
|
String name = stringHashMap.get("name"); |
||||||
|
if (!StringUtils.isEmpty(name) && name.contains(str)) { |
||||||
|
WidgetInfo nameInfo = info.copy(info); |
||||||
|
nameInfo.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); |
||||||
|
nameInfo.getContent().setOldShowStr(stringHashMap.get("name")); |
||||||
|
nameInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(name, str)); |
||||||
|
nameInfo.getContent().setSelected(true); |
||||||
|
nameInfo.setWaterMarkFlag(false); |
||||||
|
widgetInfos.add(nameInfo); |
||||||
|
} |
||||||
|
} |
||||||
|
if (stringHashMap.containsKey("waterMark")) { |
||||||
|
String waterMark = stringHashMap.get("waterMark"); |
||||||
|
if (!StringUtils.isEmpty(waterMark) && waterMark.contains(str)) { |
||||||
|
WidgetInfo widgetInfo = info.copy(info); |
||||||
|
widgetInfo.getContent().setShowStr(ShowValueUtils.getCommonString(waterMark, str)); |
||||||
|
widgetInfo.getContent().setOldShowStr(stringHashMap.get("waterMark")); |
||||||
|
widgetInfo.getContent().setShowObject(widgetInfo.getContent().getShowObject() + "水印"); |
||||||
|
widgetInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(waterMark, str)); |
||||||
|
widgetInfo.getContent().setSelected(true); |
||||||
|
widgetInfo.setWaterMarkFlag(true); |
||||||
|
widgetInfos.add(widgetInfo); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* 搜索公式 |
||||||
|
*/ |
||||||
|
FORMULA(Toolkit.i18nText("Fine-Design_Basic_Formula")) { |
||||||
|
@Override |
||||||
|
public ArrayList<? extends Info> showSearchValue(JTemplate jTemplate) { |
||||||
|
return new SearchFormulaAction(jTemplate).getFormulaInfos(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ArrayList<? extends Info> addMatchResult(String str, ArrayList<? extends Info> arrayList) { |
||||||
|
ArrayList<FormulaInfo> formulaInfos = new ArrayList<>(); |
||||||
|
HashMap<String, String> stringHashMap = new HashMap<>(); |
||||||
|
for (Info info : arrayList) { |
||||||
|
stringHashMap = info.getValue(); |
||||||
|
searchMap4Formula(stringHashMap, formulaInfos, ((FormulaInfo) info), str); |
||||||
|
} |
||||||
|
return formulaInfos; |
||||||
|
} |
||||||
|
|
||||||
|
private void searchMap4Formula(HashMap<String, String> stringHashMap, ArrayList<FormulaInfo> formulaInfos, FormulaInfo info, String str) { |
||||||
|
if (stringHashMap.containsKey("content")) { |
||||||
|
String name = stringHashMap.get("content"); |
||||||
|
if (name.contains(str)) { |
||||||
|
info.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); |
||||||
|
info.getContent().setOldShowStr(stringHashMap.get("content")); |
||||||
|
info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(name, str)); |
||||||
|
info.getContent().setSelected(true); |
||||||
|
formulaInfos.add(info); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
String name; |
||||||
|
|
||||||
|
ShowSearchResultAction(String name) { |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 匹配 |
||||||
|
* |
||||||
|
* @param name |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Nullable |
||||||
|
public static ShowSearchResultAction match(String name) { |
||||||
|
ShowSearchResultAction[] values = ShowSearchResultAction.values(); |
||||||
|
for (ShowSearchResultAction value : values) { |
||||||
|
if (value.name.equals(name)) { |
||||||
|
return value; |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,192 @@ |
|||||||
|
package com.fr.design.actions.replace.action.content.cell; |
||||||
|
|
||||||
|
import com.fr.chart.chartattr.ChartCollection; |
||||||
|
import com.fr.design.actions.replace.action.SearchAction; |
||||||
|
import com.fr.design.actions.replace.action.content.component.SearchComponentAction; |
||||||
|
import com.fr.design.actions.replace.info.ComponentInfo; |
||||||
|
import com.fr.design.actions.replace.info.DealWithInfoValue; |
||||||
|
import com.fr.design.actions.replace.info.Info; |
||||||
|
import com.fr.design.actions.replace.info.base.ITContent; |
||||||
|
|
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.design.actions.replace.info.CellInfo; |
||||||
|
import com.fr.form.main.Form; |
||||||
|
import com.fr.form.ui.ElementCaseEditor; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.container.*; |
||||||
|
import com.fr.form.ui.widget.CRBoundsWidget; |
||||||
|
import com.fr.general.GeneralUtils; |
||||||
|
import com.fr.main.impl.WorkBook; |
||||||
|
import com.fr.report.cell.CellElement; |
||||||
|
import com.fr.report.elementcase.ElementCase; |
||||||
|
import com.fr.report.poly.PolyECBlock; |
||||||
|
import com.fr.report.report.Report; |
||||||
|
import com.fr.stable.AssistUtils; |
||||||
|
import javafx.util.Pair; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Iterator; |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取有内容的单元格相关信息 |
||||||
|
* |
||||||
|
* tips:这边报表分为两块——决策报表(dealForm)和普通报表(dealWorkBook),二者最后都会归于ElementCase |
||||||
|
* 决策报表:虽然分为绝对布局和自适应布局,但是单元格可能存在的地方只有report ,二者对它(report)的处理是统一的,都属于WTitleLayout,因此没必要划分两种布局 |
||||||
|
* 普通报表:获取elementCase拿到cellIterator遍历即可 |
||||||
|
* |
||||||
|
* @author Destiny.Lin |
||||||
|
* @version 11.0 |
||||||
|
* created by Destiny.Lin on 2022-08-11 |
||||||
|
*/ |
||||||
|
public class SearchCellAction implements SearchAction { |
||||||
|
private ArrayList<CellInfo> cellInfos; |
||||||
|
|
||||||
|
/** |
||||||
|
* 构造时会搜索单元格,设置对应的单元格列表信息 |
||||||
|
* @param jTemplate 要搜索的报表对象 |
||||||
|
*/ |
||||||
|
public SearchCellAction(JTemplate jTemplate){ |
||||||
|
setCellInfos(search4Infos(jTemplate)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public ArrayList<CellInfo> getCellInfos() { |
||||||
|
return cellInfos; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCellInfos(ArrayList<CellInfo> cellInfos) { |
||||||
|
this.cellInfos = cellInfos; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 搜索对应的信息 |
||||||
|
* @param jTemplate 要搜索的报表对象 |
||||||
|
* @return 返回单元格信息Array |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public ArrayList<CellInfo> search4Infos(JTemplate jTemplate){ |
||||||
|
if (jTemplate.getTarget() instanceof Form){ |
||||||
|
return dealForm(jTemplate); |
||||||
|
|
||||||
|
} else if (jTemplate.getTarget() instanceof WorkBook){ |
||||||
|
return dealWorkBook(jTemplate); |
||||||
|
} |
||||||
|
return new ArrayList<>(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 处理决策报表 |
||||||
|
* 流程:dealForm——>getCellInfosFromBoundsWidget——>getCellInfoFromElementCase |
||||||
|
* @param jTemplate 要搜索的报表对象 |
||||||
|
* @return 返回单元格信息Array |
||||||
|
*/ |
||||||
|
private ArrayList<CellInfo> dealForm(JTemplate jTemplate) { |
||||||
|
ArrayList<CellInfo> result = new ArrayList<>(); |
||||||
|
SearchComponentAction searchComponentAction = new SearchComponentAction(jTemplate); |
||||||
|
for (ComponentInfo info : searchComponentAction.getComponentInfos()){ |
||||||
|
ITContent content = info.getContent().copy(); |
||||||
|
getCellInfosFromBoundsWidget(result,content, (Widget) info.getContent().getReplaceObject()); |
||||||
|
|
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 从组件信息中获取到的layout中的BoundsWidget中获取真正的报表块,并且将信息添加到列表中 |
||||||
|
* @param result 要操作的Array |
||||||
|
* @param content 存储查找替换相关信息的类 |
||||||
|
* @param widget 控件和组件的最高层接口 |
||||||
|
*/ |
||||||
|
private void getCellInfosFromBoundsWidget(ArrayList<CellInfo> result, ITContent content, Widget widget) { |
||||||
|
//report在两种布局中都属于WTitleLayout
|
||||||
|
if (widget instanceof WTitleLayout){ |
||||||
|
for (int i = 0 ; i < ((WTitleLayout) widget).getWidgetCount() ; i++){ |
||||||
|
//这里它又套了一层BoundsWidget
|
||||||
|
if (((CRBoundsWidget)((WTitleLayout) widget).getWidget(i)).getWidget() instanceof ElementCaseEditor){ |
||||||
|
ElementCaseEditor editor = (ElementCaseEditor) ((CRBoundsWidget)((WTitleLayout) widget).getWidget(i)).getWidget(); |
||||||
|
ITContent newContent = content.copy(); |
||||||
|
getCellInfoFromElementCase((ElementCase) editor.getElementCase(),result,newContent); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 处理普通报表 |
||||||
|
* @param jTemplate 要搜索的报表对象 |
||||||
|
* @return 对应信息Array |
||||||
|
*/ |
||||||
|
private ArrayList<CellInfo> dealWorkBook(JTemplate jTemplate) { |
||||||
|
WorkBook workBook = (WorkBook) jTemplate.getTarget(); |
||||||
|
ArrayList<CellInfo> result = new ArrayList<>(); |
||||||
|
for (int i = 0 ; i < workBook.getReportCount() ; i++){ |
||||||
|
Report report = workBook.getReport(i); |
||||||
|
ITContent content = new ITContent(); |
||||||
|
content.setSheetID(String.valueOf(i)); |
||||||
|
content.setSheetName(workBook.getReportName(i)); |
||||||
|
content.setTemplateName(jTemplate.getTemplateName()); |
||||||
|
content.addTRL(jTemplate.getTemplateName()); |
||||||
|
getCellInfoFromReport(report,result, content); |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 处理普通报表的sheet |
||||||
|
* @param report sheet |
||||||
|
* @param result 要操作的信息Array |
||||||
|
* @param content 存储查找替换相关信息的类 |
||||||
|
*/ |
||||||
|
private void getCellInfoFromReport(Report report, ArrayList<CellInfo> result,ITContent content){ |
||||||
|
|
||||||
|
if (report != null){ |
||||||
|
Iterator it = report.iteratorOfElementCase(); |
||||||
|
while (it.hasNext()){ |
||||||
|
ITContent newContent =content.copy(); |
||||||
|
ElementCase elementCase = (ElementCase) it.next(); |
||||||
|
getCellInfoFromElementCase(elementCase,result, newContent); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void getCellInfoFromElementCase(ElementCase elementCase, ArrayList<CellInfo> result,ITContent content){ |
||||||
|
Iterator cellIterator = elementCase.cellIterator(); |
||||||
|
while (cellIterator.hasNext()){ |
||||||
|
ITContent newContent = content.copy(); |
||||||
|
CellElement cell = (CellElement) cellIterator.next(); |
||||||
|
newContent.getContentObject().setCell(cell); |
||||||
|
newContent.setReplaceObject(cell); |
||||||
|
//单元格
|
||||||
|
newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Cell") +cell); |
||||||
|
newContent.setShowObject(cell); |
||||||
|
newContent.addTRL(newContent.getSheetID()); |
||||||
|
if (elementCase instanceof PolyECBlock){ |
||||||
|
newContent.setBlockName(((PolyECBlock)elementCase).getBlockName()); |
||||||
|
newContent.addTRL(((PolyECBlock)elementCase).getBlockName()); |
||||||
|
} |
||||||
|
newContent.addTRL(GeneralUtils.objectToString(cell)); |
||||||
|
CellInfo cellInfo = new CellInfo(newContent); |
||||||
|
if (cell.getValue() instanceof ChartCollection){ |
||||||
|
cellInfo.setChartExist(true); |
||||||
|
} |
||||||
|
result.add(cellInfo); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 对应的单元格信息列表是否有内容 |
||||||
|
* @return 判断的布尔值 |
||||||
|
*/ |
||||||
|
public boolean isCellInfosExist(){ |
||||||
|
return this.getCellInfos().size() > 0; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,316 @@ |
|||||||
|
package com.fr.design.actions.replace.action.content.component; |
||||||
|
|
||||||
|
import com.fr.design.actions.replace.action.content.widget.FrmWidgetType; |
||||||
|
import com.fr.design.actions.replace.action.content.widget.SearchFrmWidget; |
||||||
|
import com.fr.design.actions.replace.info.ComponentInfo; |
||||||
|
import com.fr.design.actions.replace.info.DealWithInfoValue; |
||||||
|
import com.fr.design.actions.replace.info.Info; |
||||||
|
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.form.ui.Widget; |
||||||
|
import com.fr.form.ui.container.WAbsoluteLayout; |
||||||
|
import com.fr.form.ui.container.WCardLayout; |
||||||
|
import com.fr.form.ui.container.WLayout; |
||||||
|
import com.fr.form.ui.container.WScaleLayout; |
||||||
|
import com.fr.form.ui.container.WTitleLayout; |
||||||
|
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; |
||||||
|
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||||
|
import com.fr.form.ui.container.cardlayout.WCardTitleLayout; |
||||||
|
import com.fr.form.ui.container.cardlayout.WTabFitLayout; |
||||||
|
import com.fr.form.ui.widget.CRBoundsWidget; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import javafx.util.Pair; |
||||||
|
import org.jetbrains.annotations.Nullable; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
|
||||||
|
/** |
||||||
|
* 决策报表组件类型 |
||||||
|
* @author Destiny.Lin |
||||||
|
* @version 11.0 |
||||||
|
* created by Destiny.Lin on 2022-09-08 |
||||||
|
*/ |
||||||
|
public enum ComponentType implements DealWithInfoValue{ |
||||||
|
|
||||||
|
/** |
||||||
|
* WCardMainBorderLayout属于Tab块组件中的最外层——默认命名方式为tablayout0的类型 |
||||||
|
* WCardMainBorderLayout里面放两个,一个WCardTitleLayout,一个WCardLayout |
||||||
|
* 处理该类型时需要先将该对象加入我们的组件列表中,再对其包含的内容进行递归处理 |
||||||
|
* TIP:该类型对其设置组件名时直接setWidgetName即可,设计器右侧上方和右侧下方面板中的组件名称会同步更改 |
||||||
|
*/ |
||||||
|
W_CARD_MAIN_BORDER_LAYOUT("WCardMainBorderLayout"){ |
||||||
|
@Override |
||||||
|
public void addComponent2Array(ArrayList<ComponentInfo> componentInfos, ITContent bodyContent, Widget widget) { |
||||||
|
super.addComponent2Array(componentInfos, bodyContent, widget); |
||||||
|
ITContent content = bodyContent.copy(); |
||||||
|
content.addOtherPos(widget.getWidgetName()); |
||||||
|
for (int i = 0 ; i < ((WCardMainBorderLayout)widget).getWidgetCount() ; i ++){ |
||||||
|
Widget cardLayoutWidget = ((WCardMainBorderLayout)widget).getWidget(i); |
||||||
|
if (cardLayoutWidget instanceof WCardTitleLayout){ |
||||||
|
for (int j = 0 ; j <((WCardTitleLayout) cardLayoutWidget).getWidgetCount() ; j++){ |
||||||
|
if (((WCardTitleLayout) cardLayoutWidget).getWidget(j) instanceof WCardTagLayout){ |
||||||
|
content.addOtherPos(((WCardTitleLayout) cardLayoutWidget).getWidget(j).getWidgetName()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
searchLayout4Component(componentInfos,content,((WCardMainBorderLayout)widget)); |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* WCardTitleLayout里面两个,一个CardAddButton——不必处理,一个WCardTagLayout——默认命名方式为tabpane0的类型 |
||||||
|
* 处理该类型时不用对该对象进行处理,直接对其包含的内容进行递归处理即可 |
||||||
|
*/ |
||||||
|
W_CARD_TITLE_LAYOUT("WCardTitleLayout"){ |
||||||
|
@Override |
||||||
|
public void addComponent2Array(ArrayList<ComponentInfo> componentInfos, ITContent bodyContent, Widget widget) { |
||||||
|
searchLayout4Component(componentInfos,bodyContent,(WCardTitleLayout) widget); |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* 对于WCardLayout 里面就是放的WTabFitLayout——tab00、tab10 |
||||||
|
* 处理该类型时不用对该对象进行处理,直接对其包含的内容进行递归处理即可 |
||||||
|
*/ |
||||||
|
W_CARD_LAYOUT("WCardLayout"){ |
||||||
|
@Override |
||||||
|
public void addComponent2Array(ArrayList<ComponentInfo> componentInfos, ITContent bodyContent, Widget widget) { |
||||||
|
searchLayout4Component(componentInfos,bodyContent,(WCardLayout) widget); |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* WCardTagLayout——默认命名方式为tabpane0的类型 |
||||||
|
* TIP:该类型对其设置组件名时直接setWidgetName即可,设计器右侧上方和右侧下方面板中的组件名称会同步更改 |
||||||
|
*/ |
||||||
|
W_CARD_TAG_LAYOUT("WCardTagLayout"){ |
||||||
|
@Override |
||||||
|
public void addComponent2Array(ArrayList<ComponentInfo> componentInfos, ITContent bodyContent, Widget widget) { |
||||||
|
super.addComponent2Array(componentInfos, bodyContent, widget); |
||||||
|
searchLayout4Component(componentInfos,bodyContent,(WCardTagLayout) widget); |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* WAbsoluteLayout属于绝对布局块 |
||||||
|
* 处理该类型时需要先将该对象加入我们的组件列表中,再对其包含的内容进行递归处理 |
||||||
|
* TIP:该类型对其设置组件名时直接setWidgetName即可,设计器右侧上方和右侧下方面板中的组件名称会同步更改 |
||||||
|
*/ |
||||||
|
W_ABSOLUTE_LAYOUT("WAbsoluteLayout"){ |
||||||
|
@Override |
||||||
|
public void addComponent2Array(ArrayList<ComponentInfo> componentInfos, ITContent bodyContent, Widget widget) { |
||||||
|
super.addComponent2Array(componentInfos, bodyContent, widget); |
||||||
|
serachCRBoundsWidget4Component(componentInfos,bodyContent,(WAbsoluteLayout) widget); |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* WTabFitLayout——里面放的是命名方式为tab00、tab10的tab块,在该块内部可以递归存放所有决策报表组件 |
||||||
|
* 处理该类型时需要先将该对象加入我们的组件列表中,再对其包含的内容进行递归处理 |
||||||
|
* TIP:该类型对其设置组件名时直接setWidgetName即可,设计器右侧上方和右侧下方面板中的组件名称会同步更改 |
||||||
|
*/ |
||||||
|
W_TAB_FIT_LAYOUT("WTabFitLayout"){ |
||||||
|
@Override |
||||||
|
public void addComponent2Array(ArrayList<ComponentInfo> componentInfos, ITContent bodyContent, Widget widget) { |
||||||
|
super.addComponent2Array(componentInfos, bodyContent, widget); |
||||||
|
serachCRBoundsWidget4Component(componentInfos,bodyContent,(WTabFitLayout) widget); |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* 自适应布局下报表块和图表的存储方式 |
||||||
|
* TIP:该类型对其设置组件名时需要对内外层进行setWidgetName,设计器右侧上方和右侧下方面板中的组件名称不会同步更改 |
||||||
|
*/ |
||||||
|
W_TITLE_LAYOUT("WTitleLayout"){ |
||||||
|
@Override |
||||||
|
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) { |
||||||
|
Object replaceObject = info.getContent().getReplaceObject(); |
||||||
|
if (replaceObject instanceof WTitleLayout){ |
||||||
|
WTitleLayout titleLayout = (WTitleLayout) replaceObject; |
||||||
|
info.updateOldStr(titleLayout.getWidgetName(),findStr); |
||||||
|
titleLayout.setWidgetName(ShowValueUtils.replaceAll(titleLayout.getWidgetName(),findStr,replaceStr)); |
||||||
|
CRBoundsWidget crBoundsWidget = ((CRBoundsWidget)titleLayout.getWidget(0)); |
||||||
|
crBoundsWidget.getWidget().setWidgetName(ShowValueUtils.replaceAll(crBoundsWidget.getWidget().getWidgetName(),findStr,replaceStr)); |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
/** |
||||||
|
* 自适应布局下:下拉框控件、下拉复选框控件、日期控件、数字控件、下拉树控件、密码控件都属于该类型 |
||||||
|
* TIP:该类型对其设置组件名时需要对内外层进行setWidgetName,设计器右侧上方和右侧下方面板中的组件名称不会同步更改 |
||||||
|
*/ |
||||||
|
W_SCALE_LAYOUT("WScaleLayout"){ |
||||||
|
@Override |
||||||
|
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) { |
||||||
|
Object replaceObject = info.getContent().getReplaceObject(); |
||||||
|
if (replaceObject instanceof WScaleLayout){ |
||||||
|
WScaleLayout scaleLayout = (WScaleLayout) replaceObject; |
||||||
|
info.updateOldStr(scaleLayout.getWidgetName(),findStr); |
||||||
|
scaleLayout.setWidgetName(ShowValueUtils.replaceAll(scaleLayout.getWidgetName(),findStr,replaceStr)); |
||||||
|
CRBoundsWidget crBoundsWidget = ((CRBoundsWidget)scaleLayout.getWidget(0)); |
||||||
|
crBoundsWidget.getWidget().setWidgetName(ShowValueUtils.replaceAll(crBoundsWidget.getWidget().getWidgetName(),findStr,replaceStr)); |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* 绝对布局:文本控件 |
||||||
|
*/ |
||||||
|
TEXT_EDITOR("TextEditor"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 自适应布局和绝对布局:标签控件 |
||||||
|
*/ |
||||||
|
LABEL("Label"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 自适应布局和绝对布局:按钮控件 |
||||||
|
*/ |
||||||
|
FREE_BUTTON("FreeButton"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 下绝对布局:拉框控件 |
||||||
|
*/ |
||||||
|
COMBO_BOX("ComboBox"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 绝对布局:下拉复选框控件 |
||||||
|
*/ |
||||||
|
COMBO_CHECK_BOX("ComboCheckBox"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 绝对布局:日期控件 |
||||||
|
*/ |
||||||
|
DATE_EDITOR("DateEditor"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 绝对布局:数字控件 |
||||||
|
*/ |
||||||
|
NUMBER_EDITOR("NumberEditor"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 绝对布局:下拉树控件 |
||||||
|
*/ |
||||||
|
TREE_COMBO_BOX_EDITOR("TreeComboBoxEditor"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 自适应布局和绝对布局:单选按钮组控件 |
||||||
|
*/ |
||||||
|
RADIO_GROUP("RadioGroup"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 自适应布局和绝对布局:复选按钮组控件 |
||||||
|
*/ |
||||||
|
CHECK_BOX_GROUP("CheckBoxGroup"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 自适应布局和绝对布局:查询按钮 |
||||||
|
*/ |
||||||
|
FORM_SUBMIT_BUTTON("FormSubmitButton"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 自适应布局和绝对布局:文本域控件 |
||||||
|
*/ |
||||||
|
TEXT_AREA("TextArea"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 绝对布局:密码控件 |
||||||
|
*/ |
||||||
|
PASS_WORD("Password"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 自适应布局和绝对布局:复选按钮控件 |
||||||
|
*/ |
||||||
|
CHECK_BOX("CheckBox"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 自适应布局和绝对布局:视图树 |
||||||
|
*/ |
||||||
|
TREE_EDITOR("TreeEditor"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 自适应布局和绝对布局:文件控件 |
||||||
|
*/ |
||||||
|
MULTI_FILE_EDITOR("MultiFileEditor"); |
||||||
|
|
||||||
|
|
||||||
|
String name; |
||||||
|
ComponentType(String name) { |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
public static ComponentType match(String name){ |
||||||
|
ComponentType[] values = ComponentType.values(); |
||||||
|
for (ComponentType value : values) { |
||||||
|
if(value.name.equals(name)){ |
||||||
|
return value; |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public void addComponent2Array(ArrayList<ComponentInfo> componentInfos, ITContent bodyContent, Widget widget) { |
||||||
|
componentInfos.add(new ComponentInfo(getComponentContent(bodyContent,widget))); |
||||||
|
} |
||||||
|
|
||||||
|
public ITContent getComponentContent(ITContent componentContent,Widget widget){ |
||||||
|
ITContent content = componentContent.copy(); |
||||||
|
content.setReplaceObject(widget); |
||||||
|
String widgetName = widget.getWidgetName(); |
||||||
|
if (!(widget instanceof WCardTagLayout)){ |
||||||
|
content.addOtherPos(widgetName); |
||||||
|
} |
||||||
|
content.setBlockName(widgetName); |
||||||
|
content.setShowObject(widgetName); |
||||||
|
content.addTRL(widgetName); |
||||||
|
return content; |
||||||
|
} |
||||||
|
|
||||||
|
public void searchLayout4Component(ArrayList<ComponentInfo> componentInfos, ITContent bodyContent, WLayout layout){ |
||||||
|
for (int i = 0 ; i < layout.getWidgetCount() ; i ++){ |
||||||
|
ComponentType componentType = ComponentType.match(layout.getWidget(i).getClass().getSimpleName()); |
||||||
|
if (componentType != null){ |
||||||
|
componentType.addComponent2Array(componentInfos, bodyContent, layout.getWidget(i)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void serachCRBoundsWidget4Component(ArrayList<ComponentInfo> componentInfos, ITContent bodyContent, WLayout layout){ |
||||||
|
for (int i = 0 ; i < layout.getWidgetCount() ; i ++){ |
||||||
|
//这边会套一层CRBoundsWidget
|
||||||
|
ComponentType componentType = ComponentType.match(((CRBoundsWidget)(layout.getWidget(i))).getWidget().getClass().getSimpleName()); |
||||||
|
if (componentType != null){ |
||||||
|
ITContent content = bodyContent.copy(); |
||||||
|
content.addOtherPos(layout.getWidgetName()); |
||||||
|
componentType.addComponent2Array(componentInfos, content, ((CRBoundsWidget)(layout.getWidget(i))).getWidget()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public HashMap<String, String> getValue(Object... o) { |
||||||
|
HashMap<String,String> hashMap = new HashMap<>(); |
||||||
|
if (o != null && o[0] instanceof Widget){ |
||||||
|
hashMap.put("content", ((Widget) o[0]).getWidgetName()); |
||||||
|
} |
||||||
|
return hashMap; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) { |
||||||
|
Object replaceObject = info.getContent().getReplaceObject(); |
||||||
|
if (replaceObject instanceof Widget){ |
||||||
|
Widget widget = ((Widget) replaceObject); |
||||||
|
info.updateOldStr(widget.getWidgetName(),findStr); |
||||||
|
widget.setWidgetName(widget.getWidgetName().replaceAll(findStr,replaceStr)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getInfoShowStr(Info info) { |
||||||
|
if (info instanceof ComponentInfo && info.getContent().getReplaceObject() instanceof Widget){ |
||||||
|
return ((Widget) info.getContent().getReplaceObject()).getWidgetName(); |
||||||
|
} |
||||||
|
return StringUtils.EMPTY; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,142 @@ |
|||||||
|
package com.fr.design.actions.replace.action.content.component; |
||||||
|
|
||||||
|
import com.fr.design.actions.replace.action.SearchAction; |
||||||
|
import com.fr.design.actions.replace.info.ComponentInfo; |
||||||
|
import com.fr.design.actions.replace.info.base.ITContent; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.form.main.Form; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.container.WAbsoluteLayout; |
||||||
|
import com.fr.form.ui.container.WCardLayout; |
||||||
|
import com.fr.form.ui.container.WLayout; |
||||||
|
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; |
||||||
|
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||||
|
import com.fr.form.ui.container.cardlayout.WCardTitleLayout; |
||||||
|
import com.fr.form.ui.container.cardlayout.WTabFitLayout; |
||||||
|
import com.fr.form.ui.widget.CRBoundsWidget; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.teamdev.jxbrowser.deps.org.checkerframework.checker.units.qual.C; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取决策报表组件 |
||||||
|
* TIPS:组件只在决策报表中,只用考虑决策报表Form,分为para和body两部分来处理 |
||||||
|
* |
||||||
|
* @author Destiny.Lin |
||||||
|
* @version 11.0 |
||||||
|
* created by Destiny.Lin on 2022-08-29 |
||||||
|
*/ |
||||||
|
public class SearchComponentAction implements SearchAction { |
||||||
|
|
||||||
|
private ArrayList<ComponentInfo> componentInfos; |
||||||
|
|
||||||
|
|
||||||
|
public ArrayList<ComponentInfo> getComponentInfos() { |
||||||
|
return componentInfos; |
||||||
|
} |
||||||
|
|
||||||
|
public void setComponentInfos(ArrayList<ComponentInfo> componentInfos) { |
||||||
|
this.componentInfos = componentInfos; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 构造时会搜索组件,设置对应的组件列表信息 |
||||||
|
* @param jTemplate 要搜索的模板 |
||||||
|
*/ |
||||||
|
public SearchComponentAction(JTemplate jTemplate) { |
||||||
|
setComponentInfos(search4Infos(jTemplate)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 搜索决策报表参数面板以及body面板两个地方的组件 |
||||||
|
* @param jTemplate 要搜索的模板 |
||||||
|
* @return 组件信息Array |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public ArrayList<ComponentInfo> search4Infos(JTemplate jTemplate) { |
||||||
|
ArrayList<ComponentInfo> componentInfos = new ArrayList<>(); |
||||||
|
if (jTemplate.getTarget() instanceof Form) { |
||||||
|
Form form = (Form) jTemplate.getTarget(); |
||||||
|
ITContent content = new ITContent(); |
||||||
|
content.setTemplateName(jTemplate.getTemplateName()); |
||||||
|
content.addTRL(jTemplate.getTemplateName()); |
||||||
|
content.setFrmFlag(true); |
||||||
|
//参数面板
|
||||||
|
dealPara(componentInfos, content, form.getParaContainer()); |
||||||
|
//body面板
|
||||||
|
dealBody(componentInfos, content, form.getBody()); |
||||||
|
} |
||||||
|
return componentInfos; |
||||||
|
} |
||||||
|
|
||||||
|
private void dealBody(ArrayList<ComponentInfo> componentInfos, ITContent content, Widget body) { |
||||||
|
if (body instanceof WLayout) { |
||||||
|
ITContent bodyContent = content.copy(); |
||||||
|
bodyContent.addOtherPos(body.getWidgetName()); |
||||||
|
//单独处理一下body组件
|
||||||
|
dealBodyContainer(componentInfos, bodyContent, (WLayout) body); |
||||||
|
//处理body的子组件
|
||||||
|
searchBodyComponent(componentInfos, bodyContent, body); |
||||||
|
//searchBodyComponent();
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void searchBodyComponent(ArrayList<ComponentInfo> componentInfos, ITContent bodyContent, Widget body) { |
||||||
|
for (int i = 0 ; i < ((WLayout) body).getWidgetCount(); i++){ |
||||||
|
//body下面的每个控件都会有一层BoundsWidget,为了兼容用了CRBoundsWidget,boundsWidget.getWidget()里面才是真正我们需要的widget
|
||||||
|
CRBoundsWidget boundsWidget = (CRBoundsWidget) ((WLayout) body).getWidget(i); |
||||||
|
ComponentType componentType = ComponentType.match(boundsWidget.getWidget().getClass().getSimpleName()); |
||||||
|
if (componentType != null){ |
||||||
|
componentType.addComponent2Array(componentInfos,bodyContent,boundsWidget.getWidget()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void dealBodyContainer(ArrayList<ComponentInfo> componentInfos, ITContent bodyContent, WLayout body) { |
||||||
|
ITContent content = bodyContent.copy(); |
||||||
|
content.setReplaceObject(body); |
||||||
|
dealContent(content, body.getWidgetName()); |
||||||
|
//WParameterLayout
|
||||||
|
componentInfos.add(new ComponentInfo(content)); |
||||||
|
} |
||||||
|
|
||||||
|
private void dealPara(ArrayList<ComponentInfo> componentInfos, ITContent content, WLayout paraContainer) { |
||||||
|
if (paraContainer != null) { |
||||||
|
ITContent paraContent = content.copy(); |
||||||
|
paraContent.addOtherPos(paraContainer.getWidgetName()); |
||||||
|
//单独处理一下para组件
|
||||||
|
dealParaContainer(componentInfos, paraContent, paraContainer); |
||||||
|
//处理para的子组件
|
||||||
|
searchParaComponent(componentInfos, paraContent, paraContainer); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void searchParaComponent(ArrayList<ComponentInfo> componentInfos, ITContent paraContent, WLayout paraContainer) { |
||||||
|
for (int i = 0; i < paraContainer.getWidgetCount(); i++) { |
||||||
|
ITContent content = paraContent.copy(); |
||||||
|
String widgetName = ((CRBoundsWidget) (paraContainer.getWidget(i))).getWidget().getWidgetName(); |
||||||
|
content.addOtherPos(widgetName); |
||||||
|
content.setReplaceObject(((CRBoundsWidget) (paraContainer.getWidget(i))).getWidget()); |
||||||
|
dealContent(content, widgetName); |
||||||
|
componentInfos.add(new ComponentInfo(content)); |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//单独处理WParameterLayout组件
|
||||||
|
private void dealParaContainer(ArrayList<ComponentInfo> componentInfos, ITContent content, WLayout paraContainer) { |
||||||
|
ITContent paraContent = content.copy(); |
||||||
|
paraContent.setReplaceObject(paraContainer); |
||||||
|
dealContent(paraContent, paraContainer.getWidgetName()); |
||||||
|
//WParameterLayout
|
||||||
|
componentInfos.add(new ComponentInfo(paraContent)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void dealContent(ITContent content, String widgetName) { |
||||||
|
content.setBlockName(widgetName); |
||||||
|
content.setShowObject(widgetName); |
||||||
|
content.addTRL(widgetName); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,104 @@ |
|||||||
|
package com.fr.design.actions.replace.action.content.floatelement; |
||||||
|
|
||||||
|
import com.fr.chart.chartattr.ChartCollection; |
||||||
|
import com.fr.design.actions.replace.action.SearchAction; |
||||||
|
import com.fr.design.actions.replace.info.FloatInfo; |
||||||
|
import com.fr.design.actions.replace.info.base.ITContent; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.main.impl.WorkBook; |
||||||
|
import com.fr.report.cell.FloatElement; |
||||||
|
import com.fr.report.elementcase.ElementCase; |
||||||
|
import com.fr.report.poly.PolyECBlock; |
||||||
|
import com.fr.report.report.Report; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Iterator; |
||||||
|
|
||||||
|
/** |
||||||
|
* 查找悬浮元素的信息 |
||||||
|
* |
||||||
|
* 由于决策报表没有悬浮元素,因此不用考虑决策报表,只需要考虑普通报表即可 |
||||||
|
* |
||||||
|
* @author Destiny.Lin |
||||||
|
* @version 11.0 |
||||||
|
* created by Destiny.Lin on 2022-08-16 |
||||||
|
*/ |
||||||
|
public class SearchFloatAction implements SearchAction { |
||||||
|
private ArrayList<FloatInfo> floatInfos; |
||||||
|
|
||||||
|
/** |
||||||
|
* 构造时会搜索悬浮元素,设置对应的悬浮元素信息列表 |
||||||
|
* @param jTemplate 指定搜索的模板 |
||||||
|
*/ |
||||||
|
public SearchFloatAction(JTemplate jTemplate){ setFloatInfos(search4Infos(jTemplate));} |
||||||
|
|
||||||
|
/** |
||||||
|
* 查找悬浮元素信息,只需要考虑普通报表 |
||||||
|
* @param jTemplate 指定搜索模板 |
||||||
|
* @return 悬浮元素信息列表 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public ArrayList<FloatInfo> search4Infos(JTemplate jTemplate) { |
||||||
|
ArrayList<FloatInfo> result = new ArrayList<>(); |
||||||
|
if (jTemplate.getTarget() instanceof WorkBook){ |
||||||
|
WorkBook workBook = (WorkBook) jTemplate.getTarget(); |
||||||
|
for (int i = 0 ; i < workBook.getReportCount() ; i++){ |
||||||
|
Report report = workBook.getReport(i); |
||||||
|
ITContent content = new ITContent(); |
||||||
|
content.setTemplateName(jTemplate.getTemplateName()); |
||||||
|
content.setSheetID(String.valueOf(i)); |
||||||
|
content.setSheetName(workBook.getReportName(i)); |
||||||
|
content.addTRL(jTemplate.getTemplateName()); |
||||||
|
content.addTRL(String.valueOf(i)); |
||||||
|
getFloatInfoFromReport(report,result, content); |
||||||
|
} |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void getFloatInfoFromReport(Report report, ArrayList<FloatInfo> result, ITContent content) { |
||||||
|
|
||||||
|
if (report != null){ |
||||||
|
Iterator it = report.iteratorOfElementCase(); |
||||||
|
while (it.hasNext()){ |
||||||
|
ITContent newContent = content.copy(); |
||||||
|
ElementCase elementCase = (ElementCase) it.next(); |
||||||
|
getFloatInfoFromElementCase(elementCase,result, newContent); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void getFloatInfoFromElementCase(ElementCase elementCase, ArrayList<FloatInfo> result, ITContent content) { |
||||||
|
Iterator floatIterator = elementCase.floatIterator(); |
||||||
|
while (floatIterator.hasNext()){ |
||||||
|
ITContent newContent = content.copy(); |
||||||
|
FloatElement floatElement = (FloatElement) floatIterator.next(); |
||||||
|
newContent.getContentObject().setFloatElement(floatElement); |
||||||
|
newContent.setReplaceObject(floatElement); |
||||||
|
newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Float_Element")); |
||||||
|
if (elementCase instanceof PolyECBlock){ |
||||||
|
newContent.setBlockName(((PolyECBlock)elementCase).getBlockName()); |
||||||
|
newContent.addTRL(((PolyECBlock)elementCase).getBlockName()); |
||||||
|
} |
||||||
|
newContent.setShowObject(floatElement.getName()); |
||||||
|
newContent.addTRL(floatElement.getName()); |
||||||
|
FloatInfo floatInfo = new FloatInfo(newContent); |
||||||
|
if (floatElement.getValue() instanceof ChartCollection){ |
||||||
|
floatInfo.setChartExist(true); |
||||||
|
} |
||||||
|
result.add(floatInfo); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public ArrayList<FloatInfo> getFloatInfos() { |
||||||
|
return floatInfos; |
||||||
|
} |
||||||
|
|
||||||
|
public void setFloatInfos(ArrayList<FloatInfo> floatInfos) { |
||||||
|
this.floatInfos = floatInfos; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,107 @@ |
|||||||
|
package com.fr.design.actions.replace.action.content.sql; |
||||||
|
|
||||||
|
import com.fr.data.TableDataSource; |
||||||
|
import com.fr.data.impl.DBTableData; |
||||||
|
import com.fr.design.actions.replace.action.SearchAction; |
||||||
|
import com.fr.design.actions.replace.info.SQLInfo; |
||||||
|
|
||||||
|
import com.fr.design.actions.replace.info.base.ITContent; |
||||||
|
import com.fr.design.data.tabledata.wrapper.TableDataFactory; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.file.TableDataConfig; |
||||||
|
import com.fr.form.main.Form; |
||||||
|
import com.fr.main.impl.WorkBook; |
||||||
|
import com.fr.stable.AssistUtils; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Iterator; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Destiny.Lin |
||||||
|
* @version 11.0 |
||||||
|
* created by Destiny.Lin on 2022-08-16 |
||||||
|
*/ |
||||||
|
public class SearchSQLAction implements SearchAction { |
||||||
|
private ArrayList<SQLInfo> sqlInfos; |
||||||
|
|
||||||
|
public SearchSQLAction(JTemplate jTemplate) { |
||||||
|
setSqlInfos(search4Infos(jTemplate)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ArrayList<SQLInfo> search4Infos(JTemplate jTemplate) { |
||||||
|
ArrayList<SQLInfo> sqlInfos = new ArrayList<>(); |
||||||
|
ITContent content = new ITContent(); |
||||||
|
content.setTemplateName(jTemplate.getTemplateName()); |
||||||
|
addModelDataInfos2Array(jTemplate, content, sqlInfos); |
||||||
|
addServerDataInfos2Array(content, sqlInfos); |
||||||
|
return sqlInfos; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 服务器数据集 |
||||||
|
* @param content |
||||||
|
* @param sqlInfos |
||||||
|
*/ |
||||||
|
private void addServerDataInfos2Array(ITContent content, ArrayList<SQLInfo> sqlInfos) { |
||||||
|
TableDataConfig tableDataConfig = TableDataConfig.getInstance(); |
||||||
|
String[] nameArray = TableDataFactory.getSortOfChineseNameOfServerData(tableDataConfig); |
||||||
|
for (String dataName : nameArray) { |
||||||
|
if (tableDataConfig.getTableData(dataName) instanceof DBTableData) { |
||||||
|
ITContent newContent = content.copy(); |
||||||
|
newContent.addOtherPos( |
||||||
|
Toolkit.i18nText("Fine-Design_Basic_DS_Server_TableData"), |
||||||
|
dataName |
||||||
|
); |
||||||
|
newContent.setShowObject(Toolkit.i18nText("Fine-Design_Basic_DS_Server_TableData")); |
||||||
|
newContent.setReplaceObject(tableDataConfig.getTableData(dataName)); |
||||||
|
newContent.getContentObject().setDbTableData((DBTableData) tableDataConfig.getTableData(dataName)); |
||||||
|
sqlInfos.add(new SQLInfo(newContent)); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 模板数据集 |
||||||
|
* @param jTemplate |
||||||
|
* @param content |
||||||
|
* @param sqlInfos |
||||||
|
*/ |
||||||
|
private void addModelDataInfos2Array(JTemplate jTemplate, ITContent content, ArrayList<SQLInfo> sqlInfos) { |
||||||
|
if (jTemplate.getTarget() instanceof TableDataSource) { |
||||||
|
TableDataSource source = (TableDataSource) jTemplate.getTarget(); |
||||||
|
Iterator dataIterator = source.getTableDataNameIterator(); |
||||||
|
while (dataIterator.hasNext()) { |
||||||
|
String dataName = (String) dataIterator.next(); |
||||||
|
if (source.getTableData(dataName) instanceof DBTableData) { |
||||||
|
ITContent newContent = content.copy(); |
||||||
|
newContent.addOtherPos( |
||||||
|
Toolkit.i18nText("Fine-Design_Basic_DS_Report_TableData"), |
||||||
|
dataName |
||||||
|
); |
||||||
|
newContent.setShowObject(Toolkit.i18nText("Fine-Design_Basic_DS_Report_TableData")); |
||||||
|
newContent.setReplaceObject(source.getTableData(dataName)); |
||||||
|
newContent.getContentObject().setDbTableData(((DBTableData) source.getTableData(dataName))); |
||||||
|
sqlInfos.add(new SQLInfo(newContent)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public ArrayList<SQLInfo> getSqlInfos() { |
||||||
|
return sqlInfos; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSqlInfos(ArrayList<SQLInfo> sqlInfos) { |
||||||
|
this.sqlInfos = sqlInfos; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return AssistUtils.toString(this); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,186 @@ |
|||||||
|
package com.fr.design.actions.replace.action.content.widget; |
||||||
|
|
||||||
|
import com.fr.design.actions.replace.action.content.component.ComponentType; |
||||||
|
import com.fr.design.actions.replace.info.DealWithInfoValue; |
||||||
|
import com.fr.design.actions.replace.info.Info; |
||||||
|
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.form.ui.WaterMark; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.container.WScaleLayout; |
||||||
|
import com.fr.form.ui.widget.CRBoundsWidget; |
||||||
|
import javafx.util.Pair; |
||||||
|
import org.jetbrains.annotations.Nullable; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Destiny.Lin |
||||||
|
* @version 11.0 |
||||||
|
* created by Destiny.Lin on 2022-08-29 |
||||||
|
*/ |
||||||
|
public enum FrmWidgetType implements SearchFrmWidget, DealWithInfoValue { |
||||||
|
/** |
||||||
|
* 自适应布局 |
||||||
|
*/ |
||||||
|
W_SCALE_LAYOUT("WScaleLayout") { |
||||||
|
@Override |
||||||
|
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) { |
||||||
|
WScaleLayout widget = (WScaleLayout) info.getContent().getReplaceObject(); |
||||||
|
if (((WidgetInfo) info).isWaterMark()) { |
||||||
|
FrmWidgetType frmWidgetType = FrmWidgetType.match(((CRBoundsWidget) widget.getWidget(0)).getWidget().getClass().getSimpleName()); |
||||||
|
if (frmWidgetType != null) { |
||||||
|
frmWidgetType.setValue(info, findStr, replaceStr, operatorArray); |
||||||
|
} |
||||||
|
} else { |
||||||
|
ComponentType componentType = ComponentType.match(widget.getClass().getSimpleName()); |
||||||
|
if (componentType != null) { |
||||||
|
componentType.setValue(info, findStr, replaceStr, operatorArray); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* 文本控件 |
||||||
|
*/ |
||||||
|
TEXT_EDITOR("TextEditor"), |
||||||
|
/** |
||||||
|
* 标签控件 |
||||||
|
*/ |
||||||
|
LABEL("Label"), |
||||||
|
/** |
||||||
|
* 按钮控件 |
||||||
|
*/ |
||||||
|
FREE_BUTTON("FreeButton"), |
||||||
|
/** |
||||||
|
* 下拉框控件 |
||||||
|
*/ |
||||||
|
COMBO_BOX("ComboBox"), |
||||||
|
/** |
||||||
|
* 下拉复选框控件 |
||||||
|
*/ |
||||||
|
COMBO_CHECK_BOX("ComboCheckBox"), |
||||||
|
/** |
||||||
|
* 日期控件 |
||||||
|
*/ |
||||||
|
DATE_EDITOR("DateEditor"), |
||||||
|
/** |
||||||
|
* 数字控件 |
||||||
|
*/ |
||||||
|
NUMBER_EDITOR("NumberEditor"), |
||||||
|
/** |
||||||
|
* 下拉树控件 |
||||||
|
*/ |
||||||
|
TREE_COMBO_BOX_EDITOR("TreeComboBoxEditor"), |
||||||
|
/** |
||||||
|
* 单选按钮组控件 |
||||||
|
*/ |
||||||
|
RADIO_GROUP("RadioGroup"), |
||||||
|
/** |
||||||
|
* 复选按钮组控件 |
||||||
|
*/ |
||||||
|
CHECK_BOX_GROUP("CheckBoxGroup"), |
||||||
|
/** |
||||||
|
* 查询按钮 |
||||||
|
*/ |
||||||
|
FORM_SUBMIT_BUTTON("FormSubmitButton"), |
||||||
|
/** |
||||||
|
* 文本域控件 |
||||||
|
*/ |
||||||
|
TEXT_AREA("TextArea"), |
||||||
|
/** |
||||||
|
* 密码控件 |
||||||
|
*/ |
||||||
|
PASS_WORD("Password"), |
||||||
|
/** |
||||||
|
* 复选按钮控件 |
||||||
|
*/ |
||||||
|
CHECK_BOX("CheckBox"), |
||||||
|
/** |
||||||
|
* 视图树 |
||||||
|
*/ |
||||||
|
TREE_EDITOR("TreeEditor"), |
||||||
|
/** |
||||||
|
* 文件控件 |
||||||
|
*/ |
||||||
|
MULTI_FILE_EDITOR("MultiFileEditor"); |
||||||
|
|
||||||
|
|
||||||
|
String name; |
||||||
|
|
||||||
|
FrmWidgetType(String name) { |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 处理绝对布局或者已经是真正存储对象的控件 |
||||||
|
* |
||||||
|
* @param content |
||||||
|
* @param widget |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public ArrayList<WidgetInfo> dealAbsoluteWidget(ITContent content, Widget widget) { |
||||||
|
ArrayList<WidgetInfo> widgetInfos = new ArrayList<>(); |
||||||
|
ITContent newContent = content.copy(); |
||||||
|
widgetInfos.add(new WidgetInfo(newContent)); |
||||||
|
return widgetInfos; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 匹配 |
||||||
|
* |
||||||
|
* @param name |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Nullable |
||||||
|
public static FrmWidgetType match(String name) { |
||||||
|
FrmWidgetType[] values = FrmWidgetType.values(); |
||||||
|
for (FrmWidgetType value : values) { |
||||||
|
if (value.name.equals(name)) { |
||||||
|
return value; |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public HashMap<String, String> getValue(Object... o) { |
||||||
|
return new HashMap<>(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setValue(Info info, String findStr, String replaceStr, ArrayList<Pair<Integer, Integer>> operatorArray) { |
||||||
|
Widget widget = (Widget) info.getContent().getReplaceObject(); |
||||||
|
if (widget instanceof WScaleLayout) { |
||||||
|
widget = ((CRBoundsWidget) ((WScaleLayout) widget).getWidget(0)).getWidget(); |
||||||
|
} |
||||||
|
if (((WidgetInfo) info).isWaterMark()) { |
||||||
|
WaterMark waterMark = (WaterMark) widget; |
||||||
|
info.updateOldStr(waterMark.getWaterMark(), findStr); |
||||||
|
waterMark.setWaterMark(ShowValueUtils.replaceAll(waterMark.getWaterMark(), findStr, replaceStr)); |
||||||
|
} else { |
||||||
|
info.updateOldStr(widget.getWidgetName(), findStr); |
||||||
|
ComponentType componentType = ComponentType.match(widget.getClass().getSimpleName()); |
||||||
|
if (componentType != null) { |
||||||
|
componentType.setValue(info, findStr, replaceStr, operatorArray); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getInfoShowStr(Info info) { |
||||||
|
return info.getContent().getOldShowStr(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ArrayList<WidgetInfo> addFrmWidget2Array(ITContent content, Widget widget) { |
||||||
|
return dealAbsoluteWidget(content, widget); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,166 @@ |
|||||||
|
package com.fr.design.actions.replace.action.content.widget; |
||||||
|
|
||||||
|
import com.fr.base.parameter.ParameterUI; |
||||||
|
import com.fr.design.actions.replace.action.SearchAction; |
||||||
|
import com.fr.design.actions.replace.action.content.cell.SearchCellAction; |
||||||
|
import com.fr.design.actions.replace.action.content.component.SearchComponentAction; |
||||||
|
import com.fr.design.actions.replace.info.CellInfo; |
||||||
|
import com.fr.design.actions.replace.info.ComponentInfo; |
||||||
|
import com.fr.design.actions.replace.info.WidgetInfo; |
||||||
|
import com.fr.design.actions.replace.info.base.ITContent; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.form.main.Form; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.container.WLayout; |
||||||
|
import com.fr.form.ui.widget.CRBoundsWidget; |
||||||
|
import com.fr.main.impl.WorkBook; |
||||||
|
import com.fr.main.parameter.ReportParameterAttr; |
||||||
|
import com.fr.report.cell.TemplateCellElement; |
||||||
|
import com.fr.report.cell.cellattr.highlight.DefaultHighlight; |
||||||
|
import com.fr.report.cell.cellattr.highlight.HighlightAction; |
||||||
|
import com.fr.report.cell.cellattr.highlight.HighlightGroup; |
||||||
|
import com.fr.report.cell.cellattr.highlight.WidgetHighlightAction; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取控件 |
||||||
|
* 目前获取位置:单元格本身、单元格条件属性内超链控件、参数面板控件、决策报表的组件 |
||||||
|
* |
||||||
|
* @author Destiny.Lin |
||||||
|
* @version 11.0 |
||||||
|
* created by Destiny.Lin on 2022-08-16 |
||||||
|
*/ |
||||||
|
public class SearchWidgetAction implements SearchAction { |
||||||
|
ArrayList<WidgetInfo> widgetInfos; |
||||||
|
|
||||||
|
public SearchWidgetAction(JTemplate jTemplate) { |
||||||
|
setWidgetInfos(search4Infos(jTemplate)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ArrayList<WidgetInfo> search4Infos(JTemplate jTemplate) { |
||||||
|
ArrayList<WidgetInfo> widgetInfos = new ArrayList<>(); |
||||||
|
ITContent content = new ITContent(); |
||||||
|
content.setTemplateName(jTemplate.getTemplateName()); |
||||||
|
//这边拿SearchCellAction里的CellInfo来查找,由于在SearchCellAction里面已经考虑了决策报表和普通报表两种情况了,这边就不用再做区分
|
||||||
|
addCellWidget2Array(widgetInfos, jTemplate); |
||||||
|
content.addTRL(jTemplate.getTemplateName()); |
||||||
|
if (jTemplate.getTarget() instanceof WorkBook) { |
||||||
|
addWorkBookParaWidget2Array(content, widgetInfos, jTemplate); |
||||||
|
} else if (jTemplate.getTarget() instanceof Form) { |
||||||
|
addFrmWidget2Array(content, widgetInfos, jTemplate); |
||||||
|
} |
||||||
|
|
||||||
|
return widgetInfos; |
||||||
|
} |
||||||
|
|
||||||
|
private void addFrmWidget2Array(ITContent content, ArrayList<WidgetInfo> widgetInfos, JTemplate jTemplate) { |
||||||
|
SearchComponentAction searchComponentAction = new SearchComponentAction(jTemplate); |
||||||
|
for (ComponentInfo componentInfo : searchComponentAction.getComponentInfos()) { |
||||||
|
FrmWidgetType frmWidgetType = FrmWidgetType.match(componentInfo.getContent().getReplaceObject().getClass().getSimpleName()); |
||||||
|
if (frmWidgetType != null) { |
||||||
|
widgetInfos.addAll(frmWidgetType.addFrmWidget2Array(componentInfo.getContent(), (Widget) componentInfo.getContent().getReplaceObject())); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void addCellWidget2Array(ArrayList<WidgetInfo> widgetInfos, JTemplate jTemplate) { |
||||||
|
SearchCellAction searchCellAction = new SearchCellAction(jTemplate); |
||||||
|
if (searchCellAction.getCellInfos().size() > 0) { |
||||||
|
for (CellInfo cellInfo : searchCellAction.getCellInfos()) { |
||||||
|
//单元格本身的控件
|
||||||
|
addWidget2ArrayFromCell(widgetInfos, cellInfo); |
||||||
|
//单元格条件属性中超链内的控件
|
||||||
|
addWidget2ArrayFromCellHighlight(widgetInfos, cellInfo); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void addWidget2ArrayFromCellHighlight(ArrayList<WidgetInfo> widgetInfos, CellInfo cellInfo) { |
||||||
|
if (cellInfo.getContent().getReplaceObject() instanceof TemplateCellElement) { |
||||||
|
TemplateCellElement cell = (TemplateCellElement) cellInfo.getContent().getReplaceObject(); |
||||||
|
if (cell.getHighlightGroup() != null) { |
||||||
|
HighlightGroup highlightGroup = cell.getHighlightGroup(); |
||||||
|
dealWithHighlightGroup4Widget(highlightGroup, widgetInfos, cellInfo); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void dealWithHighlightGroup4Widget(HighlightGroup highlightGroup, ArrayList<WidgetInfo> widgetInfos, CellInfo cellInfo) { |
||||||
|
for (int i = 0; i < highlightGroup.size(); i++) { |
||||||
|
for (int j = 0; j < ((DefaultHighlight) highlightGroup.getHighlight(i)).actionCount(); j++) { |
||||||
|
HighlightAction highlightAction = ((DefaultHighlight) highlightGroup.getHighlight(i)).getHighlightAction(j); |
||||||
|
//处理HighlightAction
|
||||||
|
if (isHighlightWidgetExist(highlightAction)) { |
||||||
|
ITContent content = cellInfo.getContent().copy(); |
||||||
|
content.addOtherPos("条件属性-超链控件"); |
||||||
|
content.setReplaceObject(((WidgetHighlightAction) highlightAction).getWidget()); |
||||||
|
content.setShowObject(cellInfo.getContent().getReplaceObject()); |
||||||
|
widgetInfos.add(new WidgetInfo(content)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private boolean isHighlightWidgetExist(HighlightAction highlightAction) { |
||||||
|
return highlightAction instanceof WidgetHighlightAction && ((WidgetHighlightAction) highlightAction).getWidget() != null; |
||||||
|
} |
||||||
|
|
||||||
|
private void addWidget2ArrayFromCell(ArrayList<WidgetInfo> widgetInfos, CellInfo cellInfo) { |
||||||
|
if (cellInfo.getContent().getReplaceObject() instanceof TemplateCellElement |
||||||
|
&& ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getWidget() != null) { |
||||||
|
// 单元格内有控件
|
||||||
|
ITContent newContent = cellInfo.getContent().copy(); |
||||||
|
|
||||||
|
Widget widget = ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getWidget(); |
||||||
|
newContent.addOtherPos("控件"); |
||||||
|
if (!StringUtils.isEmpty(widget.getWidgetName())) { |
||||||
|
newContent.addOtherPos(widget.getWidgetName()); |
||||||
|
} |
||||||
|
newContent.getContentObject().setWidget(widget); |
||||||
|
newContent.setReplaceObject(widget); |
||||||
|
newContent.setShowObject(cellInfo.getContent().getReplaceObject()); |
||||||
|
widgetInfos.add(new WidgetInfo(newContent)); |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void addWorkBookParaWidget2Array(ITContent content, ArrayList<WidgetInfo> widgetInfos, JTemplate jTemplate) { |
||||||
|
WorkBook workBook = (WorkBook) jTemplate.getTarget(); |
||||||
|
ReportParameterAttr reportParameterAttr = workBook.getReportParameterAttr(); |
||||||
|
if (reportParameterAttr != null && reportParameterAttr.getParameterUI() != null) { |
||||||
|
ParameterUI parameterUI = reportParameterAttr.getParameterUI(); |
||||||
|
Widget[] widgets = parameterUI.getAllWidgets(); |
||||||
|
for (Widget widget : widgets) { |
||||||
|
ITContent newContent = content.copy(); |
||||||
|
newContent.addOtherPos("参数面板控件-" + widget.getWidgetName()); |
||||||
|
newContent.setReplaceObject(widget); |
||||||
|
newContent.getContentObject().setWidget(widget); |
||||||
|
newContent.setShowObject("参数面板控件"); |
||||||
|
widgetInfos.add(new WidgetInfo(newContent)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否为空 |
||||||
|
* @return 为空返回true |
||||||
|
*/ |
||||||
|
public boolean isWidgetInfosEmpty() { |
||||||
|
return widgetInfos.isEmpty(); |
||||||
|
} |
||||||
|
|
||||||
|
public ArrayList<WidgetInfo> getWidgetInfos() { |
||||||
|
return widgetInfos; |
||||||
|
} |
||||||
|
|
||||||
|
public void setWidgetInfos(ArrayList<WidgetInfo> widgetInfos) { |
||||||
|
this.widgetInfos = widgetInfos; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue