Browse Source

REPORT-75998 搜索公式——数据集、悬浮元素、模板全局属性

feature/x
Destiny.Lin 2 years ago
parent
commit
6dc4f3ba96
  1. 31
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/AbstractSearchDataFormulaAction.java
  2. 124
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/DataType.java
  3. 75
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/SearchDataFormulaAction.java
  4. 26
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/AbstractSearchFloatFormula.java
  5. 111
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/SearchFloatFormulaAction.java
  6. 27
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/AbstractSearchTemplateFormula.java
  7. 65
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java

31
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/AbstractSearchDataFormulaAction.java

@ -0,0 +1,31 @@
package com.fr.design.actions.replace.action.content.formula.data;
import com.fr.design.actions.replace.info.FormulaInfo;
import com.fr.design.actions.replace.info.Info;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.mainframe.JTemplate;
import java.util.ArrayList;
/**
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-08-26
*/
public abstract class AbstractSearchDataFormulaAction implements SearchDataFormula{
@Override
public void searchFormulaFromData(JTemplate jTemplate,ArrayList<FormulaInfo> fomulaInfos) {
}
@Override
public void searchFormula(ArrayList<FormulaInfo> formulaInfos, ITContent content) {
}
@Override
public ArrayList<? extends Info> search4Infos(JTemplate jTemplate) {
return null;
}
}

124
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/DataType.java

@ -0,0 +1,124 @@
package com.fr.design.actions.replace.action.content.formula.data;
import com.fr.base.Formula;
import com.fr.base.TableData;
import com.fr.data.impl.*;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.actions.replace.info.FormulaInfo;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.i18n.Toolkit;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import java.util.ArrayList;
/**
*
* 分别对不同类型的数据集进行获取公式处理
* 暂不支持ClassTableData(用户自定义数据集)FileTableData(用户自定义数据集),EmbeddedTableData(无公式)
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-08-26
*/
public enum DataType {
/**
* 数据库查询
*/
DB_TABLE_DATA("DBTableData"){
@Override
public void searchFormula(TableData tableData, ITContent content, ArrayList<FormulaInfo> fomulaInfos) {
if (((DBTableData)tableData).getParameters() != null){
for (ParameterProvider provider : ((DBTableData)tableData).getParameters()){
dealProvider(provider,content,fomulaInfos);
}
}
}
},
/**
* 存储过程
*/
STORE_PROCEDURE("StoreProcedure"){
@Override
public void searchFormula(TableData tableData, ITContent content, ArrayList<FormulaInfo> fomulaInfos) {
if (((StoreProcedure)tableData).getParameters() != null){
for (ParameterProvider provider : ((StoreProcedure)tableData).getParameters()){
dealProvider(provider,content,fomulaInfos);
}
}
}
},
/**
* 关联数据集
*/
CONDITION_TABLE_DATA("ConditionTableData"){
@Override
public void searchFormula(TableData tableData, ITContent content, ArrayList<FormulaInfo> fomulaInfos) {
if (((ConditionTableData)tableData).getDefineParameters() != null){
for (ParameterProvider provider : ((ConditionTableData)tableData).getDefineParameters()){
dealProvider(provider,content,fomulaInfos);
}
}
}
},
/**
* 树数据集
*/
RECURSION_TABLE_DATA("RecursionTableData"){
@Override
public void searchFormula(TableData tableData, ITContent content, ArrayList<FormulaInfo> fomulaInfos) {
if (((RecursionTableData)tableData).getParameters() != null){
for (ParameterProvider provider : ((RecursionTableData)tableData).getParameters()){
dealProvider(provider,content,fomulaInfos);
}
}
}
};
String name;
DataType(String name) {
this.name = name;
}
/**
* 处理参数
* @param provider
* @param content
* @param formulaInfos
*/
public void dealProvider(ParameterProvider provider, ITContent content, ArrayList<FormulaInfo> formulaInfos) {
if (provider .getValue()instanceof Formula && !StringUtils.isEmpty((((Formula) provider.getValue())).getContent() )){
ITContent newContent = content.copy();
newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Parameter"));
newContent.setReplaceObject(provider);
formulaInfos.add(new FormulaInfo(newContent));
}
}
/**
* 匹配
* @param name
* @return
*/
public static DataType match(String name){
DataType[] values = DataType.values();
for (DataType value : values) {
if(value.name.equals(name)){
return value;
}
}
return null;
}
/**
* 从数据集中获取公式
* @param tableData
* @param content
* @param fomulaInfos
*/
void searchFormula(TableData tableData, ITContent content , ArrayList<FormulaInfo> fomulaInfos){}
}

75
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/SearchDataFormulaAction.java

