Browse Source

Merge pull request #932 in DESIGN/design from ~ZHENG/c-design:refactor/19.4.3 to refactor/19.4.3

* commit '0dce6dd580fdc3deca9328f8290fc1f9663f8fac':
  update
  代码质量
  代码质量
  update
  CHART-4027 系列+值 自定义相关celldata design
  CHART-4027 系列+值 自定义相关 design
research/10.0
zheng 6 years ago
parent
commit
a99cfd69ff
  1. 216
      designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java
  2. 56
      designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java
  3. 58
      designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java
  4. 107
      designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java
  5. 130
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java
  6. 19
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractEditorComponent.java
  7. 45
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/CalculateComboBoxEditorComponent.java
  8. 20
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java
  9. 56
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java
  10. 55
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UIComboBoxEditorComponent.java
  11. 41
      designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UITextFieldEditorComponent.java
  12. 16
      designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java
  13. 41
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java
  14. 60
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java
  15. 60
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java
  16. 13
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java
  17. 10
      designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java
  18. 19
      designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java

216
designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java

@ -2,14 +2,15 @@ package com.fr.design.chartx.component;
import com.fr.data.util.function.AbstractDataFunction; import com.fr.data.util.function.AbstractDataFunction;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.event.UIObserverListener; import com.fr.design.chartx.component.correlation.AbstractCorrelationPane;
import com.fr.design.chartx.component.correlation.CalculateComboBoxEditorComponent;
import com.fr.design.chartx.component.correlation.FieldEditorComponentWrapper;
import com.fr.design.chartx.component.correlation.UIComboBoxEditorComponent;
import com.fr.design.chartx.component.correlation.UITextFieldEditorComponent;
import com.fr.design.gui.frpane.UIComboBoxPane; 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.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itable.UITable; import com.fr.design.i18n.Toolkit;
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.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartDataPane;
@ -19,17 +20,11 @@ import com.fr.extended.chart.UIComboBoxWithNone;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; 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.ArrayList;
import java.util.List; import java.util.List;
@ -38,7 +33,6 @@ import java.util.List;
* 系列名使用字段名or字段值的抽象的pane 支持多种属性结构的存取 * 系列名使用字段名or字段值的抽象的pane 支持多种属性结构的存取
*/ */
public abstract class AbstractCustomFieldComboBoxPane<T> extends UIComboBoxPane<T> { public abstract class AbstractCustomFieldComboBoxPane<T> extends UIComboBoxPane<T> {
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 AbstractUseFieldValuePane useFieldValuePane;
@ -64,7 +58,31 @@ public abstract class AbstractCustomFieldComboBoxPane<T> extends UIComboBoxPane<
customFieldNamePane = createCustomFieldNamePane(); customFieldNamePane = createCustomFieldNamePane();
List<FurtherBasicBeanPane<? extends T>> list = new ArrayList<FurtherBasicBeanPane<? extends T>>(); List<FurtherBasicBeanPane<? extends T>> list = new ArrayList<FurtherBasicBeanPane<? extends T>>();
list.add(useFieldValuePane); list.add(useFieldValuePane);
list.add(customFieldNamePane); FurtherBasicBeanPane pane = new FurtherBasicBeanPane() {
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Name");
}
@Override
public boolean accept(Object ob) {
return false;
}
@Override
public void reset() {
}
@Override
public void populateBean(Object ob) {
}
@Override
public Object updateBean() {
return null;
}
};
list.add(pane);
return list; return list;
} }
@ -112,7 +130,7 @@ public abstract class AbstractCustomFieldComboBoxPane<T> extends UIComboBoxPane<
useFieldValuePane.updateBean(t); useFieldValuePane.updateBean(t);
} }
protected abstract class AbstractUseFieldValuePane<T> extends FurtherBasicBeanPane<T> { protected abstract class AbstractUseFieldValuePane extends FurtherBasicBeanPane<T> {
private UIComboBox series; private UIComboBox series;
private UIComboBox value; private UIComboBox value;
private CalculateComboBox function; private CalculateComboBox function;
@ -129,9 +147,9 @@ public abstract class AbstractCustomFieldComboBoxPane<T> extends UIComboBoxPane<
function = new CalculateComboBox(); function = new CalculateComboBox();
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{new UILabel(HEADS[1], SwingConstants.LEFT), series}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Name"), 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(Toolkit.i18nText("Fine-Design_Chart_Use_Value"), SwingConstants.LEFT), value},
new Component[]{new UILabel(HEADS[2], SwingConstants.LEFT), function}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Summary_Method"), SwingConstants.LEFT), function},
}; };
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
@ -204,165 +222,25 @@ public abstract class AbstractCustomFieldComboBoxPane<T> extends UIComboBoxPane<
} }
} }
protected abstract class AbstractCustomFieldNamePane<T> extends FurtherBasicBeanPane<T> { protected abstract class AbstractCustomFieldNamePane extends AbstractCorrelationPane<T> {
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() { @Override
return new Editor() { protected FieldEditorComponentWrapper[] createFieldEditorComponentWrappers() {
return new FieldEditorComponentWrapper[]{
new UIComboBoxEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Field_Name")) {
@Override @Override
protected UICorrelationPane getParent() { protected List<String> items() {
return correlationPane; return fieldList;
} }
}; },
} new UITextFieldEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Name")),
new CalculateComboBoxEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Summary_Method"))
}; };
this.setLayout(new BorderLayout());
this.add(correlationPane, BorderLayout.CENTER);
}
protected void populate(List<Object[]> list) {
correlationPane.populateBean(list);
}
protected List<Object[]> update() {
return correlationPane.updateBean();
}
@Override
public boolean accept(Object ob) {
return true;
}
@Override
public void reset() {
} }
@Override @Override
public String title4PopupWindow() { protected Object[] createLine() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Name"); return new String[]{StringUtils.EMPTY, StringUtils.EMPTY, Toolkit.i18nText("Fine-Design_Chart_Use_None")};
}
@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;
}
}
} }

