@ -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 writeProtect Pane ;
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 ) ;
rowAndColumn Pane. add ( isExportHidedRow ) ;
outNorth Pane. 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 ( ) {
passwordWriteFlow Pane . 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 ( ) ) {
writeProtect Pane . 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 ) ;
}
}
}
}