|
|
|
package com.fr.design.dscolumn;
|
|
|
|
|
|
|
|
import com.fr.design.constants.LayoutConstants;
|
|
|
|
import com.fr.design.gui.ibutton.UIButton;
|
|
|
|
import com.fr.design.gui.ibutton.UIRadioButton;
|
|
|
|
import com.fr.design.gui.icombobox.FunctionComboBox;
|
|
|
|
import com.fr.design.i18n.Toolkit;
|
|
|
|
|
|
|
|
import com.fr.report.cell.TemplateCellElement;
|
|
|
|
import com.fr.design.utils.gui.GUICoreUtils;
|
|
|
|
import com.fr.report.cell.cellattr.core.group.CustomGrouper;
|
|
|
|
import com.fr.report.cell.cellattr.core.group.DSColumn;
|
|
|
|
import com.fr.report.cell.cellattr.core.group.FunctionGrouper;
|
|
|
|
import com.fr.report.cell.cellattr.core.group.RecordGrouper;
|
|
|
|
import com.fr.report.cell.cellattr.core.group.SummaryGrouper;
|
|
|
|
|
|
|
|
import javax.swing.ButtonGroup;
|
|
|
|
import java.awt.BorderLayout;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
import java.awt.event.ItemEvent;
|
|
|
|
import java.awt.event.ItemListener;
|
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.cell;
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.column;
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.row;
|
|
|
|
|
|
|
|
public class ResultSetGroupPopUpPane extends ResultSetGroupPane {
|
|
|
|
|
|
|
|
private UIRadioButton groupRadioButton;
|
|
|
|
private UIButton advancedButton;
|
|
|
|
private UIRadioButton listRadioButton;
|
|
|
|
private UIRadioButton summaryRadioButton;
|
|
|
|
private FunctionComboBox functionComboBox;
|
|
|
|
|
|
|
|
public ResultSetGroupPopUpPane() {
|
|
|
|
this(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 将结果集进行分组: 分组,列表,汇总,自定义
|
|
|
|
public ResultSetGroupPopUpPane(boolean isGroup) {
|
|
|
|
super();
|
|
|
|
this.initComponents(isGroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void initComponents(boolean isGroup) {
|
|
|
|
this.setLayout(new BorderLayout());
|
|
|
|
|
|
|
|
// 分组
|
|
|
|
groupRadioButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Bind_Column_Group(Merger_The_Items_Which_Have_The_Same_Value_in_Column)"));
|
|
|
|
groupRadioButton.addActionListener(checkEnabledActionListener);
|
|
|
|
|
|
|
|
groupComboBox.addItemListener(new ItemListener() {
|
|
|
|
public void itemStateChanged(ItemEvent e) {
|
|
|
|
checkButtonEnabled();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
advancedButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"));
|
|
|
|
advancedButton.addActionListener(groupAdvancedListener);
|
|
|
|
|
|
|
|
// 列表
|
|
|
|
listRadioButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Bind_Column_Select(Regardless_of_Having_the_Same_Value,Display_All_Item_in_Column)"));
|
|
|
|
listRadioButton.addActionListener(checkEnabledActionListener);
|
|
|
|
|
|
|
|
// 汇总
|
|
|
|
summaryRadioButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Bind_Column_Summary(Including_SUM_,_AVERAGE_,_MAX_,_MIN_And_So_On)"), true);
|
|
|
|
summaryRadioButton.addActionListener(checkEnabledActionListener);
|
|
|
|
functionComboBox = new FunctionComboBox(GUICoreUtils.getFunctionArray());
|
|
|
|
|
|
|
|
this.add(column(LayoutConstants.VERTICAL_GAP,
|
|
|
|
row(10,
|
|
|
|
cell(groupRadioButton), cell(groupComboBox), cell(advancedButton)
|
|
|
|
),
|
|
|
|
cell(listRadioButton),
|
|
|
|
row(10,
|
|
|
|
cell(summaryRadioButton), cell(functionComboBox)
|
|
|
|
)
|
|
|
|
).getComponent());
|
|
|
|
|
|
|
|
ButtonGroup resultSetGroupButtonGroup = new ButtonGroup();
|
|
|
|
resultSetGroupButtonGroup.add(groupRadioButton);
|
|
|
|
if (isGroup) {
|
|
|
|
groupRadioButton.setSelected(true);
|
|
|
|
} else {
|
|
|
|
listRadioButton.setSelected(true);
|
|
|
|
}
|
|
|
|
resultSetGroupButtonGroup.add(listRadioButton);
|
|
|
|
resultSetGroupButtonGroup.add(summaryRadioButton);
|
|
|
|
checkButtonEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void populate(TemplateCellElement cellElement) {
|
|
|
|
this.cellElement = cellElement;
|
|
|
|
|
|
|
|
if (isNPE(cellElement)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
DSColumn dSColumn = (DSColumn) cellElement.getValue();
|
|
|
|
|
|
|
|
// populate groupPane
|
|
|
|
// RecordGrouper
|
|
|
|
recordGrouper = dSColumn.getGrouper();
|
|
|
|
if (recordGrouper instanceof FunctionGrouper && !((FunctionGrouper) recordGrouper).isCustom()) {
|
|
|
|
int mode = ((FunctionGrouper) recordGrouper).getDivideMode();
|
|
|
|
if (mode == FunctionGrouper.GROUPING_MODE) {
|
|
|
|
this.groupRadioButton.setSelected(true);
|
|
|
|
this.groupComboBox.setSelectedIndex(COMMON);
|
|
|
|
} else if (mode == FunctionGrouper.CONTINUUM_MODE) {
|
|
|
|
this.groupRadioButton.setSelected(true);
|
|
|
|
this.groupComboBox.setSelectedIndex(CONTINUUM);
|
|
|
|
} else if (mode == FunctionGrouper.LIST_MODE) {
|
|
|
|
this.listRadioButton.setSelected(true);
|
|
|
|
}
|
|
|
|
} else if (recordGrouper instanceof FunctionGrouper && ((FunctionGrouper) recordGrouper).isCustom()) {
|
|
|
|
// 这种情况也放到自定义分组里面
|
|
|
|
this.groupRadioButton.setSelected(true);
|
|
|
|
this.groupComboBox.setSelectedIndex(ADVANCED);
|
|
|
|
} else if (recordGrouper instanceof SummaryGrouper) {
|
|
|
|
this.summaryRadioButton.setSelected(true);
|
|
|
|
this.functionComboBox.setFunction(((SummaryGrouper) recordGrouper).getFunction());
|
|
|
|
} else if (recordGrouper instanceof CustomGrouper) {
|
|
|
|
// 自定义分组 or 高级分组
|
|
|
|
this.groupRadioButton.setSelected(true);
|
|
|
|
this.groupComboBox.setSelectedIndex(ADVANCED);
|
|
|
|
}
|
|
|
|
|
|
|
|
checkButtonEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void update() {
|
|
|
|
if (isNPE(cellElement)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
DSColumn dSColumn = (DSColumn) cellElement.getValue();
|
|
|
|
|
|
|
|
if (this.groupRadioButton.isSelected()) {
|
|
|
|
recordGrouper = updateGroupCombox();
|
|
|
|
} else if (this.listRadioButton.isSelected()) {
|
|
|
|
FunctionGrouper valueGrouper = new FunctionGrouper();
|
|
|
|
valueGrouper.setDivideMode(FunctionGrouper.LIST_MODE);
|
|
|
|
valueGrouper.setCustom(false);
|
|
|
|
recordGrouper = valueGrouper;
|
|
|
|
} else if (this.summaryRadioButton.isSelected()) {
|
|
|
|
SummaryGrouper summaryGrouper = new SummaryGrouper();
|
|
|
|
summaryGrouper.setFunction(functionComboBox.getFunction());
|
|
|
|
recordGrouper = summaryGrouper;
|
|
|
|
}
|
|
|
|
|
|
|
|
dSColumn.setGrouper(recordGrouper);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void checkButtonEnabled() {
|
|
|
|
advancedButton.setEnabled(false);
|
|
|
|
functionComboBox.setEnabled(false);
|
|
|
|
groupComboBox.setEnabled(false);
|
|
|
|
if (summaryRadioButton.isSelected()) {
|
|
|
|
functionComboBox.setEnabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (groupRadioButton.isSelected()) {
|
|
|
|
groupComboBox.setEnabled(true);
|
|
|
|
if (groupComboBox.getSelectedIndex() == 2) {
|
|
|
|
advancedButton.setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isSummaryRadioButtonSelected() {
|
|
|
|
return summaryRadioButton.isSelected();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addListeners(ActionListener summaryListener, ActionListener otherListener, ActionListener sdcListener) {
|
|
|
|
summaryRadioButton.addActionListener(summaryListener);
|
|
|
|
groupRadioButton.addActionListener(otherListener);
|
|
|
|
listRadioButton.addActionListener(otherListener);
|
|
|
|
advancedButton.addActionListener(sdcListener);
|
|
|
|
}
|
|
|
|
|
|
|
|
ActionListener checkEnabledActionListener = new ActionListener() {
|
|
|
|
public void actionPerformed(ActionEvent evt) {
|
|
|
|
checkButtonEnabled();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setRecordGrouper(RecordGrouper recordGrouper) {
|
|
|
|
this.recordGrouper = recordGrouper;
|
|
|
|
}
|
|
|
|
}
|