@ -0,0 +1,75 @@
package com.fr.design.actions.replace.action.content.formula.data;
import com.fr.data.TableDataSource;
import com.fr.data.impl.DBTableData;
import com.fr.design.actions.replace.info.FormulaInfo;
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.main.impl.WorkBook;
import java.util.ArrayList;
import java.util.Iterator;
/**
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-08-26
*/
public class SearchDataFormulaAction extends AbstractSearchDataFormulaAction{
public SearchDataFormulaAction(JTemplate jTemplate, ArrayList<FormulaInfo> fomulaInfos){
searchFormulaFromData(jTemplate,fomulaInfos);
}
@Override
public void searchFormulaFromData(JTemplate jTemplate, ArrayList<FormulaInfo> fomulaInfos) {
//模板数据集
dealTemplateData(jTemplate,fomulaInfos);
//服务器数据集
dealServerData(fomulaInfos);
}
private void dealServerData(ArrayList<FormulaInfo> fomulaInfos) {
TableDataConfig tableDataConfig = TableDataConfig.getInstance();
String[] nameArray = TableDataFactory.getSortOfChineseNameOfServerData(tableDataConfig);
for (String dataName : nameArray) {
ITContent content = new ITContent();
content.addOtherPos(
Toolkit.i18nText("Fine-Design_Basic_DS_Server_TableData"),
dataName
);
content.setShowObject(Toolkit.i18nText("Fine-Design_Basic_DS_Server_TableData"));
DataType dataType = DataType.match(tableDataConfig.getTableData(dataName).getClass().getSimpleName());
if (dataType != null){
dataType.searchFormula(tableDataConfig.getTableData(dataName),content,fomulaInfos);
}
}
}
private void dealTemplateData(JTemplate jTemplate, ArrayList<FormulaInfo> fomulaInfos) {
if (jTemplate.getTarget() instanceof TableDataSource){
TableDataSource source = (TableDataSource) jTemplate.getTarget();
Iterator dataIterator = source.getTableDataNameIterator();
while (dataIterator.hasNext()){
String dataName = (String) dataIterator.next();
ITContent content = new ITContent();
content.setTemplateName(jTemplate.getTemplateName());
content.addOtherPos(
Toolkit.i18nText("Fine-Design_Basic_DS_Report_TableData"),
dataName
);
content.setShowObject(Toolkit.i18nText("Fine-Design_Basic_DS_Report_TableData"));
DataType dataType = DataType.match(source.getTableData(dataName).getClass().getSimpleName());
if (dataType != null){
dataType.searchFormula(source.getTableData(dataName),content,fomulaInfos);
}
}
}
}
}

26
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/AbstractSearchFloatFormula.java

@ -0,0 +1,26 @@
package com.fr.design.actions.replace.action.content.formula.floatelement;
import com.fr.design.actions.replace.info.FormulaInfo;
import com.fr.design.actions.replace.info.Info;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.mainframe.JTemplate;
import java.util.ArrayList;
/**
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-09-12
*/
public abstract class AbstractSearchFloatFormula implements SearchFloatFormula{
@Override
public void searchFormula(ArrayList<FormulaInfo> formulaInfos, ITContent content) {
}
@Override
public ArrayList<? extends Info> search4Infos(JTemplate jTemplate) {
return new ArrayList<>();
}
}

111
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/SearchFloatFormulaAction.java

@ -0,0 +1,111 @@
package com.fr.design.actions.replace.action.content.formula.floatelement;
import com.fr.base.Formula;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.actions.replace.action.content.floatelement.SearchFloatAction;
import com.fr.design.actions.replace.action.content.formula.FormulaReplaceObject;
import com.fr.design.actions.replace.action.content.formula.chart.SearchChartCollectionFormulaAction;
import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction;
import com.fr.design.actions.replace.info.FloatInfo;
import com.fr.design.actions.replace.info.FormulaInfo;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
import com.fr.js.NameJavaScriptGroup;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.FloatElement;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
/**
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-09-12
*/
public class SearchFloatFormulaAction extends AbstractSearchFloatFormula {
public SearchFloatFormulaAction(JTemplate jTemplate, ArrayList<FormulaInfo> formulaInfos) {
SearchFloatAction searchFloatAction = new SearchFloatAction(jTemplate);
for (FloatInfo floatInfo : searchFloatAction.getFloatInfos()) {
searchFormulaFromFloat(formulaInfos, floatInfo);
searchFormulaFromFloatType(formulaInfos, floatInfo);
}
}
@Override
public void searchFormulaFromFloat(ArrayList<FormulaInfo> formulaInfos, FloatInfo floatInfo) {
NameJavaScriptGroup nameJavaScriptGroup = ((FloatElement) floatInfo.getContent().getReplaceObject()).getNameHyperlinkGroup();
if (nameJavaScriptGroup != null) {
for (int i = 0; i < nameJavaScriptGroup.size(); i++) {
SearchJSHighlightAction action = new SearchJSHighlightAction();
action.searchJSFormulaFromOther(formulaInfos, floatInfo.getContent(), nameJavaScriptGroup.getNameHyperlink(i).getJavaScript());
}
}
}
@Override
public void searchFormulaFromFloatType(ArrayList<FormulaInfo> formulaInfos, FloatInfo floatInfo) {
Object value = ((FloatElement) floatInfo.getContent().getReplaceObject()).getValue();
FloatFormulaType floatFormulaType = FloatFormulaType.match(value.getClass().getSimpleName());
if (floatFormulaType != null) {
floatFormulaType.searchFormulaFromFloatElementType(formulaInfos, floatInfo);
}
}
/**
* 悬浮元素的类型
*/
public enum FloatFormulaType {
/**
* 公式
*/
FORMULA("Formula") {
@Override
public void searchFormulaFromFloatElementType(ArrayList<FormulaInfo> formulaInfos, FloatInfo floatInfo) {
ITContent content = floatInfo.getContent().copy();
Formula value = (Formula) ((FloatElement) floatInfo.getContent().getReplaceObject()).getValue();
content.setReplaceObject(value);
formulaInfos.add(new FormulaInfo(content));
}
},
/**
* 图表
*/
CHART_COLLECTION("ChartCollection") {
@Override
public void searchFormulaFromFloatElementType(ArrayList<FormulaInfo> formulaInfos, FloatInfo floatInfo) {
ITContent content = floatInfo.getContent().copy();
ChartCollection chartCollection = (ChartCollection) ((FloatElement) floatInfo.getContent().getReplaceObject()).getValue();
content.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Chart"));
new SearchChartCollectionFormulaAction(formulaInfos, content, chartCollection);
}
};
String name;
FloatFormulaType(String name) {
this.name = name;
}
/**
* 匹配
*
* @param name
* @return
*/
@Nullable
public static FloatFormulaType match(String name) {
FloatFormulaType[] values = FloatFormulaType.values();
for (FloatFormulaType value : values) {
if (value.name.equals(name)) {
return value;
}
}
return null;
}
public void searchFormulaFromFloatElementType(ArrayList<FormulaInfo> formulaInfos, FloatInfo floatInfo) {
}
}
}

