Browse Source

REPORT-80695 【模板全局级别查找替换二期】设置项主要逻辑

feature/x
Destiny.Lin 2 years ago
parent
commit
bdb3e25ede
  1. 22
      designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java
  2. 257
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java
  3. 246
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java
  4. 72
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingContent.java
  5. 374
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java
  6. 82
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellDSColumnAction.java
  7. 92
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java
  8. 108
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java
  9. 87
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java

22
designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java

@ -3,6 +3,7 @@ package com.fr.design.actions.replace.action;
import com.fr.design.actions.replace.info.Info;
import com.fr.design.mainframe.JTemplate;
import java.util.ArrayList;
import java.util.List;
/**
@ -20,7 +21,9 @@ public interface ShowValue {
* @param jTemplate
* @return
*/
List<? extends Info> showSearchValue(JTemplate jTemplate);
default List<? extends Info> showSearchValue(JTemplate jTemplate) {
return new ArrayList<>();
}
/**
* 对搜索结果进行过滤
@ -29,6 +32,21 @@ public interface ShowValue {
* @param list
* @return
*/
List<? extends Info> addMatchResult(String str, List<? extends Info> list);
default List<? extends Info> addMatchResult(String str, List<? extends Info> list) {
return new ArrayList<>();
}
/**
* 对搜索结果进行过滤多个过滤条件主要针对设置项
*
* @param list
* @param settingStr
* @param extraStr
* @return
*/
default List<? extends Info> addMatchResult(List<? extends Info> list, String settingStr, String extraStr) {
return new ArrayList<>();
}
}

257
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java

@ -0,0 +1,257 @@
package com.fr.design.actions.replace.action.setting;
import com.fr.base.CoreDecimalFormat;
import com.fr.base.NameStyle;
import com.fr.base.TextFormat;
import com.fr.data.core.FormatField;
import com.fr.design.actions.replace.info.Info;
import com.fr.general.date.FineDateFormat;
import com.fr.report.cell.CellElement;
import com.fr.stable.StringUtils;
import org.jetbrains.annotations.Nullable;
import java.text.Format;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-25
*/
public enum CellFormatType {
/**
* 单元格-格式-数字
*/
CELL_FORMAT_NUMBER(SettingContent.FORMAT_NUMBER) {
@Override
public boolean hasExpand(String parentStr) {
return true;
}
@Override
public List<String> getItems() {
return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_NUMBER)));
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
Format format = cellElement.getStyle().getFormat();
return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr);
}
},
/**
* 单元格-格式-常规
*/
CELL_FORMAT_COMMON(SettingContent.FORMAT_COMMON) {
@Override
public List<String> getItems() {
return super.getItems();
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
return cellElement.getStyle().getFormat() == null;
}
},
/**
* 单元格-格式-货币
*/
CELL_FORMAT_MONEY(SettingContent.FORMAT_MONEY) {
@Override
public boolean hasExpand(String parentStr) {
return true;
}
@Override
public List<String> getItems() {
return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_MONEY)));
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
Format format = cellElement.getStyle().getFormat();
return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr);
}
},
/**
* 单元格-格式-日期
*/
CELL_FORMAT_DATE(SettingContent.FORMAT_DATE) {
@Override
public boolean hasExpand(String parentStr) {
return true;
}
@Override
public List<String> getItems() {
return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_DATE)));
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
Format format = cellElement.getStyle().getFormat();
return format instanceof FineDateFormat && StringUtils.equals(((FineDateFormat) format).toPattern(), secondStr);
}
},
/**
* 单元格-格式-时间
*/
CELL_FORMAT_TIME(SettingContent.FORMAT_TIME) {
@Override
public boolean hasExpand(String parentStr) {
return true;
}
@Override
public List<String> getItems() {
return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_TIME)));
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
Format format = cellElement.getStyle().getFormat();
return format instanceof FineDateFormat && StringUtils.equals(((FineDateFormat) format).toPattern(), secondStr);
}
},
/**
* 单元格-格式-科学计数
*/
CELL_FORMAT_SCIENCE(SettingContent.FORMAT_SCIENCE) {
@Override
public boolean hasExpand(String parentStr) {
return true;
}
@Override
public List<String> getItems() {
return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_SCIENCE)));
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
Format format = cellElement.getStyle().getFormat();
return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr);
}
},
/**
* 单元格-格式-百分比
*/
CELL_FORMAT_PERCENT(SettingContent.FORMAT_PERCENT) {
@Override
public boolean hasExpand(String parentStr) {
return true;
}
@Override
public List<String> getItems() {
return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_PERCENT)));
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
Format format = cellElement.getStyle().getFormat();
return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr);
}
},
/**
* 单元格-格式-千分比
*/
CELL_FORMAT_PERMILLAGE(SettingContent.FORMAT_PERMILLAGE) {
@Override
public boolean hasExpand(String parentStr) {
return true;
}
@Override
public List<String> getItems() {
return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_PERMILLAGE)));
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
Format format = cellElement.getStyle().getFormat();
return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr);
}
},
/**
* 单元格-格式-文本
*/
CELL_FORMAT_TEXT(SettingContent.FORMAT_TEXT) {
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
Format format = cellElement.getStyle().getFormat();
return format instanceof TextFormat;
}
};
private String name;
CellFormatType(String name) {
this.name = name;
}
/**
* 匹配
*
* @param name
* @return
*/
@Nullable
public static CellFormatType match(String name) {
CellFormatType[] values = CellFormatType.values();
for (CellFormatType value : values) {
if (StringUtils.equals(value.name, name)) {
return value;
}
}
return null;
}
/**
* 是否能扩展选项
*
* @return 能扩展则返回true
*/
public boolean hasExpand(String parentStr) {
return false;
}
/**
* 获取界面数据
*/
public List<String> getItems() {
return new ArrayList<>();
}
/**
* 是否是要查找的内容
*
* @param cellElement
* @param firstStr
* @param secondStr
* @return
*/
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
return false;
}
/**
* 替换
*
* @param info 存储信息的数据结构
* @param firstStr 用户输入的第一级下拉框内容
* @param secondStr 用户输入的第二级下拉框内容
*/
public void replace(Info info, String firstStr, String secondStr) {
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
cellElement.setStyle(cellElement.getStyle().deriveFormat(FormatField.getInstance().getFormat(FormatField.getInstance().getContents(firstStr), secondStr)));
if (cellElement.getStyle() instanceof NameStyle) {
((NameStyle) cellElement.getStyle()).refreshStyle();
}
}
}

