Browse Source

Merge pull request #441 in DESIGN/design from ~PLOUGH/10-design:feature/10.0 to feature/10.0

* commit '109d0ce93181fcf0273f7d2ae8d36753a450ec80':
  REPORT-10712 支持自定义纸张设置=>设计器部分
research/10.0
plough 6 years ago
parent
commit
3100beb5bc
  1. 71
      designer-realize/src/main/java/com/fr/design/webattr/printsettings/NativePrintSettingPane.java

71
designer-realize/src/main/java/com/fr/design/webattr/printsettings/NativePrintSettingPane.java

@ -15,9 +15,11 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.report.UnitFieldPane;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.report.stable.ReportConstants; import com.fr.report.stable.ReportConstants;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.print.DocFlavor; import javax.print.DocFlavor;
@ -47,6 +49,8 @@ import java.util.regex.Pattern;
public class NativePrintSettingPane extends JPanel { public class NativePrintSettingPane 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 PaperSize DEFAULT_PAPERSIZE = PaperSize.PAPERSIZE_A4;
private UICheckBox isShowDialogCheck; private UICheckBox isShowDialogCheck;
private UIComboBox printerComboBox; private UIComboBox printerComboBox;
@ -67,6 +71,9 @@ public class NativePrintSettingPane extends JPanel {
private UIRadioButton landscapeRadioButton; private UIRadioButton landscapeRadioButton;
private PageMarginSettingPane pageMarginSettingPane; private PageMarginSettingPane pageMarginSettingPane;
private JPanel centerPane; private JPanel centerPane;
private JPanel customPaperSizePane;
private UnitFieldPane customWidthFieldPane;
private UnitFieldPane customHeightFieldPane;
public NativePrintSettingPane() { public NativePrintSettingPane() {
initComponents(); initComponents();
@ -132,6 +139,12 @@ public class NativePrintSettingPane extends JPanel {
super.focusLost(e); super.focusLost(e);
} }
}); });
predefinedPaperSizeComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
updateCustomPaperSizeArea();
}
});
} }
private ItemListener getPageRaidoListener() { private ItemListener getPageRaidoListener() {
@ -222,6 +235,7 @@ public class NativePrintSettingPane extends JPanel {
Object[] tmpPaperSizeNameArray = ReportConstants.PaperSizeNameSizeArray[i]; Object[] tmpPaperSizeNameArray = ReportConstants.PaperSizeNameSizeArray[i];
predefinedPaperSizeComboBox.addItem(tmpPaperSizeNameArray[1]); predefinedPaperSizeComboBox.addItem(tmpPaperSizeNameArray[1]);
} }
predefinedPaperSizeComboBox.addItem(CUSTOM_PAPERSIZE);
predefinedPaperSizeComboBox.setRenderer(new UIComboBoxRenderer() { predefinedPaperSizeComboBox.setRenderer(new UIComboBoxRenderer() {
@Override @Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
@ -250,12 +264,41 @@ public class NativePrintSettingPane extends JPanel {
} }
}); });
JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); // 下拉框
panel.add(predefinedPaperSizeComboBox); JPanel comboPanel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 0, 0)); comboPanel.add(predefinedPaperSizeComboBox);
comboPanel.setBorder(BorderFactory.createEmptyBorder(8, 0, 0, 0));
customPaperSizePane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_M_Pane();
// 宽度设置
JPanel customWidthPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
customWidthPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Designer_Width") + ":"));
customWidthFieldPane = new UnitFieldPane(Constants.UNIT_MM);
customWidthFieldPane.setUnitValue(DEFAULT_PAPERSIZE.getWidth());
customWidthPane.add(customWidthFieldPane);
// 高度设置
JPanel customHeightPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
customHeightPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Height") + ":"));
customHeightFieldPane = new UnitFieldPane(Constants.UNIT_MM);
customHeightFieldPane.setUnitValue(DEFAULT_PAPERSIZE.getHeight());
customHeightPane.add(customHeightFieldPane);
customPaperSizePane.add(customWidthPane);
customPaperSizePane.add(customHeightPane);
customPaperSizePane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.add(comboPanel, BorderLayout.NORTH);
panel.add(customPaperSizePane, BorderLayout.CENTER);
return panel; return panel;
} }
private void updateCustomPaperSizeArea() {
boolean isCustom = ComparatorUtils.equals(predefinedPaperSizeComboBox.getSelectedItem(), CUSTOM_PAPERSIZE);
customPaperSizePane.setVisible(isCustom);
}
private JPanel getLayoutSettingPane() { private JPanel getLayoutSettingPane() {
JPanel layoutSettingPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); JPanel layoutSettingPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
layoutSettingPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); layoutSettingPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
@ -373,7 +416,17 @@ public class NativePrintSettingPane extends JPanel {
doublePrintComboBox.setEnabled(doublePrintRadioButton.isSelected()); doublePrintComboBox.setEnabled(doublePrintRadioButton.isSelected());
inheritPagePaperSettingCheck.setSelected(nativePrintAttr.isInheritPagePaperSetting()); inheritPagePaperSettingCheck.setSelected(nativePrintAttr.isInheritPagePaperSetting());
predefinedPaperSizeComboBox.setSelectedItem(nativePrintAttr.getPaperSize());
PaperSize paperSize = nativePrintAttr.getPaperSize();
predefinedPaperSizeComboBox.setSelectedItem(paperSize);
if (!ComparatorUtils.equals(predefinedPaperSizeComboBox.getSelectedItem(), paperSize)) {
// 自定义尺寸
predefinedPaperSizeComboBox.setSelectedItem(CUSTOM_PAPERSIZE);
customWidthFieldPane.setUnitValue(paperSize.getWidth());
customHeightFieldPane.setUnitValue(paperSize.getHeight());
}
updateCustomPaperSizeArea();
inheritPageLayoutSettingCheck.setSelected(nativePrintAttr.isInheritPageLayoutSetting()); inheritPageLayoutSettingCheck.setSelected(nativePrintAttr.isInheritPageLayoutSetting());
if (nativePrintAttr.getOrientation() == ReportConstants.PORTRAIT) { if (nativePrintAttr.getOrientation() == ReportConstants.PORTRAIT) {
portraitRadioButton.setSelected(true); portraitRadioButton.setSelected(true);
@ -408,7 +461,15 @@ public class NativePrintSettingPane extends JPanel {
} }
nativePrintAttr.setInheritPagePaperSetting(inheritPagePaperSettingCheck.isSelected()); nativePrintAttr.setInheritPagePaperSetting(inheritPagePaperSettingCheck.isSelected());
nativePrintAttr.setPaperSize((PaperSize) predefinedPaperSizeComboBox.getSelectedItem());
PaperSize newPaperSize;
if (ComparatorUtils.equals(predefinedPaperSizeComboBox.getSelectedItem(), CUSTOM_PAPERSIZE)) {
newPaperSize = new PaperSize(customWidthFieldPane.getUnitValue(), customHeightFieldPane.getUnitValue());
} else {
newPaperSize = (PaperSize) predefinedPaperSizeComboBox.getSelectedItem();
}
nativePrintAttr.setPaperSize(newPaperSize);
nativePrintAttr.setInheritPageLayoutSetting(inheritPageLayoutSettingCheck.isSelected()); nativePrintAttr.setInheritPageLayoutSetting(inheritPageLayoutSettingCheck.isSelected());
nativePrintAttr.setOrientation(portraitRadioButton.isSelected() ? nativePrintAttr.setOrientation(portraitRadioButton.isSelected() ?
ReportConstants.PORTRAIT : ReportConstants.LANDSCAPE); ReportConstants.PORTRAIT : ReportConstants.LANDSCAPE);

Loading…
Cancel
Save