From bd104a381116a53f69eb2275919319dc574f26df Mon Sep 17 00:00:00 2001 From: plough Date: Wed, 31 Oct 2018 10:08:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-12029=20=E6=89=93=E5=8D=B0=E6=9C=BA?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=9C=B0=E5=9D=80=E6=8F=90=E4=BE=9B=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EditReportServerParameterPane.java | 2 +- .../printsettings/NativePrintSettingPane.java | 122 +++++++++++++++--- .../NoClientPrintSettingPane.java | 2 +- .../printsettings/PageMarginSettingPane.java | 2 +- .../printsettings/PrintSettingPane.java | 14 +- 5 files changed, 119 insertions(+), 23 deletions(-) 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 0dcd16296..cf4b653a2 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 @@ -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(true)); } @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/NativePrintSettingPane.java index a99248313..ce9f03d16 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/NativePrintSettingPane.java @@ -52,6 +52,11 @@ public class NativePrintSettingPane extends JPanel { 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 defaultDownloadUrlCheck; // 采用默认的软件下载地址 + private UITextField customUrlFieldWin; + private UITextField customUrlFieldMac; + // 公共组件 private UICheckBox showDialogCheck; private UICheckBox needSelectSheetCheck; // 打印需要指定 sheet private UIComboBox printerComboBox; @@ -75,8 +80,10 @@ public class NativePrintSettingPane extends JPanel { private JPanel customPaperSizePane; private UnitFieldPane customWidthFieldPane; private UnitFieldPane customHeightFieldPane; + private boolean serverConfigMode; // 是否为服务器配置中的面板 - public NativePrintSettingPane() { + NativePrintSettingPane(boolean serverConfigMode) { + this.serverConfigMode = serverConfigMode; initComponents(); initListeners(); } @@ -84,39 +91,94 @@ 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() { + JPanel headerPane; + 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)); + if (isServerConfigMode()) { + headerPane = createHeaderLayoutPane(tipDownload, showDialogCheckPane, needSelectSheetCheckPane, getDownloadUrlSettingPane()); + headerPane.setBorder(BorderFactory.createEmptyBorder(2, 12, 5, 0)); + } else { + headerPane = createHeaderLayoutPane(tipDownload, showDialogCheckPane, needSelectSheetCheckPane); + headerPane.setBorder(BorderFactory.createEmptyBorder(2, 12, 12, 0)); + } + return headerPane; + } - printPane.add(northPane, BorderLayout.NORTH); + private JPanel createHeaderLayoutPane(Component... comps) { + // TableLayout + double p = TableLayout.PREFERRED; + double[] columnSize = {p}; - centerPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default_Settings")); + double[] rowSize = new double[comps.length]; + for (int i = 0; i < rowSize.length; i++) { + rowSize[i] = p; + } - UIScrollPane scrollPane = new UIScrollPane(getNativePrintMainSettingPane()); - scrollPane.setBorder(null); - scrollPane.setPreferredSize(new Dimension(600, 340)); - centerPane.add(scrollPane); + 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); + } - printPane.add(centerPane, BorderLayout.CENTER); + 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)); - this.setLayout(new BorderLayout()); - this.add(printPane, BorderLayout.CENTER); + // 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; } private void initListeners() { @@ -399,10 +461,14 @@ public class NativePrintSettingPane extends JPanel { private 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) { + if (isServerConfigMode()) { + serverOnlyPopulate(nativePrintAttr); + } showDialogCheck.setSelected(nativePrintAttr.isShowDialog()); needSelectSheetCheck.setSelected(nativePrintAttr.isNeedSelectSheet()); printerComboBox.setSelectedItem(nativePrintAttr.getPrinterName()); @@ -452,12 +518,18 @@ public class NativePrintSettingPane extends JPanel { checkEnabled(); } + private void serverOnlyPopulate(NativePrintAttr nativePrintAttr) { + defaultDownloadUrlCheck.setSelected(nativePrintAttr.isUseDefaultDownloadUrl()); + customUrlFieldMac.setText(nativePrintAttr.getCustomDownloadUrlMac()); + customUrlFieldWin.setText(nativePrintAttr.getCustomDownloadUrlWin()); + } + public void update(NativePrintAttr nativePrintAttr) { + if (isServerConfigMode()) { + serverOnlyUpdate(nativePrintAttr); + } nativePrintAttr.setShowDialog(showDialogCheck.isSelected()); nativePrintAttr.setNeedSelectSheet(needSelectSheetCheck.isSelected()); - if (printerComboBox.getSelectedItem() != null) { - nativePrintAttr.setPrinterName(printerComboBox.getSelectedItem().toString()); - } nativePrintAttr.setCopy((int)copySpinner.getValue()); // 页码 @@ -493,8 +565,22 @@ public class NativePrintSettingPane extends JPanel { nativePrintAttr.setScalePercent((int)scalePercentField.getValue()); } + private void serverOnlyUpdate(NativePrintAttr nativePrintAttr) { + if (defaultDownloadUrlCheck.isSelected()) { + nativePrintAttr.setUseDefaultDownloadUrl(true); + } else { + nativePrintAttr.setUseDefaultDownloadUrl(false); + nativePrintAttr.setCustomDownloadUrlMac(customUrlFieldMac.getText()); + nativePrintAttr.setCustomDownloadUrlWin(customUrlFieldWin.getText()); + } + } + // 刷新面板可用状态 public void checkEnabled() { GUICoreUtils.setEnabled(centerPane, !showDialogCheck.isSelected()); } + + public boolean isServerConfigMode() { + return serverConfigMode; + } } 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 a61cd7a3c..ae9127159 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 a7be5cd9b..1742a2b02 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 a315dab65..403cb1dd7 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,6 +3,7 @@ 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; @@ -28,8 +29,14 @@ public class PrintSettingPane extends BasicPane { private NativePrintSettingPane nativePrintSettingPane; private CardLayout printCard; private JPanel printPane; + private boolean serverConfigMode; // 是否为服务器配置中的面板 public PrintSettingPane() { + this(false); + } + + public PrintSettingPane(boolean serverConfigMode) { + this.serverConfigMode = serverConfigMode; initComponents(); initListener(); } @@ -50,12 +57,15 @@ public class PrintSettingPane extends BasicPane { north.add(radioGroupPane); noClientPrintSettingPane = new NoClientPrintSettingPane(); - nativePrintSettingPane = new NativePrintSettingPane(); + nativePrintSettingPane = new NativePrintSettingPane(serverConfigMode); 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); From fab057832912fd27e776d007a1ea81cdbab2f24b Mon Sep 17 00:00:00 2001 From: plough Date: Wed, 31 Oct 2018 15:06:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-12029=20=E6=89=93=E5=8D=B0=E6=9C=BA?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=9C=B0=E5=9D=80=E6=8F=90=E4=BE=9B=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E8=AE=BE=E7=BD=AE=3D>=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EditReportServerParameterPane.java | 8 +- ...va => AbstractNativePrintSettingPane.java} | 86 +++--------------- .../GlobalNativePrintSettingPane.java | 91 +++++++++++++++++++ .../printsettings/PrintSettingPane.java | 12 +-- .../ReportNativePrintSettingPane.java | 18 ++++ 5 files changed, 130 insertions(+), 85 deletions(-) rename designer-realize/src/main/java/com/fr/design/webattr/printsettings/{NativePrintSettingPane.java => AbstractNativePrintSettingPane.java} (86%) create mode 100644 designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java create mode 100644 designer-realize/src/main/java/com/fr/design/webattr/printsettings/ReportNativePrintSettingPane.java 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 cf4b653a2..18d110400 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(true)); + 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 86% 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 ce9f03d16..eac54ea73 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,16 +45,12 @@ 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 defaultDownloadUrlCheck; // 采用默认的软件下载地址 - private UITextField customUrlFieldWin; - private UITextField customUrlFieldMac; // 公共组件 private UICheckBox showDialogCheck; private UICheckBox needSelectSheetCheck; // 打印需要指定 sheet @@ -80,10 +75,8 @@ public class NativePrintSettingPane extends JPanel { private JPanel customPaperSizePane; private UnitFieldPane customWidthFieldPane; private UnitFieldPane customHeightFieldPane; - private boolean serverConfigMode; // 是否为服务器配置中的面板 - NativePrintSettingPane(boolean serverConfigMode) { - this.serverConfigMode = serverConfigMode; + AbstractNativePrintSettingPane() { initComponents(); initListeners(); } @@ -104,8 +97,6 @@ public class NativePrintSettingPane extends JPanel { } private JPanel getHeaderPane() { - JPanel headerPane; - UILabel tipDownload = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Tip_Native_Print_Need_Client")); // 打印时需要打印设置窗口 @@ -122,17 +113,12 @@ public class NativePrintSettingPane extends JPanel { JPanel needSelectSheetCheckPane = GUICoreUtils.createFlowPane(new Component[] { needSelectSheetCheck, needSelectSheetCheckTip}, FlowLayout.LEFT); - if (isServerConfigMode()) { - headerPane = createHeaderLayoutPane(tipDownload, showDialogCheckPane, needSelectSheetCheckPane, getDownloadUrlSettingPane()); - headerPane.setBorder(BorderFactory.createEmptyBorder(2, 12, 5, 0)); - } else { - headerPane = createHeaderLayoutPane(tipDownload, showDialogCheckPane, needSelectSheetCheckPane); - headerPane.setBorder(BorderFactory.createEmptyBorder(2, 12, 12, 0)); - } - return headerPane; + return createHeaderPane(tipDownload, showDialogCheckPane, needSelectSheetCheckPane); } - private JPanel createHeaderLayoutPane(Component... comps) { + abstract JPanel createHeaderPane(Component... comps); + + JPanel createHeaderLayoutPane(Component... comps) { // TableLayout double p = TableLayout.PREFERRED; double[] columnSize = {p}; @@ -149,37 +135,7 @@ public class NativePrintSettingPane extends JPanel { return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 10); } - 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; - } private void initListeners() { allPageRadioButton.addItemListener(getPageRaidoListener()); @@ -458,7 +414,7 @@ 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); @@ -466,9 +422,7 @@ public class NativePrintSettingPane extends JPanel { } public void populate(NativePrintAttr nativePrintAttr) { - if (isServerConfigMode()) { - serverOnlyPopulate(nativePrintAttr); - } + extraPopulate(nativePrintAttr); showDialogCheck.setSelected(nativePrintAttr.isShowDialog()); needSelectSheetCheck.setSelected(nativePrintAttr.isNeedSelectSheet()); printerComboBox.setSelectedItem(nativePrintAttr.getPrinterName()); @@ -518,16 +472,12 @@ public class NativePrintSettingPane extends JPanel { checkEnabled(); } - private void serverOnlyPopulate(NativePrintAttr nativePrintAttr) { - defaultDownloadUrlCheck.setSelected(nativePrintAttr.isUseDefaultDownloadUrl()); - customUrlFieldMac.setText(nativePrintAttr.getCustomDownloadUrlMac()); - customUrlFieldWin.setText(nativePrintAttr.getCustomDownloadUrlWin()); + protected void extraPopulate(NativePrintAttr nativePrintAttr) { + // do nothing } public void update(NativePrintAttr nativePrintAttr) { - if (isServerConfigMode()) { - serverOnlyUpdate(nativePrintAttr); - } + extraUpdate(nativePrintAttr); nativePrintAttr.setShowDialog(showDialogCheck.isSelected()); nativePrintAttr.setNeedSelectSheet(needSelectSheetCheck.isSelected()); nativePrintAttr.setCopy((int)copySpinner.getValue()); @@ -565,22 +515,12 @@ public class NativePrintSettingPane extends JPanel { nativePrintAttr.setScalePercent((int)scalePercentField.getValue()); } - private void serverOnlyUpdate(NativePrintAttr nativePrintAttr) { - if (defaultDownloadUrlCheck.isSelected()) { - nativePrintAttr.setUseDefaultDownloadUrl(true); - } else { - nativePrintAttr.setUseDefaultDownloadUrl(false); - nativePrintAttr.setCustomDownloadUrlMac(customUrlFieldMac.getText()); - nativePrintAttr.setCustomDownloadUrlWin(customUrlFieldWin.getText()); - } + protected void extraUpdate(NativePrintAttr nativePrintAttr) { + // do nothing } // 刷新面板可用状态 public void checkEnabled() { GUICoreUtils.setEnabled(centerPane, !showDialogCheck.isSelected()); } - - public boolean isServerConfigMode() { - return serverConfigMode; - } } 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 000000000..0e2a98148 --- /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/PrintSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/PrintSettingPane.java index 403cb1dd7..883a0801f 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 @@ -7,7 +7,6 @@ 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; @@ -24,19 +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; - private boolean serverConfigMode; // 是否为服务器配置中的面板 public PrintSettingPane() { - this(false); + this(new ReportNativePrintSettingPane()); } - public PrintSettingPane(boolean serverConfigMode) { - this.serverConfigMode = serverConfigMode; + public PrintSettingPane(AbstractNativePrintSettingPane nativePrintSettingPane) { + this.nativePrintSettingPane = nativePrintSettingPane; initComponents(); initListener(); } @@ -57,7 +54,6 @@ public class PrintSettingPane extends BasicPane { north.add(radioGroupPane); noClientPrintSettingPane = new NoClientPrintSettingPane(); - nativePrintSettingPane = new NativePrintSettingPane(serverConfigMode); printCard = new CardLayout(); printPane = new JPanel(); printPane.setLayout(printCard); 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 000000000..b94a89415 --- /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; + } +}