246
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java

@ -0,0 +1,246 @@
package com.fr.design.actions.replace.action.setting;
import com.fr.data.util.function.AverageFunction;
import com.fr.data.util.function.CountFunction;
import com.fr.data.util.function.DataFunction;
import com.fr.data.util.function.MaxFunction;
import com.fr.data.util.function.MinFunction;
import com.fr.data.util.function.NoneFunction;
import com.fr.data.util.function.SumFunction;
import com.fr.design.actions.replace.info.Info;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.cell.cellattr.core.group.FunctionGrouper;
import com.fr.report.cell.cellattr.core.group.RecordGrouper;
import com.fr.report.cell.cellattr.core.group.SummaryGrouper;
import com.fr.stable.StringUtils;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 处理单元格的格式对于高级由于需要自定义不加入处理范围
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-26
*/
public enum CellGroupType {
/**
* 分组
*/
GROUP(SettingContent.DIGIT_SETTING_GROUP) {
@Override
public List<String> getItems() {
List<String> items = new ArrayList<String>() {
{
add(SettingContent.GROUP_COMMON);
add(SettingContent.GROUP_CONTINUUM);
}
};
return items;
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
DSColumn column = (DSColumn) cellElement.getValue();
RecordGrouper grouper = column.getGrouper();
return grouper instanceof FunctionGrouper && grouper.getDivideMode() == getGroupType(secondStr);
}
},
/**
* 列表
*/
LIST(SettingContent.DIGIT_SETTING_LIST) {
@Override
public boolean hasExpand(String parentStr) {
return false;
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
DSColumn column = (DSColumn) cellElement.getValue();
RecordGrouper grouper = column.getGrouper();
return grouper instanceof FunctionGrouper && grouper.getDivideMode() == getGroupType(firstStr);
}
},
/**
* 汇总
*/
SUM(SettingContent.DIGIT_SETTING_SUM) {
@Override
public List<String> getItems() {
List<String> items = new ArrayList<String>() {
{
add(SettingContent.SUMMARY_SUM);
add(SettingContent.SUMMARY_AVERAGE);
add(SettingContent.SUMMARY_MAX);
add(SettingContent.SUMMARY_MIN);
add(SettingContent.SUMMARY_COUNT);
add(SettingContent.SUMMARY_NONE);
}
};
return items;
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
DSColumn column = (DSColumn) cellElement.getValue();
RecordGrouper grouper = column.getGrouper();
return grouper instanceof SummaryGrouper && ((SummaryGrouper) grouper).getFunction() != null && StringUtils.equals(((SummaryGrouper) grouper).getFunction().getClass().getSimpleName(), getSummaryType(secondStr));
}
@Override
public void replace(Info info, String firstStr, String secondStr) {
SummaryGrouper grouper = new SummaryGrouper();
grouper.setFunction(createDataFunction(secondStr));
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
DSColumn column = (DSColumn) cellElement.getValue();
column.setGrouper(grouper);
}
};
private String name;
private Map<String, Integer> groupMap = new HashMap<String, Integer>() {
{
put(SettingContent.GROUP_COMMON, FunctionGrouper.GROUPING_MODE);
put(SettingContent.GROUP_CONTINUUM, FunctionGrouper.CONTINUUM_MODE);
put(SettingContent.DIGIT_LIST, FunctionGrouper.LIST_MODE);
}
};
private Map<String, String> summaryMap = new HashMap<String, String>() {
{
put(SettingContent.SUMMARY_SUM, SUM_FUNCTION);
put(SettingContent.SUMMARY_AVERAGE, AVERAGE_FUNCTION);
put(SettingContent.SUMMARY_MAX, MAX_FUNCTION);
put(SettingContent.SUMMARY_MIN, MIN_FUNCTION);
put(SettingContent.SUMMARY_COUNT, COUNT_FUNCTION);
put(SettingContent.SUMMARY_NONE, NONE_FUNCTION);
}
};
public static final String SUM_FUNCTION = "SumFunction";
public static final String AVERAGE_FUNCTION = "AverageFunction";
public static final String MAX_FUNCTION = "MaxFunction";
public static final String MIN_FUNCTION = "MinFunction";
public static final String COUNT_FUNCTION = "CountFunction";
public static final String NONE_FUNCTION = "NoneFunction";
CellGroupType(String name) {
this.name = name;
}
/**
* 匹配
*
* @param name
* @return
*/
@Nullable
public static CellGroupType match(String name) {
CellGroupType[] values = CellGroupType.values();
for (CellGroupType value : values) {
if (StringUtils.equals(value.name, name)) {
return value;
}
}
return null;
}
/**
* 是否是要查找的内容
*
* @param cellElement
* @param firstStr
* @param secondStr
* @return
*/
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
DSColumn column = (DSColumn) cellElement.getValue();
RecordGrouper recordGrouper = column.getGrouper();
return recordGrouper instanceof FunctionGrouper && recordGrouper.getDivideMode() == getGroupType(secondStr);
}
/**
* 匹配分组
*
* @param str
* @return
*/
public Integer getGroupType(String str) {
return groupMap.getOrDefault(str, -1);
}
/**
* 匹配汇总
*/
public String getSummaryType(String str) {
return summaryMap.getOrDefault(str, StringUtils.EMPTY);
}
/**
* 创建对应汇总的DataFunction
*
* @param str 汇总子级下拉框的内容
* @return 指定类型的DataFunction
*/
public DataFunction createDataFunction(String str) {
switch (getSummaryType(str)) {
case SUM_FUNCTION:
return new SumFunction();
case AVERAGE_FUNCTION:
return new AverageFunction();
case MAX_FUNCTION:
return new MaxFunction();
case MIN_FUNCTION:
return new MinFunction();
case COUNT_FUNCTION:
return new CountFunction();
case NONE_FUNCTION:
return new NoneFunction();
}
return new NoneFunction();
}
/**
* 是否能扩展选项
*
* @return 能扩展则返回true
*/
public boolean hasExpand(String parentStr) {
return true;
}
/**
* 获取界面数据
*/
public List<String> getItems() {
return new ArrayList<>();
}
/**
* 替换
*
* @param info 存储信息的数据结构
* @param firstStr 用户输入的第一级下拉框
* @param secondStr 用户输入的第二级下拉框
*/
public void replace(Info info, String firstStr, String secondStr) {
FunctionGrouper grouper = new FunctionGrouper();
grouper.setDivideMode(getGroupType(secondStr));
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
DSColumn column = (DSColumn) cellElement.getValue();
column.setGrouper(grouper);
}
}

