Browse Source
Merge in DESIGN/design from ~DESTINY.LIN/design:feature/x to feature/x * commit 'b688e55822c67bd3e24b47e3016a80c7caecc80e': REPORT-80695 【模板全局级别查找替换二期】刪除多余常量 REPORT-80695 【模板全局级别查找替换二期】合法性校验 REPORT-80695 【模板全局级别查找替换二期】更改部分静态,删减多余代码 REPORT-80695 【模板全局级别查找替换二期】去除多余引入,增加接口注释 REPORT-80695 【模板全局级别查找替换二期】增加设置项的滚轮 REPORT-80695 【模板全局级别查找替换二期】补充注释 REPORT-80695 【模板全局级别查找替换二期】补充注释 REPORT-80695 【模板全局级别查找替换二期】补充注释 REPORT-80695 【模板全局级别查找替换二期】适配表格多出来的替换后内容这一列,以及部分校验内容 REPORT-80695 【模板全局级别查找替换二期】设置项主要逻辑 REPORT-80695 【模板全局级别查找替换二期】基础数据结构修改,适配多出来的替换后内容这一列 REPORT-80695 【模板全局级别查找替换二期】工具类 REPORT-80695 【模板全局级别查找替换二期】UI界面feature/x
Destiny.Lin-林锦龙
2 years ago
36 changed files with 2969 additions and 209 deletions
@ -0,0 +1,15 @@
|
||||
package com.fr.design.actions.replace.action.content.js; |
||||
|
||||
/** |
||||
* 检查JS的标签 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @version 11.0 |
||||
* created by Destiny.Lin on 2022-10-26 |
||||
*/ |
||||
public class JSCheckTag { |
||||
/** |
||||
* 单元格-超级链接 |
||||
*/ |
||||
public static final int CELL_HYPERLINK = 0; |
||||
} |
@ -0,0 +1,70 @@
|
||||
package com.fr.design.actions.replace.action.content.js; |
||||
|
||||
import com.fr.design.actions.replace.info.Info; |
||||
import com.fr.js.NameJavaScript; |
||||
import com.fr.js.NameJavaScriptGroup; |
||||
import com.fr.report.cell.Elem; |
||||
import org.jetbrains.annotations.Nullable; |
||||
|
||||
/** |
||||
* 检查JS是否修改过 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @version 11.0 |
||||
* created by Destiny.Lin on 2022-10-26 |
||||
*/ |
||||
public enum JSCheckType { |
||||
/** |
||||
* 单元格-超级链接 |
||||
*/ |
||||
CELL_HYPERLINK(JSCheckTag.CELL_HYPERLINK) { |
||||
@Override |
||||
public boolean check(Info info) { |
||||
Elem elem = (Elem) info.getContent().getHoldObject(); |
||||
NameJavaScriptGroup group = elem.getNameHyperlinkGroup(); |
||||
int len = group.size(); |
||||
if (len == 0) { |
||||
return false; |
||||
} |
||||
NameJavaScript javaScript = (NameJavaScript) info.getContent().getReplaceObject(); |
||||
for (int i = 0; i < len; i++) { |
||||
if (group.getNameHyperlink(i).equals(javaScript)) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
}; |
||||
|
||||
|
||||
int index; |
||||
|
||||
JSCheckType(int index) { |
||||
this.index = index; |
||||
} |
||||
|
||||
/** |
||||
* 匹配 |
||||
* |
||||
* @param index |
||||
* @return |
||||
*/ |
||||
@Nullable |
||||
public static JSCheckType match(int index) { |
||||
JSCheckType[] values = JSCheckType.values(); |
||||
for (JSCheckType value : values) { |
||||
if (value.index == index) { |
||||
return value; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 校验是否修改 |
||||
* @param info 存储信息的数据结构 |
||||
* @return |
||||
*/ |
||||
public abstract boolean check(Info info); |
||||
|
||||
} |
@ -0,0 +1,259 @@
|
||||
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(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,245 @@
|
||||
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(); |
||||
default: |
||||
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); |
||||
} |
||||
} |
@ -0,0 +1,74 @@
|
||||
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"; |
||||
|
||||
|
||||
} |
@ -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.DataSourceInfo; |
||||
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<DataSourceInfo> connectionInfos = new ArrayList<>(); |
||||
for (Info info : list) { |
||||
if (StringUtils.equals(info.getContent().getShowStr(), settingStr)) { |
||||
connectionInfos.add((DataSourceInfo) 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; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,98 @@
|
||||
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); |
||||
} |
||||
|
||||
/** |
||||
* 单元格的内容是否是在查找范围内 |
||||
* |
||||
* @param cellElement 单元格 |
||||
* @return 在查找范围内返回true |
||||
*/ |
||||
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; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,114 @@
|
||||
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.DataSourceInfo; |
||||
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<DataSourceInfo> connectionInfos = new ArrayList<>(); |
||||
|
||||
|
||||
private SearchConnectionAction() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void search4Infos(JTemplate jTemplate) { |
||||
List<DataSourceInfo> 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 DataSourceInfo(content)); |
||||
} |
||||
setConnectionInfos(connectionInfos); |
||||
} |
||||
|
||||
/** |
||||
* 数据连接是否可用 |
||||
* |
||||
* @param data 数据库 |
||||
* @return 可用返回true |
||||
*/ |
||||
public boolean isNameDataBaseConnectionValid(TableData data) { |
||||
return data instanceof TableDataConnection && ((TableDataConnection) data).getDatabase() instanceof NameDatabaseConnection; |
||||
} |
||||
|
||||
public List<DataSourceInfo> getConnectionInfos() { |
||||
return connectionInfos; |
||||
} |
||||
|
||||
public void setConnectionInfos(List<DataSourceInfo> 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; |
||||
} |
||||
} |
||||
} |
@ -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.DataSourceInfo; |
||||
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<DataSourceInfo> dsColumnInfos = new ArrayList<>(); |
||||
|
||||
|
||||
private SearchDSColumnAction() { |
||||
} |
||||
|
||||
@Override |
||||
public void search4Infos(JTemplate jTemplate) { |
||||
List<DataSourceInfo> 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 DataSourceInfo(content)); |
||||
setDsColumnInfos(dsColumnInfos); |
||||
} |
||||
} |
||||
|
||||
public List<DataSourceInfo> getDsColumnInfos() { |
||||
return dsColumnInfos; |
||||
} |
||||
|
||||
public void setDsColumnInfos(List<DataSourceInfo> 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; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.fr.design.actions.replace.info; |
||||
|
||||
import com.fr.design.actions.replace.info.base.ITContent; |
||||
|
||||
/** |
||||
* 存储数据源相关的信息,后续数据源部分如果有自己额外的信息把这个当成父类进行拓展即可 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @version 11.0 |
||||
* created by Destiny.Lin on 2022-10-28 |
||||
*/ |
||||
public class DataSourceInfo implements Info{ |
||||
private ITContent content; |
||||
|
||||
|
||||
public DataSourceInfo(ITContent content) { |
||||
this.content = content; |
||||
} |
||||
|
||||
@Override |
||||
public ITContent getContent() { |
||||
return content; |
||||
} |
||||
|
||||
public void setContent(ITContent content) { |
||||
this.content = content; |
||||
} |
||||
} |
@ -0,0 +1,96 @@
|
||||
package com.fr.design.actions.replace.ui; |
||||
|
||||
|
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
|
||||
import com.fr.design.gui.itableeditorpane.UITableEditorPane; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
import static com.fr.design.actions.replace.ui.ITTableEditorPane.getEditTable; |
||||
|
||||
/** |
||||
* 合法性校验的面板 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @version 11.0 |
||||
* created by Destiny.Lin on 2022-10-28 |
||||
*/ |
||||
public class ITCheckDialog extends UIDialog { |
||||
private UITableEditorPane editorPane; |
||||
private ITCheckEditor editor; |
||||
private static final int DIALOG_WIDTH = 660, DIALOG_HEIGHT = 400; |
||||
private static final int TABLE_WIDTH = 640, TABLE_HEIGHT = 320; |
||||
private static final int LABEL_HEIGHT = 20; |
||||
|
||||
public ITCheckDialog() { |
||||
super(ITReplaceMainDialog.getInstance()); |
||||
setTitle(Toolkit.i18nText("Fine-Design_Replace_Check_Title")); |
||||
JPanel centerPanel = new JPanel(); |
||||
JPanel southPanel = new JPanel(); |
||||
southPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
||||
|
||||
editor = new ITCheckEditor(); |
||||
editorPane = new UITableEditorPane(editor); |
||||
editor.add(ITReplaceMainDialog.getCheckValidList()); |
||||
|
||||
UILabel label = new UILabel("<html>" + Toolkit.i18nText("Fine-Design_Replace_Check") + "<font color = 'rgb(236,124,125)'>" + ITReplaceMainDialog.contentReplaceFailedCount + "</font>" + Toolkit.i18nText("Fine-Design_Replace_Check_Tip")); |
||||
JPanel center = new JPanel(new BorderLayout()); |
||||
UIButton location = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Location")); |
||||
UIButton cancel = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")); |
||||
|
||||
location.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
for (int i : ITReplaceMainDialog.getSerialNumber()) { |
||||
getEditTable().addRowSelectionInterval(i, i); |
||||
} |
||||
ITCheckDialog.this.dispose(); |
||||
} |
||||
}); |
||||
|
||||
cancel.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
ITCheckDialog.this.dispose(); |
||||
} |
||||
}); |
||||
|
||||
|
||||
editorPane.setPreferredSize(new Dimension(TABLE_WIDTH, TABLE_HEIGHT)); |
||||
label.setPreferredSize(new Dimension(TABLE_WIDTH, LABEL_HEIGHT)); |
||||
|
||||
centerPanel.add(editorPane); |
||||
southPanel.add(location); |
||||
southPanel.add(cancel); |
||||
center.add(southPanel, BorderLayout.SOUTH); |
||||
center.add(label, BorderLayout.NORTH); |
||||
center.add(centerPanel, BorderLayout.CENTER); |
||||
center.setVisible(true); |
||||
//主体部分
|
||||
add(center); |
||||
|
||||
|
||||
setSize(DIALOG_WIDTH, DIALOG_HEIGHT); |
||||
setMaximumSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); |
||||
setMinimumSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); |
||||
|
||||
setLocation(ITReplaceMainDialog.getInstance().getX() + ITReplaceMainDialog.getInstance().getWidth() / 2 - DIALOG_WIDTH / 2, ITReplaceMainDialog.getInstance().getY()); |
||||
setVisible(true); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void checkValid() throws Exception { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,64 @@
|
||||
package com.fr.design.actions.replace.ui; |
||||
|
||||
import com.fr.design.actions.replace.info.Info; |
||||
import com.fr.design.actions.replace.info.base.ITContent; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itableeditorpane.UITableEditAction; |
||||
import com.fr.design.gui.itableeditorpane.UITableModelAdapter; |
||||
import com.fr.design.i18n.Toolkit; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 合法性校验表格的Model |
||||
* |
||||
* @author Destiny.Lin |
||||
* @version 11.0 |
||||
* created by Destiny.Lin on 2022-10-28 |
||||
*/ |
||||
public class ITCheckEditor extends UITableModelAdapter { |
||||
|
||||
public ITCheckEditor() { |
||||
super(new String[]{ |
||||
Toolkit.i18nText("Fine-Design_Replace_Check_Content"), |
||||
Toolkit.i18nText("Fine-Design_Replace_Check_Reason") |
||||
}); |
||||
|
||||
this.setColumnClass(new Class[]{ |
||||
UILabel.class, |
||||
UILabel.class, |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public Object getValueAt(int rowIndex, int columnIndex) { |
||||
ITContent content = (ITContent) this.getList().get(rowIndex); |
||||
if (columnIndex == 0) { |
||||
return content.getShowStr(); |
||||
} else { |
||||
return content.getCheckStr(); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean isCellEditable(int row, int col) { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public UITableEditAction[] createAction() { |
||||
return new UITableEditAction[0]; |
||||
} |
||||
|
||||
/** |
||||
* 添加数据 |
||||
* |
||||
* @param list |
||||
*/ |
||||
public void add(List<? extends Info> list) { |
||||
for (Info info : list) { |
||||
addRow(info.getContent()); |
||||
} |
||||
fireTableDataChanged(); |
||||
} |
||||
} |
Loading…
Reference in new issue