56
designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java

@ -0,0 +1,56 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.ColumnField;
import com.fr.chartx.data.field.SeriesValueCorrelationDefinition;
import com.fr.chartx.data.field.SeriesValueField;
import com.fr.design.chartx.component.correlation.AbstractCorrelationPane;
import com.fr.design.chartx.component.correlation.FieldEditorComponentWrapper;
import com.fr.design.chartx.component.correlation.TinyFormulaPaneEditorComponent;
import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralUtils;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2019/6/4.
*/
public class CellDataSeriesValueCorrelationPane extends AbstractCorrelationPane<SeriesValueCorrelationDefinition> {
@Override
protected FieldEditorComponentWrapper[] createFieldEditorComponentWrappers() {
return new FieldEditorComponentWrapper[]{
new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Name")),
new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Value"))
};
}
@Override
protected List<Object[]> covertTBeanToTableModelList(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) {
List<Object[]> result = new ArrayList<Object[]>();
List<SeriesValueField> seriesValueFieldList = seriesValueCorrelationDefinition.getSeriesValueFieldList();
for (SeriesValueField seriesValueField : seriesValueFieldList) {
Object[] array = new Object[]{seriesValueField.getSeries().getFieldName(), seriesValueField.getValue().getFieldName()};
result.add(array);
}
return result;
}
@Override
protected void setTableModelListToTBean(List<Object[]> tableValues, SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) {
List<SeriesValueField> seriesValueFieldList = new ArrayList<SeriesValueField>();
for (Object[] oneLine : tableValues) {
SeriesValueField seriesValueField = new SeriesValueField();
ColumnField series = new ColumnField(GeneralUtils.objectToString(oneLine[0]));
ColumnField value = new ColumnField(GeneralUtils.objectToString(oneLine[1]));
seriesValueField.setSeries(series);
seriesValueField.setValue(value);
seriesValueFieldList.add(seriesValueField);
}
seriesValueCorrelationDefinition.setSeriesValueFieldList(seriesValueFieldList);
}
}

58
designer-chart/src/main/java/com/fr/design/chartx/component/CustomFieldComboBoxPane.java

@ -1,58 +0,0 @@
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<CustomFieldValueColumnFields> {
@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<CustomFieldValueColumnFields> {
@Override
public void populateBean(CustomFieldValueColumnFields ob) {
}
}
private class CustomFieldNamePane extends AbstractCustomFieldNamePane<CustomFieldValueColumnFields> {
@Override
public void populateBean(CustomFieldValueColumnFields ob) {
}
}
}

107
designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java

