From e2fb52733f43cd8d38cceab1d7a15bdae0be25a8 Mon Sep 17 00:00:00 2001 From: zheng Date: Thu, 13 Sep 2018 21:08:28 +0800 Subject: [PATCH 1/4] =?UTF-8?q?CHART-2912=20&&=20CHART-2969=20=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E6=8E=A5=E5=8F=A3=20=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/AbstractTableDataContentPane.java | 14 +- .../table/SeriesNameUseFieldNamePane.java | 13 +- .../AbstractExtendedChartReportDataPane.java | 33 +- .../AbstractExtendedChartTableDataPane.java | 74 ++-- .../ExtendedCustomFieldComboBoxPane.java | 381 ++++++++++++++++++ 5 files changed, 476 insertions(+), 39 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java index 75c7f47b8f..1fff1bfe36 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java @@ -5,8 +5,8 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.gui.icombobox.UIComboBox; -import javax.swing.*; -import java.awt.*; +import javax.swing.JSeparator; +import java.awt.Dimension; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.List; @@ -46,8 +46,8 @@ public abstract class AbstractTableDataContentPane extends BasicBeanPane extends AbstractReportDataContentPane { + private TinyFormulaPane seriesPane; + private TinyFormulaPane valuePane; + public AbstractExtendedChartReportDataPane() { initComponents(); } @@ -30,11 +35,18 @@ public abstract class AbstractExtendedChartReportDataPane fieldList = new ArrayList(); + if (hasCustomFieldPane()) { + fieldList.add(new ExtendedField(seriesPane.updateBean())); + fieldList.add(new ExtendedField(valuePane.updateBean())); + } + dataConfig.setCustomFields(fieldList); chart.setFilterDefinition(dataSet); } diff --git a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java index f9beeca2bd..b49d34ec86 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java @@ -11,11 +11,11 @@ import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.general.GeneralUtils; +import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Component; -import java.awt.Dimension; import java.util.Arrays; import java.util.List; @@ -24,7 +24,7 @@ import java.util.List; */ public abstract class AbstractExtendedChartTableDataPane extends AbstractTableDataContentPane { - private CalculateComboBox function; + private ExtendedCustomFieldComboBoxPane customFieldComboBoxPane; public AbstractExtendedChartTableDataPane() { initComponents(); @@ -37,28 +37,27 @@ public abstract class AbstractExtendedChartTableDataPane { + private static final String[] HEADS = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Field_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Summary_Method")}; + + private UseFieldValuePane useFieldValuePane; + private CustomFieldNamePane customFieldNamePane; + + private List fieldList = new ArrayList(); + + @Override + protected void initLayout() { + this.setLayout(new BorderLayout(0, 6)); + JPanel northPane = new JPanel(new BorderLayout()); + northPane.add(jcb, BorderLayout.CENTER); + UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From")); + label.setPreferredSize(new Dimension(82, 20)); + northPane.add(label, BorderLayout.WEST); + this.add(northPane, BorderLayout.NORTH); + this.add(cardPane, BorderLayout.CENTER); + } + + @Override + protected List> initPaneList() { + useFieldValuePane = new UseFieldValuePane(); + customFieldNamePane = new CustomFieldNamePane(); + List> list = new ArrayList>(); + list.add(useFieldValuePane); + list.add(customFieldNamePane); + return list; + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } + + public void checkBoxUse(boolean hasUse) { + jcb.setEnabled(hasUse); + useFieldValuePane.checkBoxUse(hasUse); + } + + public void clearAllBoxList() { + useFieldValuePane.clearAllBoxList(); + fieldList.clear(); + } + + protected void refreshBoxListWithSelectTableData(List columnNameList) { + useFieldValuePane.refreshBoxListWithSelectTableData(columnNameList); + fieldList = columnNameList; + } + + @Override + public void populateBean(AbstractDataConfig ob) { + if (ob.isCustomName()) { + customFieldNamePane.populateBean(ob); + jcb.setSelectedIndex(1); + } else { + useFieldValuePane.populateBean(ob); + jcb.setSelectedIndex(0); + } + } + + @Override + public void updateBean(AbstractDataConfig ob) { + if (jcb.getSelectedIndex() == 0) { + ob.setCustomName(false); + useFieldValuePane.updateBean(ob); + } else { + ob.setCustomName(true); + customFieldNamePane.updateBean(ob); + } + } + + private class UseFieldValuePane extends FurtherBasicBeanPane { + private UIComboBox series; + private UIComboBox value; + private CalculateComboBox function; + + private UseFieldValuePane() { + initComponents(); + } + + private void initComponents() { + + series = new UIComboBox(); + value = new UIComboBox(); + function = new CalculateComboBox(); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel("series", SwingConstants.LEFT), series}, + new Component[]{new UILabel("value", SwingConstants.LEFT), value}, + new Component[]{new UILabel("function", SwingConstants.LEFT), function}, + }; + + double p = TableLayout.PREFERRED; + double[] columnSize = {76, 120}; + double[] rowSize = {p, p, p}; + + JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + + this.setLayout(new BorderLayout(0, 6)); + this.add(panel, BorderLayout.CENTER); + } + + public void checkBoxUse(boolean hasUse) { + series.setEnabled(hasUse); + value.setEnabled(hasUse); + function.setEnabled(hasUse); + } + + public void clearAllBoxList() { + AbstractTableDataContentPane.clearBoxItems(series); + AbstractTableDataContentPane.clearBoxItems(value); + } + + public void refreshBoxListWithSelectTableData(List columnNameList) { + AbstractTableDataContentPane.refreshBoxItems(series, columnNameList); + AbstractTableDataContentPane.refreshBoxItems(value, columnNameList); + } + + @Override + public void populateBean(AbstractDataConfig ob) { + List list = ob.getCustomFields(); + if (list.size() == 2) { + series.setSelectedItem(list.get(0).getFieldName()); + value.setSelectedItem(list.get(1).getFieldName()); + function.populateBean((AbstractDataFunction) list.get(1).getDataFunction()); + } + } + + @Override + public void updateBean(AbstractDataConfig ob) { + List list = new ArrayList(); + + list.add(new ExtendedField(Utils.objectToString(series.getSelectedItem()))); + ExtendedField field = new ExtendedField(Utils.objectToString(value.getSelectedItem())); + field.setDataFunction(function.updateBean()); + list.add(field); + + ob.setCustomFields(list); + } + + @Override + public boolean accept(Object ob) { + return true; + } + + @Override + public void reset() { + } + + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Value"); + } + + @Override + public AbstractDataConfig updateBean() { + return null; + } + } + + private class CustomFieldNamePane extends FurtherBasicBeanPane { + + private UICorrelationPane correlationPane; + + public CustomFieldNamePane() { + initComponents(); + } + + private void initComponents() { + + correlationPane = new UICorrelationPane(HEADS) { + @Override + protected ActionListener getAddButtonListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + tablePane.addLine(new String[]{StringUtils.EMPTY, StringUtils.EMPTY, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}); + fireTargetChanged(); + } + }; + } + + public UITableEditor createUITableEditor() { + return new Editor() { + @Override + protected UICorrelationPane getParent() { + return correlationPane; + } + }; + } + }; + + this.setLayout(new BorderLayout()); + this.add(correlationPane, BorderLayout.CENTER); + + } + + @Override + public void populateBean(AbstractDataConfig ob) { + List customFields = ob.getCustomFields(); + + List list = new ArrayList(); + for (ExtendedField field : customFields) { + String[] array = {field.getFieldName(), field.getCustomName(), SeriesNameUseFieldNamePane.getFunctionString(field.getDataFunction())}; + list.add(array); + } + correlationPane.populateBean(list); + } + + + @Override + public void updateBean(AbstractDataConfig ob) { + List list = correlationPane.updateBean(); + + List customFields = new ArrayList(); + for (Object[] line : list) { + ExtendedField field = new ExtendedField(Utils.objectToString(line[0])); + field.setCustomName(Utils.objectToString(line[1])); + if (line.length > 2) { + field.setDataFunction(SeriesNameUseFieldNamePane.getFcuntionByName(Utils.objectToString(line[2]))); + } + customFields.add(field); + } + + ob.setCustomFields(customFields); + + } + + @Override + public boolean accept(Object ob) { + return true; + } + + @Override + public void reset() { + } + + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Name"); + } + + @Override + public AbstractDataConfig updateBean() { + return null; + } + } + + private abstract class Editor extends UITableEditor { + private JComponent editorComponent; + + protected abstract UICorrelationPane getParent(); + + @Override + public Object getCellEditorValue() { + if (editorComponent instanceof UIComboBox) { + return ((UIComboBox) editorComponent).getSelectedItem(); + } else if (editorComponent instanceof UITextField) { + return ((UITextField) editorComponent).getText(); + } else if (editorComponent instanceof CalculateComboBox) { + return ((CalculateComboBox) editorComponent).getSelectedItem(); + } + return super.getCellEditorValue(); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, final int row, int column) { + + switch (column) { + case 0: + editorComponent = createComboBoxEdit(row, value); + break; + case 1: + editorComponent = createTextEdit(value); + break; + default: + editorComponent = createCalculateComboBox(value); + break; + + } + return editorComponent; + } + + private void setDefaultName(int row) { + UITable table = getParent().getTable(); + Object object = table.getValueAt(row, 0); + if (object != null) { + table.setValueAt(object, row, 1); + } + } + + private UIComboBox createComboBoxEdit(final int row, Object value) { + UIComboBox uiComboBox = new UIComboBox(fieldList.toArray()); + + uiComboBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + getParent().stopCellEditing(); + getParent().fireTargetChanged(); + setDefaultName(row); + } + }); + + if (value != null && StringUtils.isNotEmpty(value.toString())) { + uiComboBox.getModel().setSelectedItem(value); + } else { + uiComboBox.getModel().setSelectedItem(value); + } + + return uiComboBox; + } + + private UITextField createTextEdit(Object value) { + UITextField uiTextField = new UITextField(); + if (value != null) { + uiTextField.setText(value.toString()); + } + + uiTextField.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + getParent().fireTargetChanged(); + } + }); + + return uiTextField; + } + + private CalculateComboBox createCalculateComboBox(Object value) { + CalculateComboBox calculateComboBox = new CalculateComboBox(); + if (value != null) { + calculateComboBox.setSelectedItem(value); + } + calculateComboBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + getParent().stopCellEditing(); + getParent().fireTargetChanged(); + } + }); + return calculateComboBox; + } + } + +} From 9e0941cfea54c8b4b915cd5c482419cab63960fb Mon Sep 17 00:00:00 2001 From: zheng Date: Thu, 13 Sep 2018 21:17:41 +0800 Subject: [PATCH 2/4] update --- .../fr/extended/chart/AbstractExtendedChartTableDataPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java index b49d34ec86..19a7b8e16b 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java @@ -43,7 +43,7 @@ public abstract class AbstractExtendedChartTableDataPane Date: Thu, 13 Sep 2018 21:44:32 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extended/chart/AbstractExtendedChartReportDataPane.java | 6 +++--- .../fr/extended/chart/ExtendedCustomFieldComboBoxPane.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartReportDataPane.java b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartReportDataPane.java index cfc0886a46..82ebbda6e8 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartReportDataPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartReportDataPane.java @@ -43,14 +43,14 @@ public abstract class AbstractExtendedChartReportDataPane Date: Fri, 14 Sep 2018 09:29:57 +0800 Subject: [PATCH 4/4] =?UTF-8?q?static=E6=96=B9=E6=B3=95=E6=8B=BF=E5=87=BA?= =?UTF-8?q?=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/AbstractTableDataContentPane.java | 25 ++---- .../chart/gui/data/table/DataPaneHelper.java | 84 +++++++++++++++++++ .../table/SeriesNameUseFieldNamePane.java | 34 +------- .../table/SeriesNameUseFieldValuePane.java | 39 +++------ .../ExtendedCustomFieldComboBoxPane.java | 15 ++-- .../component/ComboBoxWithButtonPane.java | 20 +---- 6 files changed, 111 insertions(+), 106 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java index 1fff1bfe36..df5d99fbdb 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java @@ -46,32 +46,17 @@ public abstract class AbstractTableDataContentPane extends BasicBeanPane list = new ArrayList(); for (int i = 0; i < chartSummaryColumnArray.length; i++) { ChartSummaryColumn column = chartSummaryColumnArray[i]; - String[] nameArray = {column.getName(), column.getCustomName(), getFunctionString(column.getFunction())}; + String[] nameArray = {column.getName(), column.getCustomName(), DataPaneHelper.getFunctionString(column.getFunction())}; list.add(nameArray); } seriesDataPane.populateBean(list); @@ -215,16 +212,6 @@ public class SeriesNameUseFieldNamePane extends FurtherBasicBeanPane list = new ArrayList(); for (ExtendedField field : customFields) { - String[] array = {field.getFieldName(), field.getCustomName(), SeriesNameUseFieldNamePane.getFunctionString(field.getDataFunction())}; + String[] array = {field.getFieldName(), field.getCustomName(), DataPaneHelper.getFunctionString(field.getDataFunction())}; list.add(array); } correlationPane.populateBean(list); @@ -255,7 +254,7 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane 2) { - field.setDataFunction(SeriesNameUseFieldNamePane.getFcuntionByName(Utils.objectToString(line[2]))); + field.setDataFunction(DataPaneHelper.getFunctionByName(Utils.objectToString(line[2]))); } customFields.add(field); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/data/data/component/ComboBoxWithButtonPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/data/data/component/ComboBoxWithButtonPane.java index 75ad743def..c00109db92 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/data/data/component/ComboBoxWithButtonPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/data/data/component/ComboBoxWithButtonPane.java @@ -4,6 +4,7 @@ import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -62,29 +63,14 @@ public abstract class ComboBoxWithButtonPane extends JPanel { * 刷新Box的选项. */ public void refreshBoxItems(java.util.List list) { - if(comboBoxName == null) { - return; - } - - Object ob = comboBoxName.getSelectedItem(); - comboBoxName.removeAllItems(); - - int length = list.size(); - for(int i = 0; i < length; i++) { - comboBoxName.addItem(list.get(i)); - } - - comboBoxName.getModel().setSelectedItem(ob); + DataPaneHelper.refreshBoxItems(comboBoxName, list); } /** * 清空box里所有东西 */ public void clearBoxItems(){ - if(comboBoxName == null){ - return; - } - comboBoxName.removeAllItems(); + DataPaneHelper.clearBoxItems(comboBoxName); }