diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerContext.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerContext.java index 49fffa6cef..4079ae7b22 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerContext.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerContext.java @@ -7,6 +7,7 @@ import com.fr.base.Style; import com.fr.design.base.clipboard.DesignerClipboard; import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.BasicDialog; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.log.FineLoggerFactory; import com.fr.stable.StableUtils; @@ -25,6 +26,8 @@ public class DesignerContext { private static Clipboard clipboard = null; //当前的剪贴板. private static int formatState = FORMAT_STATE_NULL; private static Style[][] referencedStyle = null; + private static String referencedStyleFromTemplatePath = null; + private static TargetComponent referencedElementCasePane; private static int referencedIndex = 0; private static ThreadLocal reportWriteThread = new ThreadLocal(); @@ -114,12 +117,19 @@ public class DesignerContext { public static void setReferencedStyle(Style[][] styles) { referencedStyle = styles; + + JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + referencedStyleFromTemplatePath = currentTemplate != null ? currentTemplate.getPath() : null; } public static Style[][] getReferencedStyle() { return referencedStyle; } + public static String getReferencedStyleFromTemplatePath() { + return referencedStyleFromTemplatePath; + } + public static void setReferencedElementCasePane(TargetComponent t) { referencedElementCasePane = t; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/utils/CellElementStylePaster.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/utils/CellElementStylePaster.java new file mode 100644 index 0000000000..983beda5e8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/utils/CellElementStylePaster.java @@ -0,0 +1,99 @@ +package com.fr.design.mainframe.theme.utils; + +import com.fr.base.CloneTransformer; +import com.fr.base.NameStyle; +import com.fr.base.Style; +import com.fr.base.theme.FineColorSynchronizer; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.ThemedCellStyle; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.JTemplate; +import com.fr.log.FineLoggerFactory; +import com.fr.report.cell.TemplateCellElement; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2022/9/21 + * + * 如果粘贴到的模板主题单元格样式与复制过来的主题单元格样式不同,那么需要转换复制过来的主题单元格样式为自定义样式,以保持被复制的样式。 + * 转换非主题单元格样式内的主题色,以及单元格内的其他主题色,为自定义色 + */ +public class CellElementStylePaster { + + /** + * 为没有实现FCloneable接口的类而抽象出的clone方法包装接口, + * 使用者需要实现此接口方法,调用真正的clone方法. + * @param + */ + private interface CloneExecutor { + T clone(T o) throws Exception; + } + private static boolean needConvertThemedStyleToCustomStyle(NameStyle nameStyle) { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentOpeningOrEditingTemplate(); + if (template != null) { + TemplateTheme theme = template.getTemplateTheme(); + if (theme != null) { + ThemedCellStyle themedCellStyle = theme.getCellStyleList().find(nameStyle.getName()); + return !nameStyle.getRealStyle().equals(themedCellStyle.getStyle()); + } + } + return false; + } + + + private static T convertThemedColorToCustomColor(T o, CloneExecutor executor) { + CloneTransformer.setTransformer(new FineColorSynchronizer.FineColorTransformer(fineColor -> { + fineColor.setHor(-1); + fineColor.setVer(-1); + })); + + Object cloned = null; + try { + cloned = executor.clone(o); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + + CloneTransformer.clearTransformer(); + return (T) cloned; + } + + /** + * + * @param cellElement 粘贴到的单元格 + * @return + * 如果粘贴到的模板主题单元格样式与复制过来的主题单元格样式不同,那么需要转换复制过来的主题单元格样式为自定义样式,以保持被复制的样式。 + * 转换非主题单元格样式内的主题色,以及单元格内的其他主题色,为自定义色 + */ + public static TemplateCellElement convertStyleAndColor(TemplateCellElement cellElement) { + Style backupStyle = cellElement.getStyle(); + cellElement = convertThemedColorToCustomColor(cellElement, o -> (TemplateCellElement) o.clone()); + + Style style = convertStyleAndColor(backupStyle); + cellElement.setStyle(style); + + return cellElement; + } + + /** + * + * @param style + * @return + * 如果粘贴到的模板主题单元格样式与复制过来的主题单元格样式不同,那么需要转换复制过来的主题单元格样式为自定义样式,以保持被复制的样式。 + * 转换非主题单元格样式内的主题色 + */ + public static Style convertStyleAndColor(Style style) { + if (style instanceof NameStyle) { + NameStyle nameStyle = (NameStyle) style; + if (needConvertThemedStyleToCustomStyle(nameStyle)) { + style = nameStyle.getRealStyle(); + } + } + if (!(style instanceof NameStyle)) { + style = convertThemedColorToCustomColor(style, o -> (Style) o.clone()); + } + + return style; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java index 2f44137c78..601b3d09e5 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java @@ -2,6 +2,7 @@ package com.fr.design.actions.replace.action; import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Title; import com.fr.design.actions.replace.action.content.cell.SearchCellAction; import com.fr.design.actions.replace.action.content.component.SearchComponentAction; import com.fr.design.actions.replace.action.content.floatelement.SearchFloatAction; @@ -58,8 +59,8 @@ public enum ShowSearchResultAction implements ShowValue { CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); ChartCollection chartCollection = (ChartCollection) cellElement.getValue(); for (int i = 0; i < chartCollection.getChartCount(); i++) { - String titleName = GeneralUtils.objectToString(chartCollection.getChart(i).getTitle().getTextObject()); - if (titleName.contains(str)) { + if (isTitleNameValid(chartCollection.getChart(i).getTitle(), str)) { + String titleName = GeneralUtils.objectToString(chartCollection.getChart(i).getTitle().getTextObject()); CellInfo cellInfo = ((CellInfo) info).copy(); cellInfo.setCellChartIndex(i); cellInfo.getContent().addOtherPos( @@ -92,6 +93,7 @@ public enum ShowSearchResultAction implements ShowValue { cellInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(titleName, str)); cellInfo.getContent().setSelected(true); } + }, /** * 搜索JS事件 @@ -229,8 +231,8 @@ public enum ShowSearchResultAction implements ShowValue { if (((FloatInfo) info).isChartExist()) { ChartCollection chartCollection = (ChartCollection) floatElement.getValue(); for (int i = 0; i < chartCollection.getChartCount(); i++) { - String titleName = GeneralUtils.objectToString(chartCollection.getChart(i).getTitle().getTextObject()); - if (titleName.contains(str)) { + if (isTitleNameValid(chartCollection.getChart(i).getTitle(),str)) { + String titleName = GeneralUtils.objectToString(chartCollection.getChart(i).getTitle().getTextObject()); FloatInfo floatInfo = ((FloatInfo) info).copy(); floatInfo.setFloatChartIndex(i); floatInfo.getContent().addOtherPos( @@ -406,4 +408,14 @@ public enum ShowSearchResultAction implements ShowValue { } return null; } + + /** + * 标题是否可用 + * @param title + * @param str + * @return + */ + public boolean isTitleNameValid(Title title, String str){ + return title != null && GeneralUtils.objectToString(title.getTextObject()).contains(str) && StringUtils.isNotEmpty(GeneralUtils.objectToString(title.getTextObject())); + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/SearchComponentAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/SearchComponentAction.java index 4326f62287..336aa93745 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/SearchComponentAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/SearchComponentAction.java @@ -52,6 +52,8 @@ public class SearchComponentAction implements SearchAction { content.setTemplateName(jTemplate.getTemplateName()); content.addTRL(jTemplate.getTemplateName()); content.setFrmFlag(true); + //处理最底层form组件 + dealForm(componentInfos, content, form.getContainer()); //参数面板 dealPara(componentInfos, content, form.getParaContainer()); //body面板 @@ -60,6 +62,15 @@ public class SearchComponentAction implements SearchAction { setComponentInfos(componentInfos); } + private void dealForm(List componentInfos, ITContent content, WLayout container) { + ITContent formContent = ITContent.copy(content); + formContent.setReplaceObject(container); + dealContent(formContent, container.getWidgetName()); + formContent.addOtherPos(container.getWidgetName()); + formContent.setJumpAble(false); + componentInfos.add(new ComponentInfo(formContent)); + } + private void dealBody(List componentInfos, ITContent content, Widget body) { if (body instanceof WLayout) { ITContent bodyContent = ITContent.copy(content); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java index 3aaea18b33..720dbab1e8 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java @@ -502,7 +502,35 @@ public enum FormulaReplaceObject implements DealWithInfoValue { } return false; } - }; + }, + /** + * 存储字符串类型需要特殊处理 + */ + STRING("String"){ + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(GeneralUtils.objectToString(o[0]))){ + map.put("content", GeneralUtils.objectToString(o[0])); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + FormulaTag formulaTag = FormulaTag.match(info.getContent().getTag()); + if (formulaTag != null){ + info.updateOldStr(GeneralUtils.objectToString(info.getContent().getReplaceObject()), findStr); + formulaTag.setValue(info, findStr, replaceStr, operatorArray); + } + } + + @Override + public boolean check(Info info) { + return true; + } + } + ; String name; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java new file mode 100644 index 0000000000..c5c12d3bfc --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java @@ -0,0 +1,128 @@ +package com.fr.design.actions.replace.action.content.formula; + +import com.fr.chart.chartdata.MeterReportDefinition; +import com.fr.design.actions.replace.info.DealWithInfoValue; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.base.SearchTag; +import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.general.GeneralUtils; +import com.fr.plugin.chart.map.data.VanMapReportDefinition; +import com.fr.stable.collections.combination.Pair; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + + +/** + * 针对特殊类型进行处理,负责公式校验(公式设置值时如果是new一个新的公式都要放进来这里根据持有对象来校验) + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public enum FormulaTag implements DealWithInfoValue { + /** + * 经度 + */ + CHART_DATA_LONGITUDE(SearchTag.CHART_DATA_LONGITUDE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); + definition.setLongitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getLongitude()), findStr, replaceStr)); + } + } + }, + /** + * 纬度 + */ + CHART_DATA_LATITUDE(SearchTag.CHART_DATA_LATITUDE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); + definition.setLatitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getLatitude()), findStr, replaceStr)); + } + } + }, + /** + * 区域名 + */ + CHART_AREA_NAME(SearchTag.CHART_AREA_NAME) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); + definition.setCategoryName(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getCategoryName()), findStr, replaceStr)); + } + } + }, + /** + * 终点经度 + */ + CHART_DATA_END_LONGITUDE(SearchTag.CHART_DATA_END_LONGITUDE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); + definition.setEndLongitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getEndLongitude()), findStr, replaceStr)); + } + } + }, + /** + * 终点纬度 + */ + CHART_DATA_END_LATITUDE(SearchTag.CHART_DATA_END_LATITUDE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); + definition.setEndLatitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getEndLatitude()), findStr, replaceStr)); + } + } + }, + /** + * 终点区域名 + */ + CHART_AREA_END_NAME(SearchTag.CHART_AREA_END_NAME) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); + definition.setEndAreaName(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getEndAreaName()), findStr, replaceStr)); + } + } + }; + + int index; + + FormulaTag(int index) { + this.index = index; + } + + /** + * 匹配 + * + * @param index + * @return + */ + @Nullable + public static FormulaTag match(int index) { + FormulaTag[] values = FormulaTag.values(); + for (FormulaTag value : values) { + if (value.index == index) { + return value; + } + } + return null; + } + + + @Override + abstract public void setValue(Info info, String findStr, String replaceStr, List> operatorArray); + + @Override + public String getInfoShowStr(Info info) { + return info.getContent().getOldShowStr(); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartBoxDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartBoxDataFormulaAction.java new file mode 100644 index 0000000000..b677d3e86f --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartBoxDataFormulaAction.java @@ -0,0 +1,95 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +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.plugin.chart.box.data.VanBoxReportDefinition; +import com.fr.plugin.chart.box.data.VanBoxReportDetailedDefinition; +import com.fr.plugin.chart.box.data.VanBoxReportResultDefinition; + +import java.util.List; + +/** + * 箱型图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartBoxDataFormulaAction implements SearchChartDataFormula { + + private SearchChartBoxDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof VanBoxReportDefinition) { + VanBoxReportDefinition definition = (VanBoxReportDefinition) provider; + //明细数据 + ITContent detailContent = ITContent.copy(content); + detailContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Detailed_Data")); + dealDetailDefinition(formulaInfos, detailContent, definition.getDetailedDefinition()); + //结果数据 + ITContent resultContent = ITContent.copy(content); + resultContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Result_Data")); + dealResultDefinition(formulaInfos, resultContent, definition.getResultDefinition()); + } + } + + private void dealResultDefinition(List formulaInfos, ITContent content, VanBoxReportResultDefinition resultDefinition) { + //分类 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Category"), resultDefinition.getCategoryName()); + //系列名 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Series_Name"), resultDefinition.getSeriesName()); + //最大值 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Data_Max"), resultDefinition.getMax()); + //上四分位数 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Data_Q3"), resultDefinition.getQ3()); + //中位数 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Data_Median"), resultDefinition.getMedian()); + //下四分位数 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Data_Q1"), resultDefinition.getQ1()); + //最小值 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Min_Value"), resultDefinition.getMin()); + + } + + private void dealDetailDefinition(List formulaInfos, ITContent content, VanBoxReportDetailedDefinition detailedDefinition) { + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Category_Name"), detailedDefinition.getCategoryName()); + SearchChartMapDataFormulaAction.dealSeriesDefinition(formulaInfos, content, detailedDefinition.getSeriesList()); + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartBoxDataFormulaAction getInstance() { + return SearchChartBoxDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartBoxDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartBoxDataFormulaAction instance; + + SearchChartBoxDataFormulaActionEnum() { + instance = new SearchChartBoxDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartBoxDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartBubbleDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartBubbleDataFormulaAction.java new file mode 100644 index 0000000000..d012ad58b3 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartBubbleDataFormulaAction.java @@ -0,0 +1,79 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartdata.BubbleReportDefinition; +import com.fr.chart.chartdata.BubbleSeriesValue; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; + +import java.util.List; + +/** + * 散点图、气泡图数据 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartBubbleDataFormulaAction implements SearchChartDataFormula { + + private SearchChartBubbleDataFormulaAction() { + } + + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof BubbleReportDefinition) { + BubbleReportDefinition reportDefinition = (BubbleReportDefinition) provider; + for (int i = 0; i < reportDefinition.size(); i++) { + if (reportDefinition.get(i) instanceof BubbleSeriesValue) { + BubbleSeriesValue seriesValue = (BubbleSeriesValue) reportDefinition.get(i); + dealBubbleSeriesValue(formulaInfos, content, seriesValue); + } + } + } + } + + private void dealBubbleSeriesValue(List formulaInfos, ITContent content, BubbleSeriesValue seriesValue) { + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Series_Name"), seriesValue.getBubbleSereisName()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Size"), seriesValue.getBubbleSeriesSize()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_X_Axis"), seriesValue.getBubbleSeriesX()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Y_Axis"), seriesValue.getBubbleSeriesY()); + } + + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartBubbleDataFormulaAction getInstance() { + return SearchChartBubbleDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartBubbleDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartBubbleDataFormulaAction instance; + + SearchChartBubbleDataFormulaActionEnum() { + instance = new SearchChartBubbleDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartBubbleDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java index 15da2cd842..9276302a90 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java @@ -1,19 +1,25 @@ package com.fr.design.actions.replace.action.content.formula.chart; import com.fr.base.Formula; +import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.chart.chartattr.Axis; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.Title; -import com.fr.chart.chartdata.NormalChartData; + +import com.fr.chart.chartdata.NormalReportDataDefinition; +import com.fr.chart.chartdata.SeriesDefinition; + 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.plugin.chart.attr.axis.VanChartAlertValue; import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartValueAxis; import java.util.List; +import java.util.Map; /** * 图表类型获取公式汇总 @@ -24,7 +30,6 @@ import java.util.List; */ public class SearchChartCollectionFormulaAction { - private SearchChartCollectionFormulaAction() { } @@ -39,17 +44,23 @@ public class SearchChartCollectionFormulaAction { for (int i = 0; i < chartCollection.getChartCount(); i++) { ITContent chartContent = ITContent.copy(content); searchChartPatternFormula(formulaInfos, chartContent, chartCollection.getChart(i)); + //数据-单元格数据-分类名&系列名&值 - searchChartDataFormula(formulaInfos, content, chartCollection.getChart(i)); + SearchChartDataFormulaManager searchChartDataFormulaManager = SearchChartDataFormulaManager.getInstance(); + Map type = searchChartDataFormulaManager.getChartDataType(); + if (isDefinitionValid(chartCollection.getChart(i).getFilterDefinition())) { + String name = chartCollection.getChart(i).getFilterDefinition().getClass().getSimpleName(); + SearchChartDataFormula searchChartDataFormula = type.get(name); + TopDefinitionProvider provider = chartCollection.getChart(i).getFilterDefinition(); + ITContent dataContent = ITContent.copy(content); + dataContent.addOtherPos(chartCollection.getChart(i).getChartName(), Toolkit.i18nText("Fine-Design_Basic_Data")); + searchChartDataFormula.searchChartDataFormula(formulaInfos, dataContent, provider); + } } } - - private void searchChartDataFormula(List formulaInfos, ITContent content, Chart chart) { - if (chart.defaultChartData() instanceof NormalChartData) { - NormalChartData chartData = (NormalChartData) chart.defaultChartData(); - //todo - } + private boolean isDefinitionValid(TopDefinitionProvider provider) { + return provider != null && SearchChartDataFormulaManager.getInstance().getChartDataType().containsKey(provider.getClass().getSimpleName()); } @@ -65,34 +76,37 @@ public class SearchChartCollectionFormulaAction { } private void searchChartPatternFormulaFromAlertLine(List formulaInfos, ITContent chartContent, Chart chart) { - Axis xAxis = chart.getPlot().getxAxis(); - Axis yAxis = chart.getPlot().getyAxis(); - ITContent content = ITContent.copy(chartContent); - content.addOtherPos( - Toolkit.i18nText("Fine-Design_Chart_Pattern"), - Toolkit.i18nText("Fine-Design_Chart_Background"), - Toolkit.i18nText("Fine-Design_Chart_Plot_Region"), - Toolkit.i18nText("Fine-Design_Chart_Alert_Line") - ); - if (xAxis instanceof VanChartAxis) { - List list = ((VanChartAxis) xAxis).getAlertValues(); - for (VanChartAlertValue alertValue : list) { - //警戒线设置 - dealAlertValue(formulaInfos, content, alertValue); - //提示文字 - dealAlertContent(formulaInfos, content, alertValue); + if (chart.getPlot() != null){ + Axis xAxis = chart.getPlot().getxAxis(); + Axis yAxis = chart.getPlot().getyAxis(); + ITContent content = ITContent.copy(chartContent); + content.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Pattern"), + Toolkit.i18nText("Fine-Design_Chart_Background"), + Toolkit.i18nText("Fine-Design_Chart_Plot_Region"), + Toolkit.i18nText("Fine-Design_Chart_Alert_Line") + ); + if (xAxis instanceof VanChartAxis) { + List list = ((VanChartAxis) xAxis).getAlertValues(); + for (VanChartAlertValue alertValue : list) { + //警戒线设置 + dealAlertValue(formulaInfos, content, alertValue); + //提示文字 + dealAlertContent(formulaInfos, content, alertValue); + } } - } - if (yAxis instanceof VanChartAxis) { - List list = ((VanChartAxis) yAxis).getAlertValues(); - for (VanChartAlertValue alertValue : list) { - //警戒线设置 - dealAlertValue(formulaInfos, content, alertValue); - //提示文字 - dealAlertContent(formulaInfos, content, alertValue); + if (yAxis instanceof VanChartAxis) { + List list = ((VanChartAxis) yAxis).getAlertValues(); + for (VanChartAlertValue alertValue : list) { + //警戒线设置 + dealAlertValue(formulaInfos, content, alertValue); + //提示文字 + dealAlertContent(formulaInfos, content, alertValue); + } } } + } private void dealAlertContent(List formulaInfos, ITContent content, VanChartAlertValue alertValue) { @@ -114,39 +128,40 @@ public class SearchChartCollectionFormulaAction { } private void searchChartPatternFormulaFromAxisValue(List formulaInfos, ITContent chartContent, Chart chart) { - Axis xAxis = chart.getPlot().getxAxis(); - Axis yAxis = chart.getPlot().getyAxis(); - //样式-坐标轴-x轴 - if (xAxis != null) { - //轴标题 - ITContent xAxisContent = ITContent.copy(chartContent); - if (!chartContent.isFrm()){ - xAxisContent.addOtherPos(chart.getChartName()); + if (chart.getPlot() != null){ + Axis xAxis = chart.getPlot().getxAxis(); + Axis yAxis = chart.getPlot().getyAxis(); + //样式-坐标轴-x轴 + if (xAxis != null) { + //轴标题 + ITContent xAxisContent = ITContent.copy(chartContent); + if (!chartContent.isFrm()) { + xAxisContent.addOtherPos(chart.getChartName()); + } + xAxisContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Pattern"), + Toolkit.i18nText("Fine-Design_Chart_Axis"), + Toolkit.i18nText("Fine-Design_Chart_X_Axis") + ); + dealTitle(formulaInfos, xAxisContent, xAxis.getTitle()); + dealChartValueDefine(formulaInfos, xAxisContent, xAxis); } - xAxisContent.addOtherPos( - Toolkit.i18nText("Fine-Design_Chart_Pattern"), - Toolkit.i18nText("Fine-Design_Chart_Axis"), - Toolkit.i18nText("Fine-Design_Chart_X_Axis") - ); - dealTitle(formulaInfos, xAxisContent, xAxis.getTitle()); - dealChartValueDefine(formulaInfos, xAxisContent, xAxis); - } - //样式-坐标轴-y轴-轴标题 - if (yAxis != null) { - ITContent yAxisContent = ITContent.copy(chartContent); - yAxisContent.addOtherPos( - chart.getChartName(), - Toolkit.i18nText("Fine-Design_Chart_Pattern"), - Toolkit.i18nText("Fine-Design_Chart_Axis"), - Toolkit.i18nText("Fine-Design_Chart_Y_Axis") - - ); - dealTitle(formulaInfos, yAxisContent, yAxis.getTitle()); - dealChartValueDefine(formulaInfos, yAxisContent, yAxis); + //样式-坐标轴-y轴-轴标题 + if (yAxis != null) { + ITContent yAxisContent = ITContent.copy(chartContent); + yAxisContent.addOtherPos( + chart.getChartName(), + Toolkit.i18nText("Fine-Design_Chart_Pattern"), + Toolkit.i18nText("Fine-Design_Chart_Axis"), + Toolkit.i18nText("Fine-Design_Chart_Y_Axis") + + ); + dealTitle(formulaInfos, yAxisContent, yAxis.getTitle()); + dealChartValueDefine(formulaInfos, yAxisContent, yAxis); + } } - } private void dealChartValueDefine(List formulaInfos, ITContent axisContent, Axis axis) { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCustomDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCustomDataFormulaAction.java new file mode 100644 index 0000000000..5c63ac52e0 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCustomDataFormulaAction.java @@ -0,0 +1,79 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.plugin.chart.custom.CustomDefinition; +import com.fr.plugin.chart.custom.CustomPlotFactory; +import com.fr.plugin.chart.custom.type.CustomPlotType; + + +import java.util.List; +import java.util.Map; + +/** + * 组合图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartCustomDataFormulaAction implements SearchChartDataFormula { + + private SearchChartCustomDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof CustomDefinition) { + CustomDefinition definition = (CustomDefinition) provider; + Map map = SearchChartDataFormulaManager.getInstance().getChartDataType(); + for (CustomPlotType customPlotType : definition.getDefinitionProviderMap().keySet()) { + TopDefinitionProvider definitionProvider = definition.getDefinitionProviderMap().get(customPlotType); + if (map.containsKey(definitionProvider.getClass().getSimpleName())) { + ITContent customContent = ITContent.copy(content); + customContent.addOtherPos(CustomPlotFactory.getTitle(customPlotType)); + map.get(definitionProvider.getClass().getSimpleName()).searchChartDataFormula(formulaInfos, customContent, definitionProvider); + } + } + + + } + } + + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartCustomDataFormulaAction getInstance() { + return SearchChartCustomDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartCustomDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartCustomDataFormulaAction instance; + + SearchChartCustomDataFormulaActionEnum() { + instance = new SearchChartCustomDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartCustomDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDataFormula.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDataFormula.java new file mode 100644 index 0000000000..6378d9dfb1 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDataFormula.java @@ -0,0 +1,46 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.Formula; +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.design.actions.replace.action.content.formula.SearchFormula; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; + +import java.util.List; + +/** + * 搜索图表-数据中的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public interface SearchChartDataFormula extends SearchFormula { + + + /** + * 搜索图表-数据中的公式 + * + * @param formulaInfos + * @param content + * @param provider + */ + void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider); + + /** + * 快速处理Formula + * + * @param formulaInfos + * @param reportContent + * @param otherPos + * @param o + */ + default void dealFormulaObject(List formulaInfos, ITContent reportContent, String otherPos, Object o) { + if (o instanceof Formula) { + ITContent content = ITContent.copy(reportContent); + content.addOtherPos(otherPos); + content.setReplaceObject(o); + formulaInfos.add(new FormulaInfo(content)); + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDataFormulaManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDataFormulaManager.java new file mode 100644 index 0000000000..f8916a757f --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDataFormulaManager.java @@ -0,0 +1,160 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.action.SearchManager; + +import java.util.HashMap; +import java.util.Map; + +/** + * 管理图表-数据中的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartDataFormulaManager implements SearchManager { + private static Map chartDataType = new HashMap<>(); + /** + * 其余普通类型 + */ + public static final String VAN_CHART_NORMAL_REPORT_DATA_DEFINITION = "VanChartNormalReportDataDefinition"; + /** + * 散点图、气泡图数据 + */ + public static final String BUBBLE_REPORT_DEFINITION = "BubbleReportDefinition"; + /** + * 组合图 + */ + public static final String CUSTOM_DEFINITION = "CustomDefinition"; + /** + * 多层饼图、矩形树图 + */ + public static final String MULTI_PIE_REPORT_DATA_DEFINITION = "MultiPieReportDataDefinition"; + /** + * 地图、热力地图 + */ + public static final String VAN_MAP_DEFINITION = "VanMapDefinition"; + /** + * 钻取地图 + */ + public static final String DRILL_MAP_DEFINITION = "DrillMapDefinition"; + /** + * 词云 + */ + public static final String WORD_CLOUD_REPORT_DEFINITION = "WordCloudReportDefinition"; + /** + * 漏斗图 + */ + public static final String METER_REPORT_DEFINITION = "MeterReportDefinition"; + /** + * 甘特图 + */ + public static final String VAN_GANTT_DEFINITION = "VanGanttDefinition"; + /** + * 框架图 + */ + public static final String STRUCTURE_REPORT_DEFINITION = "StructureReportDefinition"; + /** + * 箱型图 + */ + public static final String VAN_BOX_REPORT_DEFINITION = "VanBoxReportDefinition"; + + /** + * 组合图中的大部分类型 + */ + public static final String NORMAL_REPORT_DATA_DEFINITION = "NormalReportDataDefinition"; + + private SearchChartDataFormulaManager() { + register(VAN_CHART_NORMAL_REPORT_DATA_DEFINITION, SearchChartVanNormalDataFormulaAction.getInstance()); + register(BUBBLE_REPORT_DEFINITION, SearchChartBubbleDataFormulaAction.getInstance()); + register(MULTI_PIE_REPORT_DATA_DEFINITION, SearchChartMultiPieDataFormulaAction.getInstance()); + register(VAN_MAP_DEFINITION, SearchChartMapDataFormulaAction.getInstance()); + register(DRILL_MAP_DEFINITION, SearchChartDrillMapDataFormulaAction.getInstance()); + register(WORD_CLOUD_REPORT_DEFINITION, SearchChartWordCloudDataFormulaAction.getInstance()); + register(METER_REPORT_DEFINITION, SearchChartMeterDataFormulaAction.getInstance()); + register(VAN_GANTT_DEFINITION, SearchChartGanttDataFormulaAction.getInstance()); + register(STRUCTURE_REPORT_DEFINITION, SearchChartStructureDataFormulaAction.getInstance()); + register(VAN_BOX_REPORT_DEFINITION, SearchChartBoxDataFormulaAction.getInstance()); + register(CUSTOM_DEFINITION, SearchChartCustomDataFormulaAction.getInstance()); + register(NORMAL_REPORT_DATA_DEFINITION, SearchChartNormalReportDataFormulaAction.getInstance()); + } + + + /** + * 获取类别 + * + * @return + */ + public Map getChartDataType() { + return chartDataType; + } + + + @Override + public void registerAction(String tag, SearchAction searchAction) { + if (searchAction instanceof SearchChartDataFormula) { + register(tag, (SearchChartDataFormula) searchAction); + } + } + + @Override + public void removeAction(String tag) { + remove(tag); + } + + + /** + * 注册 + * + * @param tag 用于匹配的类型tag + * @param searchChartDataFormula 对应的实现类 + */ + private void register(String tag, SearchChartDataFormula searchChartDataFormula) { + chartDataType.put(tag, searchChartDataFormula); + } + + /** + * 注销 + * + * @param tag 用于匹配的tag + */ + private void remove(String tag) { + chartDataType.remove(tag); + } + + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartDataFormulaManager getInstance() { + return SearchChartCollectionFormulaManagerEnum.SINGLETON.getInstance(); + } + + + /** + * 枚举实现单例 + */ + private enum SearchChartCollectionFormulaManagerEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartDataFormulaManager instance; + + SearchChartCollectionFormulaManagerEnum() { + instance = new SearchChartDataFormulaManager(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartDataFormulaManager getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDrillMapDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDrillMapDataFormulaAction.java new file mode 100644 index 0000000000..e4e6000e85 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDrillMapDataFormulaAction.java @@ -0,0 +1,93 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.chartx.data.DrillMapChartDataDefinition; +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.plugin.chart.drillmap.data.DrillMapDefinition; +import com.fr.plugin.chart.map.data.VanMapReportDefinition; + +import java.util.List; + +/** + * 钻取地图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartDrillMapDataFormulaAction implements SearchChartDataFormula { + private SearchChartDrillMapDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof DrillMapDefinition) { + DrillMapDefinition definition = (DrillMapDefinition) provider; + + if (definition.isFromBottomData()) { + dealDefinition(formulaInfos, content, definition.getBottomDataDefinition()); + } else { + for (int i = 0; i < definition.getEachLayerDataDefinitionList().size(); i++) { + ITContent listContent = ITContent.copy(content); + int index = i + 1; + listContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Index_Article") + index + Toolkit.i18nText("Fine-Design_Chart_Index_Layer") + ); + dealDefinition(formulaInfos, listContent, definition.getEachLayerDataDefinitionList().get(i)); + } + } + } + } + + /** + * 这边存在点地图和区域地图两种,点地图特殊的地方需要处理一下 + * + * @param formulaInfos + * @param content + * @param provider + */ + private void dealDefinition(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof VanMapReportDefinition) { + SearchChartMapDataFormulaAction.getInstance().dealAreaName(formulaInfos, content, ((VanMapReportDefinition) provider).getCategoryName(), (VanMapReportDefinition) provider); + SearchChartMapDataFormulaAction.dealSeriesDefinition(formulaInfos, content, ((VanMapReportDefinition) provider).getSeriesList()); + SearchChartMapDataFormulaAction.getInstance().dealPointDefinition4Special(formulaInfos, content, provider); + } + + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartDrillMapDataFormulaAction getInstance() { + return SearchChartDrillMapDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartDrillMapDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartDrillMapDataFormulaAction instance; + + SearchChartDrillMapDataFormulaActionEnum() { + instance = new SearchChartDrillMapDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartDrillMapDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartGanttDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartGanttDataFormulaAction.java new file mode 100644 index 0000000000..75c6daf235 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartGanttDataFormulaAction.java @@ -0,0 +1,108 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.Formula; +import com.fr.base.chart.chartdata.TopDefinitionProvider; +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.plugin.chart.gantt.data.VanGanttDefinition; +import com.fr.plugin.chart.gantt.data.VanGanttLinkReportDefinition; +import com.fr.plugin.chart.gantt.data.VanGanttReportDefinition; + +import java.util.List; + +/** + * 甘特图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartGanttDataFormulaAction implements SearchChartDataFormula { + private SearchChartGanttDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof VanGanttDefinition) { + VanGanttDefinition definition = (VanGanttDefinition) provider; + if (definition.getDataDefinition() instanceof VanGanttReportDefinition) { + VanGanttReportDefinition reportDefinition = (VanGanttReportDefinition) definition.getDataDefinition(); + ITContent reportContent = ITContent.copy(content); + reportContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Gantt_Chart")); + dealReportDefinition(formulaInfos, reportContent, reportDefinition); + } + if (definition.getLinkDefinition() instanceof VanGanttLinkReportDefinition) { + VanGanttLinkReportDefinition linkReportDefinition = (VanGanttLinkReportDefinition) definition.getLinkDefinition(); + ITContent linkContent = ITContent.copy(content); + linkContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Task_Link")); + dealLinkDefinition(formulaInfos, linkContent, linkReportDefinition); + + } + } + } + + private void dealLinkDefinition(List formulaInfos, ITContent linkContent, VanGanttLinkReportDefinition linkReportDefinition) { + //起始任务id + dealFormulaObject(formulaInfos, linkContent, Toolkit.i18nText("Fine-Design_Chart_Start_Task_ID"), linkReportDefinition.getStartTaskID()); + //结束任务id + dealFormulaObject(formulaInfos, linkContent, Toolkit.i18nText("Fine-Design_Chart_End_Task_ID"), linkReportDefinition.getEndTaskID()); + //关联类型 + dealFormulaObject(formulaInfos, linkContent, Toolkit.i18nText("Fine-Design_Chart_Link_Type"), linkReportDefinition.getLinkType()); + } + + private void dealReportDefinition(List formulaInfos, ITContent reportContent, VanGanttReportDefinition reportDefinition) { + //系列名 + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_Series_Name"), reportDefinition.getSeriesName()); + //开始时间 + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_Start_Time"), reportDefinition.getStartTime()); + //结束时间 + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_End_Time"), reportDefinition.getEndTime()); + //里程碑时间 + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_Marker_Time"), reportDefinition.getMarkTime()); + //进度 + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_Process"), reportDefinition.getProgress()); + //任务ID + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_Task_ID"), reportDefinition.getLinkID()); + //项目名称 + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_Project_Name"), reportDefinition.getFirstProcess()); + //项目 + for (Object o : reportDefinition.getProcessList()) { + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_Project"), o); + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartGanttDataFormulaAction getInstance() { + return SearchChartGanttDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartGanttDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartGanttDataFormulaAction instance; + + SearchChartGanttDataFormulaActionEnum() { + instance = new SearchChartGanttDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartGanttDataFormulaAction getInstance() { + return instance; + } + } +} + diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMapDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMapDataFormulaAction.java new file mode 100644 index 0000000000..b892e35c82 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMapDataFormulaAction.java @@ -0,0 +1,246 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.Formula; +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartdata.SeriesDefinition; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.info.base.SearchTag; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.map.data.VanMapDefinition; +import com.fr.plugin.chart.map.data.VanMapReportDefinition; + +import java.util.List; + +/** + * 地图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartMapDataFormulaAction implements SearchChartDataFormula { + private SearchChartMapDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof VanMapDefinition) { + VanMapDefinition mapDefinition = (VanMapDefinition) provider; + //区域地图 + ITContent areaContent = ITContent.copy(content); + areaContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Region_Map")); + dealAreaDefinition(formulaInfos, areaContent, mapDefinition.getAreaDefinition()); + //流向地图 + ITContent lineContent = ITContent.copy(content); + lineContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_LineMap")); + dealLineDefinition(formulaInfos, content, mapDefinition.getLineDefinition()); + //点地图 + ITContent pointContent = ITContent.copy(content); + pointContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_PointMap")); + dealPointDefinition(formulaInfos, content, mapDefinition.getPointDefinition()); + } + } + + /** + * 处理点地图 + * + * @param formulaInfos + * @param content + * @param pointDefinition + */ + public void dealPointDefinition(List formulaInfos, ITContent content, TopDefinitionProvider pointDefinition) { + if (pointDefinition instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) pointDefinition; + ITContent pointContent = ITContent.copy(content); + //系列名&值 + dealSeriesDefinition(formulaInfos, pointContent, definition.getSeriesList()); + //经纬度 + dealLongitudeAndLatitude(formulaInfos, pointContent, definition); + //区域名 + dealAreaName(formulaInfos, pointContent, definition.getCategoryName(), definition); + } + } + + private boolean isFormulaString(Object o) { + String formulaFlag = "="; + return o instanceof String && ((String) o).startsWith(formulaFlag); + } + + private void dealLineDefinition(List formulaInfos, ITContent content, TopDefinitionProvider lineDefinition) { + if (lineDefinition instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) lineDefinition; + ITContent lineContent = ITContent.copy(content); + //系列名&值 + dealSeriesDefinition(formulaInfos, lineContent, definition.getSeriesList()); + //经纬度 + dealLongitudeAndLatitude(formulaInfos, lineContent, definition); + //终点经纬度 + if (isFormulaString(definition.getEndLongitude())) { + ITContent longContent = ITContent.copy(lineContent); + longContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_End_Longitude")); + longContent.setReplaceObject(definition.getEndLongitude()); + longContent.setTag(SearchTag.CHART_DATA_END_LONGITUDE); + longContent.setHoldObject(definition); + formulaInfos.add(new FormulaInfo(longContent)); + } + if (isFormulaString(definition.getEndLatitude())) { + ITContent latitudeContent = ITContent.copy(lineContent); + latitudeContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_End_Latitude")); + latitudeContent.setReplaceObject(definition.getEndLatitude()); + latitudeContent.setTag(SearchTag.CHART_DATA_END_LATITUDE); + latitudeContent.setHoldObject(definition); + formulaInfos.add(new FormulaInfo(latitudeContent)); + } + if (isFormulaString(definition.getEndAreaName())) { + ITContent endAreaNameContent = ITContent.copy(lineContent); + endAreaNameContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_End_Area_Name")); + endAreaNameContent.setReplaceObject(definition.getEndAreaName()); + endAreaNameContent.setTag(SearchTag.CHART_AREA_END_NAME); + endAreaNameContent.setHoldObject(definition); + formulaInfos.add(new FormulaInfo(endAreaNameContent)); + } + //区域名 + dealAreaName(formulaInfos, lineContent, definition.getCategoryName(), definition); + } + } + + private void dealLongitudeAndLatitude(List formulaInfos, ITContent content, VanMapReportDefinition definition) { + if (isFormulaString(definition.getLongitude())) { + ITContent longContent = ITContent.copy(content); + longContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Longitude")); + longContent.setReplaceObject(definition.getLongitude()); + longContent.setTag(SearchTag.CHART_DATA_LONGITUDE); + longContent.setHoldObject(definition); + formulaInfos.add(new FormulaInfo(longContent)); + } + if (isFormulaString(definition.getLatitude())) { + ITContent latitudeContent = ITContent.copy(content); + latitudeContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Latitude")); + latitudeContent.setReplaceObject(definition.getLatitude()); + latitudeContent.setHoldObject(definition); + latitudeContent.setTag(SearchTag.CHART_DATA_LATITUDE); + formulaInfos.add(new FormulaInfo(latitudeContent)); + } + } + + /** + * 处理区域地图 + * + * @param formulaInfos + * @param content + * @param areaDefinition + */ + public void dealAreaDefinition(List formulaInfos, ITContent content, TopDefinitionProvider areaDefinition) { + if (areaDefinition instanceof VanMapReportDefinition) { + VanMapReportDefinition reportDefinition = (VanMapReportDefinition) areaDefinition; + ITContent mapContent = ITContent.copy(content); + //系列名&值 + dealSeriesDefinition(formulaInfos, mapContent, reportDefinition.getSeriesList()); + //区域名 + dealAreaName(formulaInfos, mapContent, reportDefinition.getCategoryName(), reportDefinition); + } + } + + + /** + * 处理点地图特有的 + * + * @param formulaInfos + * @param content + * @param pointDefinition + */ + public void dealPointDefinition4Special(List formulaInfos, ITContent content, TopDefinitionProvider pointDefinition) { + if (pointDefinition instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) pointDefinition; + ITContent pointContent = ITContent.copy(content); + //经纬度 + dealLongitudeAndLatitude(formulaInfos, pointContent, definition); + } + } + + /** + * 处理区域名 + * @param formulaInfos + * @param content + * @param object + * @param definition + */ + public void dealAreaName(List formulaInfos, ITContent content, Object object, VanMapReportDefinition definition) { + if (object instanceof Formula) { + ITContent cateContent = ITContent.copy(content); + cateContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Area_Name") + ); + cateContent.setReplaceObject(object); + formulaInfos.add(new FormulaInfo(cateContent)); + } else if (isFormulaString(object)) { + ITContent strContent = ITContent.copy(content); + strContent.setHoldObject(definition); + strContent.setTag(SearchTag.CHART_AREA_NAME); + strContent.setReplaceObject(object); + strContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Area_Name")); + formulaInfos.add(new FormulaInfo(strContent)); + } + } + + + /** + * 处理系列名&值 + */ + public static void dealSeriesDefinition(List formulaInfos, ITContent content, List seriesDefinitions) { + for (SeriesDefinition seriesDefinition : seriesDefinitions) { + if (seriesDefinition.getValue() instanceof Formula) { + ITContent valueContent = ITContent.copy(content); + valueContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Series_Value") + ); + valueContent.setReplaceObject(seriesDefinition.getValue()); + formulaInfos.add(new FormulaInfo(valueContent)); + } + if (seriesDefinition.getSeriesName() instanceof Formula) { + ITContent nameContent = ITContent.copy(content); + nameContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Series_Name") + ); + nameContent.setReplaceObject(seriesDefinition.getSeriesName()); + formulaInfos.add(new FormulaInfo(nameContent)); + } + + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartMapDataFormulaAction getInstance() { + return SearchChartMapDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartMapDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartMapDataFormulaAction instance; + + SearchChartMapDataFormulaActionEnum() { + instance = new SearchChartMapDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartMapDataFormulaAction getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMeterDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMeterDataFormulaAction.java new file mode 100644 index 0000000000..6b635ebfda --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMeterDataFormulaAction.java @@ -0,0 +1,68 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.Formula; +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartdata.MeterReportDefinition; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; + +import java.util.List; + +/** + * 漏斗图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartMeterDataFormulaAction implements SearchChartDataFormula { + + private SearchChartMeterDataFormulaAction() { + } + + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof MeterReportDefinition) { + MeterReportDefinition definition = (MeterReportDefinition) provider; + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Series_Name"), definition.getName()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Series_Value"), definition.getValue()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Target_Value"), definition.getTarget()); + } + } + + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartMeterDataFormulaAction getInstance() { + return SearchChartMeterDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartMeterDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartMeterDataFormulaAction instance; + + SearchChartMeterDataFormulaActionEnum() { + instance = new SearchChartMeterDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartMeterDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMultiPieDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMultiPieDataFormulaAction.java new file mode 100644 index 0000000000..75f1147a98 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMultiPieDataFormulaAction.java @@ -0,0 +1,71 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.Formula; +import com.fr.base.chart.chartdata.TopDefinitionProvider; + +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.plugin.chart.multilayer.data.MultiPieReportDataDefinition; + +import java.util.List; + +/** + * 层次图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartMultiPieDataFormulaAction implements SearchChartDataFormula { + private SearchChartMultiPieDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof MultiPieReportDataDefinition) { + //层次 + MultiPieReportDataDefinition definition = (MultiPieReportDataDefinition) provider; + for (int i = 0; i < definition.getLevelColumnNameList().size(); i++) { + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Level"), definition.getLevelColumnNameList().get(i)); + } + + //值字段 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Basic_Base_Value"), definition.getValue()); + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartMultiPieDataFormulaAction getInstance() { + return SearchChartMultiPieDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartMultiPieDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartMultiPieDataFormulaAction instance; + + SearchChartMultiPieDataFormulaActionEnum() { + instance = new SearchChartMultiPieDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartMultiPieDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartNormalReportDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartNormalReportDataFormulaAction.java new file mode 100644 index 0000000000..cfd3f0e68e --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartNormalReportDataFormulaAction.java @@ -0,0 +1,65 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartdata.NormalReportDataDefinition; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; + +import java.util.List; + +/** + * 组合图中的大部分类型 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-22 + */ +public class SearchChartNormalReportDataFormulaAction implements SearchChartDataFormula { + + private SearchChartNormalReportDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof NormalReportDataDefinition) { + NormalReportDataDefinition dataDefinition = (NormalReportDataDefinition) provider; + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Category_Name"), dataDefinition.getCategoryName()); + SearchChartMapDataFormulaAction.dealSeriesDefinition(formulaInfos, content, dataDefinition.getSeriesList()); + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartNormalReportDataFormulaAction getInstance() { + return SearchChartNormalReportDataFormulaActionEnum.SINGLETON.getInstance(); + } + + + /** + * 枚举实现单例 + */ + private enum SearchChartNormalReportDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartNormalReportDataFormulaAction instance; + + SearchChartNormalReportDataFormulaActionEnum() { + instance = new SearchChartNormalReportDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartNormalReportDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartStructureDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartStructureDataFormulaAction.java new file mode 100644 index 0000000000..266d1fe4a0 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartStructureDataFormulaAction.java @@ -0,0 +1,69 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +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.plugin.chart.structure.data.StructureReportDefinition; + +import java.util.List; + +/** + * 框架图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartStructureDataFormulaAction implements SearchChartDataFormula { + private SearchChartStructureDataFormulaAction() { + } + + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof StructureReportDefinition) { + StructureReportDefinition definition = (StructureReportDefinition) provider; + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Node_Name"), definition.getNodeName()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Node_Id"), definition.getNodeID()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Parent_Node_Id"), definition.getParentID()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Series_Value"), definition.getNodeValue()); + + + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartStructureDataFormulaAction getInstance() { + return SearchChartStructureDataFormulaActionEnum.SINGLETON.getInstance(); + } + + + /** + * 枚举实现单例 + */ + private enum SearchChartStructureDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartStructureDataFormulaAction instance; + + SearchChartStructureDataFormulaActionEnum() { + instance = new SearchChartStructureDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartStructureDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartVanNormalDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartVanNormalDataFormulaAction.java new file mode 100644 index 0000000000..65f4800d21 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartVanNormalDataFormulaAction.java @@ -0,0 +1,74 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartdata.NormalReportDataDefinition; +import com.fr.chart.chartdata.SeriesDefinition; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; + +import java.util.List; + +/** + * 普通图表类型 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartVanNormalDataFormulaAction implements SearchChartDataFormula { + private SearchChartVanNormalDataFormulaAction() { + } + + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof NormalReportDataDefinition) { + NormalReportDataDefinition normalReportDataDefinition = (NormalReportDataDefinition) provider; + //分类名 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Category_Name"), normalReportDataDefinition.getCategoryName()); + //系列名&值 + for (Object seriesDefinition : normalReportDataDefinition.getSeriesList()) { + if (seriesDefinition instanceof SeriesDefinition) { + SeriesDefinition definition = (SeriesDefinition) seriesDefinition; + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Series_Name"), definition.getSeriesName()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Series_Value"), definition.getValue()); + } + } + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartVanNormalDataFormulaAction getInstance() { + return SearchChartNormalDataFormulaActionEnum.SINGLETON.getInstance(); + } + + + /** + * 枚举实现单例 + */ + private enum SearchChartNormalDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartVanNormalDataFormulaAction instance; + + SearchChartNormalDataFormulaActionEnum() { + instance = new SearchChartVanNormalDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartVanNormalDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartWordCloudDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartWordCloudDataFormulaAction.java new file mode 100644 index 0000000000..d22eadaeab --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartWordCloudDataFormulaAction.java @@ -0,0 +1,63 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +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.plugin.chart.wordcloud.data.WordCloudReportDefinition; + +import java.util.List; + +/** + * 词云 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartWordCloudDataFormulaAction implements SearchChartDataFormula { + private SearchChartWordCloudDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof WordCloudReportDefinition) { + WordCloudReportDefinition definition = (WordCloudReportDefinition) provider; + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Word_Name"), definition.getWordName()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Word_Value"), definition.getWordValue()); + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartWordCloudDataFormulaAction getInstance() { + return SearchWordCloudDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchWordCloudDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartWordCloudDataFormulaAction instance; + + SearchWordCloudDataFormulaActionEnum() { + instance = new SearchChartWordCloudDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartWordCloudDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchChartHyperPopLinkAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchChartHyperPopLinkAction.java new file mode 100644 index 0000000000..4edd5b4f17 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchChartHyperPopLinkAction.java @@ -0,0 +1,68 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.javascript; + +import com.fr.base.chart.BaseChartCollection; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.web.ChartHyperPoplink; +import com.fr.design.actions.replace.action.content.formula.chart.SearchChartCollectionFormulaAction; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.js.JavaScript; + +import java.util.List; + +/** + * 图表超链-悬浮窗图表的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-20 + */ +public class SearchChartHyperPopLinkAction implements SearchJSFormula { + private SearchChartHyperPopLinkAction() { + } + + + @Override + public void searchJSFormulaFromOther(List formulaInfos, ITContent content, JavaScript javaScript) { + if (javaScript instanceof ChartHyperPoplink) { + ChartHyperPoplink chartHyperPoplink = (ChartHyperPoplink) javaScript; + if (chartHyperPoplink.getChartCollection() instanceof ChartCollection) { + SearchChartCollectionFormulaAction.getInstance().searchChartCollectionFormula(formulaInfos, content, (ChartCollection) chartHyperPoplink.getChartCollection()); + } + } + } + + /** + * 获取单例 + * + * @return + */ + public static SearchChartHyperPopLinkAction getInstance() { + return SearchChartHyperPopLinkActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartHyperPopLinkActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchChartHyperPopLinkAction instance; + + SearchChartHyperPopLinkActionEnum() { + instance = new SearchChartHyperPopLinkAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchChartHyperPopLinkAction getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchJSFormulaManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchJSFormulaManager.java index df797a36fa..e77e4c60ec 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchJSFormulaManager.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchJSFormulaManager.java @@ -20,6 +20,7 @@ public class SearchJSFormulaManager implements SearchManager { public static final String COMMIT_2_DB_JAVASCRIPT = "Commit2DBJavaScript"; public static final String EXPORT_JAVASCRIPT = "ExportJavaScript"; public static final String MOBILE_POPUP_HYPERLINK = "MobilePopupHyperlink"; + public static final String CHART_HYPER_POP_LINK = "ChartHyperPoplink"; private SearchJSFormulaManager() { //控件事件里面需要特殊处理的类型 @@ -35,11 +36,12 @@ public class SearchJSFormulaManager implements SearchManager { //JavaScriptImpl——只有参数可以放公式,不需要特殊处理 //MobilePopupHyperlink //ChartHyperPoplink - //ChartHyperRelateCellLink - //ChartHyperRelateFloatLink + //ChartHyperRelateCellLink——只有参数可以放公式,不需要特殊处理 + //ChartHyperRelateFloatLink——只有参数可以放公式,不需要特殊处理 register(COMMIT_2_DB_JAVASCRIPT, SearchCommit2DBJSFormulaAction.getInstance()); register(EXPORT_JAVASCRIPT, SearchExportJSFormulaAction.getInstance()); register(MOBILE_POPUP_HYPERLINK, SearchMobileHyperlinkFormulaAction.getInstance()); + register(CHART_HYPER_POP_LINK, SearchChartHyperPopLinkAction.getInstance()); } @Override diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaAction.java index 769d608382..3e1f4a8bcf 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaAction.java @@ -20,6 +20,7 @@ import com.fr.form.ui.ChartEditor; import com.fr.form.ui.Label; import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WScaleLayout; import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.widget.CRBoundsWidget; @@ -74,22 +75,21 @@ public class SearchWidgetFormulaAction extends AbstractSearchWidgetFormulaAction private void searchFormulaFromWidgetValue(Info info, List formulaInfos) { Widget widget = (Widget) info.getContent().getReplaceObject(); - if (widget instanceof WScaleLayout) { widget = ((CRBoundsWidget) ((WScaleLayout) widget).getWidget(0)).getWidget(); info.getContent().setReplaceObject(widget); } if (widget instanceof WTitleLayout) { - if (((WTitleLayout) widget).getTitleBoundsWidget() != null){ + if (((WTitleLayout) widget).getTitleBoundsWidget() != null) { CRBoundsWidget boundsWidget = ((WTitleLayout) widget).getTitleBoundsWidget(); - if (boundsWidget.getWidget() instanceof Label){ + if (boundsWidget.getWidget() instanceof Label) { ITContent titleContent = ITContent.copy(info.getContent()); titleContent.setReplaceObject(((Label) boundsWidget.getWidget()).getWidgetValue().getValue()); formulaInfos.add(new FormulaInfo(titleContent)); } } Widget tempWidget = (((WTitleLayout) widget).getBodyBoundsWidget()).getWidget(); - if (tempWidget instanceof ChartEditor && ((ChartEditor) tempWidget).getChartCollection() instanceof ChartCollection) { + if (isChartValid(tempWidget)) { SearchChartCollectionFormulaAction.getInstance().searchChartCollectionFormula(formulaInfos, info.getContent(), (ChartCollection) ((ChartEditor) tempWidget).getChartCollection()); } } @@ -102,6 +102,9 @@ public class SearchWidgetFormulaAction extends AbstractSearchWidgetFormulaAction } + private boolean isChartValid(Widget tempWidget) { + return tempWidget instanceof ChartEditor && ((ChartEditor) tempWidget).getChartCollection() instanceof ChartCollection; + } public boolean isReplaceObjectExist(Info info) { return info.getContent() != null && info.getContent().getReplaceObject() != null; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaManager.java index 719f49f003..1d11046164 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaManager.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaManager.java @@ -33,6 +33,7 @@ public class SearchWidgetFormulaManager implements SearchManager { private static final String TREE_COMBO_BOX_EDITOR = "TreeComboBoxEditor"; private static final String TREE_EDITOR = "TreeEditor"; private static final String W_TITLE_LAYOUT = "WTitleLayout"; + private static final String W_BORDER_LAYOUT = "WBorderLayout"; private SearchWidgetFormulaManager() { /** @@ -48,7 +49,7 @@ public class SearchWidgetFormulaManager implements SearchManager { register(NUMBER_EDITOR, SearchCommonWidgetFormulaAction.getInstance()); register(TEXT_EDITOR, SearchCommonWidgetFormulaAction.getInstance()); register(W_TITLE_LAYOUT, SearchCommonWidgetFormulaAction.getInstance()); - + register(W_BORDER_LAYOUT, SearchCommonWidgetFormulaAction.getInstance()); /** * 日期类型 */ diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java index 768972c679..b7269318e5 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java @@ -10,7 +10,9 @@ import com.fr.design.i18n.Toolkit; import com.fr.js.NameJavaScript; import com.fr.plugin.chart.attr.axis.VanChartAxis; +import com.fr.plugin.chart.base.RefreshMoreLabel; import com.fr.plugin.chart.base.VanChartHtmlLabel; +import com.fr.plugin.chart.vanchart.VanChart; import com.fr.stable.collections.combination.Pair; import java.util.List; @@ -42,7 +44,7 @@ public class SearchChartJSAction { ITContent htmlITContent = ITContent.copy(content); htmlITContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Chart")); SearchJSUtils.addJSInfosFromHtmlLabel(htmlITContent, htmlLabels, jsInfos); - //图表-特效-交互属性 + //图表-特效-交互属性-超级链接 ITContent conditionContent = ITContent.copy(content); conditionContent.addOtherPos( Toolkit.i18nText("Fine-Design_Chart_Chart"), @@ -51,35 +53,62 @@ public class SearchChartJSAction { ); SearchJSUtils.addJSInfosFromNameJS(conditionContent, nameJavaScripts, jsInfos); + //图表-特效-交互属性-监控刷新 + dealMonitorRefreshJS(conditionContent,chartCollection,jsInfos); for (int i = 0; i < chartCollection.getChartCount(); i++) { ITContent chartContent = ITContent.copy(content); + chartContent.addOtherPos(chartCollection.getChart(i).getChartName()); searchAxisJS(jsInfos, chartContent, chartCollection.getChart(i)); } } - private void searchAxisJS(List jsInfos, ITContent chartContent, Chart chart) { - Axis xAxis = chart.getPlot().getxAxis(); - Axis yAxis = chart.getPlot().getyAxis(); - if (xAxis instanceof VanChartAxis) { - ITContent xAxisContent = ITContent.copy(chartContent); - xAxisContent.addOtherPos( - Toolkit.i18nText("Fine-Design_Chart_Axis"), - Toolkit.i18nText("Fine-Design_Chart_X_Axis"), - Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format") - ); - dealAxisHtmlLabelJS(jsInfos, ((VanChartAxis) xAxis).getHtmlLabel(), xAxisContent); + private void dealMonitorRefreshJS(ITContent conditionContent, ChartCollection chartCollection, List jsInfos) { + for (int i = 0 ; i < chartCollection.getChartCount() ; i ++){ + if (chartCollection.getChart(i) instanceof VanChart){ + VanChart chart = (VanChart) chartCollection.getChart(i); + if (isMonitorValid(chart.getRefreshMoreLabel())){ + VanChartHtmlLabel htmlLabel = chart.getRefreshMoreLabel().getAttrTooltip().getContent().getHtmlLabel(); + if (htmlLabel != null){ + ITContent content = ITContent.copy(conditionContent); + content.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Moniter_refresh")); + content.setReplaceObject(htmlLabel); + jsInfos.add(new JSInfo(content)); + } + } + } } + } + + private boolean isMonitorValid(RefreshMoreLabel moreLabel){ + return moreLabel.isMoreLabel() && moreLabel.getAttrTooltip() != null && moreLabel.getAttrTooltip().isEnable(); + } - if (yAxis instanceof VanChartAxis) { - ITContent yAxisContent = ITContent.copy(chartContent); - yAxisContent.addOtherPos( - Toolkit.i18nText("Fine-Design_Chart_Axis"), - Toolkit.i18nText("Fine-Design_Chart_Y_Axis"), - Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format") - ); - dealAxisHtmlLabelJS(jsInfos, ((VanChartAxis) yAxis).getHtmlLabel(), yAxisContent); + private void searchAxisJS(List jsInfos, ITContent chartContent, Chart chart) { + if (chart.getPlot() != null){ + Axis xAxis = chart.getPlot().getxAxis(); + Axis yAxis = chart.getPlot().getyAxis(); + if (xAxis instanceof VanChartAxis) { + ITContent xAxisContent = ITContent.copy(chartContent); + xAxisContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Axis"), + Toolkit.i18nText("Fine-Design_Chart_X_Axis"), + Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format") + ); + dealAxisHtmlLabelJS(jsInfos, ((VanChartAxis) xAxis).getHtmlLabel(), xAxisContent); + } + + if (yAxis instanceof VanChartAxis) { + ITContent yAxisContent = ITContent.copy(chartContent); + yAxisContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Axis"), + Toolkit.i18nText("Fine-Design_Chart_Y_Axis"), + Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format") + ); + dealAxisHtmlLabelJS(jsInfos, ((VanChartAxis) yAxis).getHtmlLabel(), yAxisContent); + } } + } private void dealAxisHtmlLabelJS(List jsInfos, VanChartHtmlLabel label, ITContent content) { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/DealWithInfoValue.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/DealWithInfoValue.java index feb5cc1a78..2330fa5fdf 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/DealWithInfoValue.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/DealWithInfoValue.java @@ -1,10 +1,11 @@ package com.fr.design.actions.replace.info; +import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; - +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -23,7 +24,9 @@ public interface DealWithInfoValue { * @param o 用于替换的replaceObject * @return 返回便于处理的Map(不同类型可能会存在多个需要存储的数据,eg:控件名 & 水印) */ - Map getValue(Object... o); + default Map getValue(Object... o) { + return new HashMap<>(); + } /** @@ -34,7 +37,8 @@ public interface DealWithInfoValue { * @param replaceStr 用于替换的字符串 * @param operatorArray 存储内容类替换所要操作的所有位置(Pair<起始位置,结束位置>) */ - void setValue(Info info, String findStr, String replaceStr, List> operatorArray); + default void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + } /** @@ -43,5 +47,7 @@ public interface DealWithInfoValue { * @param info 信息 * @return 返回用于展示的字符串 */ - String getInfoShowStr(Info info); + default String getInfoShowStr(Info info) { + return StringUtils.EMPTY; + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java index de736cb27f..afa9847f37 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java @@ -66,6 +66,16 @@ public class ITContent implements Cloneable { */ private boolean jumpAble = true; + /** + * 持有公式的对象 + */ + private Object holdObject; + + /** + * 与SearchTag对应的标签,用于后续校验处理 + */ + private int tag = -1; + public ITContent() { this.sheetID = StringUtils.EMPTY; this.sheetName = StringUtils.EMPTY; @@ -79,6 +89,7 @@ public class ITContent implements Cloneable { this.lastSearchStr = StringUtils.EMPTY; this.trlString = StringUtils.EMPTY; this.operatorArray = new ArrayList<>(); + this.holdObject = new Object(); } @@ -89,23 +100,43 @@ public class ITContent implements Cloneable { */ public static ITContent copy(ITContent content) { ITContent result = new ITContent(); - result.setSheetID(content.getSheetID()); - result.setSheetName(content.getSheetName()); - result.setTemplateName(content.getTemplateName()); - result.setBlockName(content.getBlockName()); - result.addOtherPos(content.getOtherPos()); - result.setReplaceObject(content.getReplaceObject()); - result.setShowObject(content.getShowObject()); - result.setTrlString(content.getTrlString()); - result.setShowStr(content.getShowStr()); - result.setOldShowStr(content.getOldShowStr()); - result.setLastSearchStr(content.getLastSearchStr()); - result.setOperatorArray(content.getOperatorArray()); - result.setFrmFlag(content.isFrm()); - result.setJumpAble(content.isJumpAble()); + if (content != null){ + result.setSheetID(content.getSheetID()); + result.setSheetName(content.getSheetName()); + result.setTemplateName(content.getTemplateName()); + result.setBlockName(content.getBlockName()); + result.addOtherPos(content.getOtherPos()); + result.setReplaceObject(content.getReplaceObject()); + result.setShowObject(content.getShowObject()); + result.setTrlString(content.getTrlString()); + result.setShowStr(content.getShowStr()); + result.setOldShowStr(content.getOldShowStr()); + result.setLastSearchStr(content.getLastSearchStr()); + result.setOperatorArray(content.getOperatorArray()); + result.setFrmFlag(content.isFrm()); + result.setJumpAble(content.isJumpAble()); + result.setHoldObject(content.getHoldObject()); + result.setTag(content.getTag()); + } return result; } + public int getTag() { + return tag; + } + + public void setTag(int tag) { + this.tag = tag; + } + + public Object getHoldObject() { + return holdObject; + } + + public void setHoldObject(Object holdObject) { + this.holdObject = holdObject; + } + public Object getReplaceObject() { return replaceObject; } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java new file mode 100644 index 0000000000..2106c51c0f --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java @@ -0,0 +1,37 @@ +package com.fr.design.actions.replace.info.base; + +/** + * 用于校验的标签 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchTag { + /** + * 经度 + */ + public static final int CHART_DATA_LONGITUDE = 0; + /** + * 纬度 + */ + public static final int CHART_DATA_LATITUDE = 1; + /** + * 区域名 + */ + public static final int CHART_AREA_NAME = 2; + /** + * 终点经度 + */ + public static final int CHART_DATA_END_LONGITUDE = 3; + /** + * 终点纬度 + */ + public static final int CHART_DATA_END_LATITUDE = 4; + /** + * 终点区域名 + */ + public static final int CHART_AREA_END_NAME = 5; + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 4ac477cdc5..a1443d89f4 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -10,6 +10,7 @@ import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.UIDialog; import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; @@ -97,7 +98,7 @@ public class ITReplaceMainDialog extends UIDialog { setSize(width, height); setLocation(new Point(point.x, point.y + jTemplate.getHeight() / 2 + jTemplate.getHeight() / 2 - 385)); - northPane.fitScreen(0, 0, jTemplate.getWidth()); + northPane.fitScreen(0, 0,width); } @@ -142,7 +143,7 @@ public class ITReplaceMainDialog extends UIDialog { } } }); - center.add(northPane.getUpPanel(), BorderLayout.NORTH); + center.add(northPane.getScrollPane(), BorderLayout.NORTH); center.add(southPanel.getTableEditorPane(), BorderLayout.CENTER); add(westPanel.getLeftJpanel(), BorderLayout.WEST); //主体部分 @@ -154,42 +155,43 @@ public class ITReplaceMainDialog extends UIDialog { * 替换 */ private void replace() { + String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); + String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText(); + if (StringUtils.equals(getSearchStr(), searchStr)) { + if (isITReplaceValid() && checkTemplateChanged(searchResultList)) { + for (Info info : searchResultList) { + if (info.getContent().isSelected()) { + info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray()); + ShowValueUtils.updateHighlight(info, replaceStr); + } + } + southPanel.getTableEditorPane().update(); + northPane.refreshReplaceInputComboBoxItems(); + ITTableEditorPane.getEditTable().repaint(); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); + setSearchFlag(false); - if (isITReplaceValid() && checkTemplateChanged(searchResultList)) { - String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); - String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText(); - - - for (Info info : searchResultList) { - if (info.getContent().isSelected()) { - info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray()); - ShowValueUtils.updateHighlight(info, replaceStr); + } else { + Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")}; + int optionSelected = FineJOptionPane.showOptionDialog( + ITReplaceMainDialog.this, + Toolkit.i18nText("Fine-Design_Replace_Message"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.ERROR_MESSAGE, + null, + // 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框) + options, + options[0] + ); + //如果选择了重新查找,则再查找一遍 + if (optionSelected == 0) { + search(); } } - southPanel.getTableEditorPane().update(); - northPane.refreshReplaceInputComboBoxItems(); - ITTableEditorPane.getEditTable().repaint(); - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); - setSearchFlag(false); - } else { - Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")}; - int optionSelected = FineJOptionPane.showOptionDialog( - ITReplaceMainDialog.this, - Toolkit.i18nText("Fine-Design_Replace_Message"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.ERROR_MESSAGE, - null, - // 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框) - options, - options[0] - ); - //如果选择了重新查找,则再查找一遍 - if (optionSelected == 0) { - search(); - } + search(); } @@ -281,9 +283,11 @@ public class ITReplaceMainDialog extends UIDialog { JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); templateID = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID(); itTableEditor.clear(); + String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); + setSearchStr(searchStr); ShowSearchResultAction searchAction = ShowSearchResultAction.match(GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem())); if (searchAction != null) { - searchResultList = searchAction.addMatchResult(((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(), searchAction.showSearchValue(jTemplate)); + searchResultList = searchAction.addMatchResult(searchStr, searchAction.showSearchValue(jTemplate)); itTableEditor.add(searchResultList); northPane.getResultLabel().setText("" + Toolkit.i18nText("Fine-Design_Replace_Search_Finish") + "" + searchResultList.size() + "" + Toolkit.i18nText("Fine-Design_Replace_Result")); } @@ -291,7 +295,6 @@ public class ITReplaceMainDialog extends UIDialog { northPane.refreshFindInputComboBoxItems(); setSearchFlag(true); - String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); if (StringUtils.isNotEmpty(searchStr)) { ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setEditable(true); northPane.getReplaceInputCombobox().setEditable(true); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java index ff5b3c8199..bc4e82255f 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -1,8 +1,8 @@ package com.fr.design.actions.replace.ui; -import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; @@ -12,6 +12,7 @@ import com.fr.stable.StringUtils; import javax.swing.ComboBoxEditor; import javax.swing.JCheckBox; import javax.swing.JPanel; +import javax.swing.ScrollPaneConstants; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -36,12 +37,16 @@ public class ITReplaceNorthPanel { private UIComboBox findInputCombobox; private UIComboBox replaceInputCombobox; - + private UIScrollPane scrollPane; private UIButton replaceButton; private UIButton searchButton; //存储的5次最近输入 private int maxItemCount = 5; + private static final int LIMIT_WIDTH = 1250; + private static final int HEIGHT = 161; + private static final int BUTTON_WIDTH = 60; + private static final int BUTTON_GAP = 20; private int findLabelX, findLabelY, findLabelWidth, findLabelHeight; @@ -52,9 +57,9 @@ public class ITReplaceNorthPanel { private int resultLabelX, resultLabelY, resultLabelWidth, resultLabelHeight; private int findInputComboBoxX, findInputComboBoxY, findInputComboBoxWidth, findInputComboBoxHeight; private int replaceInputComboBoxX, replaceInputComboBoxY, replaceInputComboBoxWidth, replaceInputComboBoxHeight; - private int replaceButtonX, replaceButtonY, replaceButtonWidth, replaceButtonHeight; - private int searchButtonX, searchButtonY, searchButtonWidth, searchButtonHeight; - private int buttonGap; + private int replaceButtonX, replaceButtonY, replaceButtonHeight; + private int searchButtonX, searchButtonY, searchButtonHeight; + public static ArrayList findItems = new ArrayList<>(); public static ArrayList findInputItems = new ArrayList<>(); @@ -103,9 +108,8 @@ public class ITReplaceNorthPanel { replaceButton = new UIButton(Toolkit.i18nText("Fine-Design_Replace_Button")); searchButton = new UIButton(Toolkit.i18nText("Fine-Design_Search_Button")); - - setLimitSize(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getWidth()); - + upPanel.setPreferredSize(new Dimension(LIMIT_WIDTH, HEIGHT)); + scrollPane = new UIScrollPane(upPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); upPanel.add(findLabel); upPanel.add(rangeLabel); upPanel.add(resultLabel); @@ -124,8 +128,8 @@ public class ITReplaceNorthPanel { * @param width */ public void setLimitSize(int width) { + width = Math.max(LIMIT_WIDTH, width); upPanel.setMaximumSize(new Dimension(width, 161)); - upPanel.setMinimumSize(new Dimension(width, 161)); upPanel.setPreferredSize(new Dimension(width, 161)); } @@ -139,6 +143,8 @@ public class ITReplaceNorthPanel { */ public void fitScreen(int x, int y, int templateWidth) { + templateWidth = Math.max(templateWidth, LIMIT_WIDTH); + setFindLabelBounds(x, y, templateWidth); setRangeLabelBounds(x, y, templateWidth); setResultLabelBounds(x, y, templateWidth); @@ -152,6 +158,7 @@ public class ITReplaceNorthPanel { setReplaceButtonBounds(x, y, templateWidth); setSearchButtonBounds(x, y, templateWidth); + } @@ -198,27 +205,31 @@ public class ITReplaceNorthPanel { } - private void setSearchButtonBounds(int x, int y, int templateWidth) { - buttonGap = templateWidth / 90; - searchButtonWidth = templateWidth / 30; + public UIScrollPane getScrollPane() { + return scrollPane; + } + + public void setScrollPane(UIScrollPane scrollPane) { + this.scrollPane = scrollPane; + } + + private void setSearchButtonBounds(int x, int y, int templateWidth) { searchButtonHeight = 25; searchButtonY = resultLabelY; - searchButtonX = replaceInputComboBoxX + replaceInputComboBoxWidth - replaceButtonWidth * 2 - buttonGap; - searchButton.setBounds(searchButtonX, searchButtonY, searchButtonWidth, searchButtonHeight); + searchButtonX = replaceInputComboBoxX + replaceInputComboBoxWidth - BUTTON_WIDTH * 2 - BUTTON_GAP; + searchButton.setBounds(searchButtonX, searchButtonY, BUTTON_WIDTH, searchButtonHeight); } private void setReplaceButtonBounds(int x, int y, int templateWidth) { - buttonGap = templateWidth / 90; - replaceButtonWidth = templateWidth / 30; replaceButtonHeight = 25; replaceButtonY = resultLabelY; - replaceButtonX = replaceInputComboBoxX + replaceInputComboBoxWidth - replaceButtonWidth; - replaceButton.setBounds(replaceButtonX, replaceButtonY, replaceButtonWidth, replaceButtonHeight); + replaceButtonX = replaceInputComboBoxX + replaceInputComboBoxWidth - BUTTON_WIDTH; + replaceButton.setBounds(replaceButtonX, replaceButtonY, BUTTON_WIDTH, replaceButtonHeight); } private void setReplaceInputComboboxBounds(int x, int y, int templateWidth) { - replaceInputComboBoxX = x + templateWidth / 2 + templateWidth / 30; + replaceInputComboBoxX = x + templateWidth / 2 + templateWidth / 60; replaceInputComboBoxY = y + 55; replaceInputComboBoxWidth = templateWidth / 3 + templateWidth / 30 * 2; replaceInputComboBoxHeight = 25; @@ -243,7 +254,7 @@ public class ITReplaceNorthPanel { private void setRangeComboboxBounds(int x, int y, int templateWidth) { - rangeComboBoxX = x + templateWidth / 2 + templateWidth / 15 + templateWidth / 60; + rangeComboBoxX = x + templateWidth / 2 + templateWidth / 15; rangeComboBoxY = y + 20; rangeComboBoxWidth = templateWidth / 3 + templateWidth / 60; rangeComboBoxHeight = 25; @@ -270,7 +281,7 @@ public class ITReplaceNorthPanel { } private void setRangeLabelBounds(int x, int y, int templateWidth) { - rangeLabelX = x + templateWidth / 2 + templateWidth / 30; + rangeLabelX = x + templateWidth / 2 + templateWidth / 60; rangeLabelY = y + 20; rangeLabelWidth = findLabelWidth; rangeLabelHeight = 25; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java index a552f4f841..9295baf655 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java @@ -3,6 +3,7 @@ package com.fr.design.actions.replace.ui; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; +import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -27,9 +28,10 @@ public class ITReplaceWestPanel { contentButton.setBorderPainted(false); leftJpanel.add(contentButton); leftJpanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, new Color(218, 218, 221))); + //填充一下面板 int labelNum = 14; for (int i = 0; i < labelNum; i++) { - leftJpanel.add(new UILabel("")); + leftJpanel.add(new UILabel(StringUtils.EMPTY)); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java index 6ec96038eb..13094fc5c8 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java @@ -1,8 +1,11 @@ package com.fr.design.actions.replace.utils; +import com.fr.chart.base.DataSeriesCondition; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; +import com.fr.chart.web.ChartHyperPoplink; +import com.fr.design.actions.replace.action.content.js.SearchChartJSAction; import com.fr.design.actions.replace.info.JSInfo; import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.i18n.Toolkit; @@ -14,6 +17,7 @@ import com.fr.js.JavaScriptImpl; import com.fr.js.NameJavaScript; import com.fr.js.NameJavaScriptGroup; import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.base.AttrLabel; import com.fr.plugin.chart.base.AttrTooltip; import com.fr.plugin.chart.base.VanChartHtmlLabel; import com.fr.plugin.chart.vanchart.VanChart; @@ -38,7 +42,7 @@ public class SearchJSUtils { * 从Listener中获取JS */ public static void searchJSFromListener(List jsInfos, ITContent content) { - if (content.getReplaceObject() instanceof Listener){ + if (content.getReplaceObject() instanceof Listener) { Listener listener = (Listener) (content.getReplaceObject()); JavaScript javaScript = listener.getAction(); if (javaScript instanceof JavaScriptImpl) { @@ -69,12 +73,14 @@ public class SearchJSUtils { */ private static void addHtmlLabel2Array(List> arrayList, ChartCollection collection) { for (int i = 0; i < collection.getChartCount(); i++) { - VanChart chart = ((VanChart) collection.getChart(i)); - int size = chart.getPlot().getConditionCollection().getConditionAttrSize(); - ConditionCollection conditionCollection = chart.getPlot().getConditionCollection(); - addAttrLabelHtmlLabel(chart, arrayList); - for (int j = 0; j < size; j++) { - searchConditionCollection(arrayList, conditionCollection.getConditionAttr(j)); + if (collection.getChart(i) instanceof VanChart){ + VanChart chart = ((VanChart) collection.getChart(i)); + int size = chart.getPlot().getConditionCollection().getConditionAttrSize(); + ConditionCollection conditionCollection = chart.getPlot().getConditionCollection(); + addAttrLabelHtmlLabel(chart, arrayList); + for (int j = 0; j < size; j++) { + searchConditionCollection(arrayList, conditionCollection.getConditionAttr(j)); + } } } } @@ -102,15 +108,18 @@ public class SearchJSUtils { Toolkit.i18nText("Fine-Design_Chart_Tooltip") + "-" + Toolkit.i18nText("Fine-Design_Basic_Custom"))); } } - private static boolean isToolTipValid(VanChartPlot plot){ + + private static boolean isToolTipValid(VanChartPlot plot) { return plot.getAttrTooltipFromConditionCollection() != null && ((AttrTooltip) plot.getAttrTooltipFromConditionCollection()).isEnable() && plot.getAttrTooltipFromConditionCollection() instanceof AttrTooltip; } + private static void addAttrLabelDetail2Array(VanChartPlot plot, List> arrayList) { if (isLabelDetailValid(plot)) { arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel(), Toolkit.i18nText("Fine-Design_Chart_Value_Label"))); } } - private static boolean isLabelDetailValid(VanChartPlot plot){ + + private static boolean isLabelDetailValid(VanChartPlot plot) { return plot.getAttrLabelFromConditionCollection() != null && plot.getAttrLabelFromConditionCollection().getAttrLabelDetail() != null && plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel() != null; @@ -121,7 +130,8 @@ public class SearchJSUtils { arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getSecondLabelDetail().getContent().getHtmlLabel(), Toolkit.i18nText("Fine-Design_Chart_Category_Label"))); } } - private static boolean isSecondLabelDetailValid(VanChartPlot plot){ + + private static boolean isSecondLabelDetailValid(VanChartPlot plot) { return plot.getAttrLabelFromConditionCollection() != null && plot.getAttrLabelFromConditionCollection().getSecondLabelDetail() != null && plot.getAttrLabelFromConditionCollection().getSecondLabelDetail().getContent().getHtmlLabel() != null; @@ -140,14 +150,28 @@ public class SearchJSUtils { private static void searchConditionCollection(List> arrayList, ConditionAttr conditionAttr) { int conditionSize = conditionAttr.getDataSeriesConditionCount(); for (int t = 0; t < conditionSize; t++) { - if (conditionAttr.getDataSeriesCondition(t) instanceof AttrTooltip) { - arrayList.add(new Pair<>(((AttrTooltip) conditionAttr.getDataSeriesCondition(t)).getContent().getHtmlLabel(), - Toolkit.i18nText("Fine-Design_Chart_Animation_Special") + "-" + Toolkit.i18nText("Fine-Design_Chart_Condition_Display"))); + DataSeriesCondition condition = conditionAttr.getDataSeriesCondition(t); + String str = Toolkit.i18nText("Fine-Design_Chart_Animation_Special") + "-" + Toolkit.i18nText("Fine-Design_Chart_Condition_Display"); + if (StringUtils.isNotEmpty(conditionAttr.getName())){ + str += "-"+conditionAttr.getName(); + } + if (condition instanceof AttrTooltip) { + arrayList.add(new Pair<>(((AttrTooltip) condition).getContent().getHtmlLabel(), str+"-"+Toolkit.i18nText("Fine-Design_Chart_Data_Point_Tooltip"))); + } + if (condition instanceof AttrLabel){ + AttrLabel label = (AttrLabel) condition; + if (isAttrLabelValid(label)){ + arrayList.add(new Pair<>(label.getContent().getHtmlLabel(), str+"-"+Toolkit.i18nText("Fine-Design_Chart_Label"))); + } } } } + private static boolean isAttrLabelValid(AttrLabel label){ + return label.isEnable() && label.getContent() != null && label.getContent().getHtmlLabel() != null; + } + /** * 获取图表-特效-交互属性中的JS * @@ -157,10 +181,11 @@ public class SearchJSUtils { public static List getNameJavaScript(ChartCollection chartCollection) { ArrayList nameJavaScriptArrayList = new ArrayList<>(); for (int i = 0; i < chartCollection.getChartCount(); i++) { - VanChart chart = ((VanChart) chartCollection.getChart(i)); - NameJavaScriptGroup nameJavaScriptGroup = chart.getPlot().getHotHyperLink(); - addNameJavaScript2Array(nameJavaScriptArrayList, nameJavaScriptGroup); - + if (chartCollection.getChart(i) instanceof VanChart){ + VanChart chart = ((VanChart) chartCollection.getChart(i)); + NameJavaScriptGroup nameJavaScriptGroup = chart.getPlot().getHotHyperLink(); + addNameJavaScript2Array(nameJavaScriptArrayList, nameJavaScriptGroup); + } } return nameJavaScriptArrayList; } @@ -239,17 +264,34 @@ public class SearchJSUtils { public static void addJSInfosFromHyperLink(Elem elem, List jsInfos, ITContent content) { if (elem.getNameHyperlinkGroup() != null) { for (int j = 0; j < elem.getNameHyperlinkGroup().size(); j++) { - if ((elem.getNameHyperlinkGroup().getNameHyperlink(j).getJavaScript()) instanceof JavaScriptImpl) { + NameJavaScript nameJavaScript = elem.getNameHyperlinkGroup().getNameHyperlink(j); + JavaScript javaScript = nameJavaScript.getJavaScript(); + if (javaScript instanceof JavaScriptImpl) { ITContent newContent = ITContent.copy(content); newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Hyperlink")); - newContent.setReplaceObject(elem.getNameHyperlinkGroup().getNameHyperlink(j)); - newContent.addOtherPos(elem.getNameHyperlinkGroup().getNameHyperlink(j).getName()); + newContent.setReplaceObject(nameJavaScript); + newContent.addOtherPos(nameJavaScript.getName()); SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent)); + } else if (isChartHyperPopLinkValid(javaScript)) { + ITContent chartContent = ITContent.copy(content); + chartContent.addOtherPos(nameJavaScript.getName()); + ChartCollection chartCollection = (ChartCollection) ((ChartHyperPoplink) javaScript).getChartCollection(); + SearchChartJSAction.getInstance().searchChartJS(chartCollection, chartContent, jsInfos); } } } } + /** + * 是否图表悬浮超链且内部图表是否可用 + * + * @param javaScript + * @return + */ + private static boolean isChartHyperPopLinkValid(JavaScript javaScript) { + return javaScript instanceof ChartHyperPoplink && ((ChartHyperPoplink) javaScript).getChartCollection() instanceof ChartCollection; + } + /** * 从Action中拿JS * diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java index 75288d0f92..b215a16c6d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java @@ -3,7 +3,7 @@ package com.fr.design.actions.replace.utils; import com.fr.design.actions.replace.info.Info; -import com.fr.design.actions.replace.ui.ITReplaceMainDialog; + import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; @@ -30,6 +30,7 @@ public class ShowValueUtils { public static final String ANY_THING_REGEX = "."; public static final String NUMBER_REGEX = "[0-9]"; public static final String ENGLISH_REGEX = "[a-zA-Z]"; + /** * 获取除内容外其他一次性展示所有的内容(名称、水印...) * @@ -61,13 +62,14 @@ public class ShowValueUtils { /** * 转换正则表达式 + * * @param regex * @return */ - public static String changeRegex(String regex){ - regex = regex.replace(NUMBER,NUMBER_REGEX); + public static String changeRegex(String regex) { + regex = regex.replace(NUMBER, NUMBER_REGEX); regex = regex.replace(ENGLISH, ENGLISH_REGEX); - regex = regex.replace(ANY_THING,ANY_THING_REGEX); + regex = regex.replace(ANY_THING, ANY_THING_REGEX); return regex; } @@ -128,17 +130,18 @@ public class ShowValueUtils { /** * 支持正则表达式的indexOf + * * @param str * @param regex * @return */ - public static int indexOf(String str, String regex){ + public static int indexOf(String str, String regex) { CharSequence inputStr = str; int failReturn = -1; String patternStr = changeRegex(regex); Pattern pattern = Pattern.compile(patternStr); Matcher matcher = pattern.matcher(inputStr); - if(matcher.find()){ + if (matcher.find()) { return matcher.start(); } return failReturn; diff --git a/designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java b/designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java index b54c871e0a..cef0d1d841 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java +++ b/designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java @@ -6,6 +6,9 @@ package com.fr.design.cell.clipboard; import com.fr.base.TableData; import com.fr.design.base.clipboard.ClipboardHelper; import com.fr.design.data.tabledata.paste.TableDataFollowingPasteUtils; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.theme.utils.CellElementStylePaster; import com.fr.grid.selection.CellSelection; import com.fr.log.FineLoggerFactory; import com.fr.report.cell.CellElement; @@ -20,11 +23,13 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; /** * The clip of CellElement. */ public class CellElementsClip implements Cloneable, java.io.Serializable { + private String copyFromTemplatePath; private int columnSpan = 0; private int rowSpan = 0; private FU[] columnWidth; @@ -39,6 +44,7 @@ public class CellElementsClip implements Cloneable, java.io.Serializable { this.rowHeight = rowHeight; this.clips = clips; this.elementUsedTableDatas = TableDataFollowingPasteUtils.transferProvider2TableDataMap(clips); + this.copyFromTemplatePath = this.getCurrentTemplatePath(); } public CellElementsClip(int columnSpan, int rowSpan, TemplateCellElement[] clips) { @@ -46,6 +52,7 @@ public class CellElementsClip implements Cloneable, java.io.Serializable { this.rowSpan = rowSpan; this.clips = clips; this.elementUsedTableDatas = TableDataFollowingPasteUtils.transferProvider2TableDataMap(clips); + this.copyFromTemplatePath = this.getCurrentTemplatePath(); } public int getColumnSpan() { @@ -133,6 +140,12 @@ public class CellElementsClip implements Cloneable, java.io.Serializable { return null; } + String pasteToTemplatePath = this.getCurrentTemplatePath(); + boolean pastingToDifferentTemplate = copyFromTemplatePath != null && pasteToTemplatePath != null && !Objects.equals(copyFromTemplatePath, pasteToTemplatePath); + if (pastingToDifferentTemplate) { + cellElement = CellElementStylePaster.convertStyleAndColor(cellElement); + } + // peter:因为前面已经将这个位置的元素删除了,所以不需要override了. ec.addCellElement((TemplateCellElement) cellElement.deriveCellElement( column + cellElement.getColumn(), row + cellElement.getRow() @@ -176,6 +189,11 @@ public class CellElementsClip implements Cloneable, java.io.Serializable { } } + private String getCurrentTemplatePath() { + JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + return currentTemplate != null ? currentTemplate.getPath() : null; + } + /** * Clone. */ @@ -183,6 +201,8 @@ public class CellElementsClip implements Cloneable, java.io.Serializable { public Object clone() throws CloneNotSupportedException { CellElementsClip cloned = (CellElementsClip) super.clone(); + cloned.copyFromTemplatePath = this.copyFromTemplatePath; + if (this.clips != null) { cloned.clips = new TemplateCellElement[this.clips.length]; for (int i = 0; i < this.clips.length; i++) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/FormatBrushAction.java b/designer-realize/src/main/java/com/fr/design/mainframe/FormatBrushAction.java index 1256c76644..9ec053bd01 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/FormatBrushAction.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/FormatBrushAction.java @@ -4,6 +4,8 @@ import com.fr.base.Style; import com.fr.design.actions.ElementCaseAction; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.theme.utils.CellElementStylePaster; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; @@ -13,6 +15,7 @@ import com.fr.report.elementcase.TemplateElementCase; import javax.swing.*; import java.awt.*; import java.awt.event.KeyEvent; +import java.util.Objects; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; @@ -48,7 +51,7 @@ public class FormatBrushAction extends ElementCaseAction { if (cellRectangleCount > 1) { //格式刷只支持单次选择的区域,如果用ctrl复选选中了多片区域,点击格式刷按钮时弹出提示 //判断是不是连续区域 - //荣国是连续区域,那么这些长方形的长加起来应该等于 + //如果是连续区域,那么这些长方形的长加起来应该等于 if (!isContinueArea()) { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Can_Not_Use_Format_Brush")); ePane.setFormatState(DesignerContext.FORMAT_STATE_NULL); @@ -103,7 +106,14 @@ public class FormatBrushAction extends ElementCaseAction { } - public void updateFormatBrush(Style[][] referencedStyle, CellSelection cs, ElementCasePane reportPane) { + /** + * 将格式刷获取到的样式,应用到指定单元格区域 + * @param referencedStyleFromTemplatePath 格式刷获取到的样式来自哪张模板 + * @param referencedStyle 格式刷获取到的样式 + * @param cs 应用格式刷区域的指定单元格区域 + * @param reportPane 应用格式刷的报表块面板 + */ + public void updateFormatBrush(String referencedStyleFromTemplatePath, Style[][] referencedStyle, CellSelection cs, ElementCasePane reportPane) { //得到被参照的单元格的行列数 if (referencedStyle == null) { return; @@ -132,7 +142,17 @@ public class FormatBrushAction extends ElementCaseAction { cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); elementCase.addCellElement(cellElement); } - cellElement.setStyle(referencedStyle[i % columnSpan][j % rowSpan]); + Style style = referencedStyle[i % columnSpan][j % rowSpan]; + + JTemplate pasteToTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + String pasteToTemplatePath = pasteToTemplate != null ? pasteToTemplate.getPath() : null; + boolean pastingToDifferentTemplate = referencedStyleFromTemplatePath != null && pasteToTemplatePath != null && !Objects.equals(referencedStyleFromTemplatePath, pasteToTemplatePath); + + if (pastingToDifferentTemplate) { + style = CellElementStylePaster.convertStyleAndColor(style); + } + + cellElement.setStyle(style); } } diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index 61e6484c65..c213a90e46 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java @@ -295,7 +295,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous } if (reportPane.getCellNeedTOFormat() != null) { - reportPane.getFormatBrushAction().updateFormatBrush(DesignerContext.getReferencedStyle(), reportPane.getCellNeedTOFormat(), reportPane); + reportPane.getFormatBrushAction().updateFormatBrush(DesignerContext.getReferencedStyleFromTemplatePath(), DesignerContext.getReferencedStyle(), reportPane.getCellNeedTOFormat(), reportPane); reportPane.fireTargetModified(); }