@ -0,0 +1,107 @@
package com.fr.design.chartx.component;
import com.fr.chartx.data.field.ColumnField;
import com.fr.chartx.data.field.SeriesValueCorrelationDefinition;
import com.fr.chartx.data.field.SeriesValueField;
import com.fr.data.util.function.AbstractDataFunction;
import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper;
import com.fr.general.GeneralUtils;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2019/5/17.
*/
public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPane<SeriesValueCorrelationDefinition> {
@Override
protected AbstractUseFieldValuePane createUseFieldValuePane() {
return new UseFieldValuePane();
}
@Override
protected AbstractCustomFieldNamePane createCustomFieldNamePane() {
return new CustomFieldNamePane();
}
@Override
public void populateBean(SeriesValueCorrelationDefinition ob) {
if (ob.isCustomFieldValue()) {
populateCustomFieldNamePane(ob);
jcb.setSelectedIndex(1);
} else {
populateUseFieldValuePane(ob);
jcb.setSelectedIndex(0);
}
}
@Override
public void updateBean(SeriesValueCorrelationDefinition 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(SeriesValueCorrelationDefinition ob) {
List<SeriesValueField> list = ob.getSeriesValueFieldList();
if (list != null && list.size() > 0) {
populateSeries(list.get(0).getSeries().getFieldName());
populateValue(list.get(0).getValue().getFieldName());
populateFunction((AbstractDataFunction) list.get(0).getValue().getDataFunction());
}
}
@Override
public void updateBean(SeriesValueCorrelationDefinition ob) {
List<SeriesValueField> list = new ArrayList<SeriesValueField>();
SeriesValueField seriesValueField = new SeriesValueField();
ColumnField series = new ColumnField(updateSeries());
ColumnField value = new ColumnField(updateValue());
value.setDataFunction(updateFunction());
seriesValueField.setValue(value);
seriesValueField.setSeries(series);
list.add(seriesValueField);
ob.setSeriesValueFieldList(list);
}
}
private class CustomFieldNamePane extends AbstractCustomFieldNamePane {
@Override
protected List<Object[]> covertTBeanToTableModelList(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) {
List<Object[]> list = new ArrayList<Object[]>();
for (SeriesValueField seriesValueField : seriesValueCorrelationDefinition.getSeriesValueFieldList()) {
Object[] array = new Object[]{
seriesValueField.getSeries().getFieldName(),
seriesValueField.getValue().getFieldName(),
DataPaneHelper.getFunctionString(seriesValueField.getValue().getDataFunction())
};
list.add(array);
}
return list;
}
@Override
protected void setTableModelListToTBean(List<Object[]> tableValues, SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) {
List<SeriesValueField> seriesValueFields = new ArrayList<SeriesValueField>();
for (Object[] line : tableValues) {
ColumnField series = new ColumnField(GeneralUtils.objectToString(line[0]));
ColumnField value = new ColumnField(GeneralUtils.objectToString(line[1]));
value.setDataFunction(DataPaneHelper.getFunctionByName(GeneralUtils.objectToString(line[2])));
SeriesValueField seriesValueField = new SeriesValueField();
seriesValueField.setValue(value);
seriesValueField.setSeries(series);
seriesValueFields.add(seriesValueField);
}
seriesValueCorrelationDefinition.setSeriesValueFieldList(seriesValueFields);
}
}
}

130
designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java