72
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingContent.java

@ -0,0 +1,72 @@
package com.fr.design.actions.replace.action.setting;
import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.design.i18n.Toolkit;
/**
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-24
*/
public class SettingContent {
public static final String CELL_FORMAT_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Cell"), Toolkit.i18nText("Fine-Design_Report_Base_Format"));
public static final String CELL_DATA_SETTING_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Cell"), Toolkit.i18nText("Fine-Design_Chart_Data_Setting"));
public static final String CELL_DS_COLUMN_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Cell"), Toolkit.i18nText("Fine-Design_Basic_DS_Column"));
public static final String DATASOURCE_CONNECTION_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Replace_Data_Source"), Toolkit.i18nText("Fine-Design_Replace_Data_Connection"));
public static final String DATASOURCE_COLLECT_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Replace_Data_Source"), Toolkit.i18nText("Fine-Design_Replace_Data_Collect"));
/**
* 单元格-格式
*/
public static final String FORMAT_COMMON = Toolkit.i18nText("Fine-Design_Replace_Common");
public static final String FORMAT_NUMBER = Toolkit.i18nText("Fine-Design_Replace_Number");
public static final String FORMAT_MONEY = Toolkit.i18nText("Fine-Design_Replace_Money");
public static final String FORMAT_PERCENT = Toolkit.i18nText("Fine-Design_Replace_Percent");
public static final String FORMAT_PERMILLAGE = Toolkit.i18nText("Fine-Design_Replace_Permillage");
public static final String FORMAT_SCIENCE = Toolkit.i18nText("Fine-Design_Replace_Science");
public static final String FORMAT_DATE = Toolkit.i18nText("Fine-Design_Replace_Date");
public static final String FORMAT_TIME = Toolkit.i18nText("Fine-Design_Replace_Time");
public static final String FORMAT_TEXT = Toolkit.i18nText("Fine-Design_Replace_Text");
/**
* 单元格-数据设置
*/
public static final String DIGIT_SETTING_GROUP = Toolkit.i18nText("Fine-Design_Replace_Group");
public static final String DIGIT_SETTING_LIST = Toolkit.i18nText("Fine-Design_Replace_List");
public static final String DIGIT_SETTING_SUM = Toolkit.i18nText("Fine-Design_Replace_Sum");
/**
* 单元格-数据设置-分组
*/
public static final String GROUP_COMMON = Toolkit.i18nText("Fine-Design_Report_Common");
public static final String GROUP_CONTINUUM = Toolkit.i18nText("Fine-Design_Report_Continuum");
/**
* 单元格-数据设置-列表
*/
public static final String DIGIT_LIST = Toolkit.i18nText("Fine-Design_Report_Bind_Column_Select");
/**
* 单元格-数据设置-汇总
*/
public static final String SUMMARY_SUM = Toolkit.i18nText("Fine-Design_DataFunction_Sum");
public static final String SUMMARY_AVERAGE = Toolkit.i18nText("Fine-Design_DataFunction_Average");
public static final String SUMMARY_MAX = Toolkit.i18nText("Fine-Design_DataFunction_Max");
public static final String SUMMARY_MIN = Toolkit.i18nText("Fine-Design_DataFunction_Min");
public static final String SUMMARY_COUNT = Toolkit.i18nText("Fine-Design_DataFunction_Count");
public static final String SUMMARY_NONE = Toolkit.i18nText("Fine-Design_DataFunction_None");
/**
* 数据连接
*/
public static final String CONNECTION_TEMPLATE = Toolkit.i18nText("Fine-Design_Basic_DS_Report_TableData");
/**
* 扩展出来的可能的选项
*/
public static final String DS_COLUMN_EXPEND = "DS_COLUMN_EXPEND";
}

