From 714994940d4f15273c49162d8c0a80db5bb6b277 Mon Sep 17 00:00:00 2001 From: pengda Date: Sun, 24 Apr 2022 17:30:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-68363=20=E6=9D=A1=E4=BB=B6=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E7=B3=BB=E5=88=97=E9=97=B4=E5=80=BC=E7=9A=84=E6=AF=94?= =?UTF-8?q?=E8=BE=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/SummaryMethodComboBox.java | 64 +++++++++++++ .../images/buttonicon/ds_column_summary.png | Bin 0 -> 356 bytes .../com/fr/design/chart/ChartDataHelper.java | 69 ++++++++++++++ .../SeriesCondition/ChartConditionPane.java | 7 +- .../ColSelectedWithSummaryMethodEditor.java | 89 ++++++++++++++++++ .../mainframe/chart/gui/ChartOtherPane.java | 2 + .../chart/gui/data/CalculateComboBox.java | 63 +------------ ...anChartCustomPlotConditionAttrTabPane.java | 2 + .../custom/style/VanChartCustomStylePane.java | 2 + .../designer/style/VanChartStylePane.java | 2 + 10 files changed, 241 insertions(+), 59 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java create mode 100644 designer-base/src/main/resources/com/fr/design/images/buttonicon/ds_column_summary.png create mode 100644 designer-chart/src/main/java/com/fr/design/chart/ChartDataHelper.java create mode 100644 designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java b/designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java new file mode 100644 index 0000000000..bd57e7ea2a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java @@ -0,0 +1,64 @@ +package com.fr.design.data.datapane; + +import com.fr.data.util.function.AbstractDataFunction; +import com.fr.data.util.function.AverageFunction; +import com.fr.data.util.function.CountFunction; +import com.fr.data.util.function.MaxFunction; +import com.fr.data.util.function.MinFunction; +import com.fr.data.util.function.NoneFunction; +import com.fr.data.util.function.SumFunction; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; +import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.base.FirstFunction; + +public class SummaryMethodComboBox extends UIComboBox { + public static final String[] CALCULATE_ARRAY = {Toolkit.i18nText("Fine-Design_Chart_Data_Function_First"), Toolkit.i18nText("Fine-Design_Chart_Data_Function_Last"), + Toolkit.i18nText("Fine-Design_Chart_Data_Function_Sum"), Toolkit.i18nText("Fine-Design_Chart_Data_Function_Average"), + Toolkit.i18nText("Fine-Design_Chart_Data_Function_Max"), Toolkit.i18nText("Fine-Design_Chart_Data_Function_Min"), + Toolkit.i18nText("Fine-Design_Chart_Data_Function_Count")}; + public static final Class[] CLASS_ARRAY = {FirstFunction.class, NoneFunction.class, SumFunction.class, AverageFunction.class, + MaxFunction.class, MinFunction.class, CountFunction.class}; + + public SummaryMethodComboBox() { + super(CALCULATE_ARRAY); + setSelectedIndex(2); + } + + public void reset() { + this.setSelectedItem(Toolkit.i18nText("Fine-Design_Chart_Data_Function_Sum")); + } + + /** + * 更新公式选择. + */ + public void populateBean(AbstractDataFunction function) { + for (int i = 0; i < CLASS_ARRAY.length; i++) { + if (function != null && ComparatorUtils.equals(function.getClass(), CLASS_ARRAY[i])) { + setSelectedIndex(i); + break; + } + } + } + + /** + * 返回当前选择的公式 + */ + public AbstractDataFunction updateBean() { + try { + int selectIndex = getSelectedIndex(); + if (selectIndex >= 0 && selectIndex < CLASS_ARRAY.length) { + return (AbstractDataFunction) CLASS_ARRAY[selectIndex].newInstance(); + } + } catch (InstantiationException e) { + FineLoggerFactory.getLogger().error("Function Error"); + return null; + } catch (IllegalAccessException e) { + FineLoggerFactory.getLogger().error("Function Error"); + return null; + } + + return null; + } +} diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/ds_column_summary.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/ds_column_summary.png new file mode 100644 index 0000000000000000000000000000000000000000..1d7e13aa488b0a1e7d5335632a166d4f01c24c02 GIT binary patch literal 356 zcmV-q0h|7bP)Px$9!W$&R5(wi)5|JHQ547VkCMBAD1&_ zz`)c<6uG4kDMd?rbNWY|?Ao1kR%?CFZ~xZXRsOlEQvDlF(_X;-58Od4qdD!q40uI# zNin+^&VU!JVIDQuLoJ%n7>U?KJ36q4i6Y<$4LCt>g_3{`6=Kt##KPEkpT&CN2&)(=0?yD=at=PalTD2F9i_gn{4$9#19^P{O8)#S zJuCPNU<})Z#I5kH3?ORbGHqZ7GZ82Yh?)T$W+m@X`#2F2 definitionProviderMap = customDefinition.getDefinitionProviderMap(); + return getFieldNames(definitionProviderMap.get(plotType)); + } + return null; + } + + private static String[] getFieldNames(TopDefinitionProvider definition) { + if (definition == null) { + return null; + } + DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter(); + TableDataSource tableDataSource = adapter == null ? null : adapter.getBook(); + TableData tableData = null; + if (ComparatorUtils.equals(definition.getDataDefinitionType(), OneValueCDDefinition.DEFINITION_TYPE)) { + OneValueCDDefinition oneValueCDDefinition = (OneValueCDDefinition) definition; + tableData = oneValueCDDefinition.getTableData(); + } else if (ComparatorUtils.equals(definition.getDataDefinitionType(), MoreNameCDDefinition.DEFINITION_TYPE)) { + MoreNameCDDefinition moreNameCDDefinition = (MoreNameCDDefinition) definition; + tableData = moreNameCDDefinition.getTableData(); + } + if (tableData == null) { + return null; + } + return DesignTableDataManager.getSelectedColumnNames(tableDataSource, tableData.getName()); + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ChartConditionPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ChartConditionPane.java index af44b6331c..4085c7f10c 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ChartConditionPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ChartConditionPane.java @@ -7,6 +7,7 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.condition.LiteConditionPane; import com.fr.design.editor.ValueEditorPane; import com.fr.design.editor.ValueEditorPaneFactory; +import com.fr.design.editor.editor.Editor; import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.VariableResolver; import com.fr.design.gui.icombobox.UIComboBox; @@ -17,6 +18,7 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.type.ConditionKeyType; +import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; import javax.swing.DefaultComboBoxModel; @@ -79,7 +81,10 @@ public class ChartConditionPane extends LiteConditionPane { return this; } }); - conditionValuePane = ValueEditorPaneFactory.createAllValueEditorPane(); + Editor[] editors = ValueEditorPaneFactory.allEditors(); + ColSelectedWithSummaryMethodEditor colSelectedWithSummaryMethodEditor = new ColSelectedWithSummaryMethodEditor(); + Editor[] allEditors = ArrayUtils.add(editors,colSelectedWithSummaryMethodEditor); + conditionValuePane = ValueEditorPaneFactory.createValueEditorPane(allEditors,StringUtils.EMPTY,StringUtils.EMPTY); conditionKeyComboBox.setPreferredSize(new Dimension(175, conditionKeyComboBox.getPreferredSize().height)); conditionOPComboBox.setPreferredSize(new Dimension(80, 20)); Component[][] components = { diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java new file mode 100644 index 0000000000..6b6fe08cc7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java @@ -0,0 +1,89 @@ +package com.fr.design.chart.series.SeriesCondition; + +import com.fr.chart.chartattr.Chart; +import com.fr.data.DSColumnWithSummaryMethod; +import com.fr.design.chart.ChartDataHelper; +import com.fr.design.data.datapane.SummaryMethodComboBox; +import com.fr.design.editor.editor.Editor; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.plugin.chart.custom.type.CustomPlotType; +import java.awt.Dimension; +import javax.swing.DefaultComboBoxModel; + +public class ColSelectedWithSummaryMethodEditor extends Editor { + private UIComboBox columnNameComboBox = new UIComboBox(); + private SummaryMethodComboBox summaryMethodComboBox; + private static DefaultComboBoxModel columnNameComboBoxModel = new DefaultComboBoxModel<>(); + private static DefaultComboBoxModel summaryMethodComboBoxModel = new DefaultComboBoxModel<>(SummaryMethodComboBox.CALCULATE_ARRAY); + + public ColSelectedWithSummaryMethodEditor() { + this.setName(Toolkit.i18nText("Fine-Design_Chart_Summary_Array")); + this.setLayout(FRGUIPaneFactory.createLeftZeroLayout()); + if (columnNameComboBox == null) { + columnNameComboBox = new UIComboBox(); + } + columnNameComboBox.setPreferredSize(new Dimension(82, 20)); + this.add(columnNameComboBox); + summaryMethodComboBox = new SummaryMethodComboBox(); + summaryMethodComboBox.setModel(summaryMethodComboBoxModel); + summaryMethodComboBox.setPreferredSize(new Dimension(82, 20)); + this.add(summaryMethodComboBox); + columnNameComboBox.setModel(columnNameComboBoxModel); + } + + public static void refreshCommonChartFieldNames(Chart chart) { + String[] columnNames = ChartDataHelper.getCommonChartFieldNames(chart); + refreshComboBoxModel(columnNames); + } + + public static void refreshCustomChartTableFieldNames(Chart chart, CustomPlotType plotType) { + String[] columnNames = ChartDataHelper.getCustomChartTableFieldNames(chart, plotType); + refreshComboBoxModel(columnNames); + } + + private static void refreshComboBoxModel(String[] columnNames) { + if (columnNames != null) { + columnNameComboBoxModel.removeAllElements(); + for (String columnName : columnNames) { + columnNameComboBoxModel.addElement(columnName); + } + for (String method : SummaryMethodComboBox.CALCULATE_ARRAY) { + summaryMethodComboBoxModel.addElement(method); + } + } else { + columnNameComboBoxModel.removeAllElements(); + summaryMethodComboBoxModel.removeAllElements(); + } + } + + public String getIconName() { + return "ds_column_summary"; + } + + @Override + public DSColumnWithSummaryMethod getValue() { + if (columnNameComboBox.getSelectedItem() == null || summaryMethodComboBox.getSelectedItem() == null) { + return null; + } + DSColumnWithSummaryMethod dsColumnWithSummaryMethod = new DSColumnWithSummaryMethod(); + dsColumnWithSummaryMethod.setFieldName(columnNameComboBox.getSelectedItem().toString()); + dsColumnWithSummaryMethod.setDataFunction(summaryMethodComboBox.updateBean()); + return dsColumnWithSummaryMethod; + } + + @Override + public void setValue(DSColumnWithSummaryMethod value) { + if (value != null) { + columnNameComboBox.setSelectedItem(value.getFieldName()); + summaryMethodComboBox.setSelectedItem(value.getDataFunction()); + } + } + + @Override + public boolean accept(Object object) { + return object instanceof DSColumnWithSummaryMethod; + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java index 4bc363306c..36bc56d6b8 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java @@ -5,6 +5,7 @@ import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.Plot; import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.series.SeriesCondition.ColSelectedWithSummaryMethodEditor; import com.fr.design.dialog.BasicPane; import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.ChartEditPane; @@ -112,6 +113,7 @@ public class ChartOtherPane extends AbstractChartAttrPane { interactivePane.populateBean(chart); if (ChartOtherPane.this.isHaveCondition()) { VanChartRichEditorPane.refreshCommonChartFieldNames(chart); + ColSelectedWithSummaryMethodEditor.refreshCommonChartFieldNames(chart); conditionAttrPane.populateBean(chart); } } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/CalculateComboBox.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/CalculateComboBox.java index a1ad223125..61a906a3f2 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/CalculateComboBox.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/CalculateComboBox.java @@ -1,17 +1,6 @@ package com.fr.design.mainframe.chart.gui.data; -import com.fr.data.util.function.AbstractDataFunction; -import com.fr.data.util.function.AverageFunction; -import com.fr.data.util.function.CountFunction; -import com.fr.data.util.function.MaxFunction; -import com.fr.data.util.function.MinFunction; -import com.fr.data.util.function.NoneFunction; -import com.fr.data.util.function.SumFunction; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.i18n.Toolkit; -import com.fr.general.ComparatorUtils; -import com.fr.log.FineLoggerFactory; -import com.fr.plugin.chart.base.FirstFunction; +import com.fr.design.data.datapane.SummaryMethodComboBox; /** @@ -20,53 +9,11 @@ import com.fr.plugin.chart.base.FirstFunction; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2013-1-8 上午09:52:15 */ -public class CalculateComboBox extends UIComboBox { - - public static final String[] CALCULATE_ARRAY = {Toolkit.i18nText("Fine-Design_Chart_Data_Function_First"), Toolkit.i18nText("Fine-Design_Chart_Data_Function_Last"), - Toolkit.i18nText("Fine-Design_Chart_Data_Function_Sum"), Toolkit.i18nText("Fine-Design_Chart_Data_Function_Average"), - Toolkit.i18nText("Fine-Design_Chart_Data_Function_Max"), Toolkit.i18nText("Fine-Design_Chart_Data_Function_Min"), - Toolkit.i18nText("Fine-Design_Chart_Data_Function_Count")}; - public static final Class[] CLASS_ARRAY = {FirstFunction.class, NoneFunction.class, SumFunction.class, AverageFunction.class, - MaxFunction.class, MinFunction.class, CountFunction.class}; +public class CalculateComboBox extends SummaryMethodComboBox { + public static final String[] CALCULATE_ARRAY = SummaryMethodComboBox.CALCULATE_ARRAY; + public static final Class[] CLASS_ARRAY = SummaryMethodComboBox.CLASS_ARRAY; public CalculateComboBox() { - super(CALCULATE_ARRAY); - setSelectedIndex(2); - } - - public void reset() { - this.setSelectedItem(Toolkit.i18nText("Fine-Design_Chart_Data_Function_Sum")); - } - - /** - * 更新公式选择. - */ - public void populateBean(AbstractDataFunction function) { - for (int i = 0; i < CLASS_ARRAY.length; i++) { - if (function != null && ComparatorUtils.equals(function.getClass(), CLASS_ARRAY[i])) { - setSelectedIndex(i); - break; - } - } - } - - /** - * 返回当前选择的公式 - */ - public AbstractDataFunction updateBean() { - try { - int selectIndex = getSelectedIndex(); - if (selectIndex >= 0 && selectIndex < CLASS_ARRAY.length) { - return (AbstractDataFunction) CLASS_ARRAY[selectIndex].newInstance(); - } - } catch (InstantiationException e) { - FineLoggerFactory.getLogger().error("Function Error"); - return null; - } catch (IllegalAccessException e) { - FineLoggerFactory.getLogger().error("Function Error"); - return null; - } - - return null; + super(); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomPlotConditionAttrTabPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomPlotConditionAttrTabPane.java index 4cb5c652f6..8c20568578 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomPlotConditionAttrTabPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomPlotConditionAttrTabPane.java @@ -1,6 +1,7 @@ package com.fr.van.chart.custom.other; import com.fr.chart.chartattr.Chart; +import com.fr.design.chart.series.SeriesCondition.ColSelectedWithSummaryMethodEditor; import com.fr.design.dialog.BasicPane; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.custom.CustomPlotFactory; @@ -91,6 +92,7 @@ public class VanChartCustomPlotConditionAttrTabPane extends VanChartCustomPlotTa CustomPlotType plotType = CustomPlotFactory.getCustomType(chartPlot); VanChartRichEditorPane.refreshCustomChartTableFieldNames(chart, plotType); + ColSelectedWithSummaryMethodEditor.refreshCustomChartTableFieldNames(chart,plotType); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomStylePane.java index da4fa2534c..234f2ee1dc 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomStylePane.java @@ -1,6 +1,7 @@ package com.fr.van.chart.custom.style; import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.chart.series.SeriesCondition.ColSelectedWithSummaryMethodEditor; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.gui.style.series.ChartSeriesPane; @@ -75,6 +76,7 @@ public class VanChartCustomStylePane extends VanChartStylePane { public void refreshTableFieldNames(VanChartPlot plot) { CustomPlotType plotType = CustomPlotFactory.getCustomType(plot); VanChartRichEditorPane.refreshCustomChartTableFieldNames(getChart(), plotType); + ColSelectedWithSummaryMethodEditor.refreshCustomChartTableFieldNames(getChart(), plotType); } public void refreshTableFieldNames() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java index 7ca77a9fc2..603b5af0a2 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java @@ -1,6 +1,7 @@ package com.fr.van.chart.designer.style; import com.fr.chart.chartattr.Plot; +import com.fr.design.chart.series.SeriesCondition.ColSelectedWithSummaryMethodEditor; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.ChartEditPane; @@ -88,6 +89,7 @@ public class VanChartStylePane extends ChartStylePane { public void refreshTableFieldNames() { VanChartRichEditorPane.refreshCommonChartFieldNames(getChart()); + ColSelectedWithSummaryMethodEditor.refreshCommonChartFieldNames(getChart()); } public void registerChartEditPane(ChartEditPane currentEditPane) { From a6238d0f61454d40b9affbcbe2794ff4fe052e72 Mon Sep 17 00:00:00 2001 From: pengda Date: Sun, 24 Apr 2022 17:48:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-68363=20=E6=9D=A1=E4=BB=B6=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E7=B3=BB=E5=88=97=E9=97=B4=E5=80=BC=E7=9A=84=E6=AF=94?= =?UTF-8?q?=E8=BE=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/data/datapane/SummaryMethodComboBox.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java b/designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java index bd57e7ea2a..7aee00e24d 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java @@ -13,6 +13,12 @@ import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.base.FirstFunction; +/** + * 图表数据汇总方式下拉框 + * + * 支持首个,最后一个,求和,平均,最大值,最小值,个数 + * + */ public class SummaryMethodComboBox extends UIComboBox { public static final String[] CALCULATE_ARRAY = {Toolkit.i18nText("Fine-Design_Chart_Data_Function_First"), Toolkit.i18nText("Fine-Design_Chart_Data_Function_Last"), Toolkit.i18nText("Fine-Design_Chart_Data_Function_Sum"), Toolkit.i18nText("Fine-Design_Chart_Data_Function_Average"),