@ -0,0 +1,130 @@
package com.fr.design.chartx.component.correlation;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.gui.itable.UITable;
import com.fr.design.gui.itable.UITableEditor;
import com.fr.stable.StringUtils;
import javax.swing.JTable;
import javax.swing.event.ChangeEvent;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
/**
* Created by shine on 2019/6/4.
* 自定义editorComponent + 支持多种数据格式
*/
public abstract class AbstractCorrelationPane<T> extends BasicBeanPane<T> {
private FieldEditorComponentWrapper[] editorComponents;
private UICorrelationPane correlationPane;
public AbstractCorrelationPane() {
this.editorComponents = createFieldEditorComponentWrappers();
String[] headers = new String[editorComponents.length];
for (int i = 0, len = editorComponents.length; i < len; i++) {
headers[i] = editorComponents[i].headerName();
}
initComps(headers);
}
protected abstract FieldEditorComponentWrapper[] createFieldEditorComponentWrappers();
@Override
public void populateBean(T ob) {
correlationPane.populateBean(covertTBeanToTableModelList(ob));
}
@Override
public void updateBean(T ob) {
setTableModelListToTBean(correlationPane.updateBean(), ob);
}
@Override
public T updateBean() {
return null;
}
protected abstract List<Object[]> covertTBeanToTableModelList(T t);
protected abstract void setTableModelListToTBean(List<Object[]> tableValues, T t);
private void initComps(String[] headers) {
correlationPane = new UICorrelationPane(headers) {
public UITableEditor createUITableEditor() {
return new Editor();
}
protected UITable initUITable() {
return new UITable(columnCount) {
public UITableEditor createTableEditor() {
return createUITableEditor();
}
public void tableCellEditingStopped(ChangeEvent e) {
stopPaneEditing(e);
}
};
}
protected ActionListener getAddButtonListener() {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
tablePane.addLine(createLine());
fireTargetChanged();
}
};
}
};
this.setLayout(new BorderLayout());
this.add(correlationPane, BorderLayout.CENTER);
}
protected Object[] createLine() {
return new Object[this.editorComponents.length];
}
private class Editor extends UITableEditor {
private Component currentComponent;
private FieldEditorComponentWrapper currentEditorWrapper;
public Object getCellEditorValue() {
return currentEditorWrapper.getValue(currentComponent);
}
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
if (column == table.getModel().getColumnCount()) {
return null;
}
correlationPane.stopCellEditing();
currentEditorWrapper = AbstractCorrelationPane.this.editorComponents[column];
currentComponent = currentEditorWrapper.getTableCellEditorComponent(correlationPane, table, isSelected, row, column);
currentEditorWrapper.setValue(currentComponent, value);
return currentComponent;
}
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
}

19
designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractEditorComponent.java

@ -0,0 +1,19 @@
package com.fr.design.chartx.component.correlation;
import java.awt.Component;
/**
* Created by shine on 2019/6/10.
*/
public abstract class AbstractEditorComponent<T extends Component> implements FieldEditorComponentWrapper<T> {
private String header;
public AbstractEditorComponent(String header) {
this.header = header;
}
@Override
public String headerName() {
return this.header;
}
}

45
designer-chart/src/main/java/com/fr/design/chartx/component/correlation/CalculateComboBoxEditorComponent.java

@ -0,0 +1,45 @@
package com.fr.design.chartx.component.correlation;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import javax.swing.JTable;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* Created by shine on 2019/6/10.
*/
public class CalculateComboBoxEditorComponent extends AbstractEditorComponent<CalculateComboBox> {
public CalculateComboBoxEditorComponent(String header) {
super(header);
}
@Override
public CalculateComboBox getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, int row, int column) {
CalculateComboBox calculateComboBox = new CalculateComboBox();
calculateComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
parent.stopCellEditing();
parent.fireTargetChanged();
}
});
return calculateComboBox;
}
@Override
public Object getValue(CalculateComboBox calculateComboBox) {
return calculateComboBox.getSelectedItem();
}
@Override
public void setValue(CalculateComboBox calculateComboBox, Object o) {
if (o != null) {
calculateComboBox.setSelectedItem(o);
}
}
}

20
designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java

@ -0,0 +1,20 @@
package com.fr.design.chartx.component.correlation;
import com.fr.design.gui.frpane.UICorrelationPane;
import javax.swing.JTable;
import java.awt.Component;
/**
* Created by shine on 2019/6/4.
*/
public interface FieldEditorComponentWrapper<T extends Component> {
String headerName();
T getTableCellEditorComponent(UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column);
Object getValue(T t);
void setValue(T t, Object o);
}

56
designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java