374
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java

@ -0,0 +1,374 @@
package com.fr.design.actions.replace.action.setting;
import com.fr.data.TableDataSource;
import com.fr.design.actions.replace.action.ShowValue;
import com.fr.design.actions.replace.action.setting.action.SearchCellDSColumnAction;
import com.fr.design.actions.replace.action.setting.action.SearchCellFormatAction;
import com.fr.design.actions.replace.action.setting.action.SearchConnectionAction;
import com.fr.design.actions.replace.action.setting.action.SearchDSColumnAction;
import com.fr.design.actions.replace.info.CellInfo;
import com.fr.design.actions.replace.info.ConnectionInfo;
import com.fr.design.actions.replace.info.Info;
import com.fr.design.actions.replace.ui.ITReplaceNorthPanel;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.ConnectionConfig;
import com.fr.general.data.TableDataColumn;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.stable.StringUtils;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/**
* 设置项的查找内容
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-24
*/
public enum SettingController implements ShowValue {
/**
* 单元格-格式
*/
CELL_FORMAT(SettingContent.CELL_FORMAT_NAME) {
@Override
public List<String> getItems() {
return ITReplaceNorthPanel.formatItems;
}
@Override
public List<? extends Info> showSearchValue(JTemplate jTemplate) {
SearchCellFormatAction.getInstance().search4Infos(jTemplate);
return SearchCellFormatAction.getInstance().getCellInfos();
}
@Override
public List<? extends Info> addMatchResult(List<? extends Info> list, String settingStr, String extraStr) {
List<CellInfo> cellInfos = new ArrayList<>();
for (Info info : list) {
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
CellFormatType type = CellFormatType.match(settingStr);
if (type != null && type.isNeed(cellElement, settingStr, extraStr)) {
cellInfos.add((CellInfo) info);
}
}
return cellInfos;
}
@Override
public boolean hasExpand(String str, String parentStr) {
CellFormatType type = CellFormatType.match(parentStr);
if (type != null) {
return type.hasExpand(parentStr);
}
return false;
}
@Override
public List<String> getExtraItems(String str) {
CellFormatType type = CellFormatType.match(str);
if (type != null) {
return type.getItems();
}
return new ArrayList<>();
}
@Override
public void replace(Info info, String firstStr, String secondStr) {
CellFormatType type = CellFormatType.match(firstStr);
if (type != null) {
type.replace(info, firstStr, secondStr);
}
}
},
/**
* 单元格-数据设置
*/
CELL_DATA_SETTING(SettingContent.CELL_DATA_SETTING_NAME) {
@Override
public List<String> getItems() {
return ITReplaceNorthPanel.digitItems;
}
@Override
public List<? extends Info> showSearchValue(JTemplate jTemplate) {
SearchCellDSColumnAction.getInstance().search4Infos(jTemplate);
return SearchCellDSColumnAction.getInstance().getCellInfos();
}
@Override
public List<? extends Info> addMatchResult(List<? extends Info> list, String settingStr, String extraStr) {
List<CellInfo> cellInfos = new ArrayList<>();
for (Info info : list) {
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
//能到这步说明单元格里是数据列
CellGroupType cellGroupType = CellGroupType.match(settingStr);
if (cellGroupType != null && cellGroupType.isNeed(cellElement, settingStr, extraStr)) {
cellInfos.add((CellInfo) info);
}
}
return cellInfos;
}
@Override
public List<String> getExtraItems(String str) {
CellGroupType type = CellGroupType.match(str);
if (type != null) {
return type.getItems();
}
return new ArrayList<>();
}
@Override
public boolean hasExpand(String str, String parentStr) {
CellGroupType type = CellGroupType.match(parentStr);
if (type != null) {
return type.hasExpand(parentStr);
}
return false;
}
@Override
public void replace(Info info, String firstStr, String secondStr) {
CellGroupType type = CellGroupType.match(firstStr);
if (type != null) {
type.replace(info, firstStr, secondStr);
}
}
},
/**
* 单元格-数据列
*/
CELL_DS_COLUMN(SettingContent.CELL_DS_COLUMN_NAME) {
@Override
public List<? extends Info> showSearchValue(JTemplate jTemplate) {
SearchCellDSColumnAction.getInstance().search4Infos(jTemplate);
return SearchCellDSColumnAction.getInstance().getCellInfos();
}
@Override
public List<? extends Info> addMatchResult(List<? extends Info> list, String settingStr, String extraStr) {
List<CellInfo> cellInfos = new ArrayList<>();
for (Info info : list) {
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
//能到这步说明单元格里是数据列
DSColumn dsColumn = (DSColumn) cellElement.getValue();
if (isNeed(dsColumn, settingStr, extraStr)) {
cellInfos.add((CellInfo) info);
}
}
return cellInfos;
}
public boolean isNeed(DSColumn dsColumn, String settingStr, String extraStr) {
return dsColumn != null && StringUtils.equals(settingStr, dsColumn.getDSName()) && dsColumn.getColumn() != null && StringUtils.equals(dsColumn.getColumnName(), extraStr);
}
@Override
public List<String> getItems() {
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
List<String> tableDataArray = new ArrayList<>();
if (jTemplate != null && jTemplate.getTarget() instanceof TableDataSource) {
TableDataSource source = (TableDataSource) jTemplate.getTarget();
Iterator dataIterator = source.getTableDataNameIterator();
while (dataIterator.hasNext()) {
String dataName = (String) dataIterator.next();
tableDataArray.add(dataName);
}
}
return tableDataArray;
}
@Override
public List<String> getExtraItems(String str) {
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
List<String> tableDataArray = new ArrayList<>();
if (jTemplate != null) {
TableDataSource source = jTemplate.getTarget();
tableDataArray = Arrays.asList(DesignTableDataManager.getSelectedColumnNames(source, str));
}
return tableDataArray;
}
@Override
public boolean hasExpand(String str, String parentStr) {
return true;
}
@Override
public void replace(Info info, String firstStr, String secondStr) {
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
DSColumn dsColumn = (DSColumn) cellElement.getValue();
dsColumn.setDSName(firstStr);
dsColumn.setColumn(TableDataColumn.createColumn(secondStr));
}
},
/**
* 数据源-数据连接
*/
DATASOURCE_CONNECTION(SettingContent.DATASOURCE_CONNECTION_NAME) {
@Override
public List<? extends Info> showSearchValue(JTemplate jTemplate) {
SearchConnectionAction.getInstance().search4Infos(jTemplate);
return SearchConnectionAction.getInstance().getConnectionInfos();
}
@Override
public List<? extends Info> addMatchResult(List<? extends Info> list, String settingStr, String extraStr) {
List<ConnectionInfo> connectionInfos = new ArrayList<>();
for (Info info : list) {
if (StringUtils.equals(info.getContent().getShowStr(), settingStr)) {
connectionInfos.add((ConnectionInfo) info);
}
}
return connectionInfos;
}
@Override
public List<String> getItems() {
List<String> nameList = new ArrayList<>();
for (String name : ConnectionConfig.getInstance().getConnections().keySet()) {
nameList.add(name);
}
return nameList;
}
},
/**
* 数据源-数据集
*/
DATASOURCE_COLLECT(SettingContent.DATASOURCE_COLLECT_NAME) {
@Override
public List<? extends Info> showSearchValue(JTemplate jTemplate) {
SearchDSColumnAction.getInstance().search4Infos(jTemplate);
return SearchDSColumnAction.getInstance().getDsColumnInfos();
}
@Override
public List<? extends Info> addMatchResult(List<? extends Info> list, String settingStr, String extraStr) {
return list;
}
@Override
public List<String> getItems() {
return ITReplaceNorthPanel.dsColumnItems;
}
};
private String name;
SettingController(String name) {
this.name = name;
}
/**
* 匹配
*
* @param name
* @return
*/
@Nullable
public static SettingController match(String name) {
SettingController[] values = SettingController.values();
for (SettingController value : values) {
if (StringUtils.equals(value.name, name)) {
return value;
}
}
return null;
}
/**
* 获取界面的数据使之与选项匹配
*
* @param name 选项
*/
public static List<String> getSettingRefreshItems(String name) {
SettingController[] values = SettingController.values();
for (SettingController value : values) {
if (StringUtils.equals(value.name, name)) {
return value.getItems();
}
}
return new ArrayList<>();
}
/**
* 获取界面的数据使之与选项匹配
*
* @param parentStr 选项
*/
public static List<String> getSettingExtraRefreshItems(String str, String parentStr) {
SettingController[] values = SettingController.values();
for (SettingController value : values) {
if (StringUtils.equals(value.name, str)) {
return value.getExtraItems(parentStr);
}
}
return new ArrayList<>();
}
/**
* 获取界面数据
*/
public List<String> getItems() {
return new ArrayList<>();
}
/**
* 获取扩展数据
*
* @param str 父类名称
* @return 扩展的数据列表
*/
public List<String> getExtraItems(String str) {
return new ArrayList<>();
}
/**
* 是否能扩展选项
*
* @return 能扩展则返回true
*/
public boolean hasExpand(String str, String parentStr) {
return false;
}
/**
* 替换
*
* @param info 存储信息的数据结构
* @param firstStr 用户设定的第一级下拉框的内容
* @param secondStr 用户设定的第二级下拉框的内容
*/
public void replace(Info info, String firstStr, String secondStr) {
}
/**
* 是否修改过
*
* @param info 存储信息的数据结构
* @param inputStr 用户搜索的一级下拉框内容
* @param extraStr 用户搜索的二级下拉框内容
* @return 没修改过则返回false
*/
public boolean isEverChanged(Info info, String inputStr, String extraStr) {
return false;
}
}

