Browse Source

REPORT-55243:重新设计报表引擎面板

research/11.0
fly.li 3 years ago
parent
commit
9656286078
  1. 211
      designer-realize/src/main/java/com/fr/design/report/LayerReportEnginePane.java

211
designer-realize/src/main/java/com/fr/design/report/LayerReportEnginePane.java

@ -0,0 +1,211 @@
package com.fr.design.report;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.editor.editor.IntegerEditor;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.FRExplainLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.locale.InterProviderFactory;
import com.fr.report.core.ReportUtils;
import com.fr.report.stable.LayerReportAttr;
import com.fr.report.worksheet.WorkSheet;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
/**
* @author fly.li
* @version 10.0
* Created on 2021/08/22
*/
public class LayerReportEnginePane extends BasicBeanPane<LayerReportAttr> {
private static final int LABEL_HEIGHT = 55;
private UICheckBox isClientPaging;
private UICheckBox isShowDataNumber;
private UICheckBox isPageQueryBox;
private IntegerEditor countPerPageEditor;
private WorkSheet worksheet;
private List<JRadioButton> radioButtons = new ArrayList<>(2);
public LayerReportEnginePane(WorkSheet worksheet) {
this.worksheet = worksheet;
this.initComponents();
}
public LayerReportEnginePane() {
this(null);
}
protected void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel outlayerReportPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Report_Engine_Attribute"));
JPanel layerReportPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane();
this.add(outlayerReportPane);
outlayerReportPane.add(layerReportPane);
JPanel isClientPagingPanle = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
isClientPaging = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Enable_Client_Page"));
isClientPaging.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
if (isClientPaging.isSelected()){
isPageQueryBox.setEnabled(true);
}else{
isPageQueryBox.setEnabled(false);
}
}
});
isClientPaging.setSelected(false);
isClientPagingPanle.add(isClientPaging);
layerReportPane.add(isClientPagingPanle);
UIRadioButton lineEngine = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_New_Engine"), false);
UIRadioButton newEngine = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Line_Engine"), false);
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(newEngine);
buttonGroup.add(lineEngine);
radioButtons.add(lineEngine);
radioButtons.add(newEngine);
double p = TableLayout.PREFERRED;
double[] rowSize = {p};
double[] columnSize = {p, p, p, p, p};
Component[][] components = new Component[][]{
new Component[] {
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Page_Engine_Select")),
lineEngine,
newEngine
}
};
JPanel pagingEngineRadioPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
layerReportPane.add(pagingEngineRadioPanel);
JPanel infoPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Attention"));
FRExplainLabel label = new FRExplainLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Layer_Report_Warnning_Info"));
label.setPreferredSize(new Dimension(label.getPreferredSize().width, LABEL_HEIGHT));
infoPane.add(label);
layerReportPane.add(infoPane);
JPanel isShowDataNumberPanle = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
isShowDataNumber = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Show_Data_Total_Number"));
isShowDataNumber.setSelected(false);
isShowDataNumberPanle.add(isShowDataNumber);
layerReportPane.add(isShowDataNumberPanle);
JPanel isPageQueryBoxPanle = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
isPageQueryBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Fixed_Line_Paging"));
isPageQueryBox.setSelected(false);
isPageQueryBox.setEnabled(false);
isPageQueryBoxPanle.add(isPageQueryBox);
layerReportPane.add(isPageQueryBoxPanle);
isPageQueryBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if (isPageQueryBox.isSelected()) {
countPerPageEditor.setEnabled(true);
} else {
countPerPageEditor.setEnabled(false);
}
}
});
JPanel pageQueryPane = createPageQueryPane();
layerReportPane.add(pageQueryPane);
}
private JPanel createPageQueryPane() {
double p = TableLayout.PREFERRED;
double rowSize[] = {p, p};
double columnSize[] = {p, p};
countPerPageEditor = new IntegerEditor(new Integer(30));
countPerPageEditor.setPreferredSize(new Dimension(120,20));
countPerPageEditor.setEnabled(false);
Component[][] components = {{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_LayerPageReport_Count_PerPage") + ":"), countPerPageEditor}};
JPanel pageQueryPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
pageQueryPane.setBorder(BorderFactory.createEmptyBorder(5, 15, 0, 0));
return pageQueryPane;
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Report_Engine_Attribute");
}
@Override
public void populateBean(LayerReportAttr ob) {
if (ob == null){
setDefaultAttr();
return;
}
isClientPaging.setSelected(ob.isClientPaging());
isShowDataNumber.setSelected(ob.isShowDataNumber());
countPerPageEditor.setValue(new Integer(ob.getCountPerPage()));
if (ob.isPageQuery()) {
isPageQueryBox.setSelected(true);
countPerPageEditor.setEnabled(true);
} else {
isPageQueryBox.setSelected(false);
countPerPageEditor.setEnabled(false);
}
radioButtons.get(0).setSelected(ob.isNewEngine());
radioButtons.get(1).setSelected(!ob.isNewEngine());
}
@Override
public LayerReportAttr updateBean() {
//这里注意一下怎么更新的,后续可能存在判断为空的调用,从而对老引擎造成影响。
LayerReportAttr attr = new LayerReportAttr();
attr.setPageQuery(isPageQueryBox.isSelected());
attr.setCountPerPage(Math.min(500, ((Integer)countPerPageEditor.getValue()).intValue()));
attr.setClientPaging(isClientPaging.isSelected());
attr.setShowDataNumber(isShowDataNumber.isSelected());
for (int i = 0; i < radioButtons.size(); i++){
if (radioButtons.get(i).isSelected()){
attr.setNewEngine((i == 0));
}
}
return attr;
}
@Override
public void checkValid() throws Exception {
if (isClientPaging.isSelected()) {
if (!ReportUtils.isLayerReportUsable(worksheet)) {
int value = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_After_Changed_Some_Attributes_Are_Different") + "?",
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION);
if (value != JOptionPane.YES_OPTION) {
isClientPaging.setSelected(false);
}
}
}
}
public void setDefaultAttr(){
isClientPaging.setSelected(false);
isShowDataNumber.setSelected(false);
countPerPageEditor.setValue(new Integer(30));
countPerPageEditor.setEnabled(false);
isPageQueryBox.setSelected(false);
isPageQueryBox.setEnabled(false);
radioButtons.get(0).setSelected(false);
radioButtons.get(1).setSelected(false);
}
}
Loading…
Cancel
Save