Browse Source

REPORT-12029 打印机下载地址提供自定义设置=>重构面板相关代码

research/10.0
plough 6 years ago
parent
commit
fab0578329
  1. 8
      designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java
  2. 86
      designer-realize/src/main/java/com/fr/design/webattr/printsettings/AbstractNativePrintSettingPane.java
  3. 91
      designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java
  4. 12
      designer-realize/src/main/java/com/fr/design/webattr/printsettings/PrintSettingPane.java
  5. 18
      designer-realize/src/main/java/com/fr/design/webattr/printsettings/ReportNativePrintSettingPane.java

8
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.LoadingBasicPane;
import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.webattr.printsettings.GlobalNativePrintSettingPane;
import com.fr.design.webattr.printsettings.PrintSettingPane; import com.fr.design.webattr.printsettings.PrintSettingPane;
import com.fr.report.core.ReportUtils; import com.fr.report.core.ReportUtils;
import com.fr.report.web.WebPage; import com.fr.report.web.WebPage;
import com.fr.report.web.WebView; import com.fr.report.web.WebView;
import com.fr.report.web.WebWrite; import com.fr.report.web.WebWrite;
import com.fr.web.attr.ReportWebAttr; import com.fr.web.attr.ReportWebAttr;
import javax.swing.*; import javax.swing.JPanel;
import java.awt.*; import java.awt.BorderLayout;
/** /**
* Edit Report Server Parameter. * 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_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_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_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 @Override

86
designer-realize/src/main/java/com/fr/design/webattr/printsettings/NativePrintSettingPane.java → 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.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer; 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.ilable.UILabel;
import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;
@ -46,16 +45,12 @@ import java.util.regex.Pattern;
/** /**
* Created by plough on 2018/3/5. * 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 ODD_INDEX = 0;
private static final int EVEN_INDEX = 1; 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 String CUSTOM_PAPERSIZE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Custom");
private static final PaperSize DEFAULT_PAPERSIZE = PaperSize.PAPERSIZE_A4; private static final PaperSize DEFAULT_PAPERSIZE = PaperSize.PAPERSIZE_A4;
// 服务器配置面板特有的组件
private UICheckBox defaultDownloadUrlCheck; // 采用默认的软件下载地址
private UITextField customUrlFieldWin;
private UITextField customUrlFieldMac;
// 公共组件 // 公共组件
private UICheckBox showDialogCheck; private UICheckBox showDialogCheck;
private UICheckBox needSelectSheetCheck; // 打印需要指定 sheet private UICheckBox needSelectSheetCheck; // 打印需要指定 sheet
@ -80,10 +75,8 @@ public class NativePrintSettingPane extends JPanel {
private JPanel customPaperSizePane; private JPanel customPaperSizePane;
private UnitFieldPane customWidthFieldPane; private UnitFieldPane customWidthFieldPane;
private UnitFieldPane customHeightFieldPane; private UnitFieldPane customHeightFieldPane;
private boolean serverConfigMode; // 是否为服务器配置中的面板
NativePrintSettingPane(boolean serverConfigMode) { AbstractNativePrintSettingPane() {
this.serverConfigMode = serverConfigMode;
initComponents(); initComponents();
initListeners(); initListeners();
} }
@ -104,8 +97,6 @@ public class NativePrintSettingPane extends JPanel {
} }
private JPanel getHeaderPane() { private JPanel getHeaderPane() {
JPanel headerPane;
UILabel tipDownload = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Tip_Native_Print_Need_Client")); 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[] { JPanel needSelectSheetCheckPane = GUICoreUtils.createFlowPane(new Component[] {
needSelectSheetCheck, needSelectSheetCheckTip}, FlowLayout.LEFT); needSelectSheetCheck, needSelectSheetCheckTip}, FlowLayout.LEFT);
if (isServerConfigMode()) { return createHeaderPane(tipDownload, showDialogCheckPane, needSelectSheetCheckPane);
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;
} }
private JPanel createHeaderLayoutPane(Component... comps) { abstract JPanel createHeaderPane(Component... comps);
JPanel createHeaderLayoutPane(Component... comps) {
// TableLayout // TableLayout
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double[] columnSize = {p}; double[] columnSize = {p};
@ -149,37 +135,7 @@ public class NativePrintSettingPane extends JPanel {
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 10); 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() { private void initListeners() {
allPageRadioButton.addItemListener(getPageRaidoListener()); allPageRadioButton.addItemListener(getPageRaidoListener());
@ -458,7 +414,7 @@ public class NativePrintSettingPane extends JPanel {
} }
// 返回包含一个标签的 panel,标签始终位于 panel 顶部 // 返回包含一个标签的 panel,标签始终位于 panel 顶部
private JPanel getTopAlignLabelPane(String labelText) { JPanel getTopAlignLabelPane(String labelText) {
JPanel labelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel labelPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
labelPane.add(new UILabel(labelText), BorderLayout.NORTH); labelPane.add(new UILabel(labelText), BorderLayout.NORTH);
labelPane.add(new JPanel(), BorderLayout.CENTER); labelPane.add(new JPanel(), BorderLayout.CENTER);
@ -466,9 +422,7 @@ public class NativePrintSettingPane extends JPanel {
} }
public void populate(NativePrintAttr nativePrintAttr) { public void populate(NativePrintAttr nativePrintAttr) {
if (isServerConfigMode()) { extraPopulate(nativePrintAttr);
serverOnlyPopulate(nativePrintAttr);
}
showDialogCheck.setSelected(nativePrintAttr.isShowDialog()); showDialogCheck.setSelected(nativePrintAttr.isShowDialog());
needSelectSheetCheck.setSelected(nativePrintAttr.isNeedSelectSheet()); needSelectSheetCheck.setSelected(nativePrintAttr.isNeedSelectSheet());
printerComboBox.setSelectedItem(nativePrintAttr.getPrinterName()); printerComboBox.setSelectedItem(nativePrintAttr.getPrinterName());
@ -518,16 +472,12 @@ public class NativePrintSettingPane extends JPanel {
checkEnabled(); checkEnabled();
} }
private void serverOnlyPopulate(NativePrintAttr nativePrintAttr) { protected void extraPopulate(NativePrintAttr nativePrintAttr) {
defaultDownloadUrlCheck.setSelected(nativePrintAttr.isUseDefaultDownloadUrl()); // do nothing
customUrlFieldMac.setText(nativePrintAttr.getCustomDownloadUrlMac());
customUrlFieldWin.setText(nativePrintAttr.getCustomDownloadUrlWin());
} }
public void update(NativePrintAttr nativePrintAttr) { public void update(NativePrintAttr nativePrintAttr) {
if (isServerConfigMode()) { extraUpdate(nativePrintAttr);
serverOnlyUpdate(nativePrintAttr);
}
nativePrintAttr.setShowDialog(showDialogCheck.isSelected()); nativePrintAttr.setShowDialog(showDialogCheck.isSelected());
nativePrintAttr.setNeedSelectSheet(needSelectSheetCheck.isSelected()); nativePrintAttr.setNeedSelectSheet(needSelectSheetCheck.isSelected());
nativePrintAttr.setCopy((int)copySpinner.getValue()); nativePrintAttr.setCopy((int)copySpinner.getValue());
@ -565,22 +515,12 @@ public class NativePrintSettingPane extends JPanel {
nativePrintAttr.setScalePercent((int)scalePercentField.getValue()); nativePrintAttr.setScalePercent((int)scalePercentField.getValue());
} }
private void serverOnlyUpdate(NativePrintAttr nativePrintAttr) { protected void extraUpdate(NativePrintAttr nativePrintAttr) {
if (defaultDownloadUrlCheck.isSelected()) { // do nothing
nativePrintAttr.setUseDefaultDownloadUrl(true);
} else {
nativePrintAttr.setUseDefaultDownloadUrl(false);
nativePrintAttr.setCustomDownloadUrlMac(customUrlFieldMac.getText());
nativePrintAttr.setCustomDownloadUrlWin(customUrlFieldWin.getText());
}
} }
// 刷新面板可用状态 // 刷新面板可用状态
public void checkEnabled() { public void checkEnabled() {
GUICoreUtils.setEnabled(centerPane, !showDialogCheck.isSelected()); GUICoreUtils.setEnabled(centerPane, !showDialogCheck.isSelected());
} }
public boolean isServerConfigMode() {
return serverConfigMode;
}
} }

91
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;
}
}

12
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.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.ButtonGroup; import javax.swing.ButtonGroup;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -24,19 +23,17 @@ import java.awt.event.ItemListener;
public class PrintSettingPane extends BasicPane { 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 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 UIRadioButton nativePrintRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Native_Print"));
private NoClientPrintSettingPane noClientPrintSettingPane; private NoClientPrintSettingPane noClientPrintSettingPane;
private NativePrintSettingPane nativePrintSettingPane; private AbstractNativePrintSettingPane nativePrintSettingPane;
private CardLayout printCard; private CardLayout printCard;
private JPanel printPane; private JPanel printPane;
private boolean serverConfigMode; // 是否为服务器配置中的面板
public PrintSettingPane() { public PrintSettingPane() {
this(false); this(new ReportNativePrintSettingPane());
} }
public PrintSettingPane(boolean serverConfigMode) { public PrintSettingPane(AbstractNativePrintSettingPane nativePrintSettingPane) {
this.serverConfigMode = serverConfigMode; this.nativePrintSettingPane = nativePrintSettingPane;
initComponents(); initComponents();
initListener(); initListener();
} }
@ -57,7 +54,6 @@ public class PrintSettingPane extends BasicPane {
north.add(radioGroupPane); north.add(radioGroupPane);
noClientPrintSettingPane = new NoClientPrintSettingPane(); noClientPrintSettingPane = new NoClientPrintSettingPane();
nativePrintSettingPane = new NativePrintSettingPane(serverConfigMode);
printCard = new CardLayout(); printCard = new CardLayout();
printPane = new JPanel(); printPane = new JPanel();
printPane.setLayout(printCard); printPane.setLayout(printCard);

18
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;
}
}
Loading…
Cancel
Save