82
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellDSColumnAction.java

@ -0,0 +1,82 @@
package com.fr.design.actions.replace.action.setting.action;
import com.fr.design.actions.replace.action.SearchAction;
import com.fr.design.actions.replace.action.content.cell.SearchCellAction;
import com.fr.design.actions.replace.info.CellInfo;
import com.fr.design.mainframe.JTemplate;
import com.fr.general.GeneralUtils;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import java.util.ArrayList;
import java.util.List;
/**
* 存储单元格-数据列
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-26
*/
public class SearchCellDSColumnAction implements SearchAction {
private List<CellInfo> cellInfos = new ArrayList<>();
private SearchCellDSColumnAction() {
}
@Override
public void search4Infos(JTemplate jTemplate) {
List<CellInfo> cellInfos = new ArrayList<>();
SearchCellAction.getInstance().search4Infos(jTemplate);
for (CellInfo info : SearchCellAction.getInstance().getCellInfos()) {
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
if (cellElement.getValue() instanceof DSColumn) {
info.getContent().setShowStr(GeneralUtils.objectToString(cellElement.getValue()));
cellInfos.add(info);
}
}
setCellInfos(cellInfos);
}
public List<CellInfo> getCellInfos() {
return cellInfos;
}
public void setCellInfos(List<CellInfo> cellInfos) {
this.cellInfos = cellInfos;
}
/**
* 对外开放的获取对象的方法
*
* @return
*/
public static SearchCellDSColumnAction getInstance() {
return SearchCellDSColumnActionEnum.SINGLETON.getInstance();
}
/**
* 枚举实现单例
*/
private enum SearchCellDSColumnActionEnum {
/**
* 单例
*/
SINGLETON;
private SearchCellDSColumnAction instance;
SearchCellDSColumnActionEnum() {
instance = new SearchCellDSColumnAction();
}
/**
* 获取对象
*
* @return
*/
public SearchCellDSColumnAction getInstance() {
return instance;
}
}
}