@ -0,0 +1,56 @@
package com.fr.design.chartx.component.correlation;
import com.fr.base.BaseFormula;
import com.fr.base.Utils;
import com.fr.design.constants.UIConstants;
import com.fr.design.event.UIObserverListener;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.frpane.UICorrelationPane;
import javax.swing.JTable;
/**
* Created by shine on 2019/6/4.
*/
public class TinyFormulaPaneEditorComponent extends AbstractEditorComponent<TinyFormulaPane> {
public TinyFormulaPaneEditorComponent(String header) {
super(header);
}
@Override
public TinyFormulaPane getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column) {
TinyFormulaPane editorComponent = new TinyFormulaPane() {
@Override
public void okEvent() {
parent.stopCellEditing();
parent.fireTargetChanged();
}
@Override
protected void populateTextField(BaseFormula fm) {
formulaTextField.setText(fm.getContent());
}
};
editorComponent.setBackground(UIConstants.FLESH_BLUE);
editorComponent.getUITextField().registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
parent.fireTargetChanged();
}
});
return editorComponent;
}
@Override
public Object getValue(TinyFormulaPane formulaPane) {
return formulaPane.getUITextField().getText();
}
@Override
public void setValue(TinyFormulaPane formulaPane, Object o) {
formulaPane.getUITextField().setText(Utils.objectToString(o));
}
}

55
designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UIComboBoxEditorComponent.java

@ -0,0 +1,55 @@
package com.fr.design.chartx.component.correlation;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.itable.UITable;
import javax.swing.JTable;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
/**
* Created by shine on 2019/6/10.
*/
public class UIComboBoxEditorComponent extends AbstractEditorComponent<UIComboBox> {
public UIComboBoxEditorComponent(String header) {
super(header);
}
protected List<String> items() {
return new ArrayList<String>();
}
@Override
public UIComboBox getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column) {
UIComboBox uiComboBox = new UIComboBox(items().toArray());
uiComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
parent.stopCellEditing();
parent.fireTargetChanged();
UITable table = parent.getTable();
Object object = table.getValueAt(row, 0);
if (object != null) {
table.setValueAt(object, row, 1);
}
}
});
return uiComboBox;
}
@Override
public Object getValue(UIComboBox uiComboBox) {
return uiComboBox.getSelectedItem();
}
@Override
public void setValue(UIComboBox uiComboBox, Object o) {
uiComboBox.getModel().setSelectedItem(o);
}
}

41
designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UITextFieldEditorComponent.java

@ -0,0 +1,41 @@
package com.fr.design.chartx.component.correlation;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.general.GeneralUtils;
import javax.swing.JTable;
/**
* Created by shine on 2019/6/10.
*/
public class UITextFieldEditorComponent extends AbstractEditorComponent<UITextField> {
public UITextFieldEditorComponent(String header) {
super(header);
}
@Override
public UITextField getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, int row, int column) {
UITextField uiTextField = new UITextField();
uiTextField.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
parent.fireTargetChanged();
}
});
return uiTextField;
}
@Override
public Object getValue(UITextField uiTextField) {
return uiTextField.getText();
}
@Override
public void setValue(UITextField uiTextField, Object o) {
uiTextField.setText(GeneralUtils.objectToString(o));
}
}

16
designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java

@ -31,19 +31,23 @@ public abstract class AbstractCellDataFieldsPane<T extends AbstractColumnFieldCo
this.setLayout(new BorderLayout(0, 6)); this.setLayout(new BorderLayout(0, 6));
this.add(addNorthPane(), BorderLayout.NORTH); this.add(createNorthPane(), BorderLayout.NORTH);
this.add(addCenterPane(), BorderLayout.CENTER); this.add(createCenterPane(), BorderLayout.CENTER);
this.add(addSouthPane(), BorderLayout.SOUTH); this.add(createSouthPane(), BorderLayout.SOUTH);
this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8)); this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8));
} }
protected JPanel addCenterPane() { protected JPanel createCenterPane() {
String[] labels = fieldLabels(); String[] labels = fieldLabels();
Component[] formulaPanes = fieldComponents(); Component[] formulaPanes = fieldComponents();
int len = Math.min(labels.length, formulaPanes.length); int len = Math.min(labels.length, formulaPanes.length);
if (len == 0) {
return null;
}
Component[][] components = new Component[len][2]; Component[][] components = new Component[len][2];
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), formulaPanes[i]}; components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), formulaPanes[i]};
@ -59,11 +63,11 @@ public abstract class AbstractCellDataFieldsPane<T extends AbstractColumnFieldCo
} }
protected JPanel addNorthPane() { protected JPanel createNorthPane() {
return new JPanel(); return new JPanel();
} }
protected JPanel addSouthPane() { protected JPanel createSouthPane() {
return new JPanel(); return new JPanel();
} }

41
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java

