Browse Source

Pull request #8669: REPORT-68363 条件属性系列间值的比较

Merge in DESIGN/design from ~PENGDA/design:feature/x to feature/x

* commit 'a6238d0f61454d40b9affbcbe2794ff4fe052e72':
  REPORT-68363 条件属性系列间值的比较
  REPORT-68363 条件属性系列间值的比较
feature/x
ju 3 years ago
parent
commit
925cb37c21
  1. 70
      designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java
  2. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/ds_column_summary.png
  3. 69
      designer-chart/src/main/java/com/fr/design/chart/ChartDataHelper.java
  4. 7
      designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ChartConditionPane.java
  5. 89
      designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java
  6. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java
  7. 63
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/CalculateComboBox.java
  8. 2
      designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomPlotConditionAttrTabPane.java
  9. 2
      designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomStylePane.java
  10. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java

70
designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java

@ -0,0 +1,70 @@
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;
}
}

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/ds_column_summary.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

69
designer-chart/src/main/java/com/fr/design/chart/ChartDataHelper.java

@ -0,0 +1,69 @@
package com.fr.design.chart;
import com.fr.base.TableData;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartdata.MoreNameCDDefinition;
import com.fr.chart.chartdata.OneValueCDDefinition;
import com.fr.data.TableDataSource;
import com.fr.design.DesignModelAdapter;
import com.fr.design.data.DesignTableDataManager;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.custom.CustomDefinition;
import com.fr.plugin.chart.custom.type.CustomPlotType;
import com.fr.van.chart.designer.PlotFactory;
import java.util.Map;
public class ChartDataHelper {
public static String[] getCommonChartFieldNames(Chart chart) {
if (chart == null) {
return null;
}
Plot plot = chart.getPlot();
if (plot == null) {
return null;
}
if (!PlotFactory.plotSupportAddTableField(plot)) {
return null;
}
TopDefinitionProvider definition = chart.getFilterDefinition();
return getFieldNames(definition);
}
public static String[] getCustomChartTableFieldNames(Chart chart, CustomPlotType plotType) {
if (chart == null || plotType == null) {
return null;
}
TopDefinitionProvider filterDefinition = chart.getFilterDefinition();
if (filterDefinition instanceof CustomDefinition) {
CustomDefinition customDefinition = (CustomDefinition) filterDefinition;
Map<CustomPlotType, TopDefinitionProvider> 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());
}
}

7
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<CommonCondition> {
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 = {

89
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<DSColumnWithSummaryMethod> {
private UIComboBox columnNameComboBox = new UIComboBox();
private SummaryMethodComboBox summaryMethodComboBox;
private static DefaultComboBoxModel<String> columnNameComboBoxModel = new DefaultComboBoxModel<>();
private static DefaultComboBoxModel<String> 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;
}
}

2
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);
}
}

63
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();
}
}

2
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);
}
}

2
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() {

2
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) {

Loading…
Cancel
Save