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 cf4b653a20..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(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 ce9f03d16d..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,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 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/PrintSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/PrintSettingPane.java index 403cb1dd7d..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 @@ -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 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; + } +}