@ -0,0 +1,41 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithSeriesValue;
import com.fr.design.chartx.component.CellDataSeriesValueCorrelationPane;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import javax.swing.JPanel;
import java.awt.BorderLayout;
/**
* Created by shine on 2019/6/4.
*/
public abstract class AbstractCellDataFieldsWithSeriesValuePane<T extends AbstractColumnFieldCollectionWithSeriesValue>
extends AbstractCellDataFieldsPane<T> {
private CellDataSeriesValueCorrelationPane seriesValueFieldsPane;
@Override
protected JPanel createCenterPane() {
JPanel normalCenter = super.createCenterPane();
seriesValueFieldsPane = new CellDataSeriesValueCorrelationPane();
if (normalCenter != null) {
JPanel panel = new JPanel(new BorderLayout());
panel.add(normalCenter, BorderLayout.CENTER);
panel.add(seriesValueFieldsPane, BorderLayout.SOUTH);
return panel;
} else {
return seriesValueFieldsPane;
}
}
protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) {
seriesValueFieldsPane.populateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition());
}
protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) {
seriesValueFieldsPane.updateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition());
}
}

60
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithCustomFieldPane.java

@ -1,60 +0,0 @@
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<T extends AbstractColumnFieldCollectionWithCustomField>
extends AbstractDataSetFieldsPane<T> {
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());
}
}

60
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java

@ -0,0 +1,60 @@
package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithSeriesValue;
import com.fr.design.chartx.component.SeriesValueFieldComboBoxPane;
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 AbstractDataSetFieldsWithSeriesValuePane<T extends AbstractColumnFieldCollectionWithSeriesValue>
extends AbstractDataSetFieldsPane<T> {
private SeriesValueFieldComboBoxPane seriesValueFieldComboBoxPane;
@Override
protected JPanel createCenterPane() {
JPanel normalCenter = super.createCenterPane();
seriesValueFieldComboBoxPane = new SeriesValueFieldComboBoxPane();
if (normalCenter != null) {
JPanel panel = new JPanel(new BorderLayout());
panel.add(normalCenter, BorderLayout.CENTER);
panel.add(seriesValueFieldComboBoxPane, BorderLayout.SOUTH);
return panel;
} else {
return seriesValueFieldComboBoxPane;
}
}
@Override
public void checkBoxUse(boolean hasUse) {
super.checkBoxUse(hasUse);
seriesValueFieldComboBoxPane.checkBoxUse(hasUse);
}
@Override
public void clearAllBoxList() {
super.clearAllBoxList();
seriesValueFieldComboBoxPane.clearAllBoxList();
}
@Override
public void refreshBoxListWithSelectTableData(List columnNameList) {
super.refreshBoxListWithSelectTableData(columnNameList);
seriesValueFieldComboBoxPane.refreshBoxListWithSelectTableData(columnNameList);
}
protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) {
seriesValueFieldComboBoxPane.populateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition());
}
protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) {
seriesValueFieldComboBoxPane.updateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition());
}
}

13
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java

@ -3,7 +3,6 @@ package com.fr.design.chartx.fields.diff;
import com.fr.chartx.data.field.ColumnField; import com.fr.chartx.data.field.ColumnField;
import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection;
import com.fr.design.chartx.component.MultiTinyFormulaPane; import com.fr.design.chartx.component.MultiTinyFormulaPane;
import com.fr.design.chartx.fields.AbstractCellDataFieldsPane;
import com.fr.design.formula.TinyFormulaPane; import com.fr.design.formula.TinyFormulaPane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -12,7 +11,7 @@ import java.util.List;
/** /**
* Created by shine on 2019/4/12. * Created by shine on 2019/4/12.
*/ */
public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsPane<MultiCategoryColumnFieldCollection> { public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithSeriesValuePane<MultiCategoryColumnFieldCollection> {
private MultiTinyFormulaPane multiCategoryPane; private MultiTinyFormulaPane multiCategoryPane;
@ -23,7 +22,7 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsPane<
} }
@Override @Override
protected JPanel addNorthPane() { protected JPanel createNorthPane() {
createMultiFormulaPane(); createMultiFormulaPane();
@ -45,11 +44,13 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsPane<
} }
@Override @Override
public void populateBean(MultiCategoryColumnFieldCollection ob) { public void populateBean(MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection) {
List<ColumnField> categoryList = ob.getCategoryList(); List<ColumnField> categoryList = multiCategoryColumnFieldCollection.getCategoryList();
multiCategoryPane.populate(categoryList); multiCategoryPane.populate(categoryList);
populateSeriesValuePane(multiCategoryColumnFieldCollection);
} }
@Override @Override
@ -60,6 +61,8 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsPane<
multiCategoryPane.update(categoryList); multiCategoryPane.update(categoryList);
updateSeriesValuePane(fieldCollection);
return fieldCollection; return fieldCollection;
} }
} }

