|
|
|
package com.fr.design.report;
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.design.constants.UIConstants;
|
|
|
|
import com.fr.design.dialog.BasicPane;
|
|
|
|
import com.fr.design.gui.ibutton.UIRadioButton;
|
|
|
|
import com.fr.design.gui.icheckbox.UICheckBox;
|
|
|
|
import com.fr.design.gui.ilable.ActionLabel;
|
|
|
|
import com.fr.design.gui.ilable.MultilineLabel;
|
|
|
|
import com.fr.design.gui.ilable.UILabel;
|
|
|
|
import com.fr.design.gui.itextfield.UITextField;
|
|
|
|
import com.fr.design.i18n.DesignSizeI18nManager;
|
|
|
|
import com.fr.design.i18n.Toolkit;
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory;
|
|
|
|
import com.fr.io.attr.WordExportAttr;
|
|
|
|
import com.fr.stable.StringUtils;
|
|
|
|
|
|
|
|
import javax.swing.AbstractButton;
|
|
|
|
import javax.swing.BorderFactory;
|
|
|
|
import javax.swing.ButtonGroup;
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
import java.awt.Color;
|
|
|
|
import java.awt.Dimension;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
|
|
|
public class WordExportPane extends BasicPane {
|
|
|
|
private UICheckBox isExportAsTable;
|
|
|
|
// 编辑保护
|
|
|
|
private UICheckBox writeProtect;
|
|
|
|
// 工作表密码
|
|
|
|
private UITextField protectedField;
|
|
|
|
// 工作表密码
|
|
|
|
private UIRadioButton workbookPassword;
|
|
|
|
// 仅限预览
|
|
|
|
private UIRadioButton onlyForPreview;
|
|
|
|
// 导出水印
|
|
|
|
private UICheckBox exportWaterMark;
|
|
|
|
|
|
|
|
private JPanel writeProtectPane;
|
|
|
|
|
|
|
|
public WordExportPane() {
|
|
|
|
this.initComponents();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void initComponents() {
|
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout());
|
|
|
|
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
|
|
|
JPanel outPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane("Word" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Excel_Export"));
|
|
|
|
JPanel outNorthPane =FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Export_Setting"));
|
|
|
|
outNorthPane.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.WordExportPane.outNorthPane"));
|
|
|
|
this.add(outPane);
|
|
|
|
outPane.add(outNorthPane);
|
|
|
|
|
|
|
|
isExportAsTable = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Is_Need_Word_Adjust"), false);
|
|
|
|
|
|
|
|
MultilineLabel wordLineLabel = new MultilineLabel();
|
|
|
|
wordLineLabel.setPreferredSize(new Dimension(560, 50));
|
|
|
|
wordLineLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alert_Word"));
|
|
|
|
wordLineLabel.setForeground(Color.GRAY);
|
|
|
|
|
|
|
|
outNorthPane.add(isExportAsTable);
|
|
|
|
outNorthPane.add(wordLineLabel);
|
|
|
|
// 内容保护
|
|
|
|
JPanel outSouthPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Export_Content_Protect"));
|
|
|
|
outSouthPane.setPreferredSize(new Dimension(580, 250));
|
|
|
|
outPane.add(outSouthPane);
|
|
|
|
// 编辑保护
|
|
|
|
writeProtect = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Export_Write_Protect"), false);
|
|
|
|
outSouthPane.add(writeProtect);
|
|
|
|
// 编辑保护勾选后展示的内容
|
|
|
|
writeProtectPane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true);
|
|
|
|
outSouthPane.add(writeProtectPane);
|
|
|
|
// 工作表密码
|
|
|
|
workbookPassword = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sheet_Password"), true);
|
|
|
|
JPanel protectedWordPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
|
|
|
|
protectedField = new UITextField(11);
|
|
|
|
protectedWordPane.add(workbookPassword);
|
|
|
|
protectedWordPane.add(protectedField);
|
|
|
|
// 仅限预览
|
|
|
|
onlyForPreview = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Export_Only_For_Preview"));
|
|
|
|
JPanel onlyForPreviewPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
|
|
|
|
onlyForPreviewPane.add(onlyForPreview);
|
|
|
|
wrapButtonsInButtonGroup(workbookPassword, onlyForPreview);
|
|
|
|
writeProtectPane.add(protectedWordPane);
|
|
|
|
writeProtectPane.add(onlyForPreviewPane);
|
|
|
|
writeProtect.addActionListener(new ActionListener() {
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
if (writeProtect.isSelected()) {
|
|
|
|
writeProtectPane.setVisible(true);
|
|
|
|
} else {
|
|
|
|
writeProtectPane.setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
// 导出水印
|
|
|
|
exportWaterMark = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Export_WaterMark"), false);
|
|
|
|
outSouthPane.add(exportWaterMark);
|
|
|
|
|
|
|
|
JPanel tips = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(5, 5, 0);
|
|
|
|
UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Export_WaterMark_Tips"));
|
|
|
|
uiLabel.setForeground(Color.GRAY);
|
|
|
|
ActionLabel actionLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Report_Export_WaterMark_Use"), UIConstants.FLESH_BLUE);
|
|
|
|
actionLabel.addActionListener(new ActionListener() {
|
|
|
|
@Override
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
writeProtect.setSelected(true);
|
|
|
|
writeProtectPane.setVisible(true);
|
|
|
|
onlyForPreview.setSelected(true);
|
|
|
|
exportWaterMark.setSelected(true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
tips.add(uiLabel);
|
|
|
|
tips.add(actionLabel);
|
|
|
|
outSouthPane.add(tips);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String title4PopupWindow() {
|
|
|
|
return "WordExport";
|
|
|
|
}
|
|
|
|
|
|
|
|
public void populate(WordExportAttr wordExportAttr) {
|
|
|
|
if(wordExportAttr == null){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(wordExportAttr.isExportAsTable()){
|
|
|
|
isExportAsTable.setSelected(true);
|
|
|
|
// southPane.setVisible(true);
|
|
|
|
}
|
|
|
|
if (wordExportAttr.isWriteProtect()) {
|
|
|
|
if (wordExportAttr.isUseProtectedWord() && StringUtils.isNotEmpty(wordExportAttr.getProtectedWord())) {
|
|
|
|
writeProtect.setSelected(true);
|
|
|
|
writeProtectPane.setVisible(true);
|
|
|
|
workbookPassword.setSelected(true);
|
|
|
|
protectedField.setText(wordExportAttr.getProtectedWord());
|
|
|
|
} else if (!wordExportAttr.isUseProtectedWord()) {
|
|
|
|
writeProtect.setSelected(true);
|
|
|
|
writeProtectPane.setVisible(true);
|
|
|
|
onlyForPreview.setSelected(true);
|
|
|
|
} else {
|
|
|
|
this.writeProtect.setSelected(false);
|
|
|
|
this.writeProtectPane.setVisible(false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.writeProtect.setSelected(false);
|
|
|
|
this.writeProtectPane.setVisible(false);
|
|
|
|
}
|
|
|
|
if (wordExportAttr.isExportWaterMark()) {
|
|
|
|
this.exportWaterMark.setSelected(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public WordExportAttr update() {
|
|
|
|
WordExportAttr wordExportAttr = new WordExportAttr();
|
|
|
|
wordExportAttr.setExportAsTable(isExportAsTable.isSelected());
|
|
|
|
if (writeProtect.isSelected()) {
|
|
|
|
wordExportAttr.setWriteProtect(true);
|
|
|
|
if (workbookPassword.isSelected()) {
|
|
|
|
wordExportAttr.setProtectedWord(protectedField.getText());
|
|
|
|
}
|
|
|
|
wordExportAttr.setUseProtectedWord(workbookPassword.isSelected());
|
|
|
|
}
|
|
|
|
if (exportWaterMark.isSelected()) {
|
|
|
|
wordExportAttr.setExportWaterMark(true);
|
|
|
|
}
|
|
|
|
return wordExportAttr;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void wrapButtonsInButtonGroup(AbstractButton... buttons) {
|
|
|
|
if (buttons != null) {
|
|
|
|
ButtonGroup buttonGroup = new ButtonGroup();
|
|
|
|
for (AbstractButton button : buttons) {
|
|
|
|
buttonGroup.add(button);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|