|
|
|
package com.fr.design.webattr;
|
|
|
|
|
|
|
|
import com.fr.design.ExtraDesignClassManager;
|
|
|
|
import com.fr.design.gui.core.WidgetOption;
|
|
|
|
import com.fr.design.gui.ibutton.UIRadioButton;
|
|
|
|
import com.fr.design.gui.icheckbox.UICheckBox;
|
|
|
|
import com.fr.design.gui.ilable.UILabel;
|
|
|
|
import com.fr.design.gui.itextfield.UITextField;
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory;
|
|
|
|
import com.fr.design.layout.TableLayout;
|
|
|
|
import com.fr.design.layout.TableLayoutHelper;
|
|
|
|
import com.fr.general.ComparatorUtils;
|
|
|
|
import com.fr.report.web.ToolBarManager;
|
|
|
|
import com.fr.report.web.WebPage;
|
|
|
|
import com.fr.stable.StringUtils;
|
|
|
|
import com.fr.web.attr.ReportWebAttr;
|
|
|
|
import com.fr.design.i18n.Toolkit;
|
|
|
|
|
|
|
|
import java.awt.Color;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
import java.awt.event.InputMethodEvent;
|
|
|
|
import java.awt.event.InputMethodListener;
|
|
|
|
import java.awt.event.KeyAdapter;
|
|
|
|
import java.awt.event.KeyEvent;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import javax.swing.ButtonGroup;
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
import java.awt.Component;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class PageWebSettingPane extends WebSettingPane<WebPage> {
|
|
|
|
private UIRadioButton centerRadioButton;
|
|
|
|
private UIRadioButton leftRadioButton;
|
|
|
|
private UICheckBox isShowAsImageBox;
|
|
|
|
private UICheckBox isAutoScaleBox;
|
|
|
|
private UICheckBox isTDHeavyBox;
|
|
|
|
private UICheckBox isPageFixedRowBox;
|
|
|
|
private UITextField pageFixedRowCountTextField;
|
|
|
|
private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92);
|
|
|
|
private static final Pattern ROW_COUNT = Pattern.compile("^[1-9][\\d]*$|^0");
|
|
|
|
private static final String DEFAULT_ROW_COUNT = "30";
|
|
|
|
|
|
|
|
//固定行数分页,每页最多500行,最少1行数据
|
|
|
|
private static final int MAX_ROW_COUNT = 500;
|
|
|
|
private static final int MIN_ROW_COUNT = 1;
|
|
|
|
|
|
|
|
public PageWebSettingPane() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected JPanel createOtherSetPane() {
|
|
|
|
centerRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Center_Display"));
|
|
|
|
leftRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Left_Display"));
|
|
|
|
ButtonGroup buttonGroup = new ButtonGroup();
|
|
|
|
leftRadioButton.setSelected(true);
|
|
|
|
buttonGroup.add(centerRadioButton);
|
|
|
|
buttonGroup.add(leftRadioButton);
|
|
|
|
JPanel buttonpane = new JPanel(FRGUIPaneFactory.createBoxFlowLayout());
|
|
|
|
buttonpane.add(centerRadioButton);
|
|
|
|
buttonpane.add(leftRadioButton);
|
|
|
|
isShowAsImageBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Is_Paint_Page"));
|
|
|
|
isAutoScaleBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_IS_Auto_Scale"));
|
|
|
|
isTDHeavyBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_IS_TD_HEAVY_EXPORT"), false);
|
|
|
|
isPageFixedRowBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Page_Fixed_Row"));
|
|
|
|
isPageFixedRowBox.addActionListener(new ActionListener() {
|
|
|
|
@Override
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
pageFixedRowCountTextField.setEnabled(isPageFixedRowBox.isSelected());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
double p = TableLayout.PREFERRED;
|
|
|
|
|
|
|
|
pageFixedRowCountTextField = new UITextField(5);
|
|
|
|
pageFixedRowCountTextField.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Page_Fixed_Row_Count_Tip"));
|
|
|
|
pageFixedRowCountTextField.addKeyListener(new KeyAdapter() {
|
|
|
|
@Override
|
|
|
|
public void keyReleased(KeyEvent e) {
|
|
|
|
String rowCount = pageFixedRowCountTextField.getText();
|
|
|
|
pageFixedRowCountTextField.setText(convert2ValidRowCount(rowCount));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
pageFixedRowCountTextField.addInputMethodListener(new InputMethodListener() {
|
|
|
|
@Override
|
|
|
|
public void inputMethodTextChanged(InputMethodEvent event) {
|
|
|
|
if (null == event.getText()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
char ch = event.getText().current();
|
|
|
|
if (!(ch >= '0' && ch <= '9')) {
|
|
|
|
event.consume();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public void caretPositionChanged(InputMethodEvent event) {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
UILabel linesPerPageLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Rows_Per_Page") + ":");
|
|
|
|
Component[][] rowCountTextFieldComponents = {{linesPerPageLabel,pageFixedRowCountTextField}};
|
|
|
|
JPanel linesPerPagePane = TableLayoutHelper.createTableLayoutPane(rowCountTextFieldComponents, new double[]{p}, new double[]{p,p});
|
|
|
|
UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Page_Fixed_Row_Tip"));
|
|
|
|
tipLabel.setForeground(TIPS_FONT_COLOR);
|
|
|
|
|
|
|
|
double[] columnSize = {p, p, p, p};
|
|
|
|
double[] rowSize = {p, p, p, p};
|
|
|
|
Component[][] components = new Component[][]{
|
|
|
|
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Show_Location") + ":", UILabel.RIGHT), buttonpane, null, null},
|
|
|
|
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_PageSetup_Page") + ":", UILabel.RIGHT), isShowAsImageBox, isAutoScaleBox, isTDHeavyBox},
|
|
|
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Paging_Settings") + ":", UILabel.RIGHT), isPageFixedRowBox, linesPerPagePane, null},
|
|
|
|
new Component[]{null, tipLabel, null, null}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void checkEnabled(boolean isSelected) {
|
|
|
|
super.checkEnabled(isSelected);
|
|
|
|
centerRadioButton.setEnabled(isSelected);
|
|
|
|
leftRadioButton.setEnabled(isSelected);
|
|
|
|
isShowAsImageBox.setEnabled(isSelected);
|
|
|
|
isAutoScaleBox.setEnabled(isSelected);
|
|
|
|
isTDHeavyBox.setEnabled(isSelected);
|
|
|
|
isPageFixedRowBox.setEnabled(isSelected);
|
|
|
|
pageFixedRowCountTextField.setEnabled(isSelected);
|
|
|
|
}
|
|
|
|
protected void setDefault(){
|
|
|
|
super.setDefault();
|
|
|
|
leftRadioButton.setSelected(true);
|
|
|
|
isShowAsImageBox.setSelected(false);
|
|
|
|
isAutoScaleBox.setSelected(false);
|
|
|
|
isTDHeavyBox.setSelected(false);
|
|
|
|
isPageFixedRowBox.setSelected(false);
|
|
|
|
pageFixedRowCountTextField.setText(DEFAULT_ROW_COUNT);
|
|
|
|
pageFixedRowCountTextField.setEnabled(false);
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
protected void populateSubWebSettingrBean(WebPage webPage) {
|
|
|
|
if (webPage == null) {
|
|
|
|
webPage = new WebPage();
|
|
|
|
}
|
|
|
|
if (webPage.isViewAtCenter()) {
|
|
|
|
centerRadioButton.setSelected(true);
|
|
|
|
} else {
|
|
|
|
leftRadioButton.setSelected(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
isShowAsImageBox.setSelected(webPage.isShowAsImage());
|
|
|
|
isAutoScaleBox.setSelected(webPage.isAutoScaleWhenEmbeddedInIframe());
|
|
|
|
isTDHeavyBox.setSelected(webPage.isTDHeavy());
|
|
|
|
isPageFixedRowBox.setSelected(webPage.isPageFixedRow());
|
|
|
|
pageFixedRowCountTextField.setText(webPage.getPageFixedRowCount().toString());
|
|
|
|
pageFixedRowCountTextField.setEnabled(webPage.isPageFixedRow());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected WebPage updateSubWebSettingBean() {
|
|
|
|
WebPage webPage = new WebPage();
|
|
|
|
webPage.setViewAtCenter(centerRadioButton.isSelected());
|
|
|
|
webPage.setShowAsImage(isShowAsImageBox.isSelected());
|
|
|
|
webPage.setAutoScaleWhenEmbeddedInIframe(isAutoScaleBox.isSelected());
|
|
|
|
webPage.setTDHeavy(isTDHeavyBox.isSelected());
|
|
|
|
webPage.setPageFixedRow(isPageFixedRowBox.isSelected());
|
|
|
|
if (!ComparatorUtils.equals(pageFixedRowCountTextField.getText(), StringUtils.EMPTY)) {
|
|
|
|
webPage.setPageFixedRowCount(Integer.parseInt(pageFixedRowCountTextField.getText()));
|
|
|
|
}
|
|
|
|
return webPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected ToolBarManager getDefaultToolBarManager() {
|
|
|
|
return ToolBarManager.createDefaultToolBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected WidgetOption[] getToolBarInstance() {
|
|
|
|
List<WidgetOption> defaultOptions = Arrays.asList(ReportWebWidgetConstants.getPageToolBarInstance());
|
|
|
|
List<WidgetOption> extraOptions = Arrays.asList(ExtraDesignClassManager.getInstance().getWebWidgetOptions());
|
|
|
|
List<WidgetOption> options = new ArrayList<WidgetOption>();
|
|
|
|
options.addAll(defaultOptions);
|
|
|
|
options.addAll(extraOptions);
|
|
|
|
return options.toArray(new WidgetOption[options.size()]);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected WebPage getWebContent(ReportWebAttr reportWebAttr) {
|
|
|
|
return reportWebAttr == null ? null :reportWebAttr.getWebPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String[] getEventNames() {
|
|
|
|
return new WebPage().supportedEvents();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void setWebContent(ReportWebAttr reportWebAttr,WebPage webContent) {
|
|
|
|
reportWebAttr.setWebPage(webContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
private String convert2ValidRowCount(String rowCount) {
|
|
|
|
Matcher matcher = ROW_COUNT.matcher(rowCount);
|
|
|
|
if (matcher.find()) {
|
|
|
|
int count = Integer.parseInt(matcher.group());
|
|
|
|
if (count > MAX_ROW_COUNT) {
|
|
|
|
count = MAX_ROW_COUNT;
|
|
|
|
} else if (count < MIN_ROW_COUNT) {
|
|
|
|
count = MIN_ROW_COUNT;
|
|
|
|
}
|
|
|
|
return String.valueOf(count);
|
|
|
|
}
|
|
|
|
return StringUtils.EMPTY;
|
|
|
|
}
|
|
|
|
}
|