92
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java

@ -0,0 +1,92 @@
package com.fr.design.actions.replace.action.setting.action;
import com.fr.base.Formula;
import com.fr.design.actions.replace.action.SearchAction;
import com.fr.design.actions.replace.action.content.cell.SearchCellAction;
import com.fr.design.actions.replace.info.CellInfo;
import com.fr.design.mainframe.JTemplate;
import com.fr.general.GeneralUtils;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import java.util.ArrayList;
import java.util.List;
/**
* 存储有格式的单元格
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-25
*/
public class SearchCellFormatAction implements SearchAction {
private List<CellInfo> cellInfos = new ArrayList<>();
private SearchCellFormatAction() {
}
@Override
public void search4Infos(JTemplate jTemplate) {
List<CellInfo> cellInfos = new ArrayList<>();
SearchCellAction.getInstance().search4Infos(jTemplate);
for (CellInfo info : SearchCellAction.getInstance().getCellInfos()) {
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
if (isFormatValid(cellElement)) {
info.getContent().setShowStr(GeneralUtils.objectToString(cellElement.getValue()));
cellInfos.add(info);
}
}
setCellInfos(cellInfos);
}
public boolean isFormatValid(CellElement cellElement) {
return cellElement.getStyle() != null
&& (cellElement.getValue() instanceof Formula
|| cellElement.getValue() instanceof DSColumn
|| cellElement.getValue() instanceof String
|| cellElement.getValue() instanceof Integer);
}
public List<CellInfo> getCellInfos() {
return cellInfos;
}
public void setCellInfos(List<CellInfo> cellInfos) {
this.cellInfos = cellInfos;
}
/**
* 对外开放的获取对象的方法
*
* @return
*/
public static SearchCellFormatAction getInstance() {
return SearchCellFormatActionEnum.SINGLETON.getInstance();
}
/**
* 枚举实现单例
*/
private enum SearchCellFormatActionEnum {
/**
* 单例
*/
SINGLETON;
private SearchCellFormatAction instance;
SearchCellFormatActionEnum() {
instance = new SearchCellFormatAction();
}
/**
* 获取对象
*
* @return
*/
public SearchCellFormatAction getInstance() {
return instance;
}
}
}

