diff --git a/designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java b/designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java index 0dcd16296c..18d110400c 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java @@ -10,16 +10,16 @@ import com.fr.config.ServerPreferenceConfig; import com.fr.design.gui.frpane.LoadingBasicPane; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.webattr.printsettings.GlobalNativePrintSettingPane; import com.fr.design.webattr.printsettings.PrintSettingPane; - import com.fr.report.core.ReportUtils; import com.fr.report.web.WebPage; import com.fr.report.web.WebView; import com.fr.report.web.WebWrite; import com.fr.web.attr.ReportWebAttr; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import java.awt.BorderLayout; /** * Edit Report Server Parameter. @@ -60,7 +60,7 @@ public class EditReportServerParameterPane extends LoadingBasicPane { tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportServerP_Import_Css"), cssPane = new WebCssPane()); tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportServerP_Import_JavaScript"), jsPane = new WebJsPane()); tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Error_Handler_Template"), errorTemplatePane = new ErrorTemplatePane()); - tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Print_Setting"), printSettingPane = new PrintSettingPane()); + tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Print_Setting"), printSettingPane = new PrintSettingPane(new GlobalNativePrintSettingPane())); } @Override diff --git a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/NativePrintSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/AbstractNativePrintSettingPane.java similarity index 94% rename from designer-realize/src/main/java/com/fr/design/webattr/printsettings/NativePrintSettingPane.java rename to designer-realize/src/main/java/com/fr/design/webattr/printsettings/AbstractNativePrintSettingPane.java index a992483132..eac54ea73b 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/NativePrintSettingPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/AbstractNativePrintSettingPane.java @@ -7,7 +7,6 @@ import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxRenderer; -import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.gui.itextfield.UINumberField; @@ -46,12 +45,13 @@ import java.util.regex.Pattern; /** * Created by plough on 2018/3/5. */ -public class NativePrintSettingPane extends JPanel { +public abstract class AbstractNativePrintSettingPane extends JPanel { private static final int ODD_INDEX = 0; private static final int EVEN_INDEX = 1; private static final String CUSTOM_PAPERSIZE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Custom"); private static final PaperSize DEFAULT_PAPERSIZE = PaperSize.PAPERSIZE_A4; + // 公共组件 private UICheckBox showDialogCheck; private UICheckBox needSelectSheetCheck; // 打印需要指定 sheet private UIComboBox printerComboBox; @@ -76,7 +76,7 @@ public class NativePrintSettingPane extends JPanel { private UnitFieldPane customWidthFieldPane; private UnitFieldPane customHeightFieldPane; - public NativePrintSettingPane() { + AbstractNativePrintSettingPane() { initComponents(); initListeners(); } @@ -84,41 +84,59 @@ public class NativePrintSettingPane extends JPanel { private void initComponents() { JPanel printPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - JPanel northPane = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(1, 0, 12); + JPanel northPane = getHeaderPane(); + printPane.add(northPane, BorderLayout.NORTH); + + centerPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default_Settings")); + centerPane.add(getNativePrintMainSettingPane()); + + printPane.add(centerPane, BorderLayout.CENTER); + + this.setLayout(new BorderLayout()); + this.add(printPane, BorderLayout.CENTER); + } + + private JPanel getHeaderPane() { UILabel tipDownload = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Tip_Native_Print_Need_Client")); - northPane.add(tipDownload); + // 打印时需要打印设置窗口 showDialogCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Show_Print_Setting_Window_When_Printing")); showDialogCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); UILabel showDialogCheckTip = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Tip_Use_Default_Settings")); JPanel showDialogCheckPane = GUICoreUtils.createFlowPane(new Component[] { showDialogCheck, showDialogCheckTip}, FlowLayout.LEFT); - northPane.add(showDialogCheckPane); + // 打印需要指定 sheet needSelectSheetCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Need_Select_Sheet_When_Printing")); needSelectSheetCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); UILabel needSelectSheetCheckTip = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Tip_Invalid_In_Page_View")); JPanel needSelectSheetCheckPane = GUICoreUtils.createFlowPane(new Component[] { needSelectSheetCheck, needSelectSheetCheckTip}, FlowLayout.LEFT); - northPane.add(needSelectSheetCheckPane); - - northPane.setBorder(BorderFactory.createEmptyBorder(3, 10, 15, 0)); - printPane.add(northPane, BorderLayout.NORTH); + return createHeaderPane(tipDownload, showDialogCheckPane, needSelectSheetCheckPane); + } - centerPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default_Settings")); + abstract JPanel createHeaderPane(Component... comps); - UIScrollPane scrollPane = new UIScrollPane(getNativePrintMainSettingPane()); - scrollPane.setBorder(null); - scrollPane.setPreferredSize(new Dimension(600, 340)); - centerPane.add(scrollPane); + JPanel createHeaderLayoutPane(Component... comps) { + // TableLayout + double p = TableLayout.PREFERRED; + double[] columnSize = {p}; - printPane.add(centerPane, BorderLayout.CENTER); + double[] rowSize = new double[comps.length]; + for (int i = 0; i < rowSize.length; i++) { + rowSize[i] = p; + } - this.setLayout(new BorderLayout()); - this.add(printPane, BorderLayout.CENTER); + Component[][] components = new Component[rowSize.length][columnSize.length]; + for (int i = 0; i < rowSize.length; i++) { + components[i][0] = comps[i]; + } + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 10); } + + private void initListeners() { allPageRadioButton.addItemListener(getPageRaidoListener()); currentPageRadioButton.addItemListener(getPageRaidoListener()); @@ -396,13 +414,15 @@ public class NativePrintSettingPane extends JPanel { } // 返回包含一个标签的 panel,标签始终位于 panel 顶部 - private JPanel getTopAlignLabelPane(String labelText) { + JPanel getTopAlignLabelPane(String labelText) { JPanel labelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); labelPane.add(new UILabel(labelText), BorderLayout.NORTH); + labelPane.add(new JPanel(), BorderLayout.CENTER); return labelPane; } public void populate(NativePrintAttr nativePrintAttr) { + extraPopulate(nativePrintAttr); showDialogCheck.setSelected(nativePrintAttr.isShowDialog()); needSelectSheetCheck.setSelected(nativePrintAttr.isNeedSelectSheet()); printerComboBox.setSelectedItem(nativePrintAttr.getPrinterName()); @@ -452,12 +472,14 @@ public class NativePrintSettingPane extends JPanel { checkEnabled(); } + protected void extraPopulate(NativePrintAttr nativePrintAttr) { + // do nothing + } + public void update(NativePrintAttr nativePrintAttr) { + extraUpdate(nativePrintAttr); nativePrintAttr.setShowDialog(showDialogCheck.isSelected()); nativePrintAttr.setNeedSelectSheet(needSelectSheetCheck.isSelected()); - if (printerComboBox.getSelectedItem() != null) { - nativePrintAttr.setPrinterName(printerComboBox.getSelectedItem().toString()); - } nativePrintAttr.setCopy((int)copySpinner.getValue()); // 页码 @@ -493,6 +515,10 @@ public class NativePrintSettingPane extends JPanel { nativePrintAttr.setScalePercent((int)scalePercentField.getValue()); } + protected void extraUpdate(NativePrintAttr nativePrintAttr) { + // do nothing + } + // 刷新面板可用状态 public void checkEnabled() { GUICoreUtils.setEnabled(centerPane, !showDialogCheck.isSelected()); diff --git a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java new file mode 100644 index 0000000000..0e2a98148d --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java @@ -0,0 +1,91 @@ +package com.fr.design.webattr.printsettings; + +import com.fr.base.print.NativePrintAttr; +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.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.Component; + +/** + * 本地打印设置面板——全局 + * Created by plough on 2018/10/31. + */ +public class GlobalNativePrintSettingPane extends AbstractNativePrintSettingPane { + // 服务器配置面板特有的组件 + private UICheckBox defaultDownloadUrlCheck; // 采用默认的软件下载地址 + private UITextField customUrlFieldWin; + private UITextField customUrlFieldMac; + + + @Override + JPanel createHeaderPane(Component... comps) { + + Component[] newComps = { + getDownloadUrlSettingPane() + }; + Component[] allComps = new Component[comps.length + newComps.length]; + System.arraycopy(comps, 0, allComps, 0, comps.length); + System.arraycopy(newComps, 0, allComps, comps.length, newComps.length); + + JPanel headerPane = createHeaderLayoutPane(allComps); + headerPane.setBorder(BorderFactory.createEmptyBorder(2, 12, 5, 0)); + return headerPane; + } + + + @Override + protected void extraUpdate(NativePrintAttr nativePrintAttr) { + if (defaultDownloadUrlCheck.isSelected()) { + nativePrintAttr.setUseDefaultDownloadUrl(true); + } else { + nativePrintAttr.setUseDefaultDownloadUrl(false); + nativePrintAttr.setCustomDownloadUrlMac(customUrlFieldMac.getText()); + nativePrintAttr.setCustomDownloadUrlWin(customUrlFieldWin.getText()); + } + } + + @Override + protected void extraPopulate(NativePrintAttr nativePrintAttr) { + defaultDownloadUrlCheck.setSelected(nativePrintAttr.isUseDefaultDownloadUrl()); + customUrlFieldMac.setText(nativePrintAttr.getCustomDownloadUrlMac()); + customUrlFieldWin.setText(nativePrintAttr.getCustomDownloadUrlWin()); + } + + private JPanel getDownloadUrlSettingPane() { + defaultDownloadUrlCheck = GUICoreUtils.createNoBorderCheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default")); + JPanel downloadUrlSettingCheckPane = GUICoreUtils.createCheckboxAndDynamicPane(defaultDownloadUrlCheck, getCustomUrlSettingPane(), true); + downloadUrlSettingCheckPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + + // TableLayout + double p = TableLayout.PREFERRED; + double[] rowSize = {p}; + double[] columnSize = {p, p}; + Component[][] components = { + {getTopAlignLabelPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Software_Download_Url") + ": "), downloadUrlSettingCheckPane} + }; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 15); + } + + private JPanel getCustomUrlSettingPane() { + customUrlFieldWin = new UITextField(20); + customUrlFieldMac = new UITextField(20); + + // TableLayout + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p}; + double[] columnSize = {60, p}; + Component[][] components = { + {new UILabel("windows: "), customUrlFieldWin}, + {new UILabel("macOS: "), customUrlFieldMac} + }; + JPanel urlSettingPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 10); + urlSettingPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); + return urlSettingPane; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java index a61cd7a3c2..ae91271598 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java @@ -26,7 +26,7 @@ public class NoClientPrintSettingPane extends JPanel { private PageMarginSettingPane pageMarginSettingPane; private JPanel centerPane; - public NoClientPrintSettingPane() { + NoClientPrintSettingPane() { initComponents(); initListeners(); } diff --git a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/PageMarginSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/PageMarginSettingPane.java index a7be5cd9bc..1742a2b02a 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/PageMarginSettingPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/PageMarginSettingPane.java @@ -19,7 +19,7 @@ public class PageMarginSettingPane extends JPanel { private UnitFieldPane marginLeftUnitFieldPane; private UnitFieldPane marginRightUnitFieldPane; - public PageMarginSettingPane() { + PageMarginSettingPane() { initComponents(); } private void initComponents() { diff --git a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/PrintSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/PrintSettingPane.java index a315dab653..883a0801fd 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/PrintSettingPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/PrintSettingPane.java @@ -3,10 +3,10 @@ package com.fr.design.webattr.printsettings; import com.fr.base.print.PrintSettingsAttrMark; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; - import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.JPanel; @@ -23,13 +23,17 @@ import java.awt.event.ItemListener; public class PrintSettingPane extends BasicPane { private UIRadioButton noClientPrintRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_No_Client_Print")); private UIRadioButton nativePrintRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Native_Print")); - private NoClientPrintSettingPane noClientPrintSettingPane; - private NativePrintSettingPane nativePrintSettingPane; + private AbstractNativePrintSettingPane nativePrintSettingPane; private CardLayout printCard; private JPanel printPane; public PrintSettingPane() { + this(new ReportNativePrintSettingPane()); + } + + public PrintSettingPane(AbstractNativePrintSettingPane nativePrintSettingPane) { + this.nativePrintSettingPane = nativePrintSettingPane; initComponents(); initListener(); } @@ -50,12 +54,14 @@ public class PrintSettingPane extends BasicPane { north.add(radioGroupPane); noClientPrintSettingPane = new NoClientPrintSettingPane(); - nativePrintSettingPane = new NativePrintSettingPane(); printCard = new CardLayout(); printPane = new JPanel(); printPane.setLayout(printCard); printPane.add(noClientPrintRadioButton.getText(), noClientPrintSettingPane); - printPane.add(nativePrintRadioButton.getText(), nativePrintSettingPane); + + UIScrollPane scrollPane = new UIScrollPane(nativePrintSettingPane); + scrollPane.setBorder(null); + printPane.add(nativePrintRadioButton.getText(), scrollPane); north.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); allPanel.add(printPane, BorderLayout.CENTER); diff --git a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/ReportNativePrintSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/ReportNativePrintSettingPane.java new file mode 100644 index 0000000000..b94a894155 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/ReportNativePrintSettingPane.java @@ -0,0 +1,18 @@ +package com.fr.design.webattr.printsettings; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.Component; + +/** + * 本地打印设置面板——单模版 + * Created by plough on 2018/10/31. + */ +public class ReportNativePrintSettingPane extends AbstractNativePrintSettingPane { + @Override + JPanel createHeaderPane(Component... comps) { + JPanel headerPane = createHeaderLayoutPane(comps); + headerPane.setBorder(BorderFactory.createEmptyBorder(2, 12, 12, 0)); + return headerPane; + } +}