From e30b3eed360ea5649470a4cc25ebb537203b1589 Mon Sep 17 00:00:00 2001 From: "Bruce.Deng" Date: Sat, 17 Sep 2022 15:34:01 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-75084=20=E5=AF=BC=E5=87=BA=E5=AE=89?= =?UTF-8?q?=E5=85=A8/=E6=9D=83=E9=99=90=EF=BC=9A=E5=AF=BC=E5=87=BAexcel?= =?UTF-8?q?=E3=80=81word=E6=94=AF=E6=8C=81=E6=B0=B4=E5=8D=B0=E3=80=81?= =?UTF-8?q?=E5=8F=AA=E8=AF=BB=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/report/ExcelExportPane.java | 181 +++++++++++++----- .../com/fr/design/report/ImageExportPane.java | 16 +- .../com/fr/design/report/PDFExportPane.java | 39 ++-- .../com/fr/design/report/WordExportPane.java | 166 +++++++++++++--- 4 files changed, 294 insertions(+), 108 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/report/ExcelExportPane.java b/designer-realize/src/main/java/com/fr/design/report/ExcelExportPane.java index f829616c7a..e00b5e22a4 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ExcelExportPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ExcelExportPane.java @@ -1,29 +1,47 @@ 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.UILabel; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.io.attr.ExcelExportAttr; 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 ExcelExportPane extends BasicPane { private UICheckBox isExportHidedRow; private UICheckBox isExportHidenColumn; - private UICheckBox isNeedPassword; + // 文件密码 private UITextField passwordField; - private UICheckBox protectedWord; + // 工作表密码 private UITextField protectedField; + // 文件保护 + private UICheckBox fileProtect; + // 编辑保护 + private UICheckBox writeProtect; + // 工作表密码 + private UIRadioButton workbookPassword; + // 仅限预览 + private UIRadioButton onlyForPreview; + // 导出水印 + private UICheckBox exportWaterMark; private JPanel passwordWritePane; - private JPanel wordPane; + private JPanel writeProtectPane; public ExcelExportPane() { this.initComponents(); @@ -32,33 +50,35 @@ public class ExcelExportPane extends BasicPane { protected void initComponents() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - JPanel outnorthPane =FRGUIPaneFactory.createTitledBorderPane("Excel" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Excel_Export")); - JPanel northPane=FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); - this.add(outnorthPane); - outnorthPane.add(northPane); - JPanel rowAndColumnPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - northPane.add(rowAndColumnPane); + JPanel outPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane("Excel" + 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(new Dimension(580, 85)); + this.add(outPane); + outPane.add(outNorthPane); isExportHidedRow = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Export_Hided_Row")); isExportHidedRow.setSelected(false); - rowAndColumnPane.add(isExportHidedRow); + outNorthPane.add(isExportHidedRow); isExportHidenColumn = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Export_Hided_Column")); isExportHidenColumn.setSelected(false); - rowAndColumnPane.add(isExportHidenColumn); - - JPanel passwordPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - isNeedPassword = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_IS_Need_Password"), false); - passwordPane.add(isNeedPassword); - northPane.add(passwordPane); - passwordWritePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - passwordPane.add(passwordWritePane); - UILabel passwordLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_File_Password") + ":"); - passwordWritePane.add(passwordLabel); + outNorthPane.add(isExportHidenColumn); + // 内容保护 + JPanel outSouthPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Export_Content_Protect")); + outSouthPane.setPreferredSize(new Dimension(580, 280)); + outPane.add(outSouthPane); + // 文件保护 + fileProtect = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Export_File_Protect"), false); + outSouthPane.add(fileProtect); + // 文件密码和密码框 + passwordWritePane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); + JPanel passwordWriteFlowPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); + UILabel filePassword = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_File_Password")); + passwordWriteFlowPane.add(filePassword); passwordField = new UITextField(11); - passwordWritePane.add(passwordField); -// UIButton displayPasswordButton = new UIButton("..."); - isNeedPassword.addActionListener(new ActionListener() { + passwordWriteFlowPane.add(passwordField); + passwordWritePane.add(passwordWriteFlowPane); + fileProtect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - if (isNeedPassword.isSelected()) { + if (fileProtect.isSelected()) { passwordWritePane.setVisible(true); } else { passwordWritePane.setVisible(false); @@ -66,28 +86,57 @@ public class ExcelExportPane extends BasicPane { } }); - - + outSouthPane.add(passwordWritePane); + // 编辑保护 + 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(); - protectedWord = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Protected_Password")); - wordPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - wordPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sheet_Password") + ":")); protectedField = new UITextField(11); - wordPane.add(protectedField); - protectedWordPane.add(protectedWord); - protectedWordPane.add(wordPane); - northPane.add(protectedWordPane); - protectedWord.addActionListener(new ActionListener() { + 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 (protectedWord.isSelected()) { - wordPane.setVisible(true); + if (writeProtect.isSelected()) { + writeProtectPane.setVisible(true); } else { - wordPane.setVisible(false); - protectedField.setText(null); + 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 @@ -102,20 +151,33 @@ public class ExcelExportPane extends BasicPane { isExportHidedRow.setSelected(excelExportAttr.isExportHidedRow()); isExportHidenColumn.setSelected(excelExportAttr.isExportHidedColumn()); if (StringUtils.isEmpty(excelExportAttr.getPassword())) { - isNeedPassword.setSelected(false); + fileProtect.setSelected(false); passwordWritePane.setVisible(false); } else { - isNeedPassword.setSelected(true); - passwordField.setText(excelExportAttr.getPassword()); + fileProtect.setSelected(true); passwordWritePane.setVisible(true); + passwordField.setText(excelExportAttr.getPassword()); } - if (StringUtils.isEmpty(excelExportAttr.getProtectedWord())) { - this.protectedWord.setSelected(false); - this.wordPane.setVisible(false); + if (excelExportAttr.isWriteProtect()) { + if (excelExportAttr.isUseProtectedWord() && StringUtils.isNotEmpty(excelExportAttr.getProtectedWord())) { + writeProtect.setSelected(true); + writeProtectPane.setVisible(true); + workbookPassword.setSelected(true); + protectedField.setText(excelExportAttr.getProtectedWord()); + } else if (!excelExportAttr.isUseProtectedWord()) { + writeProtect.setSelected(true); + writeProtectPane.setVisible(true); + onlyForPreview.setSelected(true); + } else { + this.writeProtect.setSelected(false); + this.writeProtectPane.setVisible(false); + } } else { - this.protectedWord.setSelected(true); - this.wordPane.setVisible(true); - this.protectedField.setText(excelExportAttr.getProtectedWord()); + this.writeProtect.setSelected(false); + this.writeProtectPane.setVisible(false); + } + if (excelExportAttr.isExportWaterMark()) { + this.exportWaterMark.setSelected(true); } } @@ -125,11 +187,28 @@ public class ExcelExportPane extends BasicPane { excelExportAttr.setExportHidedColumn(isExportHidenColumn.isSelected()); excelExportAttr.setExportHidedRow(isExportHidedRow.isSelected()); - if (!isNeedPassword.isSelected()) { - passwordField.setText(null); + if (fileProtect.isSelected()) { + excelExportAttr.setPassword(passwordField.getText()); + } + if (writeProtect.isSelected()) { + excelExportAttr.setWriteProtect(true); + if (workbookPassword.isSelected()) { + excelExportAttr.setProtectedWord(protectedField.getText()); + } + excelExportAttr.setUseProtectedWord(workbookPassword.isSelected()); + } + if (exportWaterMark.isSelected()) { + excelExportAttr.setExportWaterMark(true); } - excelExportAttr.setPassword(passwordField.getText()); - excelExportAttr.setProtectedWord(this.protectedField.getText()); return excelExportAttr; } + + private void wrapButtonsInButtonGroup(AbstractButton... buttons) { + if (buttons != null) { + ButtonGroup buttonGroup = new ButtonGroup(); + for (AbstractButton button : buttons) { + buttonGroup.add(button); + } + } + } } diff --git a/designer-realize/src/main/java/com/fr/design/report/ImageExportPane.java b/designer-realize/src/main/java/com/fr/design/report/ImageExportPane.java index b8d6167335..08d1a213c3 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ImageExportPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ImageExportPane.java @@ -10,13 +10,14 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.io.attr.ImageExportAttr; import com.fr.io.attr.ReportExportAttr; -import java.awt.Color; import javax.swing.AbstractButton; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.JComponent; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; /** * 导出图片配置 @@ -51,11 +52,16 @@ public class ImageExportPane extends AbstractExportPane { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); JPanel globalTitlePane = FRGUIPaneFactory.createTitledBorderPane(GLOBAL_CONF); - JPanel tipsTitlePane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Advice")); + JPanel outNorthPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Export_Setting")); + outNorthPane.setPreferredSize(new Dimension(580, 230)); UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Image_Export_Tips")); - tipLabel.setForeground(Color.RED); + tipLabel.setForeground(Color.GRAY); + JPanel tipsTitlePane = new JPanel(); + tipsTitlePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); + tipsTitlePane.setLayout(FRGUIPaneFactory.createBorderLayout()); tipsTitlePane.add(tipLabel); - this.add(globalTitlePane, BorderLayout.NORTH); + this.add(globalTitlePane); + globalTitlePane.add(outNorthPane); initGlobalSettings(); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); @@ -73,7 +79,7 @@ public class ImageExportPane extends AbstractExportPane { GAP), BorderLayout.CENTER); centerPane.add(tipsTitlePane,BorderLayout.SOUTH); - globalTitlePane.add(centerPane, BorderLayout.CENTER); + outNorthPane.add(centerPane, BorderLayout.CENTER); } diff --git a/designer-realize/src/main/java/com/fr/design/report/PDFExportPane.java b/designer-realize/src/main/java/com/fr/design/report/PDFExportPane.java index 7fa71fe950..f8e5767478 100644 --- a/designer-realize/src/main/java/com/fr/design/report/PDFExportPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/PDFExportPane.java @@ -1,20 +1,20 @@ package com.fr.design.report; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.*; - +import com.fr.design.dialog.BasicPane; 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.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.dialog.BasicPane; - import com.fr.io.attr.PDFExportAttr; import com.fr.stable.StringUtils; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + public class PDFExportPane extends BasicPane { private UICheckBox isNeedPassword; private UITextField passwordField; @@ -27,21 +27,18 @@ public class PDFExportPane extends BasicPane { protected void initComponents() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - JPanel outnorthPane =FRGUIPaneFactory.createTitledBorderPane("PDF" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Excel_Export")); - JPanel northPane=FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); - this.add(outnorthPane); - outnorthPane.add(northPane); - JPanel rowAndColumnPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - northPane.add(rowAndColumnPane); - - JPanel passwordPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - isNeedPassword = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_IS_Need_Password"), false); + JPanel outPane =FRGUIPaneFactory.createTopVerticalTitledBorderPane("PDF" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Excel_Export")); + this.add(outPane); + // 内容保护 + JPanel outNorthPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Export_Content_Protect")); + outNorthPane.setPreferredSize(new Dimension(580, 100)); + outPane.add(outNorthPane); + + isNeedPassword = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_File_Password"), false); + JPanel passwordPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); passwordPane.add(isNeedPassword); - northPane.add(passwordPane); passwordWritePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); passwordPane.add(passwordWritePane); - UILabel passwordLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_File_Password") + ":"); - passwordWritePane.add(passwordLabel); passwordField = new UITextField(11); passwordWritePane.add(passwordField); isNeedPassword.addActionListener(new ActionListener() { @@ -49,7 +46,7 @@ public class PDFExportPane extends BasicPane { passwordWritePane.setVisible(isNeedPassword.isSelected()); } }); - + outNorthPane.add(passwordPane); } @Override diff --git a/designer-realize/src/main/java/com/fr/design/report/WordExportPane.java b/designer-realize/src/main/java/com/fr/design/report/WordExportPane.java index df808c1bcb..c252a4e627 100644 --- a/designer-realize/src/main/java/com/fr/design/report/WordExportPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/WordExportPane.java @@ -1,21 +1,42 @@ package com.fr.design.report; -import java.awt.Color; -import java.awt.Dimension; - -import javax.swing.*; - +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.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.dialog.BasicPane; - 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 JPanel southPane; + // 编辑保护 + private UICheckBox writeProtect; + // 工作表密码 + private UITextField protectedField; + // 工作表密码 + private UIRadioButton workbookPassword; + // 仅限预览 + private UIRadioButton onlyForPreview; + // 导出水印 + private UICheckBox exportWaterMark; + + private JPanel writeProtectPane; public WordExportPane() { this.initComponents(); @@ -24,31 +45,74 @@ public class WordExportPane extends BasicPane { protected void initComponents() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - JPanel outnorthPane =FRGUIPaneFactory.createTitledBorderPane("Word" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Excel_Export")); - this.add(outnorthPane); - - JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); - outnorthPane.add(northPane); - - JPanel checkBoxPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); + 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(new Dimension(580, 110)); + this.add(outPane); + outPane.add(outNorthPane); + isExportAsTable = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Is_Need_Word_Adjust"), false); - checkBoxPane.add(isExportAsTable); - - southPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - JPanel innerAlertBorderPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Attention")); - JPanel alertPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); - - MultilineLabel wordLineLabel = new MultilineLabel(); - wordLineLabel.setPreferredSize(new Dimension(250, 100)); + + 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.RED); - alertPane.add(wordLineLabel); - - southPane.add(innerAlertBorderPane); - innerAlertBorderPane.add(alertPane); - - northPane.add(checkBoxPane); - northPane.add(southPane); + 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 @@ -65,11 +129,51 @@ public class WordExportPane extends BasicPane { 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); + } + } + } }