27
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/AbstractSearchTemplateFormula.java

@ -0,0 +1,27 @@
package com.fr.design.actions.replace.action.content.formula.template;
import com.fr.design.actions.replace.info.FormulaInfo;
import com.fr.design.actions.replace.info.Info;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.mainframe.JTemplate;
import java.util.ArrayList;
/**
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-09-12
*/
public abstract class AbstractSearchTemplateFormula implements SearchTemplateFormula{
@Override
public void searchFormula(ArrayList<FormulaInfo> formulaInfos, ITContent content) {
}
@Override
public ArrayList<? extends Info> search4Infos(JTemplate jTemplate) {
return null;
}
}

65
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java

@ -0,0 +1,65 @@
package com.fr.design.actions.replace.action.content.formula.template;
import com.fr.base.Formula;
import com.fr.base.Parameter;
import com.fr.base.ParameterConfig;
import com.fr.base.io.AttrMark;
import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.design.actions.replace.info.FormulaInfo;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
import com.fr.main.impl.WorkBook;
import com.fr.report.core.ReportUtils;
import com.fr.report.core.watermark.WaterMarkFactory;
import java.util.ArrayList;
/**
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-09-12
*/
public class SearchTemplateFormulaAction extends AbstractSearchTemplateFormula {
public SearchTemplateFormulaAction(JTemplate jTemplate, ArrayList<FormulaInfo> formulaInfos) {
ITContent content = new ITContent();
content.setTemplateName(jTemplate.getTemplateName());
searchTemplateParaFormula(jTemplate, formulaInfos, content);
searchTemplateWaterMarkFormula(jTemplate, formulaInfos, content);
}
@Override
public void searchTemplateWaterMarkFormula(JTemplate jTemplate, ArrayList<FormulaInfo> formulaInfos, ITContent content) {
WatermarkAttr watermarkAttr = ReportUtils.getWatermarkAttrFromTemplateAndGlobal((AttrMark) jTemplate.getTarget());
if (watermarkAttr != null) {
ITContent waterMarkContent = content.copy();
waterMarkContent.addOtherPos(Toolkit.i18nText("Fine-Design_Form_WaterMark"));
waterMarkContent.setReplaceObject(watermarkAttr);
formulaInfos.add(new FormulaInfo(waterMarkContent));
}
}
@Override
public void searchTemplateParaFormula(JTemplate jTemplate, ArrayList<FormulaInfo> formulaInfos, ITContent content) {
Parameter[] parameters = jTemplate.getJTemplateParameters();
for (Parameter parameter : parameters) {
if (parameter.getValue() instanceof Formula) {
ITContent paraContent = content.copy();
paraContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Template_Parameter"));
paraContent.setReplaceObject(parameter.getValue());
formulaInfos.add(new FormulaInfo(paraContent));
}
}
Parameter[] globalParameters = ParameterConfig.getInstance().getGlobalParameters();
for (Parameter parameter : globalParameters) {
if (parameter.getValue() instanceof Formula) {
ITContent paraContent = content.copy();
paraContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Parameter_Source_Type_Server"));
paraContent.setReplaceObject(parameter.getValue());
formulaInfos.add(new FormulaInfo(paraContent));
}
}
}
}
Loading…
Cancel
Save