108
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java

@ -0,0 +1,108 @@
package com.fr.design.actions.replace.action.setting.action;
import com.fr.base.TableData;
import com.fr.base.TableDataConnection;
import com.fr.data.TableDataSource;
import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection;
import com.fr.design.actions.replace.action.SearchAction;
import com.fr.design.actions.replace.info.ConnectionInfo;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.ConnectionConfig;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* 存储数据连接信息
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-26
*/
public class SearchConnectionAction implements SearchAction {
private List<ConnectionInfo> connectionInfos = new ArrayList<>();
private SearchConnectionAction() {
}
@Override
public void search4Infos(JTemplate jTemplate) {
List<ConnectionInfo> connectionInfos = new ArrayList<>();
Map<String, Connection> map = ConnectionConfig.getInstance().getConnections();
Map<String, Connection> needMap = new HashMap<>();
TableDataSource source = (TableDataSource) jTemplate.getTarget();
Iterator dataIterator = source.getTableDataNameIterator();
while (dataIterator.hasNext()) {
String dataName = (String) dataIterator.next();
TableData data = source.getTableData(dataName);
if (isNameDataBaseConnectionValid(data)) {
NameDatabaseConnection connection = (NameDatabaseConnection) ((TableDataConnection) data).getDatabase();
if (map.containsKey(connection.getName())) {
needMap.put(connection.getName(), connection);
}
}
}
for (String name : needMap.keySet()) {
ITContent content = new ITContent();
content.setReplaceObject(needMap.get(name));
content.setTemplateName(jTemplate.getTemplateName());
content.setJumpAble(false);
content.setShowStr(name);
connectionInfos.add(new ConnectionInfo(content));
}
setConnectionInfos(connectionInfos);
}
public boolean isNameDataBaseConnectionValid(TableData data) {
return data instanceof TableDataConnection && ((TableDataConnection) data).getDatabase() instanceof NameDatabaseConnection;
}
public List<ConnectionInfo> getConnectionInfos() {
return connectionInfos;
}
public void setConnectionInfos(List<ConnectionInfo> connectionInfos) {
this.connectionInfos = connectionInfos;
}
/**
* 对外开放的获取对象的方法
*
* @return
*/
public static SearchConnectionAction getInstance() {
return SearchConnectionActionEnum.SINGLETON.getInstance();
}
/**
* 枚举实现单例
*/
private enum SearchConnectionActionEnum {
/**
* 单例
*/
SINGLETON;
private SearchConnectionAction instance;
SearchConnectionActionEnum() {
instance = new SearchConnectionAction();
}
/**
* 获取对象
*
* @return
*/
public SearchConnectionAction getInstance() {
return instance;
}
}
}

87
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java

@ -0,0 +1,87 @@
package com.fr.design.actions.replace.action.setting.action;
import com.fr.base.TableData;
import com.fr.data.TableDataSource;
import com.fr.design.actions.replace.action.SearchAction;
import com.fr.design.actions.replace.info.DSColumnInfo;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.mainframe.JTemplate;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* 搜索数据列
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-26
*/
public class SearchDSColumnAction implements SearchAction {
private List<DSColumnInfo> dsColumnInfos = new ArrayList<>();
private SearchDSColumnAction() {
}
@Override
public void search4Infos(JTemplate jTemplate) {
List<DSColumnInfo> dsColumnInfos = new ArrayList<>();
TableDataSource source = (TableDataSource) jTemplate.getTarget();
Iterator dataIterator = source.getTableDataNameIterator();
while (dataIterator.hasNext()) {
String dataName = (String) dataIterator.next();
TableData data = source.getTableData(dataName);
ITContent content = new ITContent();
content.setJumpAble(false);
content.setReplaceObject(data);
content.setShowStr(dataName);
content.setTemplateName(jTemplate.getTemplateName());
dsColumnInfos.add(new DSColumnInfo(content));
setDsColumnInfos(dsColumnInfos);
}
}
public List<DSColumnInfo> getDsColumnInfos() {
return dsColumnInfos;
}
public void setDsColumnInfos(List<DSColumnInfo> dsColumnInfos) {
this.dsColumnInfos = dsColumnInfos;
}
/**
* 对外开放的获取对象的方法
*
* @return
*/
public static SearchDSColumnAction getInstance() {
return SearchDSColumnActionEnum.SINGLETON.getInstance();
}
/**
* 枚举实现单例
*/
private enum SearchDSColumnActionEnum {
/**
* 单例
*/
SINGLETON;
private SearchDSColumnAction instance;
SearchDSColumnActionEnum() {
instance = new SearchDSColumnAction();
}
/**
* 获取对象
*
* @return
*/
public SearchDSColumnAction getInstance() {
return instance;
}
}
}
Loading…
Cancel
Save