Browse Source

CHART-2912 && CHART-2969 扩展接口 自定义字段名

final/10.0
zheng 6 years ago
parent
commit
e2fb52733f
  1. 14
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java
  2. 13
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java
  3. 33
      designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartReportDataPane.java
  4. 74
      designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java
  5. 381
      designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java

14
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java

@ -5,8 +5,8 @@ import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import javax.swing.*; import javax.swing.JSeparator;
import java.awt.*; import java.awt.Dimension;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.List; import java.util.List;
@ -46,8 +46,8 @@ public abstract class AbstractTableDataContentPane extends BasicBeanPane<ChartCo
/** /**
* 刷新Box的选项. * 刷新Box的选项.
*/ */
protected void refreshBoxItems(UIComboBox box, List list) { public static void refreshBoxItems(UIComboBox box, List list) {
if(box == null) { if (box == null) {
return; return;
} }
@ -66,9 +66,9 @@ public abstract class AbstractTableDataContentPane extends BasicBeanPane<ChartCo
* 清空box里所有东西 * 清空box里所有东西
* @param box 容器 * @param box 容器
*/ */
protected void clearBoxItems(UIComboBox box){ public static void clearBoxItems(UIComboBox box) {
if(box == null){ if (box == null) {
return; return;
} }
box.removeAllItems(); box.removeAllItems();
} }

13
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java

@ -20,12 +20,15 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
@ -212,7 +215,7 @@ public class SeriesNameUseFieldNamePane extends FurtherBasicBeanPane<ChartCollec
this.populateBean(collection,true); this.populateBean(collection,true);
} }
private String getFunctionString(DataFunction function) { public static String getFunctionString(DataFunction function) {
for (int i = 0; i < CalculateComboBox.CLASS_ARRAY.length; i++) { for (int i = 0; i < CalculateComboBox.CLASS_ARRAY.length; i++) {
Class tmp = function.getClass(); Class tmp = function.getClass();
if (ComparatorUtils.equals(tmp, CalculateComboBox.CLASS_ARRAY[i])) { if (ComparatorUtils.equals(tmp, CalculateComboBox.CLASS_ARRAY[i])) {
@ -255,7 +258,7 @@ public class SeriesNameUseFieldNamePane extends FurtherBasicBeanPane<ChartCollec
collection.getSelectedChart().setFilterDefinition(moreDefinition); collection.getSelectedChart().setFilterDefinition(moreDefinition);
} }
private DataFunction getFcuntionByName(String name) { public static DataFunction getFcuntionByName(String name) {
int index = 0; int index = 0;
for (int i = 0; i < CalculateComboBox.CALCULATE_ARRAY.length; i++) { for (int i = 0; i < CalculateComboBox.CALCULATE_ARRAY.length; i++) {
if (ComparatorUtils.equals(name, CalculateComboBox.CALCULATE_ARRAY[i])) { if (ComparatorUtils.equals(name, CalculateComboBox.CALCULATE_ARRAY[i])) {

33
designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartReportDataPane.java

@ -13,13 +13,18 @@ import javax.swing.JPanel;
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.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
/** /**
* Created by shine on 2018/3/7. * Created by shine on 2018/3/7.
*/ */
public abstract class AbstractExtendedChartReportDataPane<T extends AbstractDataConfig> extends AbstractReportDataContentPane { public abstract class AbstractExtendedChartReportDataPane<T extends AbstractDataConfig> extends AbstractReportDataContentPane {
private TinyFormulaPane seriesPane;
private TinyFormulaPane valuePane;
public AbstractExtendedChartReportDataPane() { public AbstractExtendedChartReportDataPane() {
initComponents(); initComponents();
} }
@ -30,11 +35,18 @@ public abstract class AbstractExtendedChartReportDataPane<T extends AbstractData
int len = Math.min(labels.length, formulaPanes.length); int len = Math.min(labels.length, formulaPanes.length);
Component[][] components = new Component[len][2]; Component[][] components = new Component[len + (hasCustomFieldPane() ? 2 : 0)][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]};
} }
if (hasCustomFieldPane()) {
seriesPane = new TinyFormulaPane();
valuePane = new TinyFormulaPane();
components[len] = new Component[]{new UILabel("series", SwingConstants.LEFT), seriesPane};
components[len + 1] = new Component[]{new UILabel("series", SwingConstants.LEFT), valuePane};
}
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = {f, COMPONENT_WIDTH}; double[] columnSize = {f, COMPONENT_WIDTH};
@ -49,6 +61,10 @@ public abstract class AbstractExtendedChartReportDataPane<T extends AbstractData
this.add(panel, BorderLayout.CENTER); this.add(panel, BorderLayout.CENTER);
} }
protected boolean hasCustomFieldPane() {
return false;
}
protected Component[] fieldComponents() { protected Component[] fieldComponents() {
return formulaPanes(); return formulaPanes();
} }
@ -74,6 +90,11 @@ public abstract class AbstractExtendedChartReportDataPane<T extends AbstractData
if (dataConfig != null) { if (dataConfig != null) {
populate((T) dataConfig); populate((T) dataConfig);
if (hasCustomFieldPane() && dataConfig.getCustomFields().size() == 2) {
populateField(seriesPane, dataConfig.getCustomFields().get(0));
populateField(valuePane, dataConfig.getCustomFields().get(1));
}
} }
} }
} }
@ -86,7 +107,15 @@ public abstract class AbstractExtendedChartReportDataPane<T extends AbstractData
if (chart != null) { if (chart != null) {
ExtendedReportDataSet dataSet = new ExtendedReportDataSet(); ExtendedReportDataSet dataSet = new ExtendedReportDataSet();
dataSet.setDataConfig(update()); AbstractDataConfig dataConfig = update();
dataSet.setDataConfig(dataConfig);
List<ExtendedField> fieldList = new ArrayList<ExtendedField>();
if (hasCustomFieldPane()) {
fieldList.add(new ExtendedField(seriesPane.updateBean()));
fieldList.add(new ExtendedField(valuePane.updateBean()));
}
dataConfig.setCustomFields(fieldList);
chart.setFilterDefinition(dataSet); chart.setFilterDefinition(dataSet);
} }

74
designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java

@ -11,11 +11,11 @@ import com.fr.design.mainframe.chart.gui.data.CalculateComboBox;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
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.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -24,7 +24,7 @@ import java.util.List;
*/ */
public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataConfig> extends AbstractTableDataContentPane { public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataConfig> extends AbstractTableDataContentPane {
private CalculateComboBox function; private ExtendedCustomFieldComboBoxPane customFieldComboBoxPane;
public AbstractExtendedChartTableDataPane() { public AbstractExtendedChartTableDataPane() {
initComponents(); initComponents();
@ -37,28 +37,27 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
int len = Math.min(labels.length, fieldComponents.length); int len = Math.min(labels.length, fieldComponents.length);
Component[][] components = new Component[len + (hasFunction() ? 1 : 0)][2]; Component[][] components = new Component[len][2];
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
Component fieldComponent = fieldComponents[i]; components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), fieldComponents[i]};
fieldComponent.setPreferredSize(new Dimension(100, 20));
components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), fieldComponent};
}
if (hasFunction()) {
function = new CalculateComboBox();
components[len] = new Component[]{new UILabel("function", SwingConstants.LEFT), function};
} }
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double[] columnSize = {p, p}; double[] columnSize = {TableLayout.FILL, COMPONENT_WIDTH};
double[] rowSize = new double[len + (hasFunction() ? 1 : 0)]; double[] rowSize = new double[len];
Arrays.fill(rowSize, p); Arrays.fill(rowSize, p);
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout(0, 6));
this.add(panel, BorderLayout.CENTER); this.setBorder(BorderFactory.createEmptyBorder(2, 24, 0, 15));
this.add(panel, BorderLayout.NORTH);
if (hasCustomFieldPane()) {
customFieldComboBoxPane = new ExtendedCustomFieldComboBoxPane();
this.add(customFieldComboBoxPane, BorderLayout.CENTER);
}
this.add(addSouthPane(), BorderLayout.SOUTH); this.add(addSouthPane(), BorderLayout.SOUTH);
} }
@ -66,7 +65,7 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
return new JPanel(); return new JPanel();
} }
protected boolean hasFunction() { protected boolean hasCustomFieldPane() {
return false; return false;
} }
@ -96,10 +95,10 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
AbstractDataConfig dataConfig = dataSet.getDataConfig(); AbstractDataConfig dataConfig = dataSet.getDataConfig();
if (dataConfig != null) { if (dataConfig != null) {
populate((T) dataConfig); populate((T) dataConfig);
}
if (hasFunction()) { if (hasCustomFieldPane()) {
function.populateBean((AbstractDataFunction) dataSet.getDataFunction()); customFieldComboBoxPane.populateBean(dataConfig);
}
} }
} }
@ -116,8 +115,8 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
ExtendedTableDataSet dataSet = new ExtendedTableDataSet(); ExtendedTableDataSet dataSet = new ExtendedTableDataSet();
dataSet.setDataConfig(update()); dataSet.setDataConfig(update());
if (hasFunction()) { if (hasCustomFieldPane()) {
dataSet.setDataFunction(function.updateBean()); customFieldComboBoxPane.updateBean(dataSet.getDataConfig());
} }
chart.setFilterDefinition(dataSet); chart.setFilterDefinition(dataSet);
@ -127,8 +126,11 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
@Override @Override
public void checkBoxUse(boolean hasUse) { public void checkBoxUse(boolean hasUse) {
for (UIComboBox comboBox : filedComboBoxes()) { for (Component component : fieldComponents()) {
comboBox.setEnabled(hasUse); component.setEnabled(hasUse);
}
if (customFieldComboBoxPane != null) {
customFieldComboBoxPane.checkBoxUse(hasUse);
} }
} }
@ -137,6 +139,9 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
for (UIComboBox comboBox : filedComboBoxes()) { for (UIComboBox comboBox : filedComboBoxes()) {
clearBoxItems(comboBox); clearBoxItems(comboBox);
} }
if (customFieldComboBoxPane != null) {
customFieldComboBoxPane.clearAllBoxList();
}
} }
@Override @Override
@ -144,14 +149,33 @@ public abstract class AbstractExtendedChartTableDataPane<T extends AbstractDataC
for (UIComboBox comboBox : filedComboBoxes()) { for (UIComboBox comboBox : filedComboBoxes()) {
refreshBoxItems(comboBox, columnNameList); refreshBoxItems(comboBox, columnNameList);
} }
if (customFieldComboBoxPane != null) {
customFieldComboBoxPane.refreshBoxListWithSelectTableData(columnNameList);
}
} }
protected void populateField(UIComboBox comboBox, ExtendedField field) { protected void populateField(UIComboBox comboBox, ExtendedField field) {
comboBox.setSelectedItem(field.getFieldName()); populateFunctionField(comboBox, null, field);
} }
protected void updateField(UIComboBox comboBox, ExtendedField field) { protected void updateField(UIComboBox comboBox, ExtendedField field) {
updateFunctionField(comboBox, null, field);
}
protected void populateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ExtendedField field) {
comboBox.setSelectedItem(field.getFieldName());
if (calculateComboBox != null) {
calculateComboBox.populateBean((AbstractDataFunction) field.getDataFunction());
}
}
protected void updateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ExtendedField field) {
field.setFieldName(GeneralUtils.objectToString(comboBox.getSelectedItem())); field.setFieldName(GeneralUtils.objectToString(comboBox.getSelectedItem()));
if (calculateComboBox != null) {
field.setDataFunction(calculateComboBox.updateBean());
} else {
field.setDataFunction(null);
}
} }
} }

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

@ -0,0 +1,381 @@
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.data.CalculateComboBox;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.SeriesNameUseFieldNamePane;
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.
*/
public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane<AbstractDataConfig> {
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<String> fieldList = new ArrayList<String>();
@Override
protected void initLayout() {
this.setLayout(new BorderLayout(0, 6));
JPanel northPane = new JPanel(new BorderLayout());
northPane.add(jcb, BorderLayout.CENTER);
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From"));
label.setPreferredSize(new Dimension(82, 20));
northPane.add(label, BorderLayout.WEST);
this.add(northPane, BorderLayout.NORTH);
this.add(cardPane, BorderLayout.CENTER);
}
@Override
protected List<FurtherBasicBeanPane<? extends AbstractDataConfig>> initPaneList() {
useFieldValuePane = new UseFieldValuePane();
customFieldNamePane = new CustomFieldNamePane();
List<FurtherBasicBeanPane<? extends AbstractDataConfig>> list = new ArrayList<FurtherBasicBeanPane<? extends AbstractDataConfig>>();
list.add(useFieldValuePane);
list.add(customFieldNamePane);
return list;
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
public void checkBoxUse(boolean hasUse) {
jcb.setEnabled(hasUse);
useFieldValuePane.checkBoxUse(hasUse);
}
public void clearAllBoxList() {
useFieldValuePane.clearAllBoxList();
fieldList.clear();
}
protected void refreshBoxListWithSelectTableData(List columnNameList) {
useFieldValuePane.refreshBoxListWithSelectTableData(columnNameList);
fieldList = columnNameList;
}
@Override
public void populateBean(AbstractDataConfig ob) {
if (ob.isCustomName()) {
customFieldNamePane.populateBean(ob);
jcb.setSelectedIndex(1);
} else {
useFieldValuePane.populateBean(ob);
jcb.setSelectedIndex(0);
}
}
@Override
public void updateBean(AbstractDataConfig ob) {
if (jcb.getSelectedIndex() == 0) {
ob.setCustomName(false);
useFieldValuePane.updateBean(ob);
} else {
ob.setCustomName(true);
customFieldNamePane.updateBean(ob);
}
}
private class UseFieldValuePane extends FurtherBasicBeanPane<AbstractDataConfig> {
private UIComboBox series;
private UIComboBox value;
private CalculateComboBox function;
private UseFieldValuePane() {
initComponents();
}
private void initComponents() {
series = new UIComboBox();
value = new UIComboBox();
function = new CalculateComboBox();
Component[][] components = new Component[][]{
new Component[]{new UILabel("series", SwingConstants.LEFT), series},
new Component[]{new UILabel("value", SwingConstants.LEFT), value},
new Component[]{new UILabel("function", SwingConstants.LEFT), function},
};
double p = TableLayout.PREFERRED;
double[] columnSize = {76, 120};
double[] rowSize = {p, p, p};
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout(0, 6));
this.add(panel, BorderLayout.CENTER);
}
public void checkBoxUse(boolean hasUse) {
series.setEnabled(hasUse);
value.setEnabled(hasUse);
function.setEnabled(hasUse);
}
public void clearAllBoxList() {
AbstractTableDataContentPane.clearBoxItems(series);
AbstractTableDataContentPane.clearBoxItems(value);
}
public void refreshBoxListWithSelectTableData(List columnNameList) {
AbstractTableDataContentPane.refreshBoxItems(series, columnNameList);
AbstractTableDataContentPane.refreshBoxItems(value, columnNameList);
}
@Override
public void populateBean(AbstractDataConfig ob) {
List<ExtendedField> list = ob.getCustomFields();
if (list.size() == 2) {
series.setSelectedItem(list.get(0).getFieldName());
value.setSelectedItem(list.get(1).getFieldName());
function.populateBean((AbstractDataFunction) list.get(1).getDataFunction());
}
}
@Override
public void updateBean(AbstractDataConfig ob) {
List<ExtendedField> list = new ArrayList<ExtendedField>();
list.add(new ExtendedField(Utils.objectToString(series.getSelectedItem())));
ExtendedField field = new ExtendedField(Utils.objectToString(value.getSelectedItem()));
field.setDataFunction(function.updateBean());
list.add(field);
ob.setCustomFields(list);
}
@Override
public boolean accept(Object ob) {
return true;
}
@Override
public void reset() {
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Value");
}
@Override
public AbstractDataConfig updateBean() {
return null;
}
}
private class CustomFieldNamePane extends FurtherBasicBeanPane<AbstractDataConfig> {
private UICorrelationPane correlationPane;
public CustomFieldNamePane() {
initComponents();
}
private void initComponents() {
correlationPane = new UICorrelationPane(HEADS) {
@Override
protected ActionListener getAddButtonListener() {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
tablePane.addLine(new String[]{StringUtils.EMPTY, StringUtils.EMPTY, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")});
fireTargetChanged();
}
};
}
public UITableEditor createUITableEditor() {
return new Editor() {
@Override
protected UICorrelationPane getParent() {
return correlationPane;
}
};
}
};
this.setLayout(new BorderLayout());
this.add(correlationPane, BorderLayout.CENTER);
}
@Override
public void populateBean(AbstractDataConfig ob) {
List<ExtendedField> customFields = ob.getCustomFields();
List<Object[]> list = new ArrayList<Object[]>();
for (ExtendedField field : customFields) {
String[] array = {field.getFieldName(), field.getCustomName(), SeriesNameUseFieldNamePane.getFunctionString(field.getDataFunction())};
list.add(array);
}
correlationPane.populateBean(list);
}
@Override
public void updateBean(AbstractDataConfig ob) {
List<Object[]> list = correlationPane.updateBean();
List<ExtendedField> customFields = new ArrayList<ExtendedField>();
for (Object[] line : list) {
ExtendedField field = new ExtendedField(Utils.objectToString(line[0]));
field.setCustomName(Utils.objectToString(line[1]));
if (line.length > 2) {
field.setDataFunction(SeriesNameUseFieldNamePane.getFcuntionByName(Utils.objectToString(line[2])));
}
customFields.add(field);
}
ob.setCustomFields(customFields);
}
@Override
public boolean accept(Object ob) {
return true;
}
@Override
public void reset() {
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Name");
}
@Override
public AbstractDataConfig updateBean() {
return null;
}
}
private abstract class Editor extends UITableEditor {
private JComponent editorComponent;
protected abstract UICorrelationPane getParent();
@Override
public Object getCellEditorValue() {
if (editorComponent instanceof UIComboBox) {
return ((UIComboBox) editorComponent).getSelectedItem();
} else if (editorComponent instanceof UITextField) {
return ((UITextField) editorComponent).getText();
} else if (editorComponent instanceof CalculateComboBox) {
return ((CalculateComboBox) editorComponent).getSelectedItem();
}
return super.getCellEditorValue();
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, final int row, int column) {
switch (column) {
case 0:
editorComponent = createComboBoxEdit(row, value);
break;
case 1:
editorComponent = createTextEdit(value);
break;
default:
editorComponent = createCalculateComboBox(value);
break;
}
return editorComponent;
}
private void setDefaultName(int row) {
UITable table = getParent().getTable();
Object object = table.getValueAt(row, 0);
if (object != null) {
table.setValueAt(object, row, 1);
}
}
private UIComboBox createComboBoxEdit(final int row, Object value) {
UIComboBox uiComboBox = new UIComboBox(fieldList.toArray());
uiComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
getParent().stopCellEditing();
getParent().fireTargetChanged();
setDefaultName(row);
}
});
if (value != null && StringUtils.isNotEmpty(value.toString())) {
uiComboBox.getModel().setSelectedItem(value);
} else {
uiComboBox.getModel().setSelectedItem(value);
}
return uiComboBox;
}
private UITextField createTextEdit(Object value) {
UITextField uiTextField = new UITextField();
if (value != null) {
uiTextField.setText(value.toString());
}
uiTextField.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
getParent().fireTargetChanged();
}
});
return uiTextField;
}
private CalculateComboBox createCalculateComboBox(Object value) {
CalculateComboBox calculateComboBox = new CalculateComboBox();
if (value != null) {
calculateComboBox.setSelectedItem(value);
}
calculateComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
getParent().stopCellEditing();
getParent().fireTargetChanged();
}
});
return calculateComboBox;
}
}
}
Loading…
Cancel
Save