10
designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java

@ -13,7 +13,7 @@ import java.util.List;
/** /**
* Created by shine on 2019/4/10. * Created by shine on 2019/4/10.
*/ */
public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithCustomFieldPane<MultiCategoryColumnFieldCollection> { public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSeriesValuePane<MultiCategoryColumnFieldCollection> {
private MultiComboBoxPane multiCategoryPane; private MultiComboBoxPane multiCategoryPane;
@ -41,12 +41,12 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithCus
} }
@Override @Override
public void populateBean(MultiCategoryColumnFieldCollection ob) { public void populateBean(MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection) {
List<ColumnField> categoryList = ob.getCategoryList(); List<ColumnField> categoryList = multiCategoryColumnFieldCollection.getCategoryList();
multiCategoryPane.populate(categoryList); multiCategoryPane.populate(categoryList);
populateCustomPane(ob); populateSeriesValuePane(multiCategoryColumnFieldCollection);
} }
@Override @Override
@ -57,7 +57,7 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithCus
multiCategoryPane.update(categoryList); multiCategoryPane.update(categoryList);
updateCustomPane(columnFieldCollection); updateSeriesValuePane(columnFieldCollection);
return columnFieldCollection; return columnFieldCollection;
} }

19
designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java

@ -45,7 +45,7 @@ public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBox
} }
} }
private class ExtendedUseFieldValuePane extends AbstractUseFieldValuePane<AbstractDataConfig> { private class ExtendedUseFieldValuePane extends AbstractUseFieldValuePane {
@Override @Override
public void populateBean(AbstractDataConfig ob) { public void populateBean(AbstractDataConfig ob) {
@ -72,26 +72,24 @@ public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBox
} }
private class ExtendedCustomFieldNamePane extends AbstractCustomFieldNamePane<AbstractDataConfig> { private class ExtendedCustomFieldNamePane extends AbstractCustomFieldNamePane {
@Override @Override
public void populateBean(AbstractDataConfig ob) { protected List<Object[]> covertTBeanToTableModelList(AbstractDataConfig dataConfig) {
List<ExtendedField> customFields = ob.getCustomFields(); List<ExtendedField> customFields = dataConfig.getCustomFields();
List<Object[]> list = new ArrayList<Object[]>(); List<Object[]> list = new ArrayList<Object[]>();
for (ExtendedField field : customFields) { for (ExtendedField field : customFields) {
String[] array = {field.getFieldName(), field.getCustomName(), DataPaneHelper.getFunctionString(field.getDataFunction())}; String[] array = {field.getFieldName(), field.getCustomName(), DataPaneHelper.getFunctionString(field.getDataFunction())};
list.add(array); list.add(array);
} }
populate(list); return list;
} }
@Override @Override
public void updateBean(AbstractDataConfig ob) { protected void setTableModelListToTBean(List<Object[]> tableValues, AbstractDataConfig dataConfig) {
List<Object[]> list = update();
List<ExtendedField> customFields = new ArrayList<ExtendedField>(); List<ExtendedField> customFields = new ArrayList<ExtendedField>();
for (Object[] line : list) { for (Object[] line : tableValues) {
ExtendedField field = new ExtendedField(Utils.objectToString(line[0])); ExtendedField field = new ExtendedField(Utils.objectToString(line[0]));
field.setCustomName(Utils.objectToString(line[1])); field.setCustomName(Utils.objectToString(line[1]));
if (line.length > 2) { if (line.length > 2) {
@ -100,8 +98,9 @@ public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBox
customFields.add(field); customFields.add(field);
} }
ob.setCustomFields(customFields); dataConfig.setCustomFields(customFields);
} }
} }
} }

Loading…
Cancel
Save