forked from fanruan/finekit
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
3.3 KiB
119 lines
3.3 KiB
6 years ago
|
package com.fanruan.api.design.chart.field;
|
||
|
|
||
|
import com.fanruan.api.design.ui.component.UIComboBox;
|
||
|
import com.fanruan.api.design.ui.component.chart.CalculateComboBox;
|
||
|
import com.fanruan.api.engine.chart.field.BaseColumnFieldCollection;
|
||
|
import com.fr.chartx.data.field.ColumnField;
|
||
|
import com.fr.design.chartx.fields.AbstractDataSetFieldsPane;
|
||
|
import com.fr.general.GeneralUtils;
|
||
|
|
||
|
import javax.swing.JPanel;
|
||
|
import java.awt.Component;
|
||
|
|
||
|
/**
|
||
|
* @author Bjorn
|
||
|
* @version 10.0
|
||
|
* Created by Bjorn on 2019-09-17
|
||
|
*/
|
||
|
public abstract class BaseDataSetFieldsPane<T extends BaseColumnFieldCollection> extends AbstractDataSetFieldsPane<T> {
|
||
|
/**
|
||
|
* 初始化面板布局,默认会加载北部、中部和南部的面板
|
||
|
*/
|
||
|
@Override
|
||
|
protected void initComponents() {
|
||
|
super.initComponents();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 创建中部位置的面板,默认会通过所有的组件和组件名称生成面板。
|
||
|
*
|
||
|
* @return 面板
|
||
|
*/
|
||
|
@Override
|
||
|
protected JPanel createCenterPane() {
|
||
|
return super.createCenterPane();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 创建北部位置的面板,默认生成空面板
|
||
|
*
|
||
|
* @return 面板
|
||
|
*/
|
||
|
@Override
|
||
|
protected JPanel createNorthPane() {
|
||
|
return super.createNorthPane();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 创建南部位置的面板,默认生成空面板
|
||
|
*
|
||
|
* @return 面板
|
||
|
*/
|
||
|
@Override
|
||
|
protected JPanel createSouthPane() {
|
||
|
return super.createSouthPane();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 面板中所有组件,默认会去获取所有下拉框组件
|
||
|
*
|
||
|
* @return 所有组件的集合
|
||
|
*/
|
||
|
@Override
|
||
|
protected Component[] fieldComponents() {
|
||
|
return super.fieldComponents();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 面板中所有组件的名称
|
||
|
*
|
||
|
* @return 所有组件的名称集合
|
||
|
*/
|
||
|
@Override
|
||
|
protected abstract String[] fieldLabels();
|
||
|
|
||
|
/**
|
||
|
* 面板中的下拉框组件
|
||
|
*
|
||
|
* @return 下拉框组件的集合
|
||
|
*/
|
||
|
@Override
|
||
|
protected abstract UIComboBox[] filedComboBoxes();
|
||
|
|
||
|
/**
|
||
|
* 根据字段对象的属性,更新下拉选择组件的值
|
||
|
*/
|
||
|
protected void populateField(UIComboBox comboBox, ColumnField field) {
|
||
|
AbstractDataSetFieldsPane.populateField(comboBox, field);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 根据下拉选择组件的值,更新字段对象的属性
|
||
|
*/
|
||
|
protected void updateField(UIComboBox comboBox, ColumnField field) {
|
||
|
AbstractDataSetFieldsPane.updateField(comboBox, field);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 根据字段对象的属性,更新下拉选择组件和汇总方式选择组件的值
|
||
|
*/
|
||
|
protected void populateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ColumnField field) {
|
||
|
comboBox.setSelectedItem(field.getFieldName());
|
||
|
if (calculateComboBox != null) {
|
||
|
calculateComboBox.populateBean(field.getDataFunction());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 根据下拉选择组件和汇总方式选择组件的值,更新字段对象的属性
|
||
|
*/
|
||
|
protected 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);
|
||
|
}
|
||
|
}
|
||
|
}
|