From d8659e6b51e8822fd41747ec709dd578ecc570bd Mon Sep 17 00:00:00 2001 From: zheng Date: Wed, 22 May 2019 14:44:35 +0800 Subject: [PATCH] =?UTF-8?q?CHART-4027=20=E5=9B=BE=E8=A1=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/chartx/AbstractChartDataPane.java | 58 +++ .../fr/design/chartx/GanttChartDataPane.java | 39 ++ .../chartx/MultiCategoryChartDataPane.java | 43 ++ .../chartx/WordCloundChartDataPane.java | 20 + .../AbstractCustomFieldComboBoxPane.java | 368 ++++++++++++++++++ .../component/AbstractMultiComponentPane.java | 168 ++++++++ .../component/CustomFieldComboBoxPane.java | 58 +++ .../chartx/component/MultiComboBoxPane.java | 32 ++ .../component/MultiTinyFormulaPane.java | 31 ++ .../fields/AbstractCellDataFieldsPane.java | 93 +++++ .../fields/AbstractDataSetFieldsPane.java | 142 +++++++ ...tractDataSetFieldsWithCustomFieldPane.java | 60 +++ .../diff/MultiCategoryCellDataFieldsPane.java | 65 ++++ .../diff/MultiCategoryDataSetFieldsPane.java | 69 ++++ .../fr/design/chartx/single/CellDataPane.java | 56 +++ .../fr/design/chartx/single/DataSetPane.java | 121 ++++++ .../design/chartx/single/SingleDataPane.java | 90 +++++ .../ExtendedCustomFieldComboBoxPane.java | 322 +-------------- .../ColumnIndependentVanChartInterface.java | 8 + 19 files changed, 1542 insertions(+), 301 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/MultiCategoryChartDataPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/WordCloundChartDataPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/single/CellDataPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java create mode 100644 designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java diff --git a/designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java new file mode 100644 index 0000000000..61359d91b7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java @@ -0,0 +1,58 @@ +package com.fr.design.chartx; + +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chartx.data.ChartDataDefinitionProvider; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.plugin.chart.vanchart.VanChart; + +import java.awt.BorderLayout; + +/** + * Created by shine on 2019/4/15. + */ +public abstract class AbstractChartDataPane extends ChartDataPane { + + public AbstractChartDataPane(AttributeChangeListener listener) { + super(listener); + } + + protected abstract void populate(T t); + + protected abstract T update(); + + @Override + public void populate(ChartCollection collection) { + if (collection == null) { + return; + } + VanChart chart = collection.getSelectedChart(VanChart.class); + if (chart == null) { + return; + } + + this.removeAll(); + this.add(createContentPane(), BorderLayout.CENTER); + + ChartDataDefinitionProvider dataSetCollection = chart.getChartDataDefinition(); + + populate((T) dataSetCollection); + + this.initAllListeners(); + this.validate(); + } + + + @Override + public void update(ChartCollection collection) { + if (collection == null) { + return; + } + VanChart chart = collection.getSelectedChart(VanChart.class); + if (chart == null) { + return; + } + + chart.setChartDataDefinition(update()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java new file mode 100644 index 0000000000..e418e0c300 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java @@ -0,0 +1,39 @@ +package com.fr.design.chartx; + +import com.fr.chartx.data.GanttChartDataDefinition; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.van.chart.map.designer.VanChartGroupPane; + +import javax.swing.JPanel; + +/** + * Created by shine on 2019/5/22. + */ +public class GanttChartDataPane extends AbstractChartDataPane { + + private MultiCategoryChartDataPane dataPane; + private MultiCategoryChartDataPane linkPane; + + @Override + protected JPanel createContentPane() { + dataPane = new MultiCategoryChartDataPane(listener); + linkPane = new MultiCategoryChartDataPane(listener); + return new VanChartGroupPane(new String[]{"data", "link"}, new JPanel[]{dataPane, linkPane}) { + }; + } + + public GanttChartDataPane(AttributeChangeListener listener) { + super(listener); + } + + @Override + protected void populate(GanttChartDataDefinition ganttChartDataDefinition) { + dataPane.populate(ganttChartDataDefinition.getDataDefinition()); + linkPane.populate(ganttChartDataDefinition.getLinkDefinition()); + } + + @Override + protected GanttChartDataDefinition update() { + return null; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/MultiCategoryChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/MultiCategoryChartDataPane.java new file mode 100644 index 0000000000..721fc8480e --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/MultiCategoryChartDataPane.java @@ -0,0 +1,43 @@ +package com.fr.design.chartx; + +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.design.chartx.fields.diff.MultiCategoryCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.MultiCategoryDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; +import com.fr.design.gui.frpane.AttributeChangeListener; + +import javax.swing.JPanel; + +/** + * Created by shine on 2019/5/22. + */ +public class MultiCategoryChartDataPane extends AbstractChartDataPane { + + private SingleDataPane singleDataPane; + + public MultiCategoryChartDataPane(AttributeChangeListener listener) { + super(listener); + } + + @Override + protected void populate(AbstractDataDefinition dataDefinition) { + singleDataPane.populateBean(dataDefinition); + } + + @Override + protected AbstractDataDefinition update() { + return singleDataPane.updateBean(); + } + + @Override + protected JPanel createContentPane() { + singleDataPane = createSingleDataPane(); + return singleDataPane; + } + + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane()); + } + + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/WordCloundChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/WordCloundChartDataPane.java new file mode 100644 index 0000000000..2f3bd39a00 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/WordCloundChartDataPane.java @@ -0,0 +1,20 @@ +package com.fr.design.chartx; + +import com.fr.design.chartx.fields.diff.MultiCategoryCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.MultiCategoryDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; +import com.fr.design.gui.frpane.AttributeChangeListener; + +/** + * Created by shine on 2019/5/22. + */ +public class WordCloundChartDataPane extends MultiCategoryChartDataPane { + public WordCloundChartDataPane(AttributeChangeListener listener) { + super(listener); + } + + @Override + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java new file mode 100644 index 0000000000..8453452d25 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java @@ -0,0 +1,368 @@ +package com.fr.design.chartx.component; + +import com.fr.data.util.function.AbstractDataFunction; +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.frpane.UIComboBoxPane; +import com.fr.design.gui.frpane.UICorrelationPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itable.UITable; +import com.fr.design.gui.itable.UITableEditor; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; +import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; +import com.fr.extended.chart.UIComboBoxWithNone; +import com.fr.general.GeneralUtils; +import com.fr.stable.StringUtils; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2018/9/12. + * 系列名使用字段名or字段值的抽象的pane 支持多种属性结构的存取 + */ +public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane { + 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 AbstractUseFieldValuePane useFieldValuePane; + + private AbstractCustomFieldNamePane 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(ChartDataPane.LABEL_WIDTH, 20)); + northPane.add(label, BorderLayout.WEST); + this.add(northPane, BorderLayout.NORTH); + this.add(cardPane, BorderLayout.CENTER); + } + + @Override + protected List> initPaneList() { + useFieldValuePane = createUseFieldValuePane(); + customFieldNamePane = createCustomFieldNamePane(); + List> list = new ArrayList>(); + list.add(useFieldValuePane); + list.add(customFieldNamePane); + return list; + } + + protected abstract AbstractUseFieldValuePane createUseFieldValuePane(); + + protected abstract AbstractCustomFieldNamePane createCustomFieldNamePane(); + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } + + protected boolean valueComboBoxHasNone() { + return false; + } + + public void checkBoxUse(boolean hasUse) { + jcb.setEnabled(hasUse); + useFieldValuePane.checkBoxUse(hasUse); + } + + public void clearAllBoxList() { + useFieldValuePane.clearAllBoxList(); + fieldList.clear(); + } + + public void refreshBoxListWithSelectTableData(List columnNameList) { + useFieldValuePane.refreshBoxListWithSelectTableData(columnNameList); + fieldList = columnNameList; + } + + protected void populateCustomFieldNamePane(T t) { + customFieldNamePane.populateBean(t); + } + + protected void updateCustomFieldNamePane(T t) { + customFieldNamePane.updateBean(t); + } + + protected void populateUseFieldValuePane(T t) { + useFieldValuePane.populateBean(t); + } + + protected void updateUseFieldValuePane(T t) { + useFieldValuePane.updateBean(t); + } + + protected abstract class AbstractUseFieldValuePane extends FurtherBasicBeanPane { + private UIComboBox series; + private UIComboBox value; + private CalculateComboBox function; + + public AbstractUseFieldValuePane() { + initComponents(); + } + + private void initComponents() { + + series = new UIComboBox(); + value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox(); + + function = new CalculateComboBox(); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(HEADS[1], SwingConstants.LEFT), series}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Value"), SwingConstants.LEFT), value}, + new Component[]{new UILabel(HEADS[2], SwingConstants.LEFT), function}, + }; + + double p = TableLayout.PREFERRED; + double[] columnSize = {78, 122}; + 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() { + DataPaneHelper.clearBoxItems(series); + DataPaneHelper.clearBoxItems(value); + } + + public void refreshBoxListWithSelectTableData(List columnNameList) { + DataPaneHelper.refreshBoxItems(series, columnNameList); + DataPaneHelper.refreshBoxItems(value, columnNameList); + } + + protected void populateSeries(String item) { + series.setSelectedItem(item); + } + + protected void populateValue(String item) { + value.setSelectedItem(item); + } + + protected void populateFunction(AbstractDataFunction _function) { + function.populateBean(_function); + } + + protected String updateSeries() { + return GeneralUtils.objectToString(series.getSelectedItem()); + } + + protected String updateValue() { + return GeneralUtils.objectToString(value.getSelectedItem()); + } + + protected AbstractDataFunction updateFunction() { + return function.updateBean(); + } + + @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 T updateBean() { + return null; + } + } + + protected abstract class AbstractCustomFieldNamePane extends FurtherBasicBeanPane { + + private UICorrelationPane correlationPane; + + public AbstractCustomFieldNamePane() { + 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); + + } + + + protected void populate(List list) { + correlationPane.populateBean(list); + } + + protected List update() { + return correlationPane.updateBean(); + } + + + @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 T 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; + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java new file mode 100644 index 0000000000..008a7d91cb --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java @@ -0,0 +1,168 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.BoldFontTextLabel; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.general.IOUtils; + +import javax.swing.BoxLayout; +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + + +/** + * Created by shine on 2019/4/10. + * 一列组件 可增可删 + */ +public abstract class AbstractMultiComponentPane extends JPanel { + private static final int COM_W = 96; + private static final int H = 20; + private static final int ICON_W = 20; + + private JPanel boxPane; + private UIButton addButton; + + private T firstFieldComponent; + + private List categoryComponentList = new ArrayList(); + + + protected abstract T createFirstFieldComponent(); + + protected abstract T createOtherFieldComponent(); + + protected abstract void populateField(T component, ColumnField field); + + protected abstract void updateField(T component, ColumnField field); + + public AbstractMultiComponentPane() { + + UILabel label = new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Category")); + label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); + + firstFieldComponent = createFirstFieldComponent(); + firstFieldComponent.setPreferredSize(new Dimension(COM_W, H)); + + addButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); + addButton.setPreferredSize(new Dimension(ICON_W, H)); + addButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (canAdd()) { + addNewComboBox(); + } + } + }); + + final JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); + + panel.add(label); + panel.add(firstFieldComponent); + panel.add(addButton); + + boxPane = new JPanel(); + boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS)); + + this.setLayout(new BorderLayout(4, 0)); + this.add(panel, BorderLayout.NORTH); + this.add(boxPane, BorderLayout.CENTER); + } + + private JPanel addComboBoxAndButtonToBox(T uiComboBox, UIButton uiButton) { + final JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); + + panel.add(uiComboBox); + panel.add(uiButton); + + boxPane.add(panel); + categoryComponentList.add(uiComboBox); + + return panel; + } + + private void addNewComboBox() { + final T comboBox = createOtherFieldComponent(); + comboBox.setPreferredSize(new Dimension(COM_W, H)); + + UIButton delButton = new UIButton(IOUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); + delButton.setPreferredSize(new Dimension(ICON_W, H)); + + final JPanel panel = addComboBoxAndButtonToBox(comboBox, delButton); + + delButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + boxPane.remove(panel); + categoryComponentList.remove(comboBox); + checkAddButton(); + relayoutPane(); + } + }); + + relayoutPane(); + checkAddButton(); + } + + private void relayoutPane() { + this.revalidate(); + } + + private void checkAddButton() { + addButton.setEnabled(canAdd()); + } + + private boolean canAdd() { + return categoryComponentList.size() < 3; + } + + public List componentList() { + List list = new ArrayList<>(categoryComponentList); + list.add(firstFieldComponent); + return list; + } + + public void populate(List categoryList) { + int comboBoxSize = categoryComponentList.size(), + len = categoryList.size(); + + if (len > 0) { + populateField(firstFieldComponent, categoryList.get(0)); + } + + for (int i = 1; i < len; i++) { + if (i > comboBoxSize) { + addNewComboBox(); + } + T comboBox = categoryComponentList.get(i - 1); + populateField(comboBox, categoryList.get(i)); + } + + checkAddButton(); + relayoutPane(); + } + + public void update(List categoryList) { + categoryList.clear(); + + ColumnField temp1 = new ColumnField(); + categoryList.add(temp1); + updateField(firstFieldComponent, temp1); + + for (T comboBox : categoryComponentList) { + ColumnField temp = new ColumnField(); + categoryList.add(temp); + updateField(comboBox, temp); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java new file mode 100644 index 0000000000..8e6b98577d --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java @@ -0,0 +1,58 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.CustomFieldValueColumnFields; + +/** + * Created by shine on 2019/5/17. + */ +public class CustomFieldComboBoxPane extends AbstractCustomFieldComboBoxPane { + + @Override + protected AbstractUseFieldValuePane createUseFieldValuePane() { + return new UseFieldValuePane(); + } + + @Override + protected AbstractCustomFieldNamePane createCustomFieldNamePane() { + return new CustomFieldNamePane(); + } + + @Override + public void populateBean(CustomFieldValueColumnFields ob) { + if (ob.isCustomFieldValue()) { + populateCustomFieldNamePane(ob); + jcb.setSelectedIndex(1); + } else { + populateUseFieldValuePane(ob); + jcb.setSelectedIndex(0); + } + } + + @Override + public void updateBean(CustomFieldValueColumnFields ob) { + if (jcb.getSelectedIndex() == 0) { + ob.setCustomFieldValue(false); + updateUseFieldValuePane(ob); + } else { + ob.setCustomFieldValue(true); + updateCustomFieldNamePane(ob); + } + } + + private class UseFieldValuePane extends AbstractUseFieldValuePane { + + @Override + public void populateBean(CustomFieldValueColumnFields ob) { + + } + } + + private class CustomFieldNamePane extends AbstractCustomFieldNamePane { + + @Override + public void populateBean(CustomFieldValueColumnFields ob) { + + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java new file mode 100644 index 0000000000..37a110b7d4 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java @@ -0,0 +1,32 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.extended.chart.UIComboBoxWithNone; + +/** + * Created by shine on 2019/4/12. + */ +public class MultiComboBoxPane extends AbstractMultiComponentPane { + + @Override + protected UIComboBox createFirstFieldComponent() { + return new UIComboBoxWithNone(); + } + + @Override + protected UIComboBox createOtherFieldComponent() { + return new UIComboBox(); + } + + @Override + protected void populateField(UIComboBox component, ColumnField field) { + AbstractDataSetFieldsPane.populateField(component, field); + } + + @Override + protected void updateField(UIComboBox component, ColumnField field) { + AbstractDataSetFieldsPane.updateField(component, field); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java new file mode 100644 index 0000000000..5e56b967c4 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java @@ -0,0 +1,31 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.formula.TinyFormulaPane; + +/** + * Created by shine on 2019/4/12. + */ +public class MultiTinyFormulaPane extends AbstractMultiComponentPane { + @Override + protected TinyFormulaPane createFirstFieldComponent() { + return new TinyFormulaPane(); + } + + @Override + protected TinyFormulaPane createOtherFieldComponent() { + return new TinyFormulaPane(); + } + + @Override + protected void populateField(TinyFormulaPane component, ColumnField field) { + AbstractCellDataFieldsPane.populateField(component, field); + } + + @Override + protected void updateField(TinyFormulaPane component, ColumnField field) { + AbstractCellDataFieldsPane.updateField(component, field); + + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java new file mode 100644 index 0000000000..98400ed7ae --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java @@ -0,0 +1,93 @@ +package com.fr.design.chartx.fields; + +import com.fr.chartx.data.field.AbstractColumnFieldCollection; +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; +import java.util.Arrays; + +/** + * Created by shine on 2019/5/16. + * 单元格数据源 具体有哪些字段的一个抽象pane + */ +public abstract class AbstractCellDataFieldsPane extends BasicBeanPane { + + public AbstractCellDataFieldsPane() { + initComponents(); + } + + protected void initComponents() { + + this.setLayout(new BorderLayout(0, 6)); + + this.add(addNorthPane(), BorderLayout.NORTH); + this.add(addCenterPane(), BorderLayout.CENTER); + this.add(addSouthPane(), BorderLayout.SOUTH); + + this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8)); + } + + protected JPanel addCenterPane() { + String[] labels = fieldLabels(); + Component[] formulaPanes = fieldComponents(); + + int len = Math.min(labels.length, formulaPanes.length); + + Component[][] components = new Component[len][2]; + for (int i = 0; i < len; i++) { + components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), formulaPanes[i]}; + } + + + double p = TableLayout.PREFERRED; + double[] columnSize = {ChartDataPane.LABEL_WIDTH, 124}; + double[] rowSize = new double[len]; + Arrays.fill(rowSize, p); + + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6); + } + + + protected JPanel addNorthPane() { + return new JPanel(); + } + + protected JPanel addSouthPane() { + return new JPanel(); + } + + protected Component[] fieldComponents() { + return formulaPanes(); + } + + protected abstract String[] fieldLabels(); + + protected abstract TinyFormulaPane[] formulaPanes(); + + @Override + public abstract T updateBean(); + + public static void populateField(TinyFormulaPane formulaPane, ColumnField field) { + formulaPane.populateBean(field.getFieldName()); + } + + public static void updateField(TinyFormulaPane formulaPane, ColumnField field) { + field.setFieldName(formulaPane.updateBean()); + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java new file mode 100644 index 0000000000..84c8401c10 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java @@ -0,0 +1,142 @@ +package com.fr.design.chartx.fields; + +import com.fr.chartx.data.field.AbstractColumnFieldCollection; +import com.fr.chartx.data.field.ColumnField; +import com.fr.data.util.function.AbstractDataFunction; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; +import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; +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.util.Arrays; +import java.util.List; + +import static com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper.refreshBoxItems; + +/** + * Created by shine on 2019/5/16. + * 数据集数据源 具体有哪些字段的一个抽象pane + */ +public abstract class AbstractDataSetFieldsPane extends BasicBeanPane { + + public AbstractDataSetFieldsPane() { + initComponents(); + } + + protected void initComponents() { + + this.setLayout(new BorderLayout(0, 4)); + this.setBorder(BorderFactory.createEmptyBorder(2, 24, 0, 15)); + + JPanel north = createNorthPane(), + center = createCenterPane(), + south = createSouthPane(); + + if (north != null) { + this.add(north, BorderLayout.NORTH); + } + + if (center != null) { + this.add(center, BorderLayout.CENTER); + } + + if (south != null) { + this.add(south, BorderLayout.SOUTH); + } + } + + protected JPanel createNorthPane() { + return null; + } + + protected JPanel createCenterPane() { + String[] labels = fieldLabels(); + Component[] fieldComponents = fieldComponents(); + + int len = Math.min(labels.length, fieldComponents.length); + + if (len == 0) { + return null; + } + + Component[][] components = new Component[len][2]; + for (int i = 0; i < len; i++) { + components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), fieldComponents[i]}; + } + + double p = TableLayout.PREFERRED; + double[] columnSize = {ChartDataPane.LABEL_WIDTH, 122}; + double[] rowSize = new double[len]; + Arrays.fill(rowSize, p); + + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6); + } + + protected JPanel createSouthPane() { + return null; + } + + protected Component[] fieldComponents() { + return filedComboBoxes(); + } + + protected abstract String[] fieldLabels(); + + protected abstract UIComboBox[] filedComboBoxes(); + + public void checkBoxUse(boolean hasUse) { + for (Component component : fieldComponents()) { + component.setEnabled(hasUse); + } + } + + public void clearAllBoxList() { + for (UIComboBox comboBox : filedComboBoxes()) { + DataPaneHelper.clearBoxItems(comboBox); + } + } + + public void refreshBoxListWithSelectTableData(List columnNameList) { + for (UIComboBox comboBox : filedComboBoxes()) { + refreshBoxItems(comboBox, columnNameList); + } + } + + @Override + public abstract T updateBean(); + + public static void populateField(UIComboBox comboBox, ColumnField field) { + populateFunctionField(comboBox, null, field); + } + + public static void updateField(UIComboBox comboBox, ColumnField field) { + updateFunctionField(comboBox, null, field); + } + + protected static void populateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ColumnField field) { + comboBox.setSelectedItem(field.getFieldName()); + if (calculateComboBox != null) { + calculateComboBox.populateBean((AbstractDataFunction) field.getDataFunction()); + } + } + + protected static void updateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ColumnField field) { + field.setFieldName(GeneralUtils.objectToString(comboBox.getSelectedItem())); + if (calculateComboBox != null) { + field.setDataFunction(calculateComboBox.updateBean()); + } else { + field.setDataFunction(null); + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java new file mode 100644 index 0000000000..9b0418c306 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java @@ -0,0 +1,60 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithCustomField; +import com.fr.design.chartx.component.CustomFieldComboBoxPane; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.util.List; + +/** + * Created by shine on 2019/5/16. + * 带有 自定义系列名(fr表现为 系列名使用字段名) 的字段集合 的一个pane + */ +public abstract class AbstractDataSetFieldsWithCustomFieldPane + extends AbstractDataSetFieldsPane { + + private CustomFieldComboBoxPane customFieldComboBoxPane; + + @Override + protected JPanel createCenterPane() { + JPanel normalCenter = super.createCenterPane(); + customFieldComboBoxPane = new CustomFieldComboBoxPane(); + + if (normalCenter != null) { + JPanel panel = new JPanel(new BorderLayout()); + panel.add(normalCenter, BorderLayout.CENTER); + panel.add(customFieldComboBoxPane, BorderLayout.SOUTH); + return panel; + } else { + return customFieldComboBoxPane; + } + } + + @Override + public void checkBoxUse(boolean hasUse) { + super.checkBoxUse(hasUse); + customFieldComboBoxPane.checkBoxUse(hasUse); + } + + @Override + public void clearAllBoxList() { + super.clearAllBoxList(); + customFieldComboBoxPane.clearAllBoxList(); + } + + @Override + public void refreshBoxListWithSelectTableData(List columnNameList) { + super.refreshBoxListWithSelectTableData(columnNameList); + customFieldComboBoxPane.refreshBoxListWithSelectTableData(columnNameList); + } + + protected void populateCustomPane(AbstractColumnFieldCollectionWithCustomField t) { + customFieldComboBoxPane.populateBean(t.getCustomFieldValueColumnFields()); + } + + protected void updateCustomPane(AbstractColumnFieldCollectionWithCustomField t) { + customFieldComboBoxPane.updateBean(t.getCustomFieldValueColumnFields()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java new file mode 100644 index 0000000000..755f4a8c53 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java @@ -0,0 +1,65 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; +import com.fr.design.chartx.component.MultiTinyFormulaPane; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.formula.TinyFormulaPane; + +import javax.swing.JPanel; +import java.util.List; + +/** + * Created by shine on 2019/4/12. + */ +public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsPane { + + private MultiTinyFormulaPane multiCategoryPane; + + private void createMultiFormulaPane() { + if (multiCategoryPane == null) { + multiCategoryPane = new MultiTinyFormulaPane(); + } + } + + @Override + protected JPanel addNorthPane() { + + createMultiFormulaPane(); + + return multiCategoryPane; + } + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + + createMultiFormulaPane(); + + List list = multiCategoryPane.componentList(); + return list.toArray(new TinyFormulaPane[list.size()]); + } + + @Override + public void populateBean(MultiCategoryColumnFieldCollection ob) { + + List categoryList = ob.getCategoryList(); + + multiCategoryPane.populate(categoryList); + } + + @Override + public MultiCategoryColumnFieldCollection updateBean() { + + MultiCategoryColumnFieldCollection fieldCollection = new MultiCategoryColumnFieldCollection(); + List categoryList = fieldCollection.getCategoryList(); + + multiCategoryPane.update(categoryList); + + return fieldCollection; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java new file mode 100644 index 0000000000..f3828361b3 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java @@ -0,0 +1,69 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; +import com.fr.design.chartx.component.MultiComboBoxPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.stable.StringUtils; + +import javax.swing.JPanel; +import java.util.List; + + +/** + * Created by shine on 2019/4/10. + */ +public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithCustomFieldPane { + + private MultiComboBoxPane multiCategoryPane; + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + List list = initMultiCategoryPane().componentList(); + return list.toArray(new UIComboBox[list.size()]); + } + + private MultiComboBoxPane initMultiCategoryPane() { + if (multiCategoryPane == null) { + multiCategoryPane = new MultiComboBoxPane(); + } + return multiCategoryPane; + } + + @Override + protected JPanel createNorthPane() { + return initMultiCategoryPane(); + } + + @Override + public void populateBean(MultiCategoryColumnFieldCollection ob) { + List categoryList = ob.getCategoryList(); + + multiCategoryPane.populate(categoryList); + + populateCustomPane(ob); + } + + @Override + public MultiCategoryColumnFieldCollection updateBean() { + + MultiCategoryColumnFieldCollection columnFieldCollection = new MultiCategoryColumnFieldCollection(); + List categoryList = columnFieldCollection.getCategoryList(); + + multiCategoryPane.update(categoryList); + + updateCustomPane(columnFieldCollection); + + return columnFieldCollection; + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/single/CellDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/single/CellDataPane.java new file mode 100644 index 0000000000..f0a4ef0afd --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/single/CellDataPane.java @@ -0,0 +1,56 @@ +package com.fr.design.chartx.single; + +import com.fr.chartx.data.CellDataDefinition; +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.i18n.Toolkit; + +import java.awt.BorderLayout; + +/** + * Created by shine on 2019/5/21. + */ +public class CellDataPane extends FurtherBasicBeanPane { + + private AbstractCellDataFieldsPane cellDataFieldsPane; + + public CellDataPane(AbstractCellDataFieldsPane cellDataFieldsPane) { + initComps(cellDataFieldsPane); + } + + private void initComps(AbstractCellDataFieldsPane cellDataFieldsPane) { + this.cellDataFieldsPane = cellDataFieldsPane; + + this.setLayout(new BorderLayout()); + this.add(cellDataFieldsPane, BorderLayout.CENTER); + } + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Cell_Data"); + } + + + @Override + public boolean accept(Object ob) { + return ob instanceof CellDataDefinition; + } + + @Override + public void reset() { + this.removeAll(); + } + + @Override + public void populateBean(CellDataDefinition ob) { + cellDataFieldsPane.populateBean(ob.getColumnFieldCollection()); + } + + @Override + public CellDataDefinition updateBean() { + CellDataDefinition cellDataDefinition = new CellDataDefinition(); + cellDataDefinition.setColumnFieldCollection(cellDataFieldsPane.updateBean()); + + return cellDataDefinition; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java b/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java new file mode 100644 index 0000000000..98394c31a0 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java @@ -0,0 +1,121 @@ +package com.fr.design.chartx.single; + +import com.fr.chartx.data.DataSetDefinition; +import com.fr.data.impl.NameTableData; +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.data.tabledata.wrapper.TableDataWrapper; +import com.fr.design.gui.ilable.BoldFontTextLabel; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.mainframe.chart.gui.data.DatabaseTableDataPane; +import com.fr.design.utils.gui.UIComponentUtils; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.util.List; + +/** + * Created by shine on 2019/5/21. + */ +public class DataSetPane extends FurtherBasicBeanPane { + private static final int TABLE_DATA_LABEL_LINE_WRAP_WIDTH = 65; + private static final int TABLE_DATA_PANE_WIDTH = 246; + + private DatabaseTableDataPane tableDataPane; + + private AbstractDataSetFieldsPane dataSetFieldsPane; + + public DataSetPane(AbstractDataSetFieldsPane dataSetFieldsPane) { + initComps(dataSetFieldsPane); + } + + private void initComps(AbstractDataSetFieldsPane dataSetFieldsPane) { + UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data")); + UIComponentUtils.setLineWrap(label, TABLE_DATA_LABEL_LINE_WRAP_WIDTH); + UIComponentUtils.setPreferedWidth(label, ChartDataPane.LABEL_WIDTH); + + tableDataPane = new DatabaseTableDataPane(label) { + @Override + protected void userEvent() { + refreshBoxList(); + checkBoxUse(); + } + }; + tableDataPane.setPreferredSize(new Dimension(TABLE_DATA_PANE_WIDTH, tableDataPane.getPreferredSize().height)); + + this.dataSetFieldsPane = dataSetFieldsPane; + + this.setLayout(new BorderLayout()); + this.add(tableDataPane, BorderLayout.NORTH); + this.add(dataSetFieldsPane, BorderLayout.CENTER); + } + + /** + * 检查box是否可用. + */ + public void checkBoxUse() { + TableDataWrapper dataWrap = tableDataPane.getTableDataWrapper(); + + if (dataSetFieldsPane != null) { + dataSetFieldsPane.checkBoxUse(dataWrap != null); + } + } + + /** + * 刷新字段下拉列表 + */ + private void refreshBoxList() { + TableDataWrapper dataWrap = tableDataPane.getTableDataWrapper(); + + if (dataWrap == null) { + return; + } + + List columnNameList = dataWrap.calculateColumnNameList(); + + if (dataSetFieldsPane != null) { + dataSetFieldsPane.refreshBoxListWithSelectTableData(columnNameList); + } + } + + @Override + public boolean accept(Object ob) { + return ob instanceof DataSetDefinition; + } + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_TableData"); + } + + @Override + public void reset() { + this.removeAll(); + } + + @Override + public void populateBean(DataSetDefinition ob) { + refreshBoxList(); + checkBoxUse(); + + tableDataPane.populateBean(ob.getNameTableData()); + + dataSetFieldsPane.populateBean(ob.getColumnFieldCollection()); + } + + @Override + public DataSetDefinition updateBean() { + DataSetDefinition dataSetDefinition = new DataSetDefinition(); + + TableDataWrapper tableDataWrapper = tableDataPane.getTableDataWrapper(); + if (tableDataWrapper != null) { + dataSetDefinition.setNameTableData(new NameTableData(tableDataWrapper.getTableDataName())); + } + + dataSetDefinition.setColumnFieldCollection(dataSetFieldsPane.updateBean()); + + return dataSetDefinition; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java new file mode 100644 index 0000000000..a4e6949983 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java @@ -0,0 +1,90 @@ +package com.fr.design.chartx.single; + +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.gui.frpane.UIComboBoxPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/5/21. + */ +public class SingleDataPane extends BasicBeanPane { + + private UIComboBoxPane comboBoxPane; + + private DataSetPane dataSetPane; + + private CellDataPane cellDataPane; + + public SingleDataPane(AbstractDataSetFieldsPane dataSetFieldsPane, AbstractCellDataFieldsPane cellDataFieldsPane) { + initComps(dataSetFieldsPane, cellDataFieldsPane); + } + + private void initComps(AbstractDataSetFieldsPane dataSetFieldsPane, AbstractCellDataFieldsPane cellDataFieldsPane) { + + cellDataPane = new CellDataPane(cellDataFieldsPane); + dataSetPane = new DataSetPane(dataSetFieldsPane); + + comboBoxPane = new UIComboBoxPane() { + @Override + protected List> initPaneList() { + List> list = new ArrayList>(); + list.add(dataSetPane); + list.add(cellDataPane); + return list; + } + + protected void initLayout() { + this.setLayout(new BorderLayout(LayoutConstants.HGAP_LARGE, 6)); + JPanel northPane = new JPanel(new BorderLayout(LayoutConstants.HGAP_LARGE, 0)); + northPane.add(jcb, BorderLayout.CENTER); + UILabel label1 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Source")); + label1.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); + northPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{jcb, null, null, label1, null})); + northPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 8)); + this.add(northPane, BorderLayout.NORTH); + this.add(cardPane, BorderLayout.CENTER); + + } + + @Override + protected String title4PopupWindow() { + return null; + } + }; + + + this.setLayout(new BorderLayout()); + this.add(comboBoxPane, BorderLayout.CENTER); + + } + + @Override + public void populateBean(AbstractDataDefinition ob) { + comboBoxPane.populateBean(ob); + } + + @Override + public AbstractDataDefinition updateBean() { + return comboBoxPane.updateBean(); + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java index ceeea71c2d..cc28497658 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java @@ -2,101 +2,34 @@ package com.fr.extended.chart; import com.fr.base.Utils; import com.fr.data.util.function.AbstractDataFunction; -import com.fr.design.beans.FurtherBasicBeanPane; -import com.fr.design.event.UIObserverListener; -import com.fr.design.gui.frpane.UIComboBoxPane; -import com.fr.design.gui.frpane.UICorrelationPane; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itable.UITable; -import com.fr.design.gui.itable.UITableEditor; -import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.chart.gui.ChartDataPane; -import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; +import com.fr.design.chartx.component.AbstractCustomFieldComboBoxPane; import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; -import com.fr.stable.StringUtils; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JTable; -import javax.swing.SwingConstants; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.List; /** - * Created by shine on 2018/9/12. + * Created by shine on 2019/5/16. */ -public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane { - 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(); - +public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBoxPane { @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(ChartDataPane.LABEL_WIDTH, 20)); - northPane.add(label, BorderLayout.WEST); - this.add(northPane, BorderLayout.NORTH); - this.add(cardPane, BorderLayout.CENTER); + protected AbstractUseFieldValuePane createUseFieldValuePane() { + return new ExtendedUseFieldValuePane(); } @Override - protected List> initPaneList() { - useFieldValuePane = new UseFieldValuePane(); - customFieldNamePane = new CustomFieldNamePane(); - List> list = new ArrayList>(); - list.add(useFieldValuePane); - list.add(customFieldNamePane); - return list; + protected AbstractCustomFieldNamePane createCustomFieldNamePane() { + return new ExtendedCustomFieldNamePane(); } - @Override - protected String title4PopupWindow() { - return StringUtils.EMPTY; - } - - protected boolean valueComboBoxHasNone() { - return false; - } - - 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); + populateCustomFieldNamePane(ob); jcb.setSelectedIndex(1); } else { - useFieldValuePane.populateBean(ob); + populateUseFieldValuePane(ob); jcb.setSelectedIndex(0); } } @@ -105,68 +38,22 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane { - private UIComboBox series; - private UIComboBox value; - private CalculateComboBox function; - - private UseFieldValuePane() { - initComponents(); - } - - private void initComponents() { - - series = new UIComboBox(); - value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox(); - - function = new CalculateComboBox(); - - Component[][] components = new Component[][]{ - new Component[]{new UILabel(HEADS[1], SwingConstants.LEFT), series}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Value"), SwingConstants.LEFT), value}, - new Component[]{new UILabel(HEADS[2], SwingConstants.LEFT), function}, - }; - - double p = TableLayout.PREFERRED; - double[] columnSize = {78, 122}; - 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() { - DataPaneHelper.clearBoxItems(series); - DataPaneHelper.clearBoxItems(value); - } - - public void refreshBoxListWithSelectTableData(List columnNameList) { - DataPaneHelper.refreshBoxItems(series, columnNameList); - DataPaneHelper.refreshBoxItems(value, columnNameList); - } + private class ExtendedUseFieldValuePane extends AbstractUseFieldValuePane { @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()); + populateSeries(list.get(0).getFieldName()); + populateValue(list.get(1).getFieldName()); + populateFunction((AbstractDataFunction) list.get(1).getDataFunction()); } } @@ -174,70 +61,18 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane 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(new ExtendedField(updateSeries())); + ExtendedField field = new ExtendedField(updateValue()); + field.setDataFunction(updateFunction()); 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); - - } + private class ExtendedCustomFieldNamePane extends AbstractCustomFieldNamePane { @Override public void populateBean(AbstractDataConfig ob) { @@ -248,13 +83,12 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane list = correlationPane.updateBean(); + List list = update(); List customFields = new ArrayList(); for (Object[] line : list) { @@ -267,120 +101,6 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane