diff --git a/designer/src/com/fr/design/actions/insert/flot/ImageFloatAction.java b/designer/src/com/fr/design/actions/insert/flot/ImageFloatAction.java index 9861499bf9..e4005439be 100644 --- a/designer/src/com/fr/design/actions/insert/flot/ImageFloatAction.java +++ b/designer/src/com/fr/design/actions/insert/flot/ImageFloatAction.java @@ -5,7 +5,6 @@ package com.fr.design.actions.insert.flot; import com.fr.base.BaseUtils; import com.fr.base.DynamicUnitList; -import com.fr.base.ScreenResolution; import com.fr.design.actions.ElementCaseAction; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; @@ -24,9 +23,8 @@ import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.CoreGraphHelper; import com.fr.stable.unit.FU; -import javax.swing.*; -import java.awt.*; -import java.io.File; +import javax.swing.KeyStroke; +import java.awt.Image; /** * Insert image. @@ -83,10 +81,9 @@ public class ImageFloatAction extends ElementCaseAction { @Override public void doOk() { - File selectedFile = selectImagePane.getSelectedImage(); + Image image = selectImagePane.getSelectedImage(); - if (selectedFile != null && selectedFile.isFile()) { - Image image = BaseUtils.readImage(selectedFile.getPath()); + if (image != null ) { CellImage cellImage = selectImagePane.update(); CoreGraphHelper.waitForImage(image); diff --git a/designer/src/com/fr/design/actions/report/ReportPrintSettingAction.java b/designer/src/com/fr/design/actions/report/ReportPrintSettingAction.java new file mode 100644 index 0000000000..9051e46ff4 --- /dev/null +++ b/designer/src/com/fr/design/actions/report/ReportPrintSettingAction.java @@ -0,0 +1,74 @@ +package com.fr.design.actions.report; + +import com.fr.base.IconManager; +import com.fr.design.actions.JWorkBookAction; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JWorkBook; +import com.fr.design.menu.MenuKeySet; +import com.fr.design.webattr.printsettings.ReportPrintSettingPane; +import com.fr.general.IOUtils; +import com.fr.general.Inter; +import com.fr.main.TemplateWorkBook; +import com.fr.base.print.PrintSettingsAttrMark; +import com.fr.report.core.ReportUtils; + +import javax.swing.KeyStroke; +import java.awt.event.ActionEvent; + +/** + * Created by plough on 2018/3/5. + */ +public class ReportPrintSettingAction extends JWorkBookAction { + + public ReportPrintSettingAction(JWorkBook jwb) { + super(jwb); + this.setMenuKeySet(REPORT_APP_ATTR); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(IOUtils.readIcon(IconManager.PRINT.getPath())); + this.setSearchText(new ReportPrintSettingPane()); + } + + /** + * 执行动作 + * + * @return 是否执行成功 + */ + public void actionPerformed(ActionEvent evt) { + final JWorkBook jwb = getEditingComponent(); + if (jwb == null) { + return; + } + final TemplateWorkBook wbTpl = jwb.getTarget(); + PrintSettingsAttrMark printSettings = ReportUtils.getPrintSettingsFromWorkbook(wbTpl); + + final ReportPrintSettingPane reportPrintSettingPane = new ReportPrintSettingPane(); + reportPrintSettingPane.populate(printSettings); + BasicDialog dialog = reportPrintSettingPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + PrintSettingsAttrMark newPrintSettings = reportPrintSettingPane.updateBean(); + wbTpl.addAttrMark(newPrintSettings); + jwb.fireTargetModified(); + } + }); + dialog.setVisible(true); + } + + private static final MenuKeySet REPORT_APP_ATTR = new MenuKeySet() { + @Override + public char getMnemonic() { return 'P'; } + + @Override + public String getMenuName() { + return Inter.getLocText("FR-Designer_Print_Setting"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; +} diff --git a/designer/src/com/fr/design/headerfooter/ImagePane.java b/designer/src/com/fr/design/headerfooter/ImagePane.java index a67af01569..950ccc9fef 100644 --- a/designer/src/com/fr/design/headerfooter/ImagePane.java +++ b/designer/src/com/fr/design/headerfooter/ImagePane.java @@ -3,25 +3,22 @@ */ package com.fr.design.headerfooter; -import java.awt.BorderLayout; -import java.awt.Image; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; - -import javax.swing.BorderFactory; -import javax.swing.JFileChooser; -import javax.swing.JPanel; -import javax.swing.JScrollPane; - -import com.fr.base.BaseUtils; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.frpane.ImgChooseWrapper; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.dialog.BasicPane; -import com.fr.general.Inter; -import com.fr.stable.CoreGraphHelper; import com.fr.design.style.background.image.ImageFileChooser; import com.fr.design.style.background.image.ImagePreviewPane; +import com.fr.general.Inter; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.SwingWorker; +import java.awt.BorderLayout; +import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * Image Pane. @@ -29,6 +26,7 @@ import com.fr.design.style.background.image.ImagePreviewPane; public class ImagePane extends BasicPane { private ImagePreviewPane imagePreviewPane; private ImageFileChooser imageFileChooser = null; + private SwingWorker imageWorker; public ImagePane() { this(true); @@ -67,17 +65,17 @@ public class ImagePane extends BasicPane { imageFileChooser = new ImageFileChooser(); imageFileChooser.setMultiSelectionEnabled(false); } - + @Override protected String title4PopupWindow() { - return "image"; + return "image"; } public void populate(Image image) { - if(image == null) { - return; - } - + if(image == null) { + return; + } + this.imagePreviewPane.setImage(image); } @@ -91,19 +89,7 @@ public class ImagePane extends BasicPane { ActionListener selectPictureActionListener = new ActionListener() { public void actionPerformed(ActionEvent evt) { int returnVal = imageFileChooser.showOpenDialog(ImagePane.this); - if (returnVal != JFileChooser.CANCEL_OPTION) { - File selectedFile = imageFileChooser.getSelectedFile(); - - if (selectedFile != null && selectedFile.isFile()) { - Image image = BaseUtils.readImage(selectedFile.getPath()); - CoreGraphHelper.waitForImage(image); - - imagePreviewPane.setImage(image); - } else { - imagePreviewPane.setImage(null); - } - imagePreviewPane.repaint(); - } + ImgChooseWrapper.getInstance(imagePreviewPane, imageFileChooser, null).dealWithImageFile(returnVal); } }; } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index a93e602210..dc40470076 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -23,6 +23,7 @@ import com.fr.design.actions.file.export.WordExportAction; import com.fr.design.actions.report.ReportExportAttrAction; import com.fr.design.actions.report.ReportMobileAttrAction; import com.fr.design.actions.report.ReportParameterAction; +import com.fr.design.actions.report.ReportPrintSettingAction; import com.fr.design.actions.report.ReportWebAttrAction; import com.fr.design.cell.bar.DynamicScrollBar; import com.fr.design.constants.UIConstants; @@ -650,6 +651,7 @@ public class JWorkBook extends JTemplate { new ReportExportAttrAction(this), new ReportParameterAction(this), new ReportMobileAttrAction(this), + new ReportPrintSettingAction(this), new NameSeparator(Inter.getLocText("Utils-Current_Sheet")), }, this.reportComposite.getEditingReportComponent().shortcut4TemplateMenu()); } diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index 951333895f..e0bebfe1ef 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -7,13 +7,14 @@ import com.fr.design.editor.ValueEditorPaneFactory; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ibutton.UIButtonGroup; +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.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.layout.*; +import com.fr.design.layout.VerticalFlowLayout; +import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.JTemplate; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; @@ -63,8 +64,14 @@ public class CellOtherSetPane extends AbstractCellAttrPane { private UICheckBox canBreakOnPaginateCheckBox; private UICheckBox repeatCheckBox; - private UICheckBox autoHeightCheckBox; - private UICheckBox autoWidthCheckBox; + + // 自动调整 + private UIRadioButton autoHeightRadioButton; // 自动调整行高 + private UIRadioButton autoWidthRadioButton; // 自动调整列宽 + private UIRadioButton noAutoRadioButton; // 不自动调整 + private UIRadioButton defaultAutoRadioButton; // 跟随页面设置(默认) + private UIRadioButton[] adjustRadioButtons; + // 插入行策略 private UIButtonGroup insertRowPolicy; private ValueEditorPane valueEditor; @@ -80,7 +87,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { */ public JPanel createContentPane() { JPanel downPane = new JPanel(new BorderLayout()); - downPane.add(new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), HEAD_WDITH, HEAD_HEIGTH, seniorPane()), BorderLayout.NORTH); + downPane.add(new UIExpandablePane(Inter.getLocText("FR-Designer_Auto_Adjust_Size"), HEAD_WDITH, HEAD_HEIGTH, seniorPane()), BorderLayout.NORTH); downPane.add(new UIExpandablePane(Inter.getLocText("FR-Designer_Pagination"), HEAD_WDITH, HEAD_HEIGTH, pagePane()), BorderLayout.CENTER); JPanel contentPane = new JPanel(new BorderLayout(0, 0)); contentPane.add(new UIExpandablePane(Inter.getLocText("FR-Designer_Basic"), HEAD_WDITH, HEAD_HEIGTH, basicPane()), BorderLayout.NORTH); @@ -89,24 +96,36 @@ public class CellOtherSetPane extends AbstractCellAttrPane { return contentPane; } - private JPanel basicPane() { - autoHeightCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Auto_Adjust_Height")); - autoWidthCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Auto_Adjust_Wdith")); - autoHeightCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); - autoWidthCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); - double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p, p}; - double[] columnSize = {p}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}}; - Component[][] components = new Component[][]{ - new Component[]{null}, - new Component[]{autoHeightCheckBox}, - new Component[]{autoWidthCheckBox}, - new Component[]{null}, + defaultAutoRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Follow_Paper_Settings")); + noAutoRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_No_Auto_Adjust")); + autoHeightRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Auto_Adjust_Height")); + autoWidthRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Auto_Adjust_Width")); + adjustRadioButtons = new UIRadioButton[]{ + defaultAutoRadioButton, noAutoRadioButton, autoHeightRadioButton, autoWidthRadioButton }; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_LARGE); + // 指定分组 + ButtonGroup autoBG = new ButtonGroup(); + for (UIRadioButton radioButton : adjustRadioButtons) { + autoBG.add(radioButton); + } + + JPanel basicPane = new JPanel() { + @Override + public Insets getInsets() { + return new Insets(LayoutConstants.VGAP_MEDIUM, 0, LayoutConstants.VGAP_MEDIUM, 0); + } + }; + VerticalFlowLayout verticalFlowLayout = new VerticalFlowLayout(VerticalFlowLayout.CENTER, 0, 0); + verticalFlowLayout.setAlignLeft(true); + basicPane.setLayout(verticalFlowLayout); + basicPane.add(defaultAutoRadioButton); + basicPane.add(noAutoRadioButton); + basicPane.add(autoHeightRadioButton); + basicPane.add(autoWidthRadioButton); + + return basicPane; } private JPanel seniorPane() { @@ -268,12 +287,13 @@ public class CellOtherSetPane extends AbstractCellAttrPane { private void initAllNames() { -// autoshrik.setGlobalName(Inter.getLocText("FR-Designer_Auto_Adjust_Size")); - autoHeightCheckBox.setGlobalName(Inter.getLocText("FR-Designer_Auto_Adjust_Height")); - autoWidthCheckBox.setGlobalName(Inter.getLocText("FR-Designer_Auto_Adjust_Wdith")); + defaultAutoRadioButton.setGlobalName(Inter.getLocText("FR-Designer_Follow_Paper_Settings")); + noAutoRadioButton.setGlobalName(Inter.getLocText("FR-Designer_No_Auto_Adjust")); + autoHeightRadioButton.setGlobalName(Inter.getLocText("FR-Designer_Auto_Adjust_Height")); + autoWidthRadioButton.setGlobalName(Inter.getLocText("FR-Designer_Auto_Adjust_Width")); previewCellContent.setGlobalName(Inter.getLocText("FR-Designer_Preview")); - printAndExportContent.setGlobalName(Inter.getLocText("CellWrite-Preview_Cell_Content")); - printAndExportBackground.setGlobalName(Inter.getLocText("CellWrite-Print_Background")); + printAndExportContent.setGlobalName(Inter.getLocText("FR-Designer_CellWrite_Print_Content")); + printAndExportBackground.setGlobalName(Inter.getLocText("FR-Designer_CellWrite_Print_Background")); showContent.setGlobalName(Inter.getLocText("FR-Designer_Show_Content")); fileNameTextField.setGlobalName(Inter.getLocText("FR-Designer_Show_Content")); tooltipTextField.setGlobalName(Inter.getLocText("FR-Designer_CellWrite_ToolTip")); @@ -300,27 +320,32 @@ public class CellOtherSetPane extends AbstractCellAttrPane { if (cellGUIAttr == null) { cellGUIAttr = CellGUIAttr.DEFAULT_CELLGUIATTR; } -// autoshrik.setSelectedIndex(cellGUIAttr.getAdjustMode()); + + // 是否在编辑表单中的报表块 + boolean isInForm = EastRegionContainerPane.getInstance().getCurrentMode().equals(EastRegionContainerPane.PropertyMode.FORM_REPORT); + + defaultAutoRadioButton.setVisible(!isInForm); switch (cellGUIAttr.getAdjustMode()) { - case 0: - autoHeightCheckBox.setSelected(false); - autoWidthCheckBox.setSelected(false); + case CellGUIAttr.ADJUST_MODE_NO_AUTO: + noAutoRadioButton.setSelected(true); break; - case 1: - autoHeightCheckBox.setSelected(true); - autoWidthCheckBox.setSelected(false); + case CellGUIAttr.ADJUST_MODE_AUTO_HEIGHT: + autoHeightRadioButton.setSelected(true); break; - case 2: - autoHeightCheckBox.setSelected(false); - autoWidthCheckBox.setSelected(true); + case CellGUIAttr.ADJUST_MODE_AUTO_WIDTH: + autoWidthRadioButton.setSelected(true); break; - case 3: - autoHeightCheckBox.setSelected(true); - autoWidthCheckBox.setSelected(true); + case CellGUIAttr.ADJUST_MODE_DEFAULT: + if (isInForm) { + autoHeightRadioButton.setSelected(true); + } else { + defaultAutoRadioButton.setSelected(true); + } break; default: break; } + previewCellContent.setSelected(cellGUIAttr.isPreviewContent()); printAndExportContent.setSelected(cellGUIAttr.isPrintContent()); printAndExportBackground.setSelected(cellGUIAttr.isPrintBackground()); @@ -384,32 +409,29 @@ public class CellOtherSetPane extends AbstractCellAttrPane { cellGUIAttr = new CellGUIAttr(); } -// if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Auto_Adjust_Size"))) { -// cellGUIAttr.setAdjustMode(autoshrik.getSelectedIndex()); -// } - - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Auto_Adjust_Height")) || ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Auto_Adjust_Wdith"))) { - int flag; - if (autoHeightCheckBox.isSelected()) { - if (autoWidthCheckBox.isSelected()) { - flag = 3; + for (UIRadioButton radioButton : adjustRadioButtons) { + if (ComparatorUtils.equals(getGlobalName(), radioButton.getGlobalName())) { + // 自动调整 + int flag; + if (defaultAutoRadioButton.isSelected()) { + flag = CellGUIAttr.ADJUST_MODE_DEFAULT; + } else if (autoWidthRadioButton.isSelected()) { + flag = CellGUIAttr.ADJUST_MODE_AUTO_WIDTH; + } else if (autoHeightRadioButton.isSelected()) { + flag = CellGUIAttr.ADJUST_MODE_AUTO_HEIGHT; } else { - flag = 1; + flag = CellGUIAttr.ADJUST_MODE_NO_AUTO; } - } else if (autoWidthCheckBox.isSelected()) { - flag = 2; - } else { - flag = 0; + cellGUIAttr.setAdjustMode(flag); + break; } - cellGUIAttr.setAdjustMode(flag); } - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Preview"))) { cellGUIAttr.setPreviewContent(previewCellContent.isSelected()); } - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_CellWrite_Preview_Cell_Content"))) { + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_CellWrite_Print_Content"))) { cellGUIAttr.setPrintContent(printAndExportContent.isSelected()); } diff --git a/designer/src/com/fr/design/mainframe/form/FormElementCaseDesigner.java b/designer/src/com/fr/design/mainframe/form/FormElementCaseDesigner.java index 1cdab0e7e6..f0230be44c 100644 --- a/designer/src/com/fr/design/mainframe/form/FormElementCaseDesigner.java +++ b/designer/src/com/fr/design/mainframe/form/FormElementCaseDesigner.java @@ -130,6 +130,14 @@ public class FormElementCaseDesigner imageWorker; public SelectImagePane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -57,7 +51,7 @@ public class SelectImagePane extends BasicPane{ JPanel previewOwnerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); previewContainerPane.add(previewOwnerPane, BorderLayout.CENTER); - previewOwnerPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Preview"),null)); + previewOwnerPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Preview"), null)); previewPane = new ImagePreviewPane(); previewOwnerPane.add(new JScrollPane(previewPane)); @@ -72,10 +66,10 @@ public class SelectImagePane extends BasicPane{ selectFilePane.add(selectPictureButton, BorderLayout.NORTH); selectPictureButton.setMnemonic('S'); selectPictureButton.addActionListener(selectPictureActionListener); - - JPanel layoutPane=FRGUIPaneFactory.createMediumHGapHighTopFlowInnerContainer_M_Pane(); + + JPanel layoutPane = FRGUIPaneFactory.createMediumHGapHighTopFlowInnerContainer_M_Pane(); selectFilePane.add(layoutPane, BorderLayout.CENTER); - + //布局 defaultRadioButton = new UIRadioButton(Inter.getLocText("Default")); tiledRadioButton = new UIRadioButton(Inter.getLocText("Image-Titled")); @@ -86,7 +80,7 @@ public class SelectImagePane extends BasicPane{ tiledRadioButton.addActionListener(layoutActionListener); extendRadioButton.addActionListener(layoutActionListener); adjustRadioButton.addActionListener(layoutActionListener); - + JPanel jp = new JPanel(new GridLayout(4, 1, 15, 15)); jp.add(defaultRadioButton); jp.add(tiledRadioButton); @@ -111,95 +105,80 @@ public class SelectImagePane extends BasicPane{ * Select picture. */ ActionListener selectPictureActionListener = new ActionListener() { + @Override public void actionPerformed(ActionEvent evt) { int returnVal = imageFileChooser .showOpenDialog(SelectImagePane.this); - if (returnVal != JFileChooser.CANCEL_OPTION) { - File selectedFile = imageFileChooser.getSelectedFile(); - - if (selectedFile != null && selectedFile.isFile()) { - Image image = BaseUtils.readImage(selectedFile.getPath()); - CoreGraphHelper.waitForImage(image); - - imageFile = selectedFile; - setImageStyle(); - previewPane.setImage(image); - previewPane.setImageStyle(imageStyle); - previewImage = image; - } else { - previewPane.setImage(null); - } - previewPane.repaint(); - } + ImgChooseWrapper.getInstance(previewPane, imageFileChooser, imageStyle).dealWithImageFile(returnVal); } }; - + // 调整图片样式,只有水平和垂直对齐以及拉伸。相对于背景,平铺不予考虑。 private void changeImageStyle() { - previewPane.setImageStyle(this.imageStyle); - previewPane.repaint(); + previewPane.setImageStyle(this.imageStyle); + previewPane.repaint(); } - - private void setImageStyle(){ - if(tiledRadioButton.isSelected()){ - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); - }else if(adjustRadioButton.isSelected()){ - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); - }else if(extendRadioButton.isSelected()){ - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); - }else{ - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); + + private void setImageStyle() { + if (tiledRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); + } else if (adjustRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); + } else if (extendRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); + } else { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); } } ActionListener layoutActionListener = new ActionListener() { + @Override public void actionPerformed(ActionEvent evt) { - setImageStyle(); + setImageStyle(); changeImageStyle(); } }; - + @Override protected String title4PopupWindow() { - return Inter.getLocText("Image"); + return Inter.getLocText("Image"); } public void populate(Elem cell) { - Style style = null; - if (cell != null) { - Object value = cell.getValue(); - if (value != null && value instanceof Image) { - Image image = (Image)value; - previewPane.setImage(image); - this.previewImage = image; - } - - style = cell.getStyle(); - } - - if(style.getImageLayout() == Constants.IMAGE_TILED){ - tiledRadioButton.setSelected(true); - }else if(style.getImageLayout() == Constants.IMAGE_EXTEND){ - extendRadioButton.setSelected(true); - }else if(style.getImageLayout() == Constants.IMAGE_ADJUST){ - adjustRadioButton.setSelected(true); - }else{ - style.deriveImageLayout(Constants.IMAGE_CENTER); - defaultRadioButton.setSelected(true); - } - this.imageStyle = style; - changeImageStyle(); + Style style = null; + if (cell != null) { + Object value = cell.getValue(); + if (value != null && value instanceof Image) { + Image image = (Image) value; + previewPane.setImage(image); + } + + style = cell.getStyle(); + } + + if (style.getImageLayout() == Constants.IMAGE_TILED) { + tiledRadioButton.setSelected(true); + } else if (style.getImageLayout() == Constants.IMAGE_EXTEND) { + extendRadioButton.setSelected(true); + } else if (style.getImageLayout() == Constants.IMAGE_ADJUST) { + adjustRadioButton.setSelected(true); + } else { + style.deriveImageLayout(Constants.IMAGE_CENTER); + defaultRadioButton.setSelected(true); + } + this.imageStyle = style; + changeImageStyle(); } - public CellImage update(){ - CellImage cellImage = new CellImage(); - cellImage.setImage(previewPane.getImage()); - cellImage.setStyle(this.imageStyle); - return cellImage; + public CellImage update() { + CellImage cellImage = new CellImage(); + cellImage.setImage(previewPane.getImage()); + cellImage.setStyle(this.imageStyle); + return cellImage; } - - public File getSelectedImage(){ - return imageFile; + + public Image getSelectedImage() { + return previewPane.getImage(); } } \ No newline at end of file diff --git a/designer/src/com/fr/design/webattr/EditReportServerParameterPane.java b/designer/src/com/fr/design/webattr/EditReportServerParameterPane.java index 6a3fd219a1..04f54dc660 100644 --- a/designer/src/com/fr/design/webattr/EditReportServerParameterPane.java +++ b/designer/src/com/fr/design/webattr/EditReportServerParameterPane.java @@ -12,7 +12,10 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.design.webattr.printsettings.PrintSettingPane; import com.fr.general.Inter; +import com.fr.base.print.PrintSettingsAttrMark; +import com.fr.report.core.ReportUtils; import com.fr.stable.project.ProjectConstants; import com.fr.web.attr.ReportWebAttr; @@ -34,6 +37,7 @@ public class EditReportServerParameterPane extends LoadingBasicPane { // private FormToolBarPane formPane; private WriteToolBarPane writePane; private ReportWebAttr webAttr; + private PrintSettingsAttrMark printSettings; private WebCssPane cssPane; @@ -41,6 +45,8 @@ public class EditReportServerParameterPane extends LoadingBasicPane { private ErrorTemplatePane errorTemplatePane; + private PrintSettingPane printSettingPane; + @Override protected synchronized void initComponents(JPanel container) { @@ -68,6 +74,7 @@ public class EditReportServerParameterPane extends LoadingBasicPane { tabbedPane.addTab(Inter.getLocText("ReportServerP-Import_Css"), cssPane = new WebCssPane()); tabbedPane.addTab(Inter.getLocText("ReportServerP-Import_JavaScript"), jsPane = new WebJsPane()); tabbedPane.addTab(Inter.getLocText("FR-Designer_ErrorHandlerTemplate"), errorTemplatePane = new ErrorTemplatePane()); + tabbedPane.addTab(Inter.getLocText("FR-Designer_Print_Setting"), printSettingPane = new PrintSettingPane()); } @Override @@ -86,10 +93,11 @@ public class EditReportServerParameterPane extends LoadingBasicPane { viewPane.populateBean(webAttr.getWebView()); writePane.populateBean(webAttr.getWebWrite()); cssPane.populate(webAttr); - jsPane.populate(webAttr); } - + printSettings = ReportUtils.getPrintSettingsFromServerConfig(); + printSettingPane.populate(printSettings); + this.errorTemplatePane.populateBean(reportServerConfigManager.getErrorTemplate()); } @@ -105,10 +113,11 @@ public class EditReportServerParameterPane extends LoadingBasicPane { webAttr.setWebPage(pagePane.updateBean()); webAttr.setWebView(viewPane.updateBean()); webAttr.setWebWrite(writePane.updateBean()); - cssPane.update(webAttr); - jsPane.update(webAttr); + + printSettings = printSettingPane.updateBean(); + ((ConfigManager)reportServerConfigManager).getPrintAttr().setPrintSettings(printSettings); reportServerConfigManager.setErrorTemplate(this.errorTemplatePane.updateBean()); } diff --git a/designer/src/com/fr/design/webattr/EditToolBar.java b/designer/src/com/fr/design/webattr/EditToolBar.java index a8ebd932fc..2883329d9e 100644 --- a/designer/src/com/fr/design/webattr/EditToolBar.java +++ b/designer/src/com/fr/design/webattr/EditToolBar.java @@ -31,18 +31,32 @@ import com.fr.form.ui.WidgetManager; import com.fr.general.Background; import com.fr.general.Inter; import com.fr.report.web.button.Export; -import com.fr.report.web.button.PDFPrint; -import com.fr.report.web.button.Print; import com.fr.report.web.button.write.AppendColumnRow; import com.fr.report.web.button.write.ExcelImport; import com.fr.report.web.button.write.Submit; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.ImageIcon; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.ListCellRenderer; +import javax.swing.SpinnerNumberModel; +import javax.swing.SwingUtilities; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; @@ -320,8 +334,8 @@ public class EditToolBar extends BasicPane { private CardLayout card; private JPanel centerPane; private UICheckBox icon, text, pdf, excelP, excelO, excelS, image, word, - flashPrint, pdfPrint, appletPrint, serverPrint, isPopup, isVerify, failSubmit, - isCurSheet, excelImClean, excelImCover, excelImAppend, excelImCust; + isPopup, isVerify, failSubmit, isCurSheet, excelImClean, + excelImCover, excelImAppend, excelImCust; private UIBasicSpinner count; private Widget widget; private UITextField nameField; @@ -383,9 +397,7 @@ public class EditToolBar extends BasicPane { centerPane.add("custom", getCustomPane()); centerPane.add("export", getExport()); centerPane.add("import", getImport()); - centerPane.add("print", getPrint()); centerPane.add("none", none); - centerPane.add("pdfprint", getPdfPrintSetting()); // centerPane.add("editexcel", editExcel); centerPane.add(getCpane(), "appendcount"); centerPane.add(getSubmitPane(), "submit"); @@ -455,22 +467,6 @@ public class EditToolBar extends BasicPane { return excelImport; } - private JPanel getPrint() { - JPanel print = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - // print.setLayout(new BoxLayout(print, BoxLayout.Y_AXIS)); - flashPrint = new UICheckBox(Inter.getLocText("FR-Designer_Flash_Print")); - pdfPrint = new UICheckBox(Inter.getLocText("FR-Designer_PDF_Print")); - appletPrint = new UICheckBox(Inter.getLocText("FR-Designer_Applet_Print")); - serverPrint = new UICheckBox(Inter.getLocText("FR-Designer_Server_Print")); - print.add(flashPrint); - print.add(pdfPrint); - print.add(appletPrint); - print.add(serverPrint); - print.setBorder(BorderFactory.createTitledBorder(Inter.getLocText(new String[]{"Form-Button", "Property", "Set"}))); - return print; - } - - private JPanel getCpane() { JPanel appendCountPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); count = new UIBasicSpinner(new SpinnerNumberModel(1, 0, Integer.MAX_VALUE, 1)); @@ -482,17 +478,6 @@ public class EditToolBar extends BasicPane { return cpane; } - - private JPanel getPdfPrintSetting() { - // richer:pdf打印按钮设置 - JPanel pdfPrintSetting = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); - isPopup = new UICheckBox(Inter.getLocText("PDF-Print_isPopup")); - pdfPrintSetting.add(isPopup); - pdfPrintSetting.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("PDF-Print_Setting"))); - return pdfPrintSetting; - } - - private JPanel getSubmitPane() { isVerify = new UICheckBox(Inter.getLocText("Verify-Data_Verify")); failSubmit = new UICheckBox(Inter.getLocText(new String[]{"Verify_Fail", "Still", "Submit"})); @@ -544,10 +529,6 @@ public class EditToolBar extends BasicPane { } if (widget instanceof Export) { populateExport(); - } else if (widget instanceof Print) { - populatePrint(); - } else if (widget instanceof PDFPrint) { - populatePDFPrint(); } else if (widget instanceof AppendColumnRow) { populateAppendColumnRow(); } else if (widget instanceof Submit) { @@ -614,21 +595,6 @@ public class EditToolBar extends BasicPane { this.isCurSheet.setSelected(submit.isOnlySubmitSelect()); } - private void populatePDFPrint() { - card.show(centerPane, "pdfprint"); - PDFPrint pdfPrint = (PDFPrint) widget; - this.isPopup.setSelected(pdfPrint.isPopup()); - } - - private void populatePrint() { - card.show(centerPane, "print"); - Print print = (Print) widget; - this.pdfPrint.setSelected(print.isPDFPrint()); - this.appletPrint.setSelected(print.isAppletPrint()); - this.flashPrint.setSelected(print.isFlashPrint()); - this.serverPrint.setSelected(print.isServerPrint()); - } - private void populateDefault() { Button button = (Button) widget; this.icon.setSelected(button.isShowIcon()); @@ -645,11 +611,6 @@ public class EditToolBar extends BasicPane { public Widget update() { if (widget instanceof Export) { updateExport(); - } else if (widget instanceof Print) { - updatePrint(); - } else if (widget instanceof PDFPrint) { - PDFPrint pdfPrint = (PDFPrint) widget; - pdfPrint.setPopup(this.isPopup.isSelected()); } else if (widget instanceof AppendColumnRow) { ((AppendColumnRow) widget).setCount(((Integer) count.getValue()).intValue()); } else if (widget instanceof Submit) { @@ -685,14 +646,6 @@ public class EditToolBar extends BasicPane { submit.setOnlySubmitSelect(this.isCurSheet.isSelected()); } - private void updatePrint() { - Print print = (Print) widget; - print.setAppletPrint(this.appletPrint.isSelected()); - print.setFlashPrint(this.flashPrint.isSelected()); - print.setPDFPrint(this.pdfPrint.isSelected()); - print.setServerPrint(this.serverPrint.isSelected()); - } - private void updateExport() { Export export = (Export) widget; export.setPdfAvailable(this.pdf.isSelected()); diff --git a/designer/src/com/fr/design/webattr/ReportWebWidgetConstants.java b/designer/src/com/fr/design/webattr/ReportWebWidgetConstants.java index 55db27c051..232c332984 100644 --- a/designer/src/com/fr/design/webattr/ReportWebWidgetConstants.java +++ b/designer/src/com/fr/design/webattr/ReportWebWidgetConstants.java @@ -6,9 +6,45 @@ import com.fr.design.gui.core.WidgetOptionFactory; import com.fr.form.ui.CustomToolBarButton; import com.fr.form.ui.Widget; import com.fr.general.Inter; -import com.fr.report.web.button.*; -import com.fr.report.web.button.page.*; -import com.fr.report.web.button.write.*; +import com.fr.report.web.button.AppletPrint; +import com.fr.report.web.button.Edit; +import com.fr.report.web.button.Email; +import com.fr.report.web.button.ExcelO; +import com.fr.report.web.button.ExcelP; +import com.fr.report.web.button.ExcelS; +import com.fr.report.web.button.Export; +import com.fr.report.web.button.FlashPrint; +import com.fr.report.web.button.NewPrint; +import com.fr.report.web.button.PDF; +import com.fr.report.web.button.PDF2; +import com.fr.report.web.button.PDFPrint; +import com.fr.report.web.button.PageSetup; +import com.fr.report.web.button.Print; +import com.fr.report.web.button.PrintPreview; +import com.fr.report.web.button.Scale; +import com.fr.report.web.button.ServerPrint; +import com.fr.report.web.button.Word; +import com.fr.report.web.button.page.First; +import com.fr.report.web.button.page.Last; +import com.fr.report.web.button.page.Next; +import com.fr.report.web.button.page.PageNavi; +import com.fr.report.web.button.page.Previous; +import com.fr.report.web.button.page.SetPrinterOffset; +import com.fr.report.web.button.write.AppendColumnRow; +import com.fr.report.web.button.write.ClearStashedButton; +import com.fr.report.web.button.write.CustomizeImportExcelData; +import com.fr.report.web.button.write.DeleteColumnRow; +import com.fr.report.web.button.write.ExcelImport; +import com.fr.report.web.button.write.ImExcelAppend; +import com.fr.report.web.button.write.ImExcelClean; +import com.fr.report.web.button.write.ImExcelCover; +import com.fr.report.web.button.write.ImportExcelData; +import com.fr.report.web.button.write.ShowCellValue; +import com.fr.report.web.button.write.StashButton; +import com.fr.report.web.button.write.Submit; +import com.fr.report.web.button.write.SubmitForcibly; +import com.fr.report.web.button.write.Verify; +import com.fr.report.web.button.write.WriteOfflineHTML; import com.fr.stable.bridge.BridgeMark; import com.fr.stable.bridge.StableFactory; @@ -17,27 +53,27 @@ public class ReportWebWidgetConstants { } public static WidgetOption[] getPageToolBarInstance() { - return new WidgetOption[]{FIRST, PREVIOUS, PAGENAVI, NEXT, LAST, SCALE, EMAIL, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, + return new WidgetOption[]{FIRST, PREVIOUS, PAGENAVI, NEXT, LAST, SCALE, EMAIL, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, NEW_PRINT, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, SETPRINTEROFFSET, CUSTOM_BUTTON}; } public static WidgetOption[] getViewToolBarInstance() { - return new WidgetOption[]{PAGESETUP, EMAIL, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, SETPRINTEROFFSET, PRINTPREVIEW, CUSTOM_BUTTON}; + return new WidgetOption[]{PAGESETUP, EMAIL, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, NEW_PRINT, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, SETPRINTEROFFSET, PRINTPREVIEW, CUSTOM_BUTTON}; } public static WidgetOption[] getPreviewToolBarInstance() { - return new WidgetOption[]{FIRST, PREVIOUS, PAGENAVI, NEXT, LAST, SCALE, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, + return new WidgetOption[]{FIRST, PREVIOUS, PAGENAVI, NEXT, LAST, SCALE, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, NEW_PRINT, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, SETPRINTEROFFSET, CUSTOM_BUTTON}; } public static WidgetOption[] getWriteToolBarInstance() { - return new WidgetOption[]{SUBMIT, VERIFY, EMAIL, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, IMPORTEXCELDATA, SHOWCELLVALUE, - APPENDCOLUMNROW, DELETECOLUMNROW, SETPRINTEROFFSET, CUSTOM_BUTTON, WRITESTASH, WRITESTASHCLEAR, IMPORTEXCELDATA_CUSTOMIZED, + return new WidgetOption[]{SUBMIT, VERIFY, EMAIL, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, NEW_PRINT, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, IMPORTEXCELDATA, SHOWCELLVALUE, + APPENDCOLUMNROW, DELETECOLUMNROW, SETPRINTEROFFSET, WRITEOFFLINEHTML, CUSTOM_BUTTON, WRITESTASH, WRITESTASHCLEAR, IMPORTEXCELDATA_CUSTOMIZED, IMPORTEXCEL, IMPORTEXCEL_COVER, IMPORTEXCEL_CLEAN, IMPORTEXCEL_APPEND}; } public static WidgetOption[] getFormToolBarInstance() { - return new WidgetOption[]{EMAIL, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, SETPRINTEROFFSET, CUSTOM_BUTTON}; + return new WidgetOption[]{EMAIL, EXPORT, PDF, EXCELP, EXCELO, EXCELS, WORD, NEW_PRINT, PRINT, FLASHPRINT, APPLETPRINT, PDFPRINT, SETPRINTEROFFSET, CUSTOM_BUTTON}; } // 查询 @@ -114,7 +150,8 @@ public class ReportWebWidgetConstants { public static final WidgetOption SCALE = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Engine_Enlarge_Or_Reduce"), BaseUtils.readIcon("/com/fr/web/images/scale.png"), Scale.class); - public static final WidgetOption PRINT = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Engine_Print"), BaseUtils.readIcon("/com/fr/web/images/print.png"), Print.class); + public static final WidgetOption NEW_PRINT = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Engine_Print"), BaseUtils.readIcon("/com/fr/web/images/print.png"), NewPrint.class); + public static final WidgetOption PRINT = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Engine_Print_Compatible"), BaseUtils.readIcon("/com/fr/web/images/print.png"), Print.class); public static final WidgetOption APPENDCOLUMNROW = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("Utils-Insert_Record"), BaseUtils.readIcon("/com/fr/web/images/appendRow.png"), AppendColumnRow.class); public static final WidgetOption DELETECOLUMNROW = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("Utils-Delete_Record"), diff --git a/designer/src/com/fr/design/webattr/ToolBarPane.java b/designer/src/com/fr/design/webattr/ToolBarPane.java index 20f71827d4..530717376b 100644 --- a/designer/src/com/fr/design/webattr/ToolBarPane.java +++ b/designer/src/com/fr/design/webattr/ToolBarPane.java @@ -7,9 +7,14 @@ import com.fr.design.gui.core.WidgetOption; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.form.ui.ToolBar; import com.fr.form.ui.Widget; - -import javax.swing.*; -import java.awt.*; +import com.fr.general.Inter; +import com.fr.report.web.annotation.OldPrintMethod; + +import javax.swing.BorderFactory; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; +import javax.swing.TransferHandler; +import java.awt.Component; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.event.MouseAdapter; @@ -19,6 +24,7 @@ import java.util.List; public class ToolBarPane extends BasicBeanPane { private FToolBar ftoolbar = new FToolBar(); + private boolean populateFinished = false; // 正在 populate 数据 public ToolBarPane() { super(); @@ -79,6 +85,10 @@ public class ToolBarPane extends BasicBeanPane { */ public Component add(Component comp) { if (comp instanceof ToolBarButton) { + if (isPopulateFinished() && ((ToolBarButton) comp).getWidget().getClass().isAnnotationPresent(OldPrintMethod.class)) { + JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(this), Inter.getLocText("FR-Designer_Use_New_Print_Tip")); + return comp; + } this.ftoolbar.addButton((ToolBarButton) comp); } return super.add(comp); @@ -128,6 +138,7 @@ public class ToolBarPane extends BasicBeanPane { @Override public void populateBean(ToolBar toolbar) { + setPopulateFinished(false); this.removeAll(); this.getFToolBar().clearButton(); for (int j = 0; j < toolbar.getWidgetSize(); j++) { @@ -146,6 +157,7 @@ public class ToolBarPane extends BasicBeanPane { } this.getFToolBar().setBackground(toolbar.getBackground()); this.getFToolBar().setDefault(toolbar.isDefault()); + setPopulateFinished(true); } @Override @@ -171,6 +183,14 @@ public class ToolBarPane extends BasicBeanPane { } }; + private boolean isPopulateFinished() { + return populateFinished; + } + + private void setPopulateFinished(boolean populateFinished) { + this.populateFinished = populateFinished; + } + /* * 拖拽属性设置 diff --git a/designer/src/com/fr/design/webattr/printsettings/NativePrintSettingPane.java b/designer/src/com/fr/design/webattr/printsettings/NativePrintSettingPane.java new file mode 100644 index 0000000000..1e7545f941 --- /dev/null +++ b/designer/src/com/fr/design/webattr/printsettings/NativePrintSettingPane.java @@ -0,0 +1,320 @@ +package com.fr.design.webattr.printsettings; + +import com.fr.base.PaperSize; +import com.fr.base.Utils; +import com.fr.base.print.NativePrintAttr; +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.UITextField; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; +import com.fr.report.stable.ReportConstants; + +import javax.print.DocFlavor; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.SpinnerNumberModel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.HashSet; +import java.util.Set; + +/** + * Created by plough on 2018/3/5. + */ +public class NativePrintSettingPane extends JPanel { + private UICheckBox isShowDialogCheck; + private UIComboBox printerComboBox; + private UIBasicSpinner copySpinner; // 份数 + private UIRadioButton allPageRadioButton; + private UIRadioButton currentPageRadioButton; + private UIRadioButton customPageRadioButton; + private UITextField specifiedAreaField; + private UIComboBox predefinedPaperSizeComboBox; + private UICheckBox inheritPagePaperSettingCheck; + private UICheckBox inheritPageLayoutSettingCheck; + private UICheckBox inheritPageMarginSettingCheck; + private UICheckBox fitPaperSizeCheck; // 缩放 + private UIRadioButton portraitRadioButton; + private UIRadioButton landscapeRadioButton; + private PageMarginSettingPane pageMarginSettingPane; + + public NativePrintSettingPane() { + initComponents(); + initListeners(); + } + + private void initComponents() { + JPanel printPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + + JPanel northPane = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(1, 0, 15); + UILabel tipDownload = GUICoreUtils.createTipLabel(Inter.getLocText("FR-Designer_Tip_Native_Print_Need_Client")); + northPane.add(tipDownload); + isShowDialogCheck = new UICheckBox(Inter.getLocText("FR-Engine_Show_Print_Setting_Window_When_Printing")); + isShowDialogCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); + UILabel tipCheck = GUICoreUtils.createTipLabel(Inter.getLocText("FR-Designer_Tip_Use_Default_Settings")); + JPanel checkPane = GUICoreUtils.createFlowPane(new Component[] { + isShowDialogCheck, tipCheck}, FlowLayout.LEFT); + northPane.add(checkPane); + northPane.setBorder(BorderFactory.createEmptyBorder(3, 10, 10, 0)); + + printPane.add(northPane, BorderLayout.NORTH); + + JPanel centerPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Default_Settings")); + + UIScrollPane scrollPane = new UIScrollPane(getNativePrintMainSettingPane()); + scrollPane.setBorder(null); + scrollPane.setPreferredSize(new Dimension(600, 340)); + centerPane.add(scrollPane); + + printPane.add(centerPane, BorderLayout.CENTER); + + this.setLayout(new BorderLayout()); + this.add(printPane, BorderLayout.CENTER); + } + + private void initListeners() { + allPageRadioButton.addItemListener(getPageRaidoListener()); + currentPageRadioButton.addItemListener(getPageRaidoListener()); + customPageRadioButton.addItemListener(getPageRaidoListener()); + } + + private ItemListener getPageRaidoListener() { + return new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + specifiedAreaField.setEnabled(customPageRadioButton.isSelected()); + } + }; + } + + private JPanel getNativePrintMainSettingPane() { + // 打印机 + String[] printerArray = getAllPrinterNames(); + printerComboBox = new UIComboBox(printerArray); + printerComboBox.setPreferredSize(new Dimension(200, printerComboBox.getPreferredSize().height)); + JPanel printerPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + printerPane.add(printerComboBox); + + // 份数 + copySpinner = new UIBasicSpinner(new SpinnerNumberModel(1, 0, Integer.MAX_VALUE, 1)); + GUICoreUtils.setColumnForSpinner(copySpinner, 5); + JPanel copyPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + copyPane.add(copySpinner); + + // 继承页面纸张设置 + inheritPagePaperSettingCheck = GUICoreUtils.createNoBorderCheckBox(Inter.getLocText("FR-Designer_Inherit_Page_Paper_Setting")); + JPanel paperSettingPane = getPaperSettingPane(); + JPanel paperSettingCheckPane = GUICoreUtils.createCheckboxAndDynamicPane(inheritPagePaperSettingCheck, paperSettingPane, true); + + // 继承页面布局设置 + inheritPageLayoutSettingCheck = GUICoreUtils.createNoBorderCheckBox(Inter.getLocText("FR-Designer_Inherit_Page_Layout_Setting")); + JPanel layoutSettingPane = getLayoutSettingPane(); + JPanel layoutSettingCheckPane = GUICoreUtils.createCheckboxAndDynamicPane(inheritPageLayoutSettingCheck, layoutSettingPane, true); + + // 页码标签 + UILabel printAreaLabel = new UILabel(Inter.getLocText("FR-Engine-Page_Number") + ":"); + JPanel printAreaLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + printAreaLabelPane.add(printAreaLabel, BorderLayout.NORTH); + printAreaLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); + + // 边距 + inheritPageMarginSettingCheck = GUICoreUtils.createNoBorderCheckBox(Inter.getLocText("FR-Designer_Inherit_Page_Margin_Setting")); + pageMarginSettingPane = new PageMarginSettingPane(); + pageMarginSettingPane.setBorder(BorderFactory.createEmptyBorder(10, -10, 0, 0)); + JPanel pageMarginCheckPane = GUICoreUtils.createCheckboxAndDynamicPane(inheritPageMarginSettingCheck, pageMarginSettingPane, true); + + // 缩放 + fitPaperSizeCheck = GUICoreUtils.createNoBorderCheckBox(Inter.getLocText("FR-Designer_Print_To_Fit_Paper_Size")); + + // TableLayout + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p, p, p, p}; + double[] columnSize = {60, p}; + Component[][] components = { + {new UILabel(Inter.getLocText("FR-Designer_Printer") + ":"), printerPane}, + {new UILabel(Inter.getLocText("FR-Designer_Copy_Number") + ":"), copyPane}, + {printAreaLabelPane, getPrintAreaPane()}, + {getTopAlignLabelPane(Inter.getLocText("FR-Designer_Paper") + ":"), paperSettingCheckPane}, + {getTopAlignLabelPane(Inter.getLocText("FR-Designer_Layout") + ":"), layoutSettingCheckPane}, + {getTopAlignLabelPane(Inter.getLocText("FR-Designer_Margin") + ":"), pageMarginCheckPane} + // 此功能暂时不做,在界面上隐藏缩放选项 +// {new UILabel(Inter.getLocText("FR-Designer_Scale_EnlargeOrReduce") + ":"), fitPaperSizeCheck}, + }; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 15); + } + + private String[] getAllPrinterNames() { + PrintService[] printServices = PrintServiceLookup.lookupPrintServices( + DocFlavor.INPUT_STREAM.AUTOSENSE, null); + Set allPrinterName = new HashSet(); + + for (int i = 0, len = printServices.length; i < len; i++) { + allPrinterName.add(printServices[i].getName()); + } + + return allPrinterName.toArray(new String[allPrinterName.size()]); + } + + private JPanel getPaperSettingPane() { + predefinedPaperSizeComboBox = new UIComboBox(); + for (int i = 0; i < ReportConstants.PaperSizeNameSizeArray.length; i++) { + Object[] tmpPaperSizeNameArray = ReportConstants.PaperSizeNameSizeArray[i]; + predefinedPaperSizeComboBox.addItem(tmpPaperSizeNameArray[1]); + } + predefinedPaperSizeComboBox.setRenderer(new UIComboBoxRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + if (value instanceof PaperSize) { + PaperSize paperSize = (PaperSize) value; + for (int i = 0; i < ReportConstants.PaperSizeNameSizeArray.length; i++) { + Object[] tmpPaperSizeNameArray = ReportConstants.PaperSizeNameSizeArray[i]; + + if (ComparatorUtils.equals(paperSize, tmpPaperSizeNameArray[1])) { + String sbuf = tmpPaperSizeNameArray[0].toString() + " [" + + Utils.convertNumberStringToString(paperSize.getWidth().toMMValue4Scale2()) + + 'x' + + Utils.convertNumberStringToString(paperSize.getHeight().toMMValue4Scale2()) + + ' ' + + Inter.getLocText("PageSetup-mm") + + ']'; + this.setText(sbuf); + break; + } + } + } + + return this; + } + }); + + JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + panel.add(predefinedPaperSizeComboBox); + panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 0, 0)); + return panel; + } + + private JPanel getLayoutSettingPane() { + JPanel layoutSettingPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + layoutSettingPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); + portraitRadioButton = new UIRadioButton(Inter.getLocText("PageSetup-Portrait")); + portraitRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); + landscapeRadioButton = new UIRadioButton(Inter.getLocText("PageSetup-Landscape")); + layoutSettingPane.add(portraitRadioButton); + layoutSettingPane.add(landscapeRadioButton); + + ButtonGroup layoutButtonGroup = new ButtonGroup(); + layoutButtonGroup.add(portraitRadioButton); + layoutButtonGroup.add(landscapeRadioButton); + + portraitRadioButton.setSelected(true); + return layoutSettingPane; + } + + // 页码范围 + private JPanel getPrintAreaPane() { + allPageRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_All_Pages")); + currentPageRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Current_Page")); + customPageRadioButton = new UIRadioButton(Inter.getLocText("FR-Engine_HJS-Specified_Pages")); + ButtonGroup group = new ButtonGroup(); + group.add(allPageRadioButton); + group.add(currentPageRadioButton); + group.add(customPageRadioButton); + allPageRadioButton.setSelected(true); + + specifiedAreaField = new UITextField(20); + UILabel areaFieldTip = GUICoreUtils.createTipLabel(Inter.getLocText("FR-Designer_Print_Area_Tip")); + + // TableLayout + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p}; + double[] columnSize = {p, p, p}; + Component[][] components = { + {allPageRadioButton, null, null}, + {currentPageRadioButton, null, null}, + {customPageRadioButton, specifiedAreaField, areaFieldTip} + }; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 0); + } + + // 返回包含一个标签的 panel,标签始终位于 panel 顶部 + private JPanel getTopAlignLabelPane(String labelText) { + JPanel labelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + labelPane.add(new UILabel(labelText), BorderLayout.NORTH); + return labelPane; + } + + public void populate(NativePrintAttr nativePrintAttr) { + isShowDialogCheck.setSelected(nativePrintAttr.isShowDialog()); + printerComboBox.setSelectedItem(nativePrintAttr.getPrinterName()); + copySpinner.setValue(nativePrintAttr.getCopy()); + + if (nativePrintAttr.getPageType().equals(NativePrintAttr.PageType.ALL_PAGES)) { + allPageRadioButton.setSelected(true); + } else if (nativePrintAttr.getPageType().equals(NativePrintAttr.PageType.CURRENT_PAGE)) { + currentPageRadioButton.setSelected(true); + } else { + customPageRadioButton.setSelected(true); + specifiedAreaField.setText(nativePrintAttr.getArea()); + } + specifiedAreaField.setEnabled(customPageRadioButton.isSelected()); + + inheritPagePaperSettingCheck.setSelected(nativePrintAttr.isInheritPagePaperSetting()); + predefinedPaperSizeComboBox.setSelectedItem(nativePrintAttr.getPaperSize()); + inheritPageLayoutSettingCheck.setSelected(nativePrintAttr.isInheritPageLayoutSetting()); + if (nativePrintAttr.getOrientation() == ReportConstants.PORTRAIT) { + portraitRadioButton.setSelected(true); + } else { + landscapeRadioButton.setSelected(true); + } + inheritPageMarginSettingCheck.setSelected(nativePrintAttr.isInheritPageMarginSetting()); + pageMarginSettingPane.populate(nativePrintAttr.getMargin()); + fitPaperSizeCheck.setSelected(nativePrintAttr.isFitPaperSize()); + } + + public void update(NativePrintAttr nativePrintAttr) { + nativePrintAttr.setShowDialog(isShowDialogCheck.isSelected()); + if (printerComboBox.getSelectedItem() != null) { + nativePrintAttr.setPrinterName(printerComboBox.getSelectedItem().toString()); + } + nativePrintAttr.setCopy((int)copySpinner.getValue()); + + // 页码 + if (allPageRadioButton.isSelected()) { + nativePrintAttr.setPageType(NativePrintAttr.PageType.ALL_PAGES); + } else if (currentPageRadioButton.isSelected()) { + nativePrintAttr.setPageType(NativePrintAttr.PageType.CURRENT_PAGE); + } else { + nativePrintAttr.setPageType(NativePrintAttr.PageType.SPECIFIED_PAGES); + nativePrintAttr.setArea(specifiedAreaField.getText()); + } + + nativePrintAttr.setInheritPagePaperSetting(inheritPagePaperSettingCheck.isSelected()); + nativePrintAttr.setPaperSize((PaperSize) predefinedPaperSizeComboBox.getSelectedItem()); + nativePrintAttr.setInheritPageLayoutSetting(inheritPageLayoutSettingCheck.isSelected()); + nativePrintAttr.setOrientation(portraitRadioButton.isSelected() ? + ReportConstants.PORTRAIT : ReportConstants.LANDSCAPE); + nativePrintAttr.setInheritPageMarginSetting(inheritPageMarginSettingCheck.isSelected()); + nativePrintAttr.setMargin(pageMarginSettingPane.updateBean()); + nativePrintAttr.setFitPaperSize(fitPaperSizeCheck.isSelected()); + } +} diff --git a/designer/src/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java b/designer/src/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java new file mode 100644 index 0000000000..bb40c944e6 --- /dev/null +++ b/designer/src/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java @@ -0,0 +1,86 @@ +package com.fr.design.webattr.printsettings; + +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; +import com.fr.base.print.NoClientPrintAttr; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; + +/** + * 零客户端打印设置面板 + * Created by plough on 2018/3/5. + */ +public class NoClientPrintSettingPane extends JPanel { + private UICheckBox setMarginWhenPrintCheck; + private UICheckBox inheritPageMarginSettingCheck; // 继承页面边距设置 + + private PageMarginSettingPane pageMarginSettingPane; + + public NoClientPrintSettingPane() { + initComponents(); + } + + private void initComponents() { + JPanel printPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + + setMarginWhenPrintCheck = new UICheckBox(Inter.getLocText("FR-Engine_Set_Margin_When_Printing")); + setMarginWhenPrintCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); + UILabel tipLabel = GUICoreUtils.createTipLabel(Inter.getLocText("FR-Designer_Tip_Use_Default_Print_Margin")); + JPanel northPane = GUICoreUtils.createFlowPane(new Component[] { + setMarginWhenPrintCheck, tipLabel}, FlowLayout.LEFT); + northPane.setBorder(BorderFactory.createEmptyBorder(8, 10, 10, 0)); + + printPane.add(northPane, BorderLayout.NORTH); + + JPanel centerPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Default_Settings")); + + inheritPageMarginSettingCheck = GUICoreUtils.createNoBorderCheckBox(Inter.getLocText("FR-Designer_Inherit_Page_Margin_Setting")); + pageMarginSettingPane = new PageMarginSettingPane(); + pageMarginSettingPane.setBorder(BorderFactory.createEmptyBorder(10, -10, 0, 0)); + JPanel pageMarginCheckPane = GUICoreUtils.createCheckboxAndDynamicPane(inheritPageMarginSettingCheck, pageMarginSettingPane, true); + + // TableLayout + double p = TableLayout.PREFERRED; + double[] rowSize = {p}; + double[] columnSize = {60, p}; + Component[][] components = { + {getTopAlignLabelPane(Inter.getLocText("FR-Designer_Margin") + ":"), pageMarginCheckPane} + }; + JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 15); + + centerPane.add(panel); + + printPane.add(centerPane, BorderLayout.CENTER); + + this.setLayout(new BorderLayout()); + this.add(printPane, BorderLayout.CENTER); + } + + // 返回包含一个标签的 panel,标签始终位于 panel 顶部 + private JPanel getTopAlignLabelPane(String labelText) { + JPanel labelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + labelPane.add(new UILabel(labelText), BorderLayout.NORTH); + return labelPane; + } + + public void populate(NoClientPrintAttr noClientPrintAttr) { + setMarginWhenPrintCheck.setSelected(noClientPrintAttr.isSetMarginOnPrint()); + inheritPageMarginSettingCheck.setSelected(noClientPrintAttr.isInheritPageMarginSetting()); + pageMarginSettingPane.populate(noClientPrintAttr.getMargin()); + } + + public void update(NoClientPrintAttr noClientPrintAttr) { + noClientPrintAttr.setSetMarginOnPrint(setMarginWhenPrintCheck.isSelected()); + noClientPrintAttr.setInheritPageMarginSetting(inheritPageMarginSettingCheck.isSelected()); + noClientPrintAttr.setMargin(pageMarginSettingPane.updateBean()); + } +} diff --git a/designer/src/com/fr/design/webattr/printsettings/PageMarginSettingPane.java b/designer/src/com/fr/design/webattr/printsettings/PageMarginSettingPane.java new file mode 100644 index 0000000000..8c63fa5207 --- /dev/null +++ b/designer/src/com/fr/design/webattr/printsettings/PageMarginSettingPane.java @@ -0,0 +1,79 @@ +package com.fr.design.webattr.printsettings; + +import com.fr.base.Margin; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.report.UnitFieldPane; +import com.fr.general.Inter; +import com.fr.stable.Constants; + +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * Created by plough on 2018/3/5. + */ +public class PageMarginSettingPane extends JPanel { + private UnitFieldPane marginTopUnitFieldPane; + private UnitFieldPane marginBottomUnitFieldPane; + private UnitFieldPane marginLeftUnitFieldPane; + private UnitFieldPane marginRightUnitFieldPane; + + public PageMarginSettingPane() { + initComponents(); + } + private void initComponents() { + // 页边距设置面板 + JPanel marginPane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_M_Pane(); + // left + JPanel marginLeftPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); + marginPane.add(marginLeftPane); + + JPanel marginLeftTextPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + marginLeftPane.add(marginLeftTextPane); + marginLeftTextPane.add(new UILabel(Inter.getLocText("Top") + ":")); + marginTopUnitFieldPane = new UnitFieldPane(Constants.UNIT_MM); + marginLeftTextPane.add(marginTopUnitFieldPane); + JPanel marginLeftUnitPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + marginLeftPane.add(marginLeftUnitPane); + marginLeftUnitPane.add(new UILabel(Inter.getLocText("Bottom") + ":")); + marginBottomUnitFieldPane = new UnitFieldPane(Constants.UNIT_MM); + marginLeftUnitPane.add(marginBottomUnitFieldPane); + + // right + JPanel marginRightPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); + marginPane.add(marginRightPane); + + // peter:这个一个垂直的上下的字符panel. + JPanel marginRightTextPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + marginRightPane.add(marginRightTextPane); + marginRightTextPane.add(new UILabel(Inter.getLocText("Left") + ":")); + marginLeftUnitFieldPane = new UnitFieldPane(Constants.UNIT_MM); + marginRightTextPane.add(marginLeftUnitFieldPane); + + JPanel marginRightUnitPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + marginRightPane.add(marginRightUnitPane); + marginRightUnitPane.add(new UILabel(Inter.getLocText("Right") + ":")); + marginRightUnitFieldPane = new UnitFieldPane(Constants.UNIT_MM); + marginRightUnitPane.add(marginRightUnitFieldPane); + + this.setLayout(new BorderLayout()); + this.add(marginPane, BorderLayout.CENTER); + } + + public void populate(Margin margin) { + marginTopUnitFieldPane.setUnitValue(margin.getTop()); + marginLeftUnitFieldPane.setUnitValue(margin.getLeft()); + marginBottomUnitFieldPane.setUnitValue(margin.getBottom()); + marginRightUnitFieldPane.setUnitValue(margin.getRight()); + } + + public Margin updateBean() { + Margin margin = new Margin(); + margin.setTop(marginTopUnitFieldPane.getUnitValue()); + margin.setLeft(marginLeftUnitFieldPane.getUnitValue()); + margin.setBottom(marginBottomUnitFieldPane.getUnitValue()); + margin.setRight(marginRightUnitFieldPane.getUnitValue()); + return margin; + } +} diff --git a/designer/src/com/fr/design/webattr/printsettings/PrintSettingPane.java b/designer/src/com/fr/design/webattr/printsettings/PrintSettingPane.java new file mode 100644 index 0000000000..67119b2bb8 --- /dev/null +++ b/designer/src/com/fr/design/webattr/printsettings/PrintSettingPane.java @@ -0,0 +1,111 @@ +package com.fr.design.webattr.printsettings; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; +import com.fr.base.print.PrintSettingsAttrMark; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +/** + * Created by plough on 2018/3/1. + */ +public class PrintSettingPane extends BasicPane { + private UIRadioButton noClientPrintRadioButton = new UIRadioButton(Inter.getLocText("FR-Engine_No_Client_Print")); + private UIRadioButton nativePrintRadioButton = new UIRadioButton(Inter.getLocText("FR-Engine_Native_Print")); + + private NoClientPrintSettingPane noClientPrintSettingPane; + private NativePrintSettingPane nativePrintSettingPane; + private CardLayout printCard; + private JPanel printPane; + + public PrintSettingPane() { + initComponents(); + initListener(); + } + + private void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel allPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + this.add(allPanel, BorderLayout.CENTER); + JPanel north = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); + allPanel.add(north, BorderLayout.NORTH); + ButtonGroup buttonGroup = new ButtonGroup(); + noClientPrintRadioButton.setSelected(true); + buttonGroup.add(noClientPrintRadioButton); + buttonGroup.add(nativePrintRadioButton); + noClientPrintRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 50)); + JPanel radioGroupPane = GUICoreUtils.createFlowPane(new Component[] { + noClientPrintRadioButton, nativePrintRadioButton}, FlowLayout.LEFT, 0, 0); + 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); + + north.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + allPanel.add(printPane, BorderLayout.CENTER); + } + + private void initListener() { + noClientPrintRadioButton.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + printCard.show(printPane, noClientPrintRadioButton.getText()); + } + } + }); + nativePrintRadioButton.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + printCard.show(printPane, nativePrintRadioButton.getText()); + } + } + }); + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("FR-Designer_Print_Setting"); + } + + public void populate(PrintSettingsAttrMark printSettings) { + if (printSettings.getPrintType() == PrintSettingsAttrMark.NO_CLIENT_PRINT) { + noClientPrintRadioButton.setSelected(true); + } else { + nativePrintRadioButton.setSelected(true); + } + noClientPrintSettingPane.populate(printSettings.getNoClientPrintAttr()); + nativePrintSettingPane.populate(printSettings.getNativePrintAttr()); + } + + public PrintSettingsAttrMark updateBean() { + PrintSettingsAttrMark printSettings = new PrintSettingsAttrMark(); + printSettings.setPrintType(noClientPrintRadioButton.isSelected() ? + PrintSettingsAttrMark.NO_CLIENT_PRINT : PrintSettingsAttrMark.NATIVE_PRINT); + if (noClientPrintRadioButton.isSelected()) { + printSettings.setPrintType(PrintSettingsAttrMark.NO_CLIENT_PRINT); + noClientPrintSettingPane.update(printSettings.getNoClientPrintAttr()); + } else { + printSettings.setPrintType(PrintSettingsAttrMark.NATIVE_PRINT); + nativePrintSettingPane.update(printSettings.getNativePrintAttr()); + } + return printSettings; + } +} diff --git a/designer/src/com/fr/design/webattr/printsettings/ReportPrintSettingPane.java b/designer/src/com/fr/design/webattr/printsettings/ReportPrintSettingPane.java new file mode 100644 index 0000000000..a96621de56 --- /dev/null +++ b/designer/src/com/fr/design/webattr/printsettings/ReportPrintSettingPane.java @@ -0,0 +1,97 @@ +package com.fr.design.webattr.printsettings; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; +import com.fr.base.print.PrintSettingsAttrMark; +import com.fr.report.core.ReportUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +/** + * 模版->打印设置 + * Created by plough on 2018/3/6. + */ +public class ReportPrintSettingPane extends BasicPane { + private static final String[] CHOOSEITEM = new String[] { + Inter.getLocText("FR-Designer_I_Want_To_Set_Single"), + Inter.getLocText("FR-Designer_Using_Server_Report_View_Settings") + }; + private static final int SINGLE_SET = 0; + private static final int SERVER_SET = 1; + + private UIComboBox chooseComboBox; + private PrintSettingPane printSettingPane; + + public ReportPrintSettingPane() { + initComponents(); + } + + private void initComponents() { + chooseComboBox = new UIComboBox(CHOOSEITEM); + chooseComboBox.addItemListener(itemListener); + UILabel belowSetLabel = new UILabel(Inter.getLocText("FR-Designer_Blow_set") + ":"); + JPanel buttonPane = GUICoreUtils.createFlowPane(new Component[] { + belowSetLabel, chooseComboBox}, FlowLayout.LEFT, 0, 0); + buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 20, 0, 0)); + + printSettingPane = new PrintSettingPane(); + this.setLayout(new BorderLayout()); + this.add(buttonPane, BorderLayout.NORTH); + this.add(printSettingPane, BorderLayout.CENTER); + } + + private ItemListener itemListener = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + if (chooseComboBox.getSelectedIndex() == 0) { + checkEnabled(true); + } else { + populateServerSettings(); + checkEnabled(false); + } + } + } + }; + + private void checkEnabled(boolean isSelected) { + GUICoreUtils.setEnabled(printSettingPane, isSelected); + } + + private void populateServerSettings() { + PrintSettingsAttrMark printSettings = ReportUtils.getPrintSettingsFromServerConfig(); + printSettingPane.populate(printSettings); + } + + public void populate(PrintSettingsAttrMark printSettings) { + if (!printSettings.isValid()) { // 采用服务器配置 + chooseComboBox.setSelectedIndex(SERVER_SET); + populateServerSettings(); + return; + } + chooseComboBox.setSelectedIndex(SINGLE_SET); + printSettingPane.populate(printSettings); + } + + public PrintSettingsAttrMark updateBean() { + PrintSettingsAttrMark printSettings = printSettingPane.updateBean(); + if (chooseComboBox.getSelectedIndex() == SERVER_SET) { + printSettings.setValid(false); + } + return printSettings; + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("FR-Designer_Print_Setting"); + } +} diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index be8c7c962f..72e6c9ae1e 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -35,6 +35,7 @@ import com.fr.report.cell.cellattr.CellExpandAttr; import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.cell.cellattr.core.group.FilterTypeEnum; import com.fr.report.cell.cellattr.core.group.SelectCount; +import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -74,9 +75,6 @@ public class CellDSColumnEditor extends CellQuickEditor { private static final Color TIP_FONT_COLOR = new Color(0x7F333334, true); - private JPanel dsColumnRegion; - private JPanel centerPane; - /** * 基本和高级设置 */ @@ -117,10 +115,10 @@ public class CellDSColumnEditor extends CellQuickEditor { public JComponent createCenterBody() { this.createPanes(); this.createSwitchTab(); - dsColumnRegion = new JPanel(new BorderLayout()); + JPanel dsColumnRegion = new JPanel(new BorderLayout()); dsColumnRegion.add(tabsHeaderIconPane, BorderLayout.NORTH); dsColumnRegion.add(cardContainer, BorderLayout.CENTER); - centerPane = new JPanel(new BorderLayout()); + JPanel centerPane = new JPanel(new BorderLayout()); centerPane.add(dsColumnRegion, BorderLayout.CENTER); return centerPane; } @@ -331,6 +329,7 @@ public class CellDSColumnEditor extends CellQuickEditor { class DSColumnAdvancedEditorPane extends AbstractDSCellEditorPane { + /*pane begin*/ /** * 排列顺序 */ @@ -354,7 +353,7 @@ public class CellDSColumnEditor extends CellQuickEditor { /** * 补充空白数据 */ - private UICheckBox useMultiplyNumCheckBox; + private UICheckBox useMultiNumCheckBox; /** * 补充空白数据数目输入框 */ @@ -363,6 +362,75 @@ public class CellDSColumnEditor extends CellQuickEditor { * 补充空白数据数目面板 可隐藏 */ private JPanel multiPane; + /*pane end*/ + + + /*listeners begin*/ + private UIObserverListener sortPaneFormulaChangeListener = new UIObserverListener() { + @Override + public void doChange() { + sortPane.update(cellElement); + fireTargetModified(); + } + }; + + private ChangeListener sortTypeBtnGroupChangeListener = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + sortPane.update(cellElement); + fireTargetModified(); + } + }; + + private UIObserverListener filterPaneChangeListener = new UIObserverListener() { + @Override + public void doChange() { + filterPane.update(cellElement); + fireTargetModified(); + } + }; + + private UIObserverListener customValuePaneChangeListener = new UIObserverListener() { + @Override + public void doChange() { + valuePane.update(cellElement); + fireTargetModified(); + } + }; + + private ChangeListener heCheckBoxChangeListener = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + cellDSColumnAdvancedPane.updateExtendConfig(); + fireTargetModified(); + } + }; + + private ChangeListener veCheckBoxChangeListener = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + cellDSColumnAdvancedPane.updateExtendConfig(); + fireTargetModified(); + } + }; + + private ActionListener useMultiNumCheckBoxChangeListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkButtonEnabled(); + cellDSColumnAdvancedPane.updateMultipleConfig(); + fireTargetModified(); + } + }; + + private ChangeListener multiNumSpinnerChangeListener = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + cellDSColumnAdvancedPane.updateMultipleConfig(); + fireTargetModified(); + } + }; + /*listeners end*/ public DSColumnAdvancedEditorPane() { @@ -398,6 +466,7 @@ public class CellDSColumnEditor extends CellQuickEditor { @Override public void populate() { if (cellElement != null) { + disableListener(); sortPane.populate(cellElement); valuePane.populate(cellElement); filterPane.populate(cellElement); @@ -407,6 +476,7 @@ public class CellDSColumnEditor extends CellQuickEditor { cellElement.setCellExpandAttr(cellExpandAttr); } // extendable + //noinspection Duplicates switch (cellExpandAttr.getExtendable()) { case CellExpandAttr.Both_EXTENDABLE: heCheckBox.setSelected(true); @@ -426,12 +496,15 @@ public class CellDSColumnEditor extends CellQuickEditor { } } if (cellExpandAttr.getMultipleNumber() == -1) { - useMultiplyNumCheckBox.setSelected(false); + useMultiNumCheckBox.setSelected(false); + // 默认值 + multiNumSpinner.setValue(1); } else { - useMultiplyNumCheckBox.setSelected(true); + useMultiNumCheckBox.setSelected(true); multiNumSpinner.setValue(cellExpandAttr.getMultipleNumber()); } this.checkButtonEnabled(); + enableListener(); } } @@ -449,6 +522,7 @@ public class CellDSColumnEditor extends CellQuickEditor { cellExpandAttr = new CellExpandAttr(); cellElement.setCellExpandAttr(cellExpandAttr); } + //noinspection Duplicates if (heCheckBox.isSelected()) { if (veCheckBox.isSelected()) { cellExpandAttr.setExtendable(CellExpandAttr.Both_EXTENDABLE); @@ -469,12 +543,11 @@ public class CellDSColumnEditor extends CellQuickEditor { */ private void updateMultipleConfig() { CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); - if (this.useMultiplyNumCheckBox.isSelected()) { + if (this.useMultiNumCheckBox.isSelected()) { cellExpandAttr.setMultipleNumber((int) multiNumSpinner.getValue()); } else { cellExpandAttr.setMultipleNumber(-1); } - } /** @@ -485,68 +558,29 @@ public class CellDSColumnEditor extends CellQuickEditor { @Override protected JPanel createContentPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); + //结果集排序 sortPane = new ResultSetSortConfigPane(); - sortPane.addListener(new UIObserverListener() { - @Override - public void doChange() { - sortPane.update(cellElement); - fireTargetModified(); - } - }, new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - sortPane.update(cellElement); - fireTargetModified(); - } - } - ); + //结果筛选 filterPane = new ResultSetFilterConfigPane(); - filterPane.addListener(new UIObserverListener() { - @Override - public void doChange() { - filterPane.update(cellElement); - fireTargetModified(); - } - } - ); + //自定义值显示 valuePane = new CustomValuePane(); - valuePane.addListener(new UIObserverListener() { - @Override - public void doChange() { - valuePane.update(cellElement); - fireTargetModified(); - } - }); //可扩展性 JPanel extendableDirectionPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); extendableDirectionPane.add(heCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Horizontal_Extendable"))); extendableDirectionPane.add(veCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Vertical_Extendable"))); - heCheckBox.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - cellDSColumnAdvancedPane.updateExtendConfig(); - fireTargetModified(); - } - }); - veCheckBox.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - cellDSColumnAdvancedPane.updateExtendConfig(); - fireTargetModified(); - } - }); - JPanel multiNumPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); //补充空白数据 - useMultiplyNumCheckBox = new UICheckBox(Inter.getLocText("Fill_blank_Data")); + JPanel multiNumPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); + useMultiNumCheckBox = new UICheckBox(Inter.getLocText("Fill_blank_Data")); JPanel checkBoxPane = new JPanel(new BorderLayout()); - checkBoxPane.add(useMultiplyNumCheckBox, BorderLayout.WEST); + checkBoxPane.add(useMultiNumCheckBox, BorderLayout.WEST); multiNumPane.add(checkBoxPane); multiNumSpinner = new UISpinner(1, 10000, 1, 1); + //数据倍数 UILabel multipleLabel = new UILabel(Inter.getLocText("Column_Multiple")); multiPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ @@ -557,25 +591,11 @@ public class CellDSColumnEditor extends CellQuickEditor { ); multiPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); multiNumPane.add(multiPane); - useMultiplyNumCheckBox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkButtonEnabled(); - cellDSColumnAdvancedPane.updateMultipleConfig(); - fireTargetModified(); - } - }); - multiNumSpinner.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - cellDSColumnAdvancedPane.updateMultipleConfig(); - fireTargetModified(); - } - }); + + enableListener(); double[] rowSize = {P, P, P, P, P, P}; double[] columnSize = {F}; - Component[][] components = new Component[][]{ {sortPane}, {filterPane}, @@ -586,9 +606,29 @@ public class CellDSColumnEditor extends CellQuickEditor { return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); } + public void enableListener() { + sortPane.addListener(sortPaneFormulaChangeListener, sortTypeBtnGroupChangeListener); + filterPane.addListener(filterPaneChangeListener); + valuePane.addListener(customValuePaneChangeListener); + heCheckBox.addChangeListener(heCheckBoxChangeListener); + veCheckBox.addChangeListener(veCheckBoxChangeListener); + useMultiNumCheckBox.addActionListener(useMultiNumCheckBoxChangeListener); + multiNumSpinner.addChangeListener(multiNumSpinnerChangeListener); + } + + public void disableListener() { + sortPane.removeListener(sortTypeBtnGroupChangeListener); + filterPane.removeListener(); + valuePane.removeListener(); + heCheckBox.removeChangeListener(heCheckBoxChangeListener); + veCheckBox.removeChangeListener(veCheckBoxChangeListener); + useMultiNumCheckBox.removeActionListener(useMultiNumCheckBoxChangeListener); + multiNumSpinner.removeChangeListener(multiNumSpinnerChangeListener); + } + private void checkButtonEnabled() { - if (useMultiplyNumCheckBox.isSelected()) { + if (useMultiNumCheckBox.isSelected()) { multiNumSpinner.setEnabled(true); multiPane.setVisible(true); } else { @@ -665,7 +705,7 @@ public class CellDSColumnEditor extends CellQuickEditor { public void populate(TemplateCellElement cellElement) { if (cellElement != null) { Object value = cellElement.getValue(); - if (value != null && value instanceof DSColumn) { + if (value instanceof DSColumn) { this.formulaField.populateElement(cellElement); DSColumn dSColumn = (DSColumn) value; int sort = dSColumn.getOrder(); @@ -682,6 +722,8 @@ public class CellDSColumnEditor extends CellQuickEditor { String sortFormula = dSColumn.getSortFormula(); if (sortFormula != null && sortFormula.length() >= 1) { this.formulaField.populate(sortFormula); + } else { + this.formulaField.populate(DEFAULT_VALUE); } } } @@ -695,8 +737,8 @@ public class CellDSColumnEditor extends CellQuickEditor { public void update(CellElement cellElement) { if (cellElement != null) { Object value = cellElement.getValue(); - if (value != null && value instanceof DSColumn) { - DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + if (value instanceof DSColumn) { + DSColumn dSColumn = (DSColumn) value; dSColumn.setOrder(this.sortTypePane.getSelectedIndex()); dSColumn.setSortFormula(this.formulaField.getFormulaText()); } @@ -713,6 +755,16 @@ public class CellDSColumnEditor extends CellQuickEditor { formulaField.addListener(formulaChangeListener); sortTypePane.addChangeListener(changeListener); } + + /** + * 去除事件监听器 + * + * @param changeListener 排序类型下拉框改动事件监听器 + */ + public void removeListener(ChangeListener changeListener) { + formulaField.removeListener(); + sortTypePane.removeChangeListener(changeListener); + } } /** @@ -858,13 +910,18 @@ public class CellDSColumnEditor extends CellQuickEditor { rsComboBox.removeActionListener(actionListener); if (cellElement != null) { Object value = cellElement.getValue(); - if (value != null && value instanceof DSColumn) { + if (value instanceof DSColumn) { DSColumn dSColumn = (DSColumn) (cellElement.getValue()); SelectCount selectCount = dSColumn.getSelectCount(); this.topFormulaPane.populateElement(cellElement); this.bottomFormulaPane.populateElement(cellElement); CardLayout setCardPaneLayout = (CardLayout) setCardPane.getLayout(); CardLayout tipCardPaneLayout = (CardLayout) tipCardPane.getLayout(); + // 重置默认值 + this.topFormulaPane.populate(DEFAULT_VALUE); + this.bottomFormulaPane.populate(DEFAULT_VALUE); + this.serialTextField.setText(StringUtils.EMPTY); + if (selectCount != null) { int selectCountType = selectCount.getType(); this.rsComboBox.setSelectedIndex(selectCountType); @@ -933,6 +990,7 @@ public class CellDSColumnEditor extends CellQuickEditor { TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); } } else { + this.rsComboBox.setSelectedIndex(0); //未定义 setCardPaneLayout.show(setCardPane, UNDEFINE.name()); tipCardPaneLayout.show(tipCardPane, UNDEFINE.name()); @@ -950,8 +1008,8 @@ public class CellDSColumnEditor extends CellQuickEditor { public void update(CellElement cellElement) { if (cellElement != null) { Object value = cellElement.getValue(); - if (value != null && value instanceof DSColumn) { - DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + if (value instanceof DSColumn) { + DSColumn dSColumn = (DSColumn) value; int selectedFilterIndex = this.rsComboBox.getSelectedIndex(); if (selectedFilterIndex == 0) { dSColumn.setSelectCount(null); @@ -959,6 +1017,7 @@ public class CellDSColumnEditor extends CellQuickEditor { SelectCount selectCount = new SelectCount(); selectCount.setType(selectedFilterIndex); dSColumn.setSelectCount(selectCount); + //noinspection Duplicates if (selectedFilterIndex == TOP.getValue()) { selectCount.setFormulaCount(this.topFormulaPane.getFormulaText()); } else if (selectedFilterIndex == BOTTOM.getValue()) { @@ -982,6 +1041,16 @@ public class CellDSColumnEditor extends CellQuickEditor { rsComboBox.registerChangeListener(formulaListener); serialTextField.registerChangeListener(formulaListener); } + + /** + * 去除事件监听器 + */ + public void removeListener() { + topFormulaPane.removeListener(); + bottomFormulaPane.removeListener(); + rsComboBox.removeChangeListener(); + serialTextField.registerChangeListener(null); + } } /** @@ -1035,6 +1104,13 @@ public class CellDSColumnEditor extends CellQuickEditor { this.formulaTextField.registerChangeListener(listener); } + /** + * 取消事件监听器 + */ + public void removeListener() { + this.formulaTextField.registerChangeListener(null); + } + private ActionListener formulaButtonActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { @@ -1048,7 +1124,7 @@ public class CellDSColumnEditor extends CellQuickEditor { final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); if (cellElement != null) { Object value = cellElement.getValue(); - if (value != null && value instanceof DSColumn) { + if (value instanceof DSColumn) { DSColumn dsColumn = (DSColumn) value; String[] displayNames = DesignTableDataManager.getSelectedColumnNames(DesignTableDataManager.getEditingTableDataSource(), dsColumn.getDSName()); formulaPane.populate(valueFormula, new CustomVariableResolver(displayNames, true)); @@ -1092,12 +1168,14 @@ public class CellDSColumnEditor extends CellQuickEditor { public void populate(CellElement cellElement) { if (cellElement != null) { Object value = cellElement.getValue(); - if (value != null && value instanceof DSColumn) { + if (value instanceof DSColumn) { DSColumn dSColumn = (DSColumn) value; //formula String valueFormula = dSColumn.getResult(); if (valueFormula != null) { formulaField.populate(valueFormula); + } else { + formulaField.populate(DEFAULT_VALUE); } formulaField.populateElement(cellElement); @@ -1108,7 +1186,7 @@ public class CellDSColumnEditor extends CellQuickEditor { public void update(CellElement cellElement) { if (cellElement != null) { Object value = cellElement.getValue(); - if (value != null && value instanceof DSColumn) { + if (value instanceof DSColumn) { DSColumn dSColumn = (DSColumn) (cellElement.getValue()); dSColumn.setResult(this.formulaField.getFormulaText()); } @@ -1123,6 +1201,13 @@ public class CellDSColumnEditor extends CellQuickEditor { public void addListener(UIObserverListener formulaListener) { this.formulaField.addListener(formulaListener); } + + /** + * 移除事件监听器 + */ + public void removeListener() { + this.formulaField.removeListener(); + } } } diff --git a/designer/src/com/fr/start/ReportSplashPane.java b/designer/src/com/fr/start/ReportSplashPane.java index 4ec15fc893..82cf18c78b 100644 --- a/designer/src/com/fr/start/ReportSplashPane.java +++ b/designer/src/com/fr/start/ReportSplashPane.java @@ -15,8 +15,13 @@ import com.fr.stable.StringUtils; import com.fr.stable.module.ModuleAdapter; import com.fr.stable.module.ModuleListener; -import javax.swing.*; -import java.awt.*; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; import java.util.Locale; import java.util.Random; import java.util.TimerTask; @@ -68,6 +73,7 @@ public class ReportSplashPane extends SplashPane { this.setBackground(null); timer.schedule(new TimerTask() { + @Override public void run() { loadingIndex++; ReportSplashPane.this.setShowText(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]); @@ -87,6 +93,7 @@ public class ReportSplashPane extends SplashPane { ModuleContext.registerModuleListener(moduleListener); } + @Override protected void paintComponent(Graphics g) { Icon icon = IconLoader.getIcon(StableUtils.pathJoin(OEM_PATH, getImageName())); icon.paintIcon(null, g, 0, 0); @@ -94,16 +101,18 @@ public class ReportSplashPane extends SplashPane { g.dispose(); } + @Override public void setShowText(String text) { this.showText = text; } + @Override public Image getSplashImage() { Icon icon = IconLoader.getIcon(StableUtils.pathJoin(OEM_PATH, getImageName())); return ((ImageIcon) IconLoader.getIconSnapshot(icon)).getImage(); } - private void paintShowText(Graphics2D splashG2d) { + protected void paintShowText(Graphics2D splashG2d) { GraphHelper.applyRenderingHints(splashG2d); splashG2d.setPaint(MODULE_COLOR); @@ -160,6 +169,7 @@ public class ReportSplashPane extends SplashPane { /** * 窗口关闭后取消定时获取模块信息的timer */ + @Override public void releaseTimer() { timer.cancel(); } @@ -169,6 +179,7 @@ public class ReportSplashPane extends SplashPane { * * @return 背景图片 */ + @Override public Image createSplashBackground() { String fileName = getImageName(); return BaseUtils.readImage(StableUtils.pathJoin(OEM_PATH, fileName)); diff --git a/designer_base/src/com/fr/design/DesignerEnvManager.java b/designer_base/src/com/fr/design/DesignerEnvManager.java index 1eedded95c..7d55086045 100644 --- a/designer_base/src/com/fr/design/DesignerEnvManager.java +++ b/designer_base/src/com/fr/design/DesignerEnvManager.java @@ -148,6 +148,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private boolean isHttps = false; private static List mapWorkerList = new ArrayList(); + private boolean imageCompress = true;//图片压缩 /** * DesignerEnvManager. @@ -1414,6 +1415,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.setOracleSystemSpace(reader.getAttrAsBoolean("useOracleSystemSpace", true)); this.setCachingTemplateLimit(reader.getAttrAsInt("cachingTemplateLimit", CACHINGTEMPLATE_LIMIT)); this.setJoinProductImprove(reader.getAttrAsBoolean("joinProductImprove", true)); + this.setImageCompress(reader.getAttrAsBoolean("imageCompress", true)); this.setAutoBackUp(reader.getAttrAsBoolean("autoBackUp", true)); this.setTemplateTreePaneExpanded(reader.getAttrAsBoolean("templateTreePaneExpanded", false)); // peter:读取webinfLocation @@ -1639,6 +1641,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (!this.isJoinProductImprove()) { writer.attr("joinProductImprove", this.isJoinProductImprove()); } + if (!this.isImageCompress()) { + writer.attr("imageCompress", this.isImageCompress()); + } if (!this.isAutoBackUp()) { writer.attr("autoBackUp", this.isAutoBackUp()); } @@ -1812,4 +1817,12 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { public void setAlphaFineConfigManager(AlphaFineConfigManager alphaFineConfigManager) { this.alphaFineConfigManager = alphaFineConfigManager; } + + public boolean isImageCompress() { + return imageCompress; + } + + public void setImageCompress(boolean imageCompress) { + this.imageCompress = imageCompress; + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/editor/editor/ColumnRowEditor.java b/designer_base/src/com/fr/design/editor/editor/ColumnRowEditor.java index 7c90d3d9a4..2da3bc3108 100644 --- a/designer_base/src/com/fr/design/editor/editor/ColumnRowEditor.java +++ b/designer_base/src/com/fr/design/editor/editor/ColumnRowEditor.java @@ -1,74 +1,81 @@ -package com.fr.design.editor.editor; - -import com.fr.design.gui.columnrow.ColumnRowPane; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.stable.ColumnRow; - -import java.awt.*; - -/** - * the editor to edit ColumnRow - * - * @editor zhou - * @since 2012-3-29下午6:01:37 - */ -public class ColumnRowEditor extends Editor { - - private ColumnRowPane crPane; - - public ColumnRowEditor() { - this(""); - } - - public ColumnRowEditor(String name) { - this(null, name); - } - - - public ColumnRowEditor(ColumnRow value) { - this(value, ""); - } - - public ColumnRowEditor(ColumnRow value, String name) { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - crPane = new ColumnRowPane(); - this.add(crPane, BorderLayout.CENTER); - this.setValue(value); - this.setName(name); - } - - @Override - public ColumnRow getValue() { - return this.crPane.update(); - } - - @Override - public void setValue(ColumnRow value) { - if (value == null) { - value = ColumnRow.valueOf(0, 0); - } - - this.crPane.populate(value); - } - - @Override - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - - this.crPane.setEnabled(enabled); - } - - @Override - public void requestFocus() { - this.crPane.requestFocus(); - } - - public String getIconName() { - return "cell"; - } - - @Override - public boolean accept(Object object) { - return object instanceof ColumnRow; - } +package com.fr.design.editor.editor; + +import com.fr.design.gui.columnrow.ColumnRowPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.stable.ColumnRow; + +import java.awt.BorderLayout; + +/** + * the editor to edit ColumnRow + * + * @author zhou + * @since 2012-3-29下午6:01:37 + */ +public class ColumnRowEditor extends Editor { + + private ColumnRowPane crPane; + + public ColumnRowEditor() { + this(""); + } + + public ColumnRowEditor(String name) { + this(null, name); + } + + + public ColumnRowEditor(ColumnRow value) { + this(value, ""); + } + + public ColumnRowEditor(ColumnRow value, String name) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + crPane = new ColumnRowPane(); + this.add(crPane, BorderLayout.CENTER); + this.setValue(value); + this.setName(name); + } + + @Override + public ColumnRow getValue() { + return this.crPane.update(); + } + + @Override + public void setValue(ColumnRow value) { + if (value == null) { + value = ColumnRow.valueOf(0, 0); + } + + this.crPane.populate(value); + } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + + this.crPane.setEnabled(enabled); + } + + @Override + public void requestFocus() { + this.crPane.requestFocus(); + } + + @Override + public String getIconName() { + return "cell"; + } + + @Override + public boolean accept(Object object) { + return object instanceof ColumnRow; + } + + @Override + public void clearData() { + super.clearData(); + this.setValue(null); + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/editor/editor/TextEditor.java b/designer_base/src/com/fr/design/editor/editor/TextEditor.java index e997f23ec1..630f6956a8 100644 --- a/designer_base/src/com/fr/design/editor/editor/TextEditor.java +++ b/designer_base/src/com/fr/design/editor/editor/TextEditor.java @@ -1,153 +1,169 @@ -/* - * Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. - */ -package com.fr.design.editor.editor; - -import java.awt.BorderLayout; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; - -import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.general.Inter; -import com.fr.stable.StringUtils; - -/** - * CellEditor used to edit String object. - * - * @editor zhou - * @since 2012-3-29下午6:00:43 - */ -public class TextEditor extends Editor { - - private UITextField textField; // text field. - // the old value of text field. - private String oldValue = StringUtils.EMPTY; - - /** - * Constructor. - */ - public TextEditor() { - this(null); - } - - public TextEditor(String value) { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - textField = new UITextField(); - textField.setBorder(null); - this.add(textField, BorderLayout.CENTER); - this.textField.addKeyListener(textKeyListener); - - this.setValue(value); - this.setName(Inter.getLocText("Parameter-String")); - } - - public UITextField getTextField() { - return this.textField; - } - - /** - * Returns the horizontal alignment of the CellEditor. Valid keys are: - *
    - *
  • UITextField.LEFT - *
  • UITextField.CENTER - *
  • UITextField.RIGHT - *
  • UITextField.LEADING - *
  • UITextField.TRAILING - *
- */ - public int getHorizontalAlignment() { - return this.textField.getHorizontalAlignment(); - } - - /** - * Sets the horizontal alignment of the CellEditor. Valid keys are: - *
    - *
  • UITextField.LEFT - *
  • UITextField.CENTER - *
  • UITextField.RIGHT - *
  • UITextField.LEADING - *
  • UITextField.TRAILING - *
- */ - public void setHorizontalAlignment(int horizontalAlignment) { - this.textField.setHorizontalAlignment(horizontalAlignment); - } - - /** - * Return the value of the CellEditor. - */ - @Override - public String getValue() { - return this.textField.getText(); - } - - /** - * Set the value to the CellEditor. - */ - @Override - public void setValue(String value) { - // populate data to UI - if (value == null) { - value = StringUtils.EMPTY; - } - - oldValue = value.toString(); - this.textField.setText(oldValue); - } - - /** - * Sets whether or not this component is enabled. - */ - @Override - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - this.textField.setEnabled(enabled); - } - - - /** - * 请求焦点 - */ - public void requestFocus() { - this.textField.requestFocus(); - } - - KeyListener textKeyListener = new KeyAdapter() { - - @Override - public void keyReleased(KeyEvent evt) { - int code = evt.getKeyCode(); - if (code == KeyEvent.VK_ESCAPE) { - textField.setText(oldValue); - } - if (code == KeyEvent.VK_ENTER) { - fireEditingStopped(); - } else { - fireStateChanged(); - } - } - }; - - /** - * 被选中时文本输入框请求焦点 - */ - public void selected() { - this.textField.requestFocus(); - } - - public String getIconName() { - return "type_string"; - } - - /** - * 判断object是否是字符类型 - * - * @param object 需要判断的object - * @return 是字符类型则返回true - */ - public boolean accept(Object object) { - return object instanceof String; - } +/* + * Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. + */ +package com.fr.design.editor.editor; + +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.Inter; +import com.fr.stable.StringUtils; + +import java.awt.BorderLayout; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +/** + * CellEditor used to edit String object. + * + * @author zhou + * @since 2012-3-29下午6:00:43 + */ +public class TextEditor extends Editor { + + /** + * text field. + */ + private UITextField textField; + /** + * the old value of text field. + */ + private String oldValue = StringUtils.EMPTY; + + /** + * Constructor. + */ + public TextEditor() { + this(null); + } + + public TextEditor(String value) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + textField = new UITextField(); + textField.setBorder(null); + this.add(textField, BorderLayout.CENTER); + this.textField.addKeyListener(textKeyListener); + + this.setValue(value); + this.setName(Inter.getLocText("Parameter-String")); + } + + public UITextField getTextField() { + return this.textField; + } + + /** + * Returns the horizontal alignment of the CellEditor. Valid keys are: + *
    + *
  • UITextField.LEFT + *
  • UITextField.CENTER + *
  • UITextField.RIGHT + *
  • UITextField.LEADING + *
  • UITextField.TRAILING + *
+ */ + public int getHorizontalAlignment() { + return this.textField.getHorizontalAlignment(); + } + + /** + * Sets the horizontal alignment of the CellEditor. Valid keys are: + *
    + *
  • UITextField.LEFT + *
  • UITextField.CENTER + *
  • UITextField.RIGHT + *
  • UITextField.LEADING + *
  • UITextField.TRAILING + *
+ */ + public void setHorizontalAlignment(int horizontalAlignment) { + this.textField.setHorizontalAlignment(horizontalAlignment); + } + + /** + * Return the value of the CellEditor. + */ + @Override + public String getValue() { + return this.textField.getText(); + } + + /** + * Set the value to the CellEditor. + */ + @Override + public void setValue(String value) { + // populate data to UI + if (value == null) { + value = StringUtils.EMPTY; + } + + oldValue = value; + this.textField.setText(oldValue); + } + + /** + * Sets whether or not this component is enabled. + */ + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + this.textField.setEnabled(enabled); + } + + + /** + * 请求焦点 + */ + @Override + public void requestFocus() { + this.textField.requestFocus(); + } + + KeyListener textKeyListener = new KeyAdapter() { + + @Override + public void keyReleased(KeyEvent evt) { + int code = evt.getKeyCode(); + if (code == KeyEvent.VK_ESCAPE) { + textField.setText(oldValue); + } + if (code == KeyEvent.VK_ENTER) { + fireEditingStopped(); + } else { + fireStateChanged(); + } + } + }; + + /** + * 被选中时文本输入框请求焦点 + */ + @Override + public void selected() { + this.textField.requestFocus(); + } + + @Override + public String getIconName() { + return "type_string"; + } + + /** + * 判断object是否是字符类型 + * + * @param object 需要判断的object + * @return 是字符类型则返回true + */ + @Override + public boolean accept(Object object) { + return object instanceof String; + } + + @Override + public void clearData() { + super.clearData(); + this.textField.setText(StringUtils.EMPTY); + this.oldValue = StringUtils.EMPTY; + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/file/NewTemplatePane.java b/designer_base/src/com/fr/design/file/NewTemplatePane.java index 9bca4f0b4a..accfae7186 100644 --- a/designer_base/src/com/fr/design/file/NewTemplatePane.java +++ b/designer_base/src/com/fr/design/file/NewTemplatePane.java @@ -21,11 +21,10 @@ import java.awt.geom.Rectangle2D; public abstract class NewTemplatePane extends JComponent implements MouseListener, MouseMotionListener { private static final Icon GRAY_NEW_CPT = BaseUtils.readIcon("/com/fr/design/images/buttonicon/additicon_grey.png"); - private static final int PRE_GAP = 5; + private static final int ICON_START_X = 5; private static final int HEIGHT = 26; private Graphics2D g2d; private Icon newWorkBookIconMode = null; - private int newIconStartX = PRE_GAP; public NewTemplatePane() { @@ -50,7 +49,7 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene g2d.setColor(UIConstants.TEMPLATE_TAB_PANE_BACKGROUND); g2d.fill(new Rectangle2D.Double(0, 0, getWidth(),getHeight())); int sheetIconY = (getHeight() - newWorkBookIconMode.getIconHeight()) / 2; - newWorkBookIconMode.paintIcon(this, g2d, newIconStartX, sheetIconY); + newWorkBookIconMode.paintIcon(this, g2d, ICON_START_X, sheetIconY); // paintUnderLine(g2d); } @@ -82,7 +81,6 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene } if (isOverNewIcon(evtX) && newWorkBookIconMode != GRAY_NEW_CPT) { newWorkBookIconMode = getMousePressNew(); - newIconStartX = 0; DesignerContext.getDesignerFrame().addAndActivateJTemplate(); } this.repaint(); @@ -113,7 +111,6 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene * @param e 事件 */ public void mouseExited(MouseEvent e) { - newIconStartX = PRE_GAP; if (needGrayNewCpt()) { newWorkBookIconMode = GRAY_NEW_CPT; } else { @@ -139,7 +136,6 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene if (needGrayNewCpt()) { newWorkBookIconMode = GRAY_NEW_CPT; } else if (isOverNewIcon(evtX)) { - newIconStartX = 0; newWorkBookIconMode = getMouseOverNew(); } @@ -153,7 +149,7 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene private boolean isOverNewIcon(int evtX) { - return (evtX >= PRE_GAP && evtX <= PRE_GAP + newWorkBookIconMode.getIconWidth()); + return (evtX >= ICON_START_X && evtX <= ICON_START_X + newWorkBookIconMode.getIconWidth()); } public void setButtonGray(boolean isGray) { diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java index bc37a2549d..d0a4c12c5f 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java @@ -17,10 +17,34 @@ import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JSplitPane; import javax.swing.border.EmptyBorder; -import java.awt.*; -import java.awt.event.*; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsEnvironment; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.Window; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; /** * Created by plough on 2017/7/21. @@ -47,7 +71,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH } public UIControlPane(BasePlot plot) { - this.plot =plot; + this.plot = plot; this.initComponentPane(); } @@ -145,8 +169,8 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH this.checkButtonEnabled(); } - protected void getPopupEditDialog (JPanel cardPane) { - popupEditDialog = new PopupEditDialog(cardPane); + protected void getPopupEditDialog(JPanel cardPane) { + popupEditDialog = new PopupEditDialog(cardPane); } protected abstract JPanel createControlUpdatePane(); @@ -169,7 +193,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH toolbarDef.addShortCut(sj.getShortCut()); } toolBar = ToolBarDef.createJToolBar(); - toolBar.setUI(new UIToolBarUI(){ + toolBar.setUI(new UIToolBarUI() { @Override public void paint(Graphics g, JComponent c) { Graphics2D g2 = (Graphics2D) g; @@ -186,7 +210,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH leftContentPane.add(toolBarPane, BorderLayout.NORTH); // 顶部标签及add按钮 - topToolBar = new UIToolbar(FlowLayout.LEFT, new UIToolBarUI(){ + topToolBar = new UIToolbar(FlowLayout.LEFT, new UIToolBarUI() { @Override public void paint(Graphics g, JComponent c) { Graphics2D g2 = (Graphics2D) g; @@ -207,15 +231,15 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH return leftPane; } - protected JPanel getLeftTopPane (UIToolbar topToolBar) { + protected JPanel getLeftTopPane(UIToolbar topToolBar) { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] columnSize = { p, f, isNewStyle() ? TOP_TOOLBAR_WIDTH : TOP_TOOLBAR_WIDTH_SHORT}; + double[] columnSize = {p, f, isNewStyle() ? TOP_TOOLBAR_WIDTH : TOP_TOOLBAR_WIDTH_SHORT}; double[] rowSize = {TOP_TOOLBAR_HEIGHT}; Component[][] components = new Component[][]{ new Component[]{new UILabel(getAddItemText()), new JPanel(), topToolBar}, }; - return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } /** @@ -336,6 +360,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH initListener(); } + @Override public void setTitle(String title) { popupToolPane.setTitle(title); } @@ -349,10 +374,21 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH } // 如果有可见模态对话框,则不隐藏 for (Window window : DesignerContext.getDesignerFrame().getOwnedWindows()) { - if (window instanceof JDialog && window.isVisible() && ((JDialog)window).isModal()) { + if (window instanceof JDialog && window.isVisible() && ((JDialog) window).isModal()) { return; } } + + // 要隐藏 先检查有没有非法输入 + // 非法输入检查放在最后,因为可能出现面板弹出新弹框而失去焦点的情况,比如 输入公式时,弹出公式编辑对话框 + try { + checkValid(); + } catch (Exception exp) { + // 存在非法输入 拒绝隐藏 + JOptionPane.showMessageDialog(UIControlPane.this.controlUpdatePane, exp.getMessage()); + this.requestFocus(); + return; + } saveSettings(); setVisible(false); } @@ -361,7 +397,6 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH addWindowFocusListener(new WindowAdapter() { @Override public void windowLostFocus(WindowEvent e) { - super.windowLostFocus(e); hideDialog(); } }); @@ -389,6 +424,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH } repaint(); } + @Override public void mouseReleased(MouseEvent e) { mouseDownCompCoords = null; @@ -396,6 +432,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH contentPane.setBackground(originColor); } } + @Override public void mousePressed(MouseEvent e) { mouseDownCompCoords = e.getPoint(); @@ -409,6 +446,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH contentPane.setBackground(UIConstants.POPUP_TITLE_BACKGROUND); repaint(); } + @Override public void mouseDragged(MouseEvent e) { if (mouseDownCompCoords != null) { diff --git a/designer_base/src/com/fr/design/gui/frpane/ImgChoosePane.java b/designer_base/src/com/fr/design/gui/frpane/ImgChoosePane.java deleted file mode 100644 index bea968cea2..0000000000 --- a/designer_base/src/com/fr/design/gui/frpane/ImgChoosePane.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.fr.design.gui.frpane; - -import com.fr.base.BaseUtils; -import com.fr.base.background.ImageBackground; -import com.fr.design.dialog.BasicPane; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.style.background.image.ImageFileChooser; -import com.fr.design.style.background.image.ImagePreviewPane; -import com.fr.general.Inter; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; - -public class ImgChoosePane extends BasicPane { - - private ImagePreviewPane previewPane; - private UIButton chooseButton; - private UIButton clearButton; - private UILabel imgSizeLabel; - private ImageFileChooser imageFileChooser; - - public ImgChoosePane() { - this.initComponents(); - } - - protected void initComponents() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - - JPanel previewContainner = new JPanel(); - previewContainner.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("Preview"))); - - previewPane = new ImagePreviewPane(); - previewContainner.add(previewPane); - previewPane.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent evt) { - Image image = ((ImagePreviewPane) evt.getSource()).getImage(); - - if (image == null) { - imgSizeLabel.setText(""); - } else { -// imgSizeLabel.setText(Inter.getLocText("Size") + ": " + image.getWidth(null) + "px" -// + image.getHeight(null) + Inter.getLocText("px")); - imgSizeLabel.setText(Inter.getLocText(new String[]{"Size", "px", "px"}, - new String[]{": " + image.getWidth(null), image.getHeight(null) + ""})); - } - } - }); - - this.add(previewContainner, BorderLayout.CENTER); - - JPanel choosePane = new JPanel(new BorderLayout(0, 10)); - choosePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); - JPanel choosePane1 = new JPanel(new BorderLayout(0, 10)); - - initButton(); - choosePane.add(chooseButton, BorderLayout.NORTH); - - choosePane1.add(clearButton,BorderLayout.NORTH); - choosePane.add(choosePane1,BorderLayout.CENTER); - - imgSizeLabel = new UILabel(); - imgSizeLabel.setHorizontalAlignment(SwingConstants.CENTER); - choosePane1.add(imgSizeLabel,BorderLayout.CENTER); - this.add(choosePane,BorderLayout.EAST); - - imageFileChooser = new ImageFileChooser(); - } - - private void initButton() { - chooseButton = new UIButton(Inter.getLocText("Image-Select_Picture")); - chooseButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - - int returnVal = imageFileChooser.showOpenDialog(ImgChoosePane.this); - if (returnVal != JFileChooser.CANCEL_OPTION) { - File selectedFile = imageFileChooser.getSelectedFile(); - if (selectedFile != null && selectedFile.isFile()) { - Image image = BaseUtils.readImage(selectedFile.getPath()); - previewPane.setImage(image); - previewPane.repaint(); - } else { - previewPane.setImage(null); - } - } - } - }); - - clearButton = new UIButton(Inter.getLocText("Clear")); - clearButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - previewPane.setImage(null); - previewPane.repaint(); - } - }); - } - - public void populate(ImageBackground background) { - if(background != null && background.getImage() != null) { - previewPane.setImage(background.getImage()); - } - } - - public ImageBackground update() { - if(previewPane.getImage() == null) { - return null; - } - return new ImageBackground(previewPane.getImage()); - } - - @Override - protected String title4PopupWindow() { - return Inter.getLocText("Image"); - } -} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/frpane/ImgChooseWrapper.java b/designer_base/src/com/fr/design/gui/frpane/ImgChooseWrapper.java new file mode 100644 index 0000000000..4d38e9b830 --- /dev/null +++ b/designer_base/src/com/fr/design/gui/frpane/ImgChooseWrapper.java @@ -0,0 +1,145 @@ +package com.fr.design.gui.frpane; + +import com.fr.base.BaseUtils; +import com.fr.base.Style; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.style.background.image.ImageFileChooser; +import com.fr.design.style.background.image.ImagePreviewer; +import com.fr.design.utils.ImageUtils; +import com.fr.general.Inter; +import com.fr.stable.CoreGraphHelper; +import com.fr.stable.StringUtils; + +import javax.swing.JFileChooser; +import javax.swing.SwingWorker; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.Image; +import java.io.File; + +/** + * 图片选择框包装类 + * Created by zack on 2018/3/9. + */ +public class ImgChooseWrapper { + private ImagePreviewer previewPane = null; + + private ImageFileChooser imageFileChooser = null; + + private Style imageStyle = null; + + private SwingWorker imageWorker; + private ChangeListener changeListener; + + private transient Image selectImage; + private UILabel imageSizeLabel; + + public static ImgChooseWrapper getInstance(ImagePreviewer previewPane, ImageFileChooser imageFileChooser, Style imageStyle) { + return getInstance(previewPane, imageFileChooser, imageStyle, null); + } + + public static ImgChooseWrapper getInstance(ImagePreviewer previewPane, ImageFileChooser imageFileChooser, Style imageStyle, ChangeListener changeListener) { + return new ImgChooseWrapper(previewPane, imageFileChooser, imageStyle, changeListener, null, null); + } + + public static ImgChooseWrapper getInstance(Image selectImage, UILabel imageSizeLabel, ImageFileChooser imageFileChooser) { + return new ImgChooseWrapper(null, imageFileChooser, null, null, selectImage, imageSizeLabel); + } + + private ImgChooseWrapper(ImagePreviewer previewPane, ImageFileChooser imageFileChooser, Style imageStyle, ChangeListener changeListener, Image selectImage, UILabel imageSizeLabel) { + this.previewPane = previewPane; + this.imageFileChooser = imageFileChooser; + this.imageStyle = imageStyle; + this.changeListener = changeListener; + this.selectImage = selectImage; + this.imageSizeLabel = imageSizeLabel; + } + + + public void setPreviewPane(ImagePreviewer previewPane) { + this.previewPane = previewPane; + } + + public ImageFileChooser getImageFileChooser() { + return imageFileChooser; + } + + public void setImageFileChooser(ImageFileChooser imageFileChooser) { + this.imageFileChooser = imageFileChooser; + } + + public Style getImageStyle() { + return imageStyle; + } + + public void setImageStyle(Style imageStyle) { + this.imageStyle = imageStyle; + } + + public SwingWorker getImageWorker() { + return imageWorker; + } + + public void setImageWorker(SwingWorker imageWorker) { + this.imageWorker = imageWorker; + } + + public void dealWithImageFile(int returnVal) { + if (returnVal != JFileChooser.CANCEL_OPTION) { + final File selectedFile = imageFileChooser.getSelectedFile(); + + if (selectedFile != null && selectedFile.isFile()) { + if (previewPane != null) { + previewPane.showLoading(); + } + if (imageWorker != null && !imageWorker.isDone()) { + imageWorker = null; + } + imageWorker = new SwingWorker() { + @Override + protected Void doInBackground() throws Exception { + Image image = imageFileChooser.isCheckSelected() ? ImageUtils.defaultImageCompress(selectedFile) : BaseUtils.readImage(selectedFile.getPath()); + CoreGraphHelper.waitForImage(image); + + if (previewPane != null) { + previewPane.setImageStyle(imageStyle); + previewPane.setImage(image); + previewPane.repaint(); + } + checkLabelText(); + fireChangeListener(); + return null; + } + }; + imageWorker.execute(); + } else { + if (previewPane != null) { + previewPane.setImage(null); + } + + } + if (previewPane != null) { + previewPane.repaint(); + } + } + } + + private void fireChangeListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + + private void checkLabelText() { + if (imageSizeLabel == null) { + return; + } + if (selectImage == null) { + imageSizeLabel.setText(StringUtils.EMPTY); + } else { + imageSizeLabel.setText(selectImage.getWidth(null) + "x" + + selectImage.getHeight(null) + Inter.getLocText("px")); + } + } +} diff --git a/designer_base/src/com/fr/design/gui/ibutton/UIRadioButton.java b/designer_base/src/com/fr/design/gui/ibutton/UIRadioButton.java index 8c93e76f4f..763bf178a5 100644 --- a/designer_base/src/com/fr/design/gui/ibutton/UIRadioButton.java +++ b/designer_base/src/com/fr/design/gui/ibutton/UIRadioButton.java @@ -1,6 +1,14 @@ package com.fr.design.gui.ibutton; +import com.fr.design.event.GlobalNameListener; +import com.fr.design.event.GlobalNameObserver; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.stable.StringUtils; + import javax.swing.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; /** * Created by IntelliJ IDEA. @@ -9,38 +17,110 @@ import javax.swing.*; * Date: 13-3-27 * Time: 下午5:04 */ -public class UIRadioButton extends JRadioButton { +public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNameObserver { + private UIObserverListener uiObserverListener; + private GlobalNameListener globalNameListener = null; + private String radioButtonName = StringUtils.EMPTY; public UIRadioButton() { super(); + initListener(); } public UIRadioButton(Icon icon) { super(icon); + initListener(); } public UIRadioButton(Action a) { super(a); + initListener(); } public UIRadioButton(Icon icon, boolean selected) { super(icon, selected); + initListener(); } public UIRadioButton(String text) { super(text); + initListener(); } public UIRadioButton(String text, boolean selected) { super(text, selected); + initListener(); } public UIRadioButton(String text, Icon icon) { super(text, icon); + initListener(); } public UIRadioButton(String text, Icon icon, boolean selected) { super(text, icon, selected); + initListener(); + } + + private void initListener() { + if (shouldResponseChangeListener()) { + this.addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + if (uiObserverListener == null || e.getStateChange() != ItemEvent.SELECTED) { + return; + } + if (globalNameListener != null && shouldResponseNameListener()) { + globalNameListener.setGlobalName(radioButtonName); + } + uiObserverListener.doChange(); + } + }); + } + } + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(UIObserverListener listener) { + this.uiObserverListener = listener; + } + + + public void setGlobalName(String name) { + radioButtonName = name; + } + + public String getGlobalName() { + return radioButtonName; + } + + /** + * 组件是否需要响应添加的观察者事件 + * + * @return 如果需要响应观察者事件则返回true,否则返回false + */ + public boolean shouldResponseChangeListener() { + return true; + } + + /** + * 注册观察者监听事件 + * @param listener 观察者监听事件 + */ + public void registerNameListener(GlobalNameListener listener) { + globalNameListener = listener; + } + + /** + * 组件是否需要响应观察者事件 + * @return 如果需要响应观察者事件则返回true,否则返回false + */ + public boolean shouldResponseNameListener() { + return true; } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/ilable/UILabel.java b/designer_base/src/com/fr/design/gui/ilable/UILabel.java index 368bf2383d..86b379e62d 100644 --- a/designer_base/src/com/fr/design/gui/ilable/UILabel.java +++ b/designer_base/src/com/fr/design/gui/ilable/UILabel.java @@ -3,6 +3,7 @@ package com.fr.design.gui.ilable; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.StringUtils; +import com.fr.stable.StringUtils; import javax.swing.Icon; import javax.swing.JFrame; import javax.swing.JLabel; @@ -63,6 +64,7 @@ public class UILabel extends JLabel { return preferredSize; } + public static void main(String[] args) { // UILabel label = new UILabel("shishi",SwingConstants.LEFT); JFrame frame = new JFrame("Test"); diff --git a/designer_base/src/com/fr/design/images/control/newEdit.png b/designer_base/src/com/fr/design/images/control/newEdit.png index 49843ce8ec..a54ad7419c 100644 Binary files a/designer_base/src/com/fr/design/images/control/newEdit.png and b/designer_base/src/com/fr/design/images/control/newEdit.png differ diff --git a/designer_base/src/com/fr/design/layout/FRGUIPaneFactory.java b/designer_base/src/com/fr/design/layout/FRGUIPaneFactory.java index a613f23d8b..1ad4d3303b 100644 --- a/designer_base/src/com/fr/design/layout/FRGUIPaneFactory.java +++ b/designer_base/src/com/fr/design/layout/FRGUIPaneFactory.java @@ -416,6 +416,37 @@ public class FRGUIPaneFactory { return jp; } + /** + * 创建垂直流布局面板 + * + * @param isAlignLeft 是否左对齐 + * @return JPanel对象 + */ + public static JPanel createVerticalFlowLayout_S_Pane(boolean isAlignLeft) { + JPanel jp = new JPanel(); + VerticalFlowLayout layout = new VerticalFlowLayout(); + layout.setAlignLeft(isAlignLeft); + jp.setLayout(layout); + return jp; + } + + /** + * 创建垂直流布局面板 + * + * @param isAlignLeft 是否左对齐 + * @param align the alignment value + * @param hgap the horizontal gap between components + * @param vgap the vertical gap between components + * @return JPanel对象 + */ + public static JPanel createVerticalFlowLayout_Pane(boolean isAlignLeft, int align, int hgap, int vgap) { + JPanel jp = new JPanel(); + VerticalFlowLayout layout = new VerticalFlowLayout(align, hgap, vgap); + layout.setAlignLeft(isAlignLeft); + jp.setLayout(layout); + return jp; + } + /** * 创建边框面板L * diff --git a/designer_base/src/com/fr/design/layout/VerticalFlowLayout.java b/designer_base/src/com/fr/design/layout/VerticalFlowLayout.java index 9befe52ceb..8f9eb55461 100644 --- a/designer_base/src/com/fr/design/layout/VerticalFlowLayout.java +++ b/designer_base/src/com/fr/design/layout/VerticalFlowLayout.java @@ -71,6 +71,9 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { */ int newAlign; // This is the one we actually use + // 当列宽不一致时,是否需要左对齐(默认居中对齐) + boolean isAlignLeft = false; + /** * The flow layout manager allows a seperation of * components with gaps. The horizontal gap will @@ -345,10 +348,11 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { for (int i = rowStart; i < rowEnd; i++) { Component m = target.getComponent(i); if (m.isVisible()) { + int newX = x + (width - m.getWidth()) / 2; if (ltr) { - m.setLocation(x + (width - m.getWidth()) / 2, y); + m.setLocation(isAlignLeft ? x : newX, y); } else { - m.setLocation(x + (width - m.getWidth()) / 2, target.getHeight() - y - m.getHeight()); + m.setLocation(isAlignLeft ? x : newX, target.getHeight() - y - m.getHeight()); } y += m.getHeight() + vgap; } @@ -431,6 +435,13 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { return 0; } + /** + * 当列宽不一致时,通过此方法设置是否需要左对齐 + */ + public void setAlignLeft(boolean isAlignLeft) { + this.isAlignLeft = true; + } + /** * Returns a string representation of this FlowLayout diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 5420c443c9..c5111f1a85 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -1652,7 +1652,7 @@ Parameter_Setting=Parameter Setting Related=Related BorderLayout-Constraints=Constraints Write_Preview=Write Preview -PageSetup-Page_Order=Page Order on print +PageSetup-Page_Order=Page Order Verify-Verify_Formula=Verify Formula State=State FR-Designer-Widget-Style_Body_Background= @@ -2070,7 +2070,7 @@ FR-Designer_StyleAlignment_Single_Line=Single_Line FR-Designer_StyleAlignment_Single_Line(Adjust_Font)=Single_Line(Adjust_Font) FR-Designer_StyleAlignment_Multi_Line(Adjust_Font)=Multi_Line(Adjust_Font) FR-Designer_Auto_Adjust_Height=Auto_Adjust_Height -FR-Designer_Auto_Adjust_Wdith=Auto_Adjust_Wdith +FR-Designer_Auto_Adjust_Width=Auto_Adjust_Width FR-Designer_Type_Set=Type_Set FR-Designer_Dic_Data_Query=Data_Query FR-Designer_Dictionary_Dynamic_SQL=Dictionary_Dynamic_SQL @@ -2188,3 +2188,25 @@ FR-Designer_Support_Email=Email: FR-Designer_Tip_Chart_Adaptivity_Unavailable_In_Absolute_Layout=Under the absolute canvas block, the chart does not support the setting of self-adaptive FR-Designer_Max_Height_Cannot_Be_Negative=The maximum height cannot be negative FR-Designer_How_To_Join= +FR-Designer_Follow_Paper_Settings=follow paper settings +FR-Designer_No_Auto_Adjust=no automatic adjust +FR-Designer_Print_Setting=Print Setting +FR-Designer_Tip_Use_Default_Print_Margin=Hint: if not check, use the default settings as follows. +FR-Designer_Default_Settings=Default configuration +FR-Designer_Inherit_Page_Margin_Setting=Inherit page margin setting +FR-Designer_Margin=Margin +FR-Designer_Order=Order +FR-Designer_Tip_Native_Print_Need_Client=Hint: native printing requires the terminal to download the client, but it can support more and more powerful functions. +FR-Designer_Tip_Use_Default_Settings=Hint: if you don't check, use the default settings as follows. +FR-Designer_Inherit_Page_Paper_Setting=Inherit page paper setting +FR-Designer_Inherit_Page_Layout_Setting=Inherit page layout setting +FR-Designer_Print_To_Fit_Paper_Size=Print to fit paper size +FR-Designer_Printer=Printer +FR-Designer_Copy_Number=The number of copies +FR-Designer_Paper=Paper +FR-Designer_All_Pages=All pages +FR-Designer_Current_Page=Current page +FR-Designer_Print_Area_Tip=eg(1, 4-9, 6, 8) +FR-Designer_Image_Compress= +FR-Designer_Image_Loading= +FR-Designer_Use_New_Print_Tip=Only display for compatibility, please use the new print diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index 814ca58ed7..8fcf2d0bf0 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -1653,7 +1653,7 @@ Parameter_Setting=Parameter Setting Related=Linkage BorderLayout-Constraints=Placement Write_Preview=Filling Preview -PageSetup-Page_Order=Print Order +PageSetup-Page_Order=Page Order Verify-Verify_Formula=Validation formula State=State FR-Designer-Widget-Style_Body_Background=Body Background @@ -2072,7 +2072,7 @@ FR-Designer_StyleAlignment_Single_Line=Single Line FR-Designer_StyleAlignment_Single_Line(Adjust_Font)=Single Line(Adjust Font) FR-Designer_StyleAlignment_Multi_Line(Adjust_Font)=Multi Line(Adjust Font) FR-Designer_Auto_Adjust_Height=Auto Adjust Height -FR-Designer_Auto_Adjust_Wdith=Auto Adjust Wdith +FR-Designer_Auto_Adjust_Width=Auto Adjust Wdith FR-Designer_Type_Set=Type Set FR-Designer_Dic_Data_Query=Data Query FR-Designer_Dictionary_Dynamic_SQL=Dictionary Dynamic SQL @@ -2187,3 +2187,25 @@ FR-Designer_Support_Email=Email: FR-Designer_Tip_Chart_Adaptivity_Unavailable_In_Absolute_Layout=Under the absolute canvas block, the chart does not support the setting of self-adaptive FR-Designer_Max_Height_Cannot_Be_Negative=The maximum height cannot be negative FR-Designer_How_To_Join=Poke me to learn how to join the thank you list +FR-Designer_Follow_Paper_Settings=follow paper settings +FR-Designer_No_Auto_Adjust=no automaticly adjust +FR-Designer_Print_Setting=Print Setting +FR-Designer_Tip_Use_Default_Print_Margin=Hint: if not check, use the default settings as follows. +FR-Designer_Default_Settings=Default configuration +FR-Designer_Inherit_Page_Margin_Setting=Inherit page margin setting +FR-Designer_Margin=Margin +FR-Designer_Order=Order +FR-Designer_Tip_Native_Print_Need_Client=Hint: native printing requires the terminal to download the client, but it can support more and more powerful functions. +FR-Designer_Tip_Use_Default_Settings=Hint: if you don't check, use the default settings as follows. +FR-Designer_Inherit_Page_Paper_Setting=Inherit page paper setting +FR-Designer_Inherit_Page_Layout_Setting=Inherit page layout setting +FR-Designer_Print_To_Fit_Paper_Size=Print to fit paper size +FR-Designer_Printer=Printer +FR-Designer_Copy_Number=The number of copies +FR-Designer_Paper=Paper +FR-Designer_All_Pages=All pages +FR-Designer_Current_Page=Current page +FR-Designer_Print_Area_Tip=eg(1, 4-9, 6, 8) +FR-Designer_Image_Compress=Compress Image +FR-Designer_Image_Loading=Loading Image... +FR-Designer_Use_New_Print_Tip=Only display for compatibility, please use the new print diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index 9dbc2882ff..ef47ba878b 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -2050,7 +2050,7 @@ FR-Designer_StyleAlignment_Single_Line= FR-Designer_StyleAlignment_Single_Line(Adjust_Font)= FR-Designer_StyleAlignment_Multi_Line(Adjust_Font)= FR-Designer_Auto_Adjust_Height= -FR-Designer_Auto_Adjust_Wdith= +FR-Designer_Auto_Adjust_Width= FR-Designer_Type_Set= FR-Designer_Dic_Data_Query= FR-Designer_Dictionary_Dynamic_SQL= @@ -2185,3 +2185,25 @@ FR-Designer_Support_Email= FR-Designer_Tip_Chart_Adaptivity_Unavailable_In_Absolute_Layout= FR-Designer_Max_Height_Cannot_Be_Negative= FR-Designer_How_To_Join= +FR-Designer_Follow_Paper_Settings= +FR-Designer_No_Auto_Adjust= +FR-Designer_Print_Setting=\u5370\u5237\u8A2D\u5B9A +FR-Designer_Tip_Use_Default_Print_Margin= +FR-Designer_Default_Settings= +FR-Designer_Inherit_Page_Margin_Setting= +FR-Designer_Margin= +FR-Designer_Order= +FR-Designer_Tip_Native_Print_Need_Client= +FR-Designer_Tip_Use_Default_Settings= +FR-Designer_Inherit_Page_Paper_Setting= +FR-Designer_Inherit_Page_Layout_Setting= +FR-Designer_Print_To_Fit_Paper_Size=\u7D19\u306E\u30B5\u30A4\u30BA\u306B\u5408\u308F\u305B\u3066\u5370\u5237 +FR-Designer_Printer= +FR-Designer_Copy_Number= +FR-Designer_Paper= +FR-Designer_All_Pages= +FR-Designer_Current_Page= +FR-Designer_Print_Area_Tip= +FR-Designer_Image_Compress= +FR-Designer_Image_Loading= +FR-Designer_Use_New_Print_Tip= diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties index ab9ebead1a..d8d24777c6 100644 --- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties +++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties @@ -2048,7 +2048,7 @@ FR-Designer_StyleAlignment_Single_Line= FR-Designer_StyleAlignment_Single_Line(Adjust_Font)= FR-Designer_StyleAlignment_Multi_Line(Adjust_Font)= FR-Designer_Auto_Adjust_Height= -FR-Designer_Auto_Adjust_Wdith= +FR-Designer_Auto_Adjust_Width= FR-Designer_Type_Set= FR-Designer_Dic_Data_Query= FR-Designer_Dictionary_Dynamic_SQL= @@ -2186,3 +2186,25 @@ FR-Designer_Support_Email= FR-Designer_Tip_Chart_Adaptivity_Unavailable_In_Absolute_Layout= FR-Designer_Max_Height_Cannot_Be_Negative= FR-Designer_How_To_Join= +FR-Designer_Follow_Paper_Settings= +FR-Designer_No_Auto_Adjust= +FR-Designer_Print_Setting=\uC778\uC1C4\uC124\uC815 +FR-Designer_Tip_Use_Default_Print_Margin= +FR-Designer_Default_Settings= +FR-Designer_Inherit_Page_Margin_Setting= +FR-Designer_Margin= +FR-Designer_Order= +FR-Designer_Tip_Native_Print_Need_Client= +FR-Designer_Tip_Use_Default_Settings= +FR-Designer_Inherit_Page_Paper_Setting= +FR-Designer_Inherit_Page_Layout_Setting= +FR-Designer_Print_To_Fit_Paper_Size=\uC885\uC774\uD06C\uAE30\uC5D0\uB530\uB978\uC778\uC1C4\uCD95\uC18C +FR-Designer_Printer= +FR-Designer_Copy_Number= +FR-Designer_Paper= +FR-Designer_All_Pages= +FR-Designer_Current_Page= +FR-Designer_Print_Area_Tip= +FR-Designer_Image_Compress= +FR-Designer_Image_Loading= +FR-Designer_Use_New_Print_Tip= diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index e69134f580..c78a716e24 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -1654,7 +1654,7 @@ Parameter_Setting=\u53C2\u6570\u8BBE\u7F6E Related=\u8054\u52A8 BorderLayout-Constraints=\u4F4D\u7F6E Write_Preview=\u586B\u62A5\u9884\u89C8 -PageSetup-Page_Order=\u6253\u5370\u987A\u5E8F +PageSetup-Page_Order=\u5206\u9875\u987A\u5E8F Verify-Verify_Formula=\u6821\u9A8C\u516C\u5F0F State=\u7701\u5E02 FR-Designer-Widget-Style_Body_Background=\u4E3B\u4F53\u80CC\u666F @@ -2072,7 +2072,7 @@ FR-Designer_StyleAlignment_Single_Line=\u5355\u884C\u663E\u793A FR-Designer_StyleAlignment_Single_Line(Adjust_Font)=\u5355\u884C\u663E\u793A(\u8C03\u6574\u5B57\u4F53) FR-Designer_StyleAlignment_Multi_Line(Adjust_Font)=\u591A\u884C\u663E\u793A(\u8C03\u6574\u5B57\u4F53) FR-Designer_Auto_Adjust_Height=\u81EA\u52A8\u8C03\u6574\u884C\u9AD8 -FR-Designer_Auto_Adjust_Wdith=\u81EA\u52A8\u8C03\u6574\u5217\u5BBD +FR-Designer_Auto_Adjust_Width=\u81EA\u52A8\u8C03\u6574\u5217\u5BBD FR-Designer_Type_Set=\u7C7B\u578B\u8BBE\u7F6E FR-Designer_Dic_Data_Query=\u6570\u636E\u67E5\u8BE2 FR-Designer_Dictionary_Dynamic_SQL=\u52A8\u6001SQL @@ -2188,3 +2188,25 @@ FR-Designer_Support_Email=\u652F\u6301\u90AE\u7BB1\uFF1A FR-Designer_Tip_Chart_Adaptivity_Unavailable_In_Absolute_Layout=\u7EDD\u5BF9\u753B\u5E03\u5757\u72B6\u6001\u4E0B\uFF0C\u56FE\u8868\u4E0D\u652F\u6301\u8BBE\u7F6E\u81EA\u9002\u5E94 FR-Designer_Max_Height_Cannot_Be_Negative=\u6700\u5927\u9AD8\u5EA6\u4E0D\u53EF\u4E3A\u8D1F\u503C FR-Designer_How_To_Join=\u6233\u6211\u4E86\u89E3\u5982\u4F55\u52A0\u5165\u81F4\u8C22\u540D\u5355 +FR-Designer_Follow_Paper_Settings=\u8DDF\u968F\u9875\u9762\u8BBE\u7F6E +FR-Designer_No_Auto_Adjust=\u4E0D\u81EA\u52A8\u8C03\u6574 +FR-Designer_Print_Setting=\u6253\u5370\u8BBE\u7F6E +FR-Designer_Tip_Use_Default_Print_Margin=\u63D0\u793A\uFF1A\u82E5\u4E0D\u52FE\u9009\uFF0C\u5219\u4F7F\u7528\u5982\u4E0B\u9ED8\u8BA4\u8BBE\u7F6E\u4E2D\u7684\u6253\u5370\u8FB9\u8DDD\u3002 +FR-Designer_Default_Settings=\u9ED8\u8BA4\u914D\u7F6E +FR-Designer_Inherit_Page_Margin_Setting=\u7EE7\u627F\u9875\u9762\u8FB9\u8DDD\u8BBE\u7F6E +FR-Designer_Margin=\u8FB9\u8DDD +FR-Designer_Order=\u987A\u5E8F +FR-Designer_Tip_Native_Print_Need_Client=\u63D0\u793A\uFF1A\u672C\u5730\u8F6F\u4EF6\u6253\u5370\u9700\u8981\u7EC8\u7AEF\u4E0B\u8F7D\u5BA2\u6237\u7AEF\uFF0C\u4F46\u80FD\u652F\u6301\u66F4\u591A\u3001\u66F4\u5F3A\u5927\u7684\u529F\u80FD\u3002 +FR-Designer_Tip_Use_Default_Settings=\u63D0\u793A\uFF1A\u82E5\u4E0D\u52FE\u9009\uFF0C\u5219\u4F7F\u7528\u5982\u4E0B\u9ED8\u8BA4\u8BBE\u7F6E\u3002 +FR-Designer_Inherit_Page_Paper_Setting=\u7EE7\u627F\u9875\u9762\u7EB8\u5F20\u8BBE\u7F6E +FR-Designer_Inherit_Page_Layout_Setting=\u7EE7\u627F\u9875\u9762\u5E03\u5C40\u8BBE\u7F6E +FR-Designer_Print_To_Fit_Paper_Size=\u6839\u636E\u7EB8\u5F20\u5927\u5C0F\u7F29\u653E\u6253\u5370 +FR-Designer_Printer=\u6253\u5370\u673A +FR-Designer_Copy_Number=\u4EFD\u6570 +FR-Designer_Paper=\u7EB8\u5F20 +FR-Designer_All_Pages=\u6240\u6709\u9875 +FR-Designer_Current_Page=\u5F53\u524D\u9875 +FR-Designer_Print_Area_Tip=\u683C\u5F0F(1, 4-9, 6, 8) +FR-Designer_Image_Compress=\u56FE\u7247\u538B\u7F29 +FR-Designer_Image_Loading=\u6B63\u5728\u6253\u5F00\u56FE\u7247... +FR-Designer_Use_New_Print_Tip=\u8BE5\u529F\u80FD\u53EA\u505A\u517C\u5BB9\u663E\u793A\uFF0C\u8BF7\u4F7F\u7528\u65B0\u7248\u6253\u5370 diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index e1e3dc1777..0719164e55 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -1652,7 +1652,7 @@ Parameter_Setting=\u53C3\u6578\u8A2D\u5B9A Related=\u806F\u52D5 BorderLayout-Constraints=\u4F4D\u7F6E Write_Preview=\u586B\u5831\u9810\u89BD -PageSetup-Page_Order=\u5217\u5370\u9806\u5E8F +PageSetup-Page_Order=\u5206\u9801\u9806\u5E8F Verify-Verify_Formula=\u6821\u9A57\u516C\u5F0F State=\u7701\u5E02 FR-Designer-Widget-Style_Body_Background=\u4E3B\u9AD4\u80CC\u666F @@ -2068,7 +2068,7 @@ FR-Designer_StyleAlignment_Single_Line=\u55AE\u884C\u986F\u793A FR-Designer_StyleAlignment_Single_Line(Adjust_Font)=\u55AE\u884C\u986F\u793A(\u8ABF\u6574\u5B57\u578B) FR-Designer_StyleAlignment_Multi_Line(Adjust_Font)=\u591A\u884C\u986F\u793A(\u8ABF\u6574\u5B57\u578B) FR-Designer_Auto_Adjust_Height=\u81EA\u52D5\u8ABF\u6574\u884C\u9AD8 -FR-Designer_Auto_Adjust_Wdith=\u81EA\u52D5\u8ABF\u6574\u5217\u5BEC +FR-Designer_Auto_Adjust_Width=\u81EA\u52D5\u8ABF\u6574\u5217\u5BEC FR-Designer_Type_Set=\u578B\u5225\u8A2D\u5B9A FR-Designer_Dic_Data_Query=\u8CC7\u6599\u67E5\u8A62 FR-Designer_Dictionary_Dynamic_SQL=\u52D5\u614BSQL @@ -2187,3 +2187,25 @@ FR-Designer_Support_Email=\u652F\u6301\u90F5\u7BB1\uFF1A FR-Designer_Tip_Chart_Adaptivity_Unavailable_In_Absolute_Layout=\u7D55\u5C0D\u756B\u5E03\u584A\u72C0\u614B\u4E0B\uFF0C\u5716\u8868\u4E0D\u652F\u6301\u8A2D\u5B9A\u81EA\u6211\u8ABF\u6574 FR-Designer_Max_Height_Cannot_Be_Negative=\u6700\u5927\u9AD8\u5EA6\u4E0D\u53EF\u70BA\u8CA0\u503C FR-Designer_How_To_Join=\u6233\u6211\u4E86\u89E3\u5982\u4F55\u52A0\u5165\u81F4\u8B1D\u540D\u55AE +FR-Designer_Follow_Paper_Settings=\u8DDF\u96A8\u9801\u9762\u8A2D\u5B9A +FR-Designer_No_Auto_Adjust=\u4E0D\u81EA\u52D5\u8ABF\u6574 +FR-Designer_Print_Setting=\u5217\u5370\u8A2D\u5B9A +FR-Designer_Tip_Use_Default_Print_Margin=\u63D0\u793A\uFF1A\u82E5\u4E0D\u52FE\u9078\uFF0C\u5247\u4F7F\u7528\u5982\u4E0B\u9ED8\u8A8D\u8A2D\u7F6E\u4E2D\u7684\u5217\u5370\u908A\u8DDD\u3002 +FR-Designer_Default_Settings=\u9ED8\u8A8D\u914D\u5BD8 +FR-Designer_Inherit_Page_Margin_Setting=\u7E7C\u627F\u9801\u9762\u908A\u8DDD\u8A2D\u5B9A +FR-Designer_Margin=\u908A\u8DDD +FR-Designer_Order=\u9806\u5E8F +FR-Designer_Tip_Native_Print_Need_Client=\u63D0\u793A\uFF1A\u672C\u5730\u8EDF\u4EF6\u5217\u5370\u9700\u8981\u7D42\u7AEF\u4E0B\u8F09\u7528\u6236\u7AEF\uFF0C\u4F46\u80FD\u652F\u6301\u66F4\u591A\u3001\u66F4\u5F3A\u5927\u7684\u529F\u80FD\u3002 +FR-Designer_Tip_Use_Default_Settings=\u63D0\u793A\uFF1A\u82E5\u4E0D\u52FE\u9078\uFF0C\u5247\u4F7F\u7528\u5982\u4E0B\u9ED8\u8A8D\u8A2D\u7F6E\u3002 +FR-Designer_Inherit_Page_Paper_Setting=\u7E7C\u627F\u9801\u9762\u7D19\u5F35\u8A2D\u5B9A +FR-Designer_Inherit_Page_Layout_Setting=\u7E7C\u627F\u9801\u9762\u4F48\u5C40\u8A2D\u5B9A +FR-Designer_Print_To_Fit_Paper_Size=\u6839\u64DA\u7D19\u5F35\u5927\u5C0F\u7E2E\u653E\u5217\u5370 +FR-Designer_Printer=\u6253\u5370\u6A5F +FR-Designer_Copy_Number=\u4EFD\u6578 +FR-Designer_Paper=\u7D19\u5F35 +FR-Designer_All_Pages=\u6240\u6709\u9801 +FR-Designer_Current_Page=\u7576\u524D\u9801 +FR-Designer_Print_Area_Tip=\u683C\u5F0F(1, 4-9, 6, 8) +FR-Designer_Image_Compress=\u5716\u7247\u58D3\u7E2E +FR-Designer_Image_Loading=\u6B63\u5728\u6253\u958B\u5716\u7247\u2026 +FR-Designer_Use_New_Print_Tip=\u8A72\u529F\u80FD\u53EA\u505A\u76F8\u5BB9\u986F\u793A\uFF0C\u8ACB\u4F7F\u7528\u65B0\u7248\u5217\u5370 diff --git a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java index 357bab937f..65ecf561db 100644 --- a/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java @@ -231,6 +231,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer { updateAllPropertyPane(); } + /** + * 可通过此方法,判断当前的编辑模式 + * */ + public PropertyMode getCurrentMode() { + return currentMode; + } + public void updateAllPropertyPane() { updatePropertyItemMap(); initContentPane(); diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index 15c2624532..039015ff36 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -80,7 +80,7 @@ public abstract class JTemplate> ex protected U undoState; protected U authorityUndoState = null; protected T template; // 当前模板 - protected TemplateProcessInfo processInfo; // 模板过程的相关信息 + protected TemplateProcessInfo processInfo; // 模板过程的相关信息 private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复 private DesignModelAdapter designModel; private PreviewProvider previewType; @@ -143,7 +143,7 @@ public abstract class JTemplate> ex openTime = saveTime; // 更新 openTime,准备下一次计算 } - public abstract TemplateProcessInfo getProcessInfo(); + public abstract TemplateProcessInfo getProcessInfo(); // 追加过程记录 public void appendProcess(String s) { diff --git a/designer_base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java b/designer_base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java index 22fa2c1e28..e4e4f059cb 100644 --- a/designer_base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java +++ b/designer_base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java @@ -1,28 +1,27 @@ package com.fr.design.mainframe.backgroundpane; -import com.fr.base.BaseUtils; import com.fr.base.Style; import com.fr.base.background.ImageBackground; -import com.fr.design.constants.UIConstants; import com.fr.design.border.UIRoundedBorder; +import com.fr.design.constants.UIConstants; import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.frpane.ImgChooseWrapper; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.style.background.image.ImageFileChooser; import com.fr.general.Background; import com.fr.general.Inter; import com.fr.stable.Constants; -import com.fr.stable.CoreGraphHelper; -import com.fr.design.style.background.image.ImageFileChooser; -import javax.swing.*; +import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.File; /** * @author zhou @@ -30,159 +29,147 @@ import java.io.File; */ public class ImageBackgroundQuickPane extends BackgroundQuickPane { - private ImagePreviewPane previewPane; - private Style imageStyle = null; - private ChangeListener changeListener = null; - private ImageFileChooser imageFileChooser; + private ImagePreviewPane previewPane; + private Style imageStyle = null; + private ChangeListener changeListener = null; + private ImageFileChooser imageFileChooser; - private UIButtonGroup imageLayoutPane; + private UIButtonGroup imageLayoutPane; public ImageBackgroundQuickPane() { this(true); } - public ImageBackgroundQuickPane(boolean hasImageLayout) { - this.setLayout(new BorderLayout(0, 4)); - String[] nameArray = {Inter.getLocText("FR-Background_Image_Default"), Inter.getLocText("FR-Background_Image_Titled"), Inter.getLocText("FR-Background_Image_Adjust"), Inter.getLocText("FR-Background_Image_Extend")}; - Byte[] valueArray = {Constants.IMAGE_CENTER, Constants.IMAGE_TILED, Constants.IMAGE_EXTEND, Constants.IMAGE_ADJUST}; - imageLayoutPane = new UIButtonGroup(nameArray, valueArray); - imageLayoutPane.setSelectedIndex(0); + public ImageBackgroundQuickPane(boolean hasImageLayout) { + this.setLayout(new BorderLayout(0, 4)); + String[] nameArray = {Inter.getLocText("FR-Background_Image_Default"), Inter.getLocText("FR-Background_Image_Titled"), Inter.getLocText("FR-Background_Image_Adjust"), Inter.getLocText("FR-Background_Image_Extend")}; + Byte[] valueArray = {Constants.IMAGE_CENTER, Constants.IMAGE_TILED, Constants.IMAGE_EXTEND, Constants.IMAGE_ADJUST}; + imageLayoutPane = new UIButtonGroup(nameArray, valueArray); + imageLayoutPane.setSelectedIndex(0); - previewPane = new ImagePreviewPane(); - JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - borderPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); - borderPane.setPreferredSize(new Dimension(0, 145)); - borderPane.add(previewPane, BorderLayout.CENTER); - this.add(borderPane, BorderLayout.NORTH); - previewPane.addChangeListener(imageSizeChangeListener); + previewPane = new ImagePreviewPane(); + JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + borderPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); + borderPane.setPreferredSize(new Dimension(0, 145)); + borderPane.add(previewPane, BorderLayout.CENTER); + this.add(borderPane, BorderLayout.NORTH); + previewPane.addChangeListener(imageSizeChangeListener); - JPanel southPane = new JPanel(new BorderLayout(0, 4)); - JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - contentPane.add(southPane, BorderLayout.NORTH); - this.add(contentPane, BorderLayout.CENTER); + JPanel southPane = new JPanel(new BorderLayout(0, 4)); + JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + contentPane.add(southPane, BorderLayout.NORTH); + this.add(contentPane, BorderLayout.CENTER); - UIButton selectPictureButton = new UIButton(Inter.getLocText("Image-Select_Picture")); - selectPictureButton.addActionListener(selectPictureActionListener); + UIButton selectPictureButton = new UIButton(Inter.getLocText("Image-Select_Picture")); + selectPictureButton.addActionListener(selectPictureActionListener); - if(hasImageLayout){ + if (hasImageLayout) { southPane.add(imageLayoutPane, BorderLayout.SOUTH); } - southPane.add(selectPictureButton, BorderLayout.CENTER); - - imageLayoutPane.addChangeListener(new ChangeListener() { - - @Override - public void stateChanged(ChangeEvent e) { - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); - previewPane.setImageStyle(imageStyle); - previewPane.repaint(); - } - }); - } - - /** - * Select picture. - */ - ActionListener selectPictureActionListener = new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - if (imageFileChooser == null) { - imageFileChooser = new ImageFileChooser(); - imageFileChooser.setMultiSelectionEnabled(false); - } - int returnVal = imageFileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); - if (returnVal != JFileChooser.CANCEL_OPTION) { - File selectedFile = imageFileChooser.getSelectedFile(); - - if (selectedFile != null && selectedFile.isFile()) { - Image image = BaseUtils.readImage(selectedFile.getPath()); - CoreGraphHelper.waitForImage(image); - - previewPane.setImage(image); - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); - previewPane.setImageStyle(imageStyle); - previewPane.repaint(); - } else { - previewPane.setImage(null); - } - fireChagneListener(); - } - - } - }; - - public void populateBean(Background background) { - - ImageBackground imageBackground = (ImageBackground) background; - imageLayoutPane.setSelectedItem((byte) imageBackground.getLayout()); - Style.DEFAULT_STYLE.deriveImageLayout(imageBackground.getLayout()); - - previewPane.setImageStyle(ImageBackgroundQuickPane.this.imageStyle); - previewPane.setImage(imageBackground.getImage()); - previewPane.repaint(); - } - - public Background updateBean() { - ImageBackground imageBackground = new ImageBackground(previewPane.getImage()); - imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); - imageBackground.setLayout(imageStyle.getImageLayout()); - return imageBackground; - } - - /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ - public void registerChangeListener(final UIObserverListener listener) { - changeListener = new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }; - imageLayoutPane.addChangeListener(changeListener); - } - - - private void fireChagneListener() { - if (this.changeListener != null) { - ChangeEvent evt = new ChangeEvent(this); - this.changeListener.stateChanged(evt); - } - } - - ChangeListener imageSizeChangeListener = new ChangeListener() { - - public void stateChanged(ChangeEvent evt) { + southPane.add(selectPictureButton, BorderLayout.CENTER); + + imageLayoutPane.addChangeListener(new ChangeListener() { + + @Override + public void stateChanged(ChangeEvent e) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); + previewPane.setImageStyle(imageStyle); + previewPane.repaint(); + } + }); + } + + /** + * Select picture. + */ + ActionListener selectPictureActionListener = new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + if (imageFileChooser == null) { + imageFileChooser = new ImageFileChooser(); + imageFileChooser.setMultiSelectionEnabled(false); + } + int returnVal = imageFileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); + ImgChooseWrapper.getInstance(previewPane, imageFileChooser, imageStyle, changeListener).dealWithImageFile(returnVal); + } + }; + + + public void populateBean(Background background) { + + ImageBackground imageBackground = (ImageBackground) background; + imageLayoutPane.setSelectedItem((byte) imageBackground.getLayout()); + Style.DEFAULT_STYLE.deriveImageLayout(imageBackground.getLayout()); + + previewPane.setImageStyle(ImageBackgroundQuickPane.this.imageStyle); + previewPane.setImage(imageBackground.getImage()); + previewPane.repaint(); + } + + public Background updateBean() { + ImageBackground imageBackground = new ImageBackground(previewPane.getImage()); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); + imageBackground.setLayout(imageStyle.getImageLayout()); + return imageBackground; + } + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(final UIObserverListener listener) { + changeListener = new ChangeListener() { + public void stateChanged(ChangeEvent e) { + listener.doChange(); + } + }; + imageLayoutPane.addChangeListener(changeListener); + } + + + private void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + + ChangeListener imageSizeChangeListener = new ChangeListener() { + + public void stateChanged(ChangeEvent evt) { if (imageLayoutPane.getSelectedItem() != null) { imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); previewPane.setImageStyle(imageStyle); previewPane.repaint(); } - } - }; + } + }; /** * 判断是否是图片背景 - * @param background 背景 + * + * @param background 背景 * @return 判断是否是图片背景 */ - public boolean accept(Background background) { - return background instanceof ImageBackground; - } + public boolean accept(Background background) { + return background instanceof ImageBackground; + } /** * 标题 + * * @return 标题 */ - public String title4PopupWindow() { - return Inter.getLocText("FR-Background_Image"); - } - - @Override - public void reset() { - imageLayoutPane.setSelectedIndex(0); - previewPane.setImage(null); - } + public String title4PopupWindow() { + return Inter.getLocText("FR-Background_Image"); + } + + @Override + public void reset() { + imageLayoutPane.setSelectedIndex(0); + previewPane.setImage(null); + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java b/designer_base/src/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java index 952f5839e0..40ada95c9c 100644 --- a/designer_base/src/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java +++ b/designer_base/src/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java @@ -4,285 +4,287 @@ package com.fr.design.mainframe.backgroundpane; * Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. */ -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.List; +import com.fr.base.BaseUtils; +import com.fr.base.GraphHelper; +import com.fr.base.Style; +import com.fr.design.constants.UIConstants; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.iscrollbar.UIScrollBar; +import com.fr.design.style.background.image.ImagePreviewer; +import com.fr.general.Inter; +import com.fr.stable.Constants; +import com.fr.stable.CoreGraphHelper; import javax.swing.BorderFactory; import javax.swing.JComponent; - -import com.fr.design.constants.UIConstants; -import com.fr.design.gui.ilable.UILabel; import javax.swing.JPanel; import javax.swing.JViewport; import javax.swing.Scrollable; import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; - -import com.fr.base.BaseUtils; -import com.fr.base.GraphHelper; -import com.fr.base.Style; -import com.fr.design.gui.iscrollbar.UIScrollBar; -import com.fr.stable.Constants; -import com.fr.stable.CoreGraphHelper; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.List; /** * The pane use to preview image */ -public class ImagePreviewPane extends JComponent implements Scrollable { +public class ImagePreviewPane extends JComponent implements Scrollable, ImagePreviewer { private static final int LABEL_DELTA_X = 10; private static final int LABEL_DELTA_Y = 20; private static final int LABEL_HEIGHT = 20; private static final int INCRE_DELTA = 10; - private Image image = null; - // carl:image style - private Style imageStyle = null; - private int imageWidth = 0; - private int imageHeight = 0; + private Image image = null; + // carl:image style + private Style imageStyle = null; + private int imageWidth = 0; + private int imageHeight = 0; - private List changeListenerList = new ArrayList(); - private UILabel sizeLabel; + private List changeListenerList = new ArrayList(); + private UILabel sizeLabel; + private boolean isLoading = false; - public ImagePreviewPane() { - sizeLabel = new UILabel(); - this.add(sizeLabel); - this.setBorder(BorderFactory.createEmptyBorder(10, 10, 20, 10)); - this.setLayout(new BorderLayout()); - this.add(new JPanel() { - public void paintComponent(Graphics g) { - super.paintComponent(g); + public ImagePreviewPane() { + sizeLabel = new UILabel(); + this.add(sizeLabel); + this.setBorder(BorderFactory.createEmptyBorder(10, 10, 20, 10)); + this.setLayout(new BorderLayout()); + this.add(new JPanel() { + public void paintComponent(Graphics g) { + super.paintComponent(g); + if (isLoading) { + g.drawString(Inter.getLocText("FR-Designer_Image_Loading"), getWidth() / 2 - 25, getHeight() / 2); + return; + } + // draw image. + if (getImage() != null) { + // carl:让imagePreviewPane能预览样式 + if (getImageStyle() == null) { + g.drawImage(getImage(), 0, 0, this); + } else { + if (getImage().getWidth(this) > getWidth() || getImage().getHeight(this) > getHeight()) { + GraphHelper.paintImageMoved(g, this.getWidth(), this.getHeight(), getImage(), Constants.IMAGE_ADJUST, BaseUtils.getAlignment4Horizontal(getImageStyle()), + getImageStyle().getVerticalAlignment(), -1, -1, 0, 0, false, UIConstants.NORMAL_BACKGROUND); + } else { + int totalwidth = this.getWidth(); + int totalheight = this.getHeight(); + g.drawImage(getImage(), totalwidth / 2 - imageWidth / 2, totalheight / 2 - imageHeight / 2, this); + } + } + } + } + }, BorderLayout.CENTER); + // this.setToolTipText("View Image"); + } - // draw image. - if (getImage() != null) { - // carl:让imagePreviewPane能预览样式 - if (getImageStyle() == null) { - g.drawImage(getImage(), 0, 0, this); - } else { - if (getImage().getWidth(this) > getWidth() || getImage().getHeight(this) > getHeight()) { - GraphHelper.paintImageMoved(g, this.getWidth(), this.getHeight(), getImage(), Constants.IMAGE_ADJUST, BaseUtils.getAlignment4Horizontal(getImageStyle()), - getImageStyle().getVerticalAlignment(), -1, -1,0, 0, false, UIConstants.NORMAL_BACKGROUND); - } else { - int totalwidth = this.getWidth(); - int totalheight = this.getHeight(); - g.drawImage(getImage(), totalwidth / 2 - imageWidth / 2, totalheight / 2 - imageHeight / 2, this); - } - } - } - } - }, BorderLayout.CENTER); - // this.setToolTipText("View Image"); - } + /** + * Return image + */ + public Image getImage() { + return this.image; + } - /** - * Return image - */ - public Image getImage() { - return this.image; - } + /** + * Set image. + * + * @param image the new image. + */ + public void setImage(Image image) { + this.image = image; + // need to reset the size of JViewPort. + if (this.image == null) { + if (this.getParent() instanceof JViewport) { + UIScrollBar tmpJScrollBar = new UIScrollBar(UIScrollBar.HORIZONTAL); + Dimension newDimension = new Dimension(this.getSize().width - tmpJScrollBar.getPreferredSize().height, this.getSize().height + - tmpJScrollBar.getPreferredSize().height); + ((JViewport) this.getParent()).setPreferredSize(newDimension); + (this.getParent()).setSize(newDimension); + ((JViewport) this.getParent()).setMinimumSize(newDimension); + ((JViewport) this.getParent()).setMaximumSize(newDimension); + } + sizeLabel.setText(null); + } else { + isLoading = false; + // wait for the size of image. + CoreGraphHelper.waitForImage(image); - /** - * Set image. - * - * @param image - * the new image. - */ - public void setImage(Image image) { - this.image = image; - // need to reset the size of JViewPort. - if (this.image == null) { - if (this.getParent() instanceof JViewport) { - UIScrollBar tmpJScrollBar = new UIScrollBar(UIScrollBar.HORIZONTAL); - Dimension newDimension = new Dimension(this.getSize().width - tmpJScrollBar.getPreferredSize().height, this.getSize().height - - tmpJScrollBar.getPreferredSize().height); - ((JViewport)this.getParent()).setPreferredSize(newDimension); - (this.getParent()).setSize(newDimension); - ((JViewport)this.getParent()).setMinimumSize(newDimension); - ((JViewport)this.getParent()).setMaximumSize(newDimension); - } - sizeLabel.setText(null); - } else { - // wait for the size of image. - CoreGraphHelper.waitForImage(image); + imageWidth = image.getWidth(null); + imageHeight = image.getHeight(null); + int totalwidth = ImagePreviewPane.this.getWidth(); + int totalheight = ImagePreviewPane.this.getHeight(); + String text = imageWidth + "x" + imageHeight; + sizeLabel.setText(text); + FontMetrics cellFM = this.getFontMetrics(getFont()); + int width = cellFM.stringWidth(text); + sizeLabel.setBounds(totalwidth - width - LABEL_DELTA_X, totalheight - LABEL_DELTA_Y, width, LABEL_HEIGHT); + } + fireChangeListener(); + this.revalidate(); + } - imageWidth = image.getWidth(null); - imageHeight = image.getHeight(null); - int totalwidth = ImagePreviewPane.this.getWidth(); - int totalheight = ImagePreviewPane.this.getHeight(); - String text = imageWidth + "x" + imageHeight; - sizeLabel.setText(text); - FontMetrics cellFM = this.getFontMetrics(getFont()); - int width = cellFM.stringWidth(text); - sizeLabel.setBounds(totalwidth - width - LABEL_DELTA_X, totalheight - LABEL_DELTA_Y, width, LABEL_HEIGHT); - } - fireChangeListener(); - this.revalidate(); - } + public void showLoading() { + isLoading = true; + setImage(null); + repaint(); + } - /** - * Paint component. - */ + /** + * Paint component. + */ - public Dimension getPreferredSize() { - if (this.image == null) { - return super.getPreferredSize(); - } + public Dimension getPreferredSize() { + if (this.image == null) { + return super.getPreferredSize(); + } - return new Dimension(imageWidth, imageHeight); - } + return new Dimension(imageWidth, imageHeight); + } - /** - * Add change listener. - */ - public void addChangeListener(ChangeListener changeListener) { - changeListenerList.add(changeListener); - } + /** + * Add change listener. + */ + public void addChangeListener(ChangeListener changeListener) { + changeListenerList.add(changeListener); + } - /** - * fire change listener when image changed. - */ - private void fireChangeListener() { - if (this.changeListenerList.size() > 0) { - ChangeEvent evt = new ChangeEvent(this); + /** + * fire change listener when image changed. + */ + private void fireChangeListener() { + if (this.changeListenerList.size() > 0) { + ChangeEvent evt = new ChangeEvent(this); - for (int i = 0; i < changeListenerList.size(); i++) { - changeListenerList.get(i).stateChanged(evt); - } - } - } + for (int i = 0; i < changeListenerList.size(); i++) { + changeListenerList.get(i).stateChanged(evt); + } + } + } - // --- Scrollable methods --------------------------------------------- + // --- Scrollable methods --------------------------------------------- - /** - * Returns the preferred size of the viewport for a view component. This is - * implemented to do the default behavior of returning the preferred size of - * the component. - * - * @return the preferredSize of a JViewport whose - * view is this Scrollable - */ - public Dimension getPreferredScrollableViewportSize() { - return getPreferredSize(); - } + /** + * Returns the preferred size of the viewport for a view component. This is + * implemented to do the default behavior of returning the preferred size of + * the component. + * + * @return the preferredSize of a JViewport whose + * view is this Scrollable + */ + public Dimension getPreferredScrollableViewportSize() { + return getPreferredSize(); + } - /** - * Components that display logical rows or columns should compute the scroll - * increment that will completely expose one new row or column, depending on - * the value of orientation. Ideally, components should handle a partially - * exposed row or column by returning the distance required to completely - * expose the item. - *

- * The default implementation of this is to simply return 10% of the visible - * area. Subclasses are likely to be able to provide a much more reasonable - * value. - * - * @param visibleRect - * the view area visible within the viewport - * @param orientation - * either SwingConstants.VERTICAL or - * SwingConstants.HORIZONTAL - * @param direction - * less than zero to scroll up/left, greater than zero for - * down/right - * @return the "unit" increment for scrolling in the specified direction - * @throws IllegalArgumentException - * for an invalid orientation - * @see javax.swing.JScrollBar#setUnitIncrement - */ - public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { - switch (orientation) { - case SwingConstants.VERTICAL: - return visibleRect.height / INCRE_DELTA; - case SwingConstants.HORIZONTAL: - return visibleRect.width / INCRE_DELTA; - default: - throw new IllegalArgumentException("Invalid orientation: " + orientation); - } - } + /** + * Components that display logical rows or columns should compute the scroll + * increment that will completely expose one new row or column, depending on + * the value of orientation. Ideally, components should handle a partially + * exposed row or column by returning the distance required to completely + * expose the item. + *

+ * The default implementation of this is to simply return 10% of the visible + * area. Subclasses are likely to be able to provide a much more reasonable + * value. + * + * @param visibleRect the view area visible within the viewport + * @param orientation either SwingConstants.VERTICAL or + * SwingConstants.HORIZONTAL + * @param direction less than zero to scroll up/left, greater than zero for + * down/right + * @return the "unit" increment for scrolling in the specified direction + * @throws IllegalArgumentException for an invalid orientation + * @see javax.swing.JScrollBar#setUnitIncrement + */ + public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { + switch (orientation) { + case SwingConstants.VERTICAL: + return visibleRect.height / INCRE_DELTA; + case SwingConstants.HORIZONTAL: + return visibleRect.width / INCRE_DELTA; + default: + throw new IllegalArgumentException("Invalid orientation: " + orientation); + } + } - /** - * Components that display logical rows or columns should compute the scroll - * increment that will completely expose one block of rows or columns, - * depending on the value of orientation. - *

- * The default implementation of this is to simply return the visible area. - * Subclasses will likely be able to provide a much more reasonable value. - * - * @param visibleRect - * the view area visible within the viewport - * @param orientation - * either SwingConstants.VERTICAL or - * SwingConstants.HORIZONTAL - * @param direction - * less than zero to scroll up/left, greater than zero for - * down/right - * @return the "block" increment for scrolling in the specified direction - * @throws IllegalArgumentException - * for an invalid orientation - * @see javax.swing.JScrollBar#setBlockIncrement - */ - public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { - switch (orientation) { - case SwingConstants.VERTICAL: - return visibleRect.height; - case SwingConstants.HORIZONTAL: - return visibleRect.width; - default: - throw new IllegalArgumentException("Invalid orientation: " + orientation); - } - } + /** + * Components that display logical rows or columns should compute the scroll + * increment that will completely expose one block of rows or columns, + * depending on the value of orientation. + *

+ * The default implementation of this is to simply return the visible area. + * Subclasses will likely be able to provide a much more reasonable value. + * + * @param visibleRect the view area visible within the viewport + * @param orientation either SwingConstants.VERTICAL or + * SwingConstants.HORIZONTAL + * @param direction less than zero to scroll up/left, greater than zero for + * down/right + * @return the "block" increment for scrolling in the specified direction + * @throws IllegalArgumentException for an invalid orientation + * @see javax.swing.JScrollBar#setBlockIncrement + */ + public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { + switch (orientation) { + case SwingConstants.VERTICAL: + return visibleRect.height; + case SwingConstants.HORIZONTAL: + return visibleRect.width; + default: + throw new IllegalArgumentException("Invalid orientation: " + orientation); + } + } - /** - * Returns true if a viewport should always force the width of this - * Scrollable to match the width of the viewport. For example a - * normal text view that supported line wrapping would return true here, - * since it would be undesirable for wrapped lines to disappear beyond the - * right edge of the viewport. Note that returning true for a - * Scrollable whose ancestor is a JScrollPane - * effectively disables horizontal scrolling. - *

- * Scrolling containers, like JViewport, will use this method - * each time they are validated. - * - * @return true if a viewport should force the Scrollables - * width to match its own - */ - public boolean getScrollableTracksViewportWidth() { - if (getParent() instanceof JViewport) { - return (getParent().getWidth() > getPreferredSize().width); - } - return false; - } + /** + * Returns true if a viewport should always force the width of this + * Scrollable to match the width of the viewport. For example a + * normal text view that supported line wrapping would return true here, + * since it would be undesirable for wrapped lines to disappear beyond the + * right edge of the viewport. Note that returning true for a + * Scrollable whose ancestor is a JScrollPane + * effectively disables horizontal scrolling. + *

+ * Scrolling containers, like JViewport, will use this method + * each time they are validated. + * + * @return true if a viewport should force the Scrollables + * width to match its own + */ + public boolean getScrollableTracksViewportWidth() { + if (getParent() instanceof JViewport) { + return (getParent().getWidth() > getPreferredSize().width); + } + return false; + } - /** - * Returns true if a viewport should always force the height of this - * Scrollable to match the height of the viewport. For example - * a columnar text view that flowed text in left to right columns could - * effectively disable vertical scrolling by returning true here. - *

- * Scrolling containers, like JViewport, will use this method - * each time they are validated. - * - * @return true if a viewport should force the Scrollables height to match - * its own - */ - public boolean getScrollableTracksViewportHeight() { - if (getParent() instanceof JViewport) { - return (getParent().getHeight() > getPreferredSize().height); - } - return false; - } + /** + * Returns true if a viewport should always force the height of this + * Scrollable to match the height of the viewport. For example + * a columnar text view that flowed text in left to right columns could + * effectively disable vertical scrolling by returning true here. + *

+ * Scrolling containers, like JViewport, will use this method + * each time they are validated. + * + * @return true if a viewport should force the Scrollables height to match + * its own + */ + public boolean getScrollableTracksViewportHeight() { + if (getParent() instanceof JViewport) { + return (getParent().getHeight() > getPreferredSize().height); + } + return false; + } - public void setImageStyle(Style imageStyle) { - this.imageStyle = imageStyle; - } + public void setImageStyle(Style imageStyle) { + this.imageStyle = imageStyle; + } - public Style getImageStyle() { - return imageStyle; - } + public Style getImageStyle() { + return imageStyle; + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/form/FormECDesignerProvider.java b/designer_base/src/com/fr/design/mainframe/form/FormECDesignerProvider.java index b1ef53885c..6654f0098b 100644 --- a/designer_base/src/com/fr/design/mainframe/form/FormECDesignerProvider.java +++ b/designer_base/src/com/fr/design/mainframe/form/FormECDesignerProvider.java @@ -89,4 +89,5 @@ public interface FormECDesignerProvider { */ BufferedImage getElementCaseImage(Dimension elementCaseContainerSize); + void refreshPropertyPane(); } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/style/background/image/ExpandFileChooser.java b/designer_base/src/com/fr/design/style/background/image/ExpandFileChooser.java new file mode 100644 index 0000000000..b9690b2439 --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/image/ExpandFileChooser.java @@ -0,0 +1,196 @@ +package com.fr.design.style.background.image; + +import com.fr.base.BaseUtils; +import com.fr.design.DesignerEnvManager; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; +import com.fr.stable.StringUtils; + +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JPanel; +import javax.swing.plaf.metal.MetalFileChooserUI; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Insets; +import java.awt.LayoutManager; +import java.awt.event.ActionListener; + +/** + * 扩展的文件选择框(底部控制区域扩展一个复选框) + * Created by zack on 2018/3/8. + */ +public class ExpandFileChooser extends JFileChooser { + private JDialog dialog; + private UICheckBox checkBox;//选择框底部的复选按钮 + private int retVal = ERROR_OPTION; + private UIButton approve; + private UIButton cancel; + private static final int DEFAULT_WIDTH = 520; + + public ExpandFileChooser() { + this(StringUtils.EMPTY, StringUtils.EMPTY); + } + + public ExpandFileChooser(String checkBoxText, String approveButtonText) { + JPanel previewContainerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + MetalFileChooserUI chooserUI = (MetalFileChooserUI) getUI(); + String approveText = StringUtils.isEmpty(approveButtonText) ? chooserUI.getApproveButtonText(this) : approveButtonText; + dialog = new JDialog(); + + dialog.setSize(new Dimension(DEFAULT_WIDTH, 362)); + dialog.add(previewContainerPane); + dialog.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); + dialog.setTitle(approveText); + previewContainerPane.add(this, BorderLayout.CENTER); + + + JPanel bottomControlPanel = new JPanel(); + bottomControlPanel.setLayout(new ImageAreaLayout()); + bottomControlPanel.setPreferredSize(new Dimension(DEFAULT_WIDTH, 40)); + + approve = new UIButton(approveText); + cancel = new UIButton(Inter.getLocText("FR-Designer_Button-Cancel")); + if (StringUtils.isNotEmpty(checkBoxText)) { + checkBox = new UICheckBox(checkBoxText); + checkBox.setSelected(DesignerEnvManager.getEnvManager().isImageCompress()); + bottomControlPanel.add(checkBox); + checkBox.addActionListener(checkAction()); + } + bottomControlPanel.add(approve); + approve.addActionListener(chooserUI.getApproveSelectionAction()); + cancel.addActionListener(chooserUI.getCancelSelectionAction()); + bottomControlPanel.add(cancel); + previewContainerPane.add(bottomControlPanel, BorderLayout.SOUTH); + GUICoreUtils.centerWindow(dialog); + } + + public ActionListener checkAction() { + return null; + } + + public boolean isCheckSelected() { + if (checkBox != null) { + return checkBox.isSelected(); + } + return false; + } + + + @Override + public int showDialog(Component parent, String approveButtonText) { + dialog.setModal(true); + dialog.setVisible(true); + return retVal; + } + + @Override + public void approveSelection() { + retVal = APPROVE_OPTION; + if (dialog != null) { + dialog.setVisible(false); + } + fireActionPerformed(APPROVE_SELECTION); + } + + @Override + public void cancelSelection() { + retVal = CANCEL_OPTION; + if (dialog != null) { + dialog.setVisible(false); + } + fireActionPerformed(CANCEL_SELECTION); + } + + @Override + public boolean getControlButtonsAreShown() { + return false;//隐藏默认的控制按钮(打开/取消) + } + + private class ImageAreaLayout implements LayoutManager { + private static final int TEN = 10; + private int hGap = 5; + private int topMargin = TEN; + private int leftMargin = TEN; + private int leftStart = 8; + + @Override + public void addLayoutComponent(String string, Component comp) { + } + + @Override + public void layoutContainer(Container container) { + Component[] children = container.getComponents(); + + if (children != null && children.length > 0) { + int numChildren = children.length; + Dimension[] sizes = new Dimension[numChildren]; + Insets insets = container.getInsets(); + int yLocation = insets.top + topMargin; + int maxWidth = 0; + + for (int counter = 0; counter < numChildren; counter++) { + sizes[counter] = children[counter].getPreferredSize(); + maxWidth = Math.max(maxWidth, sizes[counter].width); + } + int xLocation, xOffset; + if (container.getComponentOrientation().isLeftToRight()) { + xLocation = container.getSize().width - insets.left - maxWidth - leftMargin; + xOffset = hGap + maxWidth; + } else { + xLocation = insets.left; + xOffset = -(hGap + maxWidth); + } + //单独设置图片压缩按钮的位置 + children[0].setBounds(leftStart, yLocation, + maxWidth, sizes[0].height); + + for (int counter = numChildren - 1; counter >= 1; counter--) { + children[counter].setBounds(xLocation, yLocation, + maxWidth, sizes[counter].height); + xLocation -= xOffset; + } + } + } + + @Override + public Dimension minimumLayoutSize(Container c) { + if (c != null) { + Component[] children = c.getComponents(); + + if (children != null && children.length > 0) { + int numChildren = children.length; + int height = 0; + Insets cInsets = c.getInsets(); + int extraHeight = topMargin + cInsets.top + cInsets.bottom; + int extraWidth = cInsets.left + cInsets.right; + int maxWidth = 0; + + for (int counter = 0; counter < numChildren; counter++) { + Dimension aSize = children[counter].getPreferredSize(); + height = Math.max(height, aSize.height); + maxWidth = Math.max(maxWidth, aSize.width); + } + return new Dimension(extraWidth + numChildren * maxWidth + + (numChildren - 1) * hGap, + extraHeight + height); + } + } + return new Dimension(0, 0); + } + + @Override + public Dimension preferredLayoutSize(Container c) { + return minimumLayoutSize(c); + } + + @Override + public void removeLayoutComponent(Component c) { + } + } +} diff --git a/designer_base/src/com/fr/design/style/background/image/ImageFileChooser.java b/designer_base/src/com/fr/design/style/background/image/ImageFileChooser.java index e2fc8862a9..2ec203ff5a 100644 --- a/designer_base/src/com/fr/design/style/background/image/ImageFileChooser.java +++ b/designer_base/src/com/fr/design/style/background/image/ImageFileChooser.java @@ -3,25 +3,27 @@ */ package com.fr.design.style.background.image; +import com.fr.base.BaseUtils; +import com.fr.design.DesignerEnvManager; +import com.fr.design.style.ChooseFileView; +import com.fr.general.Inter; + +import javax.swing.filechooser.FileFilter; import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.io.File; import java.util.Enumeration; import java.util.Hashtable; -import javax.swing.JFileChooser; -import javax.swing.filechooser.FileFilter; - -import com.fr.base.BaseUtils; -import com.fr.general.Inter; -import com.fr.design.style.ChooseFileView; - /** * This class used to choose image files. */ -public class ImageFileChooser extends JFileChooser { +public class ImageFileChooser extends ExpandFileChooser { public ImageFileChooser() { + super(Inter.getLocText("FR-Designer_Image_Compress"),Inter.getLocText("FR-Designer_Open")); ExampleFileFilter bothFilter = new ExampleFileFilter( new String[]{"jpg", "gif", "png", "bmp"}, Inter.getLocText("Image-Image_Files")); @@ -43,12 +45,23 @@ public class ImageFileChooser extends JFileChooser { return super.showDialog(parent, approveButtonText); } + @Override + public ActionListener checkAction() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + DesignerEnvManager.getEnvManager().setImageCompress(isCheckSelected()); + DesignerEnvManager.getEnvManager().saveXMLFile(); + } + }; + + } /** * A convenience implementation of FileFilter that filters out * all files except for those type extensions that it knows about. *

D:\finereport\develop\code\test\TestCase\WEB-INF\reportlets\TestCase\01903.cpt - + *

* Extensions are of the type ".foo", which is typically found on * Windows and Unix boxes, but not on Macinthosh. Case is ignored. *

diff --git a/designer_base/src/com/fr/design/style/background/image/ImagePreviewPane.java b/designer_base/src/com/fr/design/style/background/image/ImagePreviewPane.java index 862a01fa2b..edbcd7d619 100644 --- a/designer_base/src/com/fr/design/style/background/image/ImagePreviewPane.java +++ b/designer_base/src/com/fr/design/style/background/image/ImagePreviewPane.java @@ -3,12 +3,12 @@ */ package com.fr.design.style.background.image; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.List; +import com.fr.base.BaseUtils; +import com.fr.base.GraphHelper; +import com.fr.base.Style; +import com.fr.design.gui.iscrollbar.UIScrollBar; +import com.fr.general.Inter; +import com.fr.stable.CoreGraphHelper; import javax.swing.JComponent; import javax.swing.JViewport; @@ -16,27 +16,28 @@ import javax.swing.Scrollable; import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; - -import com.fr.base.BaseUtils; -import com.fr.base.GraphHelper; -import com.fr.base.Style; -import com.fr.design.gui.iscrollbar.UIScrollBar; -import com.fr.stable.CoreGraphHelper; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.List; /** * The pane use to preview image */ -public class ImagePreviewPane extends JComponent implements Scrollable { +public class ImagePreviewPane extends JComponent implements Scrollable, ImagePreviewer { private Image image = null; // carl:image style private Style imageStyle = null; - private int imageWidth = 0 ; - private int imageHeight = 0 ; + private int imageWidth = 0; + private int imageHeight = 0; + private boolean isLoading = false; private List changeListenerList = new ArrayList(); public ImagePreviewPane() { - this.setToolTipText("View Image"); + this.setToolTipText("View Image"); } /** @@ -46,6 +47,12 @@ public class ImagePreviewPane extends JComponent implements Scrollable { return this.image; } + public void showLoading() { + isLoading = true; + setImage(null); + repaint(); + } + /** * Set image. * @@ -55,7 +62,7 @@ public class ImagePreviewPane extends JComponent implements Scrollable { this.image = image; //need to reset the size of JViewPort. if (this.image == null) { - if(this.getParent() instanceof JViewport) { + if (this.getParent() instanceof JViewport) { UIScrollBar tmpJScrollBar = new UIScrollBar(UIScrollBar.HORIZONTAL); Dimension newDimension = new Dimension( this.getSize().width - tmpJScrollBar.getPreferredSize().height, @@ -67,6 +74,7 @@ public class ImagePreviewPane extends JComponent implements Scrollable { } } else { //wait for the size of image. + isLoading = false; CoreGraphHelper.waitForImage(image); imageWidth = image.getWidth(null); @@ -83,20 +91,22 @@ public class ImagePreviewPane extends JComponent implements Scrollable { */ public void paintComponent(Graphics g) { super.paintComponent(g); - - //draw image. - if (this.getImage() != null) { - // carl:让imagePreviewPane能预览样式 - if (this.getImageStyle() == null) { - g.drawImage(this.getImage(), 0, 0, this); - } else { - GraphHelper.paintImage( - g, this.getWidth(), this.getHeight(), this.getImage(), - this.getImageStyle().getImageLayout(), - BaseUtils.getAlignment4Horizontal(this.getImageStyle()), - this.getImageStyle().getVerticalAlignment(), -1, -1 - ); - } + if (isLoading) { + g.drawString(Inter.getLocText("FR-Designer_Image_Loading"), getWidth() / 2 - 25, getHeight() / 2); + return; + } + if (this.getImage() != null) { //draw image. + // carl:让imagePreviewPane能预览样式 + if (this.getImageStyle() == null) { + g.drawImage(this.getImage(), 0, 0, this); + } else { + GraphHelper.paintImage( + g, this.getWidth(), this.getHeight(), this.getImage(), + this.getImageStyle().getImageLayout(), + BaseUtils.getAlignment4Horizontal(this.getImageStyle()), + this.getImageStyle().getVerticalAlignment(), -1, -1 + ); + } } } @@ -123,7 +133,7 @@ public class ImagePreviewPane extends JComponent implements Scrollable { ChangeEvent evt = new ChangeEvent(this); for (int i = 0; i < changeListenerList.size(); i++) { - changeListenerList.get(i).stateChanged(evt); + changeListenerList.get(i).stateChanged(evt); } } } @@ -136,7 +146,7 @@ public class ImagePreviewPane extends JComponent implements Scrollable { * the preferred size of the component. * * @return the preferredSize of a JViewport - * whose view is this Scrollable + * whose view is this Scrollable */ public Dimension getPreferredScrollableViewportSize() { return getPreferredSize(); @@ -218,7 +228,7 @@ public class ImagePreviewPane extends JComponent implements Scrollable { * will use this method each time they are validated. * * @return true if a viewport should force the Scrollables - * width to match its own + * width to match its own */ public boolean getScrollableTracksViewportWidth() { if (getParent() instanceof JViewport) { @@ -238,7 +248,7 @@ public class ImagePreviewPane extends JComponent implements Scrollable { * will use this method each time they are validated. * * @return true if a viewport should force the Scrollables height - * to match its own + * to match its own */ public boolean getScrollableTracksViewportHeight() { if (getParent() instanceof JViewport) { @@ -247,11 +257,11 @@ public class ImagePreviewPane extends JComponent implements Scrollable { return false; } - public void setImageStyle(Style imageStyle) { - this.imageStyle = imageStyle; - } + public void setImageStyle(Style imageStyle) { + this.imageStyle = imageStyle; + } - public Style getImageStyle() { - return imageStyle; - } + public Style getImageStyle() { + return imageStyle; + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/style/background/image/ImagePreviewer.java b/designer_base/src/com/fr/design/style/background/image/ImagePreviewer.java new file mode 100644 index 0000000000..215671021d --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/image/ImagePreviewer.java @@ -0,0 +1,33 @@ +package com.fr.design.style.background.image; + +import com.fr.base.Style; + +import java.awt.Image; + +/** + * 图片预览接口(由于子类上层父类差别较大,无奈的接口) + * Created by zack on 2018/3/10. + */ +public interface ImagePreviewer { + /** + * 设置图片样式(平铺,拉伸) + * @param style 样式 + */ + void setImageStyle(Style style); + + /** + * 设置图片 + * @param image 图片 + */ + void setImage(Image image); + + /** + * 显示正在加载 + */ + void showLoading(); + + /** + * 重绘 + */ + void repaint(); +} diff --git a/designer_base/src/com/fr/design/style/background/image/ImageSelectPane.java b/designer_base/src/com/fr/design/style/background/image/ImageSelectPane.java index 70cb442659..02b4c4af85 100644 --- a/designer_base/src/com/fr/design/style/background/image/ImageSelectPane.java +++ b/designer_base/src/com/fr/design/style/background/image/ImageSelectPane.java @@ -1,28 +1,25 @@ package com.fr.design.style.background.image; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Image; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; - -import javax.swing.JFileChooser; -import com.fr.design.gui.ilable.UILabel; -import javax.swing.JPanel; -import javax.swing.SwingConstants; - -import com.fr.base.BaseUtils; import com.fr.base.background.ImageBackground; +import com.fr.design.gui.frpane.ImgChooseWrapper; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.AlphaPane; +import com.fr.design.style.background.BackgroundPane4BoxChange; import com.fr.general.Background; import com.fr.general.Inter; import com.fr.stable.Constants; -import com.fr.stable.CoreGraphHelper; -import com.fr.design.style.AlphaPane; -import com.fr.design.style.background.BackgroundPane4BoxChange; + +import javax.swing.JFileChooser; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** @@ -99,18 +96,12 @@ public class ImageSelectPane extends BackgroundPane4BoxChange { public void actionPerformed(ActionEvent evt) { int returnVal = imageFileChooser.showOpenDialog(ImageSelectPane.this); if (returnVal != JFileChooser.CANCEL_OPTION) { - File selectedFile = imageFileChooser.getSelectedFile(); - if (selectedFile != null && selectedFile.isFile()) { - Image image = BaseUtils.readImage(selectedFile.getPath()); - CoreGraphHelper.waitForImage(image); - selectImage = image; - } - chechLabelText(); + ImgChooseWrapper.getInstance(selectImage,imageSizeLabel,imageFileChooser).dealWithImageFile(returnVal); } } }; - private void chechLabelText() { + private void checkLabelText() { if (selectImage == null) { imageSizeLabel.setText(""); } else { @@ -133,7 +124,7 @@ public class ImageSelectPane extends BackgroundPane4BoxChange { } - chechLabelText(); + checkLabelText(); } public void populateAlpha(int alpha) { diff --git a/designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane.java b/designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane.java index ced818426c..4af1c6ccd6 100644 --- a/designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane.java +++ b/designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane.java @@ -1,8 +1,8 @@ package com.fr.design.style.background.impl; -import com.fr.base.BaseUtils; import com.fr.base.Style; import com.fr.base.background.ImageBackground; +import com.fr.design.gui.frpane.ImgChooseWrapper; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ilable.UILabel; @@ -13,15 +13,18 @@ import com.fr.design.style.background.image.ImagePreviewPane; import com.fr.general.Background; import com.fr.general.Inter; import com.fr.stable.Constants; -import com.fr.stable.CoreGraphHelper; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import javax.swing.JScrollPane; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.File; /** * Image background pane. @@ -60,7 +63,7 @@ public class ImageBackgroundPane extends BackgroundDetailPane { imageFileChooser.setMultiSelectionEnabled(false); } - public JPanel initSelectFilePane(){ + public JPanel initSelectFilePane() { JPanel selectFilePane = FRGUIPaneFactory.createBorderLayout_L_Pane(); selectFilePane.setBorder(BorderFactory.createEmptyBorder(8, 2, 4, 0)); @@ -116,31 +119,12 @@ public class ImageBackgroundPane extends BackgroundDetailPane { public void actionPerformed(ActionEvent evt) { int returnVal = imageFileChooser.showOpenDialog(ImageBackgroundPane.this); - if (returnVal != JFileChooser.CANCEL_OPTION) { - File selectedFile = imageFileChooser.getSelectedFile(); - - if (selectedFile != null && selectedFile.isFile()) { - Image image = BaseUtils.readImage(selectedFile.getPath()); - CoreGraphHelper.waitForImage(image); - - previewPane.setImage(image); - imageStyleRepaint(); - previewPane.repaint(); - } else { - previewPane.setImage(null); - } - } - - fireChagneListener(); + setImageStyle(); + ImgChooseWrapper.getInstance(previewPane, imageFileChooser, imageStyle, changeListener).dealWithImageFile(returnVal); } }; - public void imageStyleRepaint(){ - setImageStyle(); - previewPane.setImageStyle(imageStyle); - } - - private void setImageStyle() { + protected void setImageStyle() { if (tiledRadioButton.isSelected()) { imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); } else if (adjustRadioButton.isSelected()) { diff --git a/designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane4Browser.java b/designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane4Browser.java index 431ad2c0d1..537d03e575 100644 --- a/designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane4Browser.java +++ b/designer_base/src/com/fr/design/style/background/impl/ImageBackgroundPane4Browser.java @@ -1,10 +1,5 @@ package com.fr.design.style.background.impl; -import com.fr.design.gui.ibutton.UIRadioButton; -import com.fr.stable.ArrayUtils; - -import javax.swing.*; - /** * Created by richie on 16/5/18. */ @@ -15,12 +10,4 @@ public class ImageBackgroundPane4Browser extends ImageBackgroundPane { super(); } - @Override - protected UIRadioButton[] imageLayoutButtons() { - - return (UIRadioButton[]) ArrayUtils.addAll(super.imageLayoutButtons(), new UIRadioButton[] { - defaultRadioButton, - tiledRadioButton, - }); - } } diff --git a/designer_base/src/com/fr/design/style/background/impl/ImageButtonBackgroundPane.java b/designer_base/src/com/fr/design/style/background/impl/ImageButtonBackgroundPane.java index b72e67bae7..2332cd843e 100644 --- a/designer_base/src/com/fr/design/style/background/impl/ImageButtonBackgroundPane.java +++ b/designer_base/src/com/fr/design/style/background/impl/ImageButtonBackgroundPane.java @@ -6,8 +6,11 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.general.Background; import com.fr.general.Inter; import com.fr.stable.Constants; -import javax.swing.*; -import java.awt.*; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -18,13 +21,13 @@ public class ImageButtonBackgroundPane extends ImageBackgroundPane { private UIButton chooseButton; private UIButton clearButton; - public ImageButtonBackgroundPane(){ + public ImageButtonBackgroundPane() { super(); Style imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); previewPane.setImageStyle(imageStyle); } - public JPanel initSelectFilePane(){ + public JPanel initSelectFilePane() { JPanel choosePane = new JPanel(new BorderLayout(0, 10)); choosePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); @@ -33,12 +36,12 @@ public class ImageButtonBackgroundPane extends ImageBackgroundPane { choosePane.add(chooseButton, BorderLayout.NORTH); - choosePane1.add(clearButton,BorderLayout.NORTH); - choosePane.add(choosePane1,BorderLayout.CENTER); + choosePane1.add(clearButton, BorderLayout.NORTH); + choosePane.add(choosePane1, BorderLayout.CENTER); imageSizeLabel.setHorizontalAlignment(SwingConstants.CENTER); - choosePane1.add(imageSizeLabel,BorderLayout.CENTER); - this.add(choosePane,BorderLayout.EAST); + choosePane1.add(imageSizeLabel, BorderLayout.CENTER); + this.add(choosePane, BorderLayout.EAST); return choosePane; } @@ -55,15 +58,14 @@ public class ImageButtonBackgroundPane extends ImageBackgroundPane { }); } - public void imageStyleRepaint(){ - + @Override + protected void setImageStyle() { } - public void populate(Background background) { - if(background != null && background instanceof ImageBackground){ + if (background != null && background instanceof ImageBackground) { ImageBackground imageBackground = (ImageBackground) background; - if(imageBackground.getImage() != null) { + if (imageBackground.getImage() != null) { previewPane.setImage(imageBackground.getImage()); } } @@ -71,7 +73,7 @@ public class ImageButtonBackgroundPane extends ImageBackgroundPane { } public Background update() { - if(previewPane.getImage() == null) { + if (previewPane.getImage() == null) { return null; } return new ImageBackground(previewPane.getImage()); diff --git a/designer_base/src/com/fr/design/utils/ImageUtils.java b/designer_base/src/com/fr/design/utils/ImageUtils.java new file mode 100644 index 0000000000..9698b9ae70 --- /dev/null +++ b/designer_base/src/com/fr/design/utils/ImageUtils.java @@ -0,0 +1,178 @@ +package com.fr.design.utils; + +import com.fr.base.BaseUtils; +import com.fr.general.ComparatorUtils; +import com.fr.general.FRLogger; +import com.fr.stable.StringUtils; + +import javax.imageio.IIOImage; +import javax.imageio.ImageIO; +import javax.imageio.ImageReader; +import javax.imageio.ImageWriteParam; +import javax.imageio.ImageWriter; +import javax.imageio.stream.ImageInputStream; +import javax.imageio.stream.ImageOutputStream; +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.util.Iterator; + +/** + * 设计器部分的图片处理工具类 + * Created by zack on 2018/3/8. + */ +public class ImageUtils { + + /** + * 默认压缩算法,采用75%质量压缩 + * + * @param imageFile 原文件 + * @return 压缩后的BufferedImage对象 + */ + public static BufferedImage defaultImageCompress(File imageFile) { + try { + return imageCompress(imageFile, 0.75f);//默认75%质量 + } catch (IOException e) { + FRLogger.getLogger().info("image compress failed!"); + + } + return BaseUtils.readImage(imageFile.getPath()); + } + + /** + * 图片压缩 + * + * @param imageFile 原文件 + * @param quality 质量系数(0-1) + * @return 压缩后的图片 + * @throws IOException + */ + public static BufferedImage imageCompress(File imageFile, float quality) throws IOException { + BufferedImage result = BaseUtils.readImage(imageFile.getPath()); + if (imageFile == null) { + return null; + } + if (canbeCompressedToJPEG(imageFile)) { + return jpegCompress(result, quality); + } + return result; + } + + public static boolean canbeCompressedToJPEG(File imageFile) { + if (ComparatorUtils.equals(getImageType(imageFile), "JPEG")) {//JPEG大写 + return true; + } + if (ComparatorUtils.equals(getImageType(imageFile), "png")) {//png小写 + return !isAlphaAreaOverload(imageFile);//少量透明度系数的png直接压缩jpg + } + return false; + } + + /** + * JPEG格式图片压缩 + * + * @param image 压缩源图片 + * @param quality 压缩质量,在0-1之间, + * @return 返回的字节数组 + */ + public static BufferedImage jpegCompress(BufferedImage image, float quality) throws IOException { + if (image == null) { + return null; + } + // 得到指定Format图片的writer + Iterator iter = ImageIO + .getImageWritersByFormatName("jpeg");// 得到迭代器 + ImageWriter writer = iter.next(); + + // 得到指定writer的输出参数设置(ImageWriteParam ) + ImageWriteParam iwp = writer.getDefaultWriteParam(); + iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); // 设置可否压缩 + iwp.setCompressionQuality(quality); // 设置压缩质量参数 + iwp.setProgressiveMode(ImageWriteParam.MODE_DISABLED); + + // 开始打包图片,写入byte[] + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + ImageOutputStream ios = null; + ByteArrayInputStream in = null; + try { + image = copy(image, BufferedImage.TYPE_INT_RGB); + ios = ImageIO.createImageOutputStream(byteArrayOutputStream); + writer.setOutput(ios); + writer.write(null, new IIOImage(image, null, null), iwp); + in = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); + if (ios == null || in == null) { + throw new IOException("The image file cannot be compressed"); + } + return ImageIO.read(in); + } finally { + writer.dispose(); + ios.close(); + byteArrayOutputStream.close(); + in.close(); + } + } + + /** + * 判断图片中是否包含多于5%的透明区域,这个5%随便定的 + * + * @param imageFile 目标图片 + * @return 含透明度像素占比 + */ + public static boolean isAlphaAreaOverload(File imageFile) { + if (imageFile == null || !imageFile.isFile()) { + return false; + } + BufferedImage bufferedImage = BaseUtils.readImage(imageFile.getPath()); + int width = bufferedImage.getWidth(); + int height = bufferedImage.getHeight(); + long alphaCount = 0; + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) { + int rgb = bufferedImage.getRGB(i, j); + int a = (0xff & (rgb >> 24)); + if (a != 0xff) { + alphaCount++; + } + } + } + return alphaCount / (double) (width * height) > 0.05; + } + + /** + * 获取图片类型 + * + * @param imageFile 图片文件 + * @return 图片类型(JPEG, PNG, GIF) + */ + public static String getImageType(File imageFile) { + try { + ImageInputStream iis = ImageIO.createImageInputStream(imageFile); + Iterator iter = ImageIO.getImageReaders(iis); + if (!iter.hasNext()) { + return StringUtils.EMPTY; + } + ImageReader reader = iter.next(); + iis.close(); + return reader.getFormatName(); + } catch (IOException ignore) { + } + return StringUtils.EMPTY; + } + + private static BufferedImage copy(BufferedImage img, int imageType) { + int width = img.getWidth(); + int height = img.getHeight(); + + BufferedImage newImage = new BufferedImage(width, height, imageType); + Graphics g = newImage.createGraphics(); + + g.drawImage(img, 0, 0, null); + + g.dispose(); + + return newImage; + } +} diff --git a/designer_base/src/com/fr/design/utils/gui/GUICoreUtils.java b/designer_base/src/com/fr/design/utils/gui/GUICoreUtils.java index 0225cf5424..565bdc75f1 100644 --- a/designer_base/src/com/fr/design/utils/gui/GUICoreUtils.java +++ b/designer_base/src/com/fr/design/utils/gui/GUICoreUtils.java @@ -12,6 +12,7 @@ import com.fr.design.actions.core.ActionFactory; import com.fr.design.border.UITitledBorder; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.EditTextField; @@ -37,6 +38,7 @@ import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.image.BufferedImage; import java.awt.image.ImageObserver; @@ -844,4 +846,50 @@ public abstract class GUICoreUtils{ && oneRect.getWidth() == otherRect.getWidth() && oneRect.getHeight() == otherRect.getHeight(); } + + /** + * 生成提示标签 + * @param tipText 提示文字 + * @return UILabel 标签对象 + */ + public static UILabel createTipLabel(String tipText) { + UILabel tipLabel = new UILabel("" + tipText + ""); + tipLabel.setForeground(Color.gray); + return tipLabel; + } + + /** + * 生成没有边框的 UICheckBox + * @param text 说明文字 + * @return UICheckBox + */ + public static UICheckBox createNoBorderCheckBox(String text) { + UICheckBox checkBox = new UICheckBox(text); + checkBox.setBorder(BorderFactory.createEmptyBorder()); + return checkBox; + } + + /** + * 创建包含选择框和一个动态面板的联动面板。根据选择框的状态,动态面板会动态地显示或隐藏 + * @param checkBox 选择框 + * @param dynamicPane 包含任意内容的动态面板 + * @param hideOnSelected 选中时隐藏动态面板(若为false,则在"去掉勾选"时隐藏动态面板) + * @return 联动面板 + */ + public static JPanel createCheckboxAndDynamicPane(UICheckBox checkBox, final JPanel dynamicPane, final boolean hideOnSelected) { + checkBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + int visibleState = hideOnSelected ? ItemEvent.DESELECTED : ItemEvent.SELECTED; + dynamicPane.setVisible(e.getStateChange() == visibleState); + } + }); + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.add(checkBox, BorderLayout.NORTH); + JPanel dynamicPaneWrapper = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + dynamicPaneWrapper.add(dynamicPane); + panel.add(dynamicPaneWrapper, BorderLayout.CENTER); + return panel; + } + } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java b/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java index 42de5bacdf..cbef10ee49 100644 --- a/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java +++ b/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java @@ -13,6 +13,7 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.style.background.image.ImageFileChooser; import com.fr.design.style.background.image.ImagePreviewPane; +import com.fr.design.utils.ImageUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRLogger; import com.fr.general.GeneralContext; @@ -21,20 +22,21 @@ import com.fr.general.Inter; import com.fr.stable.CoreGraphHelper; import com.fr.stable.StringUtils; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; import javax.swing.JFileChooser; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.ButtonGroup; -import java.awt.Image; -import java.awt.Dimension; +import javax.swing.SwingWorker; +import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.GridLayout; +import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; /** * Created by mengao on 2017/11/23. @@ -57,11 +59,12 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane { private ImageFileChooser imageFileChooser; private Image emptyDataImage = DEFAULT_EMPTY_DATA_IMAGE; + private SwingWorker imageWorker; static { DEFAULT_EMPTY_DATA_IMAGE = GeneralContext.isChineseEnv() ? IOUtils.readImage("com/fr/design/images/zh_emptydata.png") - : IOUtils.readImage("com/fr/design/images/us_emptydata.png"); + : IOUtils.readImage("com/fr/design/images/us_emptydata.png"); } @Override @@ -161,13 +164,23 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane { public void actionPerformed(ActionEvent evt) { int returnVal = imageFileChooser.showOpenDialog(ChartEmptyDataStylePane.this); if (returnVal != JFileChooser.CANCEL_OPTION) { - File selectedFile = imageFileChooser.getSelectedFile(); + final File selectedFile = imageFileChooser.getSelectedFile(); if (selectedFile != null && selectedFile.isFile()) { - emptyDataImage = BaseUtils.readImage(selectedFile.getPath()); - CoreGraphHelper.waitForImage(emptyDataImage); - repaintPreviewPane(); - + previewPane.showLoading(); + if (imageWorker != null && !imageWorker.isDone()) { + imageWorker = null; + } + imageWorker = new SwingWorker() { + @Override + protected Void doInBackground() throws Exception { + emptyDataImage = imageFileChooser.isCheckSelected() ? ImageUtils.defaultImageCompress(selectedFile) : BaseUtils.readImage(selectedFile.getPath()); + CoreGraphHelper.waitForImage(emptyDataImage); + repaintPreviewPane(); + return null; + } + }; + imageWorker.execute(); } else { previewPane.setImage(null); } diff --git a/designer_chart/src/com/fr/plugin/chart/designer/other/VanChartInteractivePane.java b/designer_chart/src/com/fr/plugin/chart/designer/other/VanChartInteractivePane.java index 2f10e968c4..78490c4fcd 100644 --- a/designer_chart/src/com/fr/plugin/chart/designer/other/VanChartInteractivePane.java +++ b/designer_chart/src/com/fr/plugin/chart/designer/other/VanChartInteractivePane.java @@ -28,6 +28,8 @@ import com.fr.plugin.chart.vanchart.VanChart; import com.fr.stable.StableUtils; import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -163,6 +165,12 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { } axisRotation = new UIButtonGroup(new String[]{Inter.getLocText("Plugin-ChartF_Open"), Inter.getLocText("Plugin-ChartF_Close")}); + axisRotation.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + checkZoomEnabled(); + } + }); Component[][] components = new Component[][]{ new Component[]{null,null}, new Component[]{new UILabel(Inter.getLocText("Plugin-ChartF_Reversal")),axisRotation} @@ -171,6 +179,14 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Inter.getLocText("Plugin-ChartF_Axis"), panel); } + private void checkZoomEnabled() { + if (zoomWidget != null && axisRotation != null) { + zoomWidget.setSelectedIndex(1); + checkZoomPane(); + zoomWidget.setEnabled(axisRotation.getSelectedIndex() == 1); + } + } + protected String[] getNameArray() { return new String[]{Inter.getLocText("ChartF-X_Axis"), Inter.getLocText("ChartF-Y_Axis") ,Inter.getLocText("Plugin-ChartF_XYAxis"),Inter.getLocText("Chart-Use_None")}; @@ -273,6 +289,8 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { populateAutoRefresh((VanChart)chart); populateHyperlink(plot); + + checkZoomEnabled(); } diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index f818c1ee1d..ef9b95ff5b 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -811,7 +811,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { if (ry != y) { calculateNoRelatedWhileRightTop(rec, rightComp); } else { - calculateNoRelatedWhileRightBott(rec, rightComp); + calculateNoRelatedWhileRightBott(rec); } } @@ -856,8 +856,11 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height, true); } - private void calculateNoRelatedWhileRightBott(Rectangle bound, Component rcomp) { - rcomp = container.getBottomRightComp(bound.x, bound.y, bound.height, bound.width); + private void calculateNoRelatedWhileRightBott(Rectangle bound) { + Component rcomp = container.getBottomRightComp(bound.x, bound.y, bound.height, bound.width); + if(rcomp == null){ + return; + } int ry = rcomp.getY(); int rh = rcomp.getHeight(); int rw = rcomp.getWidth(); diff --git a/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java b/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java index fe94edc3b2..c7121f0e16 100644 --- a/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java @@ -65,6 +65,19 @@ public class SelectionModel { if (e.getButton() == MouseEvent.BUTTON3 || (!InputEventBaseOnOS.isControlDown(e) && !e.isShiftDown())) { // 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件 selection.reset(); + } else { + //按下Ctrl或者shift键时鼠标可以进行多选,两次点击同一控件就取消选中 + XCreator comp = designer.getComponentAt(e); + XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout(); + if (topLayout != null && !topLayout.isEditable()) { + comp = topLayout; + } + XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(comp); + for (XCreator selected : selection.getSelectedCreators()) { + if (selected == comp || XCreatorUtils.getParentXLayoutContainer(selected) != container) { + selection.removeCreator(selected); + } + } } // 获取e所在的组件 XCreator comp = designer.getComponentAt(e); diff --git a/designer_form/src/com/fr/design/designer/creator/XChartEditor.java b/designer_form/src/com/fr/design/designer/creator/XChartEditor.java index b4e2652100..a8562d644c 100644 --- a/designer_form/src/com/fr/design/designer/creator/XChartEditor.java +++ b/designer_form/src/com/fr/design/designer/creator/XChartEditor.java @@ -47,7 +47,6 @@ public class XChartEditor extends XBorderStyleWidgetCreator { private boolean isEditing = false; private boolean isHovering = false; - private JPanel coverPanel; private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30); private static final Color INNER_BORDER_COLOR = new Color(65, 155, 249); @@ -247,6 +246,10 @@ public class XChartEditor extends XBorderStyleWidgetCreator { editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter); } } + HelpDialogManager.getInstance().setPane(coverPanel); + if (this.isHelpBtnOnFocus()) { + coverPanel.setMsgDisplay(e); + } } @Override @@ -275,7 +278,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator { editor.setLayout(null); editor.setOpaque(false); - coverPanel = new CoverPane(); + coverPanel = new CoverReportPane(); coverPanel.setPreferredSize(this.getPreferredSize()); coverPanel.setBounds(this.getBounds()); diff --git a/designer_form/src/com/fr/design/designer/creator/XCreator.java b/designer_form/src/com/fr/design/designer/creator/XCreator.java index 3592f4671a..a9d6ad3df1 100644 --- a/designer_form/src/com/fr/design/designer/creator/XCreator.java +++ b/designer_form/src/com/fr/design/designer/creator/XCreator.java @@ -15,6 +15,7 @@ import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.AuthorityPropertyPane; import com.fr.design.mainframe.BaseJForm; +import com.fr.design.mainframe.CoverReportPane; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.NoSupportAuthorityEdit; @@ -58,6 +59,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo protected Widget data; protected JComponent editor; + protected CoverReportPane coverPanel; // XCreator加入到某些XLayoutContainer中时,能调整宽度或者高度 private int[] directions; private Rectangle backupBound; @@ -635,7 +637,31 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo * 设置描述信息 * @param msg 帮助信息 */ - public void setXDescrption(String msg){} + public void setXDescrption(String msg){ + if (coverPanel != null) { + coverPanel.setHelpMsg(msg); + } + } + + public JComponent getCoverPane(){ + return coverPanel; + } + + /** + * 销毁帮助提示框 + */ + public void destroyHelpDialog(){ + if (coverPanel != null) { + coverPanel.destroyHelpDialog(); + } + } + + /** + * 是否展现覆盖的pane + * @param display 是否 + */ + public void displayCoverPane(boolean display){ + } /** * 根据widget设置Xcreator描述信息 @@ -645,7 +671,6 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo if (widget != null) { setXDescrption(widget.getDescription()); } - } /** diff --git a/designer_form/src/com/fr/design/designer/creator/XElementCase.java b/designer_form/src/com/fr/design/designer/creator/XElementCase.java index cece2042ba..87eb34b851 100644 --- a/designer_form/src/com/fr/design/designer/creator/XElementCase.java +++ b/designer_form/src/com/fr/design/designer/creator/XElementCase.java @@ -1,355 +1,335 @@ -package com.fr.design.designer.creator; - -import com.fr.base.BaseUtils; -import com.fr.base.GraphHelper; -import com.fr.design.ExtraDesignClassManager; -import com.fr.design.designer.properties.mobile.ElementCasePropertyUI; -import com.fr.design.form.util.XCreatorConstants; -import com.fr.design.fun.FormElementCaseEditorProcessor; -import com.fr.design.fun.FormElementCaseEditorProvider; -import com.fr.design.fun.WidgetPropertyUIProvider; -import com.fr.design.fun.impl.AbstractFormElementCaseEditorProvider; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.*; -import com.fr.design.mainframe.widget.editors.ElementCaseToolBarEditor; -import com.fr.design.mainframe.widget.editors.PaddingMarginEditor; -import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; -import com.fr.form.FormElementCaseContainerProvider; -import com.fr.form.FormElementCaseProvider; -import com.fr.form.FormProvider; -import com.fr.form.ui.ElementCaseEditor; -import com.fr.form.ui.ElementCaseEditorProvider; -import com.fr.general.Inter; -import com.fr.stable.ArrayUtils; -import com.fr.stable.Constants; -import com.fr.stable.CoreGraphHelper; -import com.fr.stable.core.PropertyChangeAdapter; -import com.fr.stable.fun.FitProvider; -import com.fr.stable.fun.ReportFitAttrProvider; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseEvent; -import java.awt.image.BufferedImage; -import java.beans.IntrospectionException; -import java.beans.PropertyDescriptor; -import java.util.Set; - -public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider{ - private UILabel imageLable; - private CoverReportPane coverPanel; - private FormDesigner designer; - private static BufferedImage DEFAULT_BACKGROUND; - private boolean isHovering = false; - - static{ - try{ - DEFAULT_BACKGROUND = BaseUtils.readImageWithCache("com/fr/base/images/report/elementcase.png"); - }catch (Throwable e) { - //IBM jdk 1.5.0_22 并发下读取图片有时会异常(EOFException), 这个图片反正只有设计器用到, 捕获住 - DEFAULT_BACKGROUND = CoreGraphHelper.createBufferedImage(0, 0); - } - } - - public XElementCase(ElementCaseEditor widget, Dimension initSize) { - super(widget, initSize); - - - } - - protected void initXCreatorProperties() { - super.initXCreatorProperties(); - - // 报表块初始化时要加载对应的borderStyle - initBorderStyle(); - } - - /** - * 是否支持设置标题 - * @return 是返回true - */ - public boolean hasTitleStyle() { - return true; - } - - /** - * 返回组件属性值 - * @return 返回组件属性值 - * @throws IntrospectionException 异常 - */ - public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { - - CRPropertyDescriptor[] propertyTableEditor = new CRPropertyDescriptor[]{ - new CRPropertyDescriptor("widgetName", this.data.getClass()) - .setI18NName(Inter.getLocText("Form-Widget_Name")), - new CRPropertyDescriptor("visible", this.data.getClass()).setI18NName( - Inter.getLocText("FR-Designer_Widget-Visible")).setPropertyChangeListener(new PropertyChangeAdapter() { - - @Override - public void propertyChange() { - makeVisible(toData().isVisible()); - } - }), - new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( - WLayoutBorderStyleEditor.class).setI18NName( - Inter.getLocText("FR-Designer-Widget_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") - .setPropertyChangeListener(new PropertyChangeAdapter() { - - @Override - public void propertyChange() { - initStyle(); - } - }), - new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) - .setI18NName(Inter.getLocText("FR-Layout_Padding")) - .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), - new CRPropertyDescriptor("toolBars", this.data.getClass()).setEditorClass(ElementCaseToolBarEditor.class) - .setI18NName(Inter.getLocText("Form-EC_toolbar")) - .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") - }; - CRPropertyDescriptor[] extraTableEditor = getExtraTableEditor(); - return (CRPropertyDescriptor[]) ArrayUtils.addAll(propertyTableEditor, extraTableEditor); - } - - public CRPropertyDescriptor[] getExtraTableEditor(){ - CRPropertyDescriptor[] extraTableEditor = resolveCompatible(); - FormElementCaseEditorProcessor processor = ExtraDesignClassManager.getInstance().getSingle(FormElementCaseEditorProcessor.MARK_STRING); - if (processor == null) { - return extraTableEditor; - } - this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - FitProvider wbTpl = (FitProvider) designer.getTarget(); - ReportFitAttrProvider fitAttr = wbTpl.getFitAttr(); - ElementCaseEditor editor = this.toData(); - //兼容之前报表块(之前三个选项为:默认 横向 双向 现在是:横向 双向 不自适应) - if (editor.getFitStateInPC() == 0 || processor.getFitStateInPC(fitAttr) == 0 ) { - editor.setReportFitAttr(null); - } - - ReportFitAttrProvider reportFit = editor.getReportFitAttr(); - if(fitAttr != null){ - reportFit = fitAttr.fitInBrowser() ? editor.getReportFitAttr() : fitAttr; - } - ReportFitAttrProvider reportFitAttr = editor.getReportFitAttr() == null ? fitAttr : reportFit; - PropertyDescriptor[] extraEditor = processor.createPropertyDescriptor(this.data.getClass(), reportFitAttr); - if (editor.getReportFitAttr() == null) { - editor.setReportFitInPc(processor.getFitStateInPC(fitAttr)); - } - return (CRPropertyDescriptor[]) ArrayUtils.addAll(extraTableEditor, extraEditor); - } - - - private CRPropertyDescriptor[] resolveCompatible() { - CRPropertyDescriptor[] extraProperty = new CRPropertyDescriptor[0]; - //这边有个插件兼容问题,之后还是要改回process才行 - Set set = ExtraDesignClassManager.getInstance().getArray(AbstractFormElementCaseEditorProvider.MARK_STRING); - for (FormElementCaseEditorProvider provider : set) { - if (provider == null) { - continue; - } - this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - FormProvider formProvider = designer.getTarget(); - ElementCaseEditorProvider elementCaseEditorProvider = this.toData(); - PropertyDescriptor[] extraEditor = provider.createPropertyDescriptor(this.data.getClass(), formProvider, elementCaseEditorProvider); - extraProperty = (CRPropertyDescriptor[]) ArrayUtils.addAll(extraProperty, extraEditor); - } - return extraProperty; - } - - @Override - protected String getIconName() { - return "text_field_16.png"; - } - - /** - * 返回组件默认名 - * @return 组件类名(小写) - */ - public String createDefaultName() { - return "report"; - } - - @Override - protected JComponent initEditor() { - if (editor == null) { - setBorder(DEFALUTBORDER); - editor = new JPanel(); - editor.setBackground(null); - editor.setLayout(null); - imageLable = initImageBackground(); - - coverPanel = new CoverReportPane(); - coverPanel.setPreferredSize(imageLable.getPreferredSize()); - coverPanel.setBounds(imageLable.getBounds()); - - editor.add(coverPanel); - coverPanel.setVisible(false); - editor.add(imageLable); - } - return editor; - } - - /** - * 从data中获取到图片背景, 并设置到Label上 - */ - private UILabel initImageBackground(){ - UILabel imageLable = new UILabel(); - BufferedImage image = toData().getECImage(); - if (image == null) { - image = DEFAULT_BACKGROUND; - } - setLabelBackground(image, imageLable); - - return imageLable; - } - - /** - * 设置指定Label的背景 - */ - private void setLabelBackground(Image image, UILabel imageLable){ - ImageIcon icon = new ImageIcon(image); - imageLable.setIcon(icon); - imageLable.setOpaque(true); - imageLable.setLayout(null); - imageLable.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight()); - } - - /** - * 是否展现覆盖的pane - * @param display 是否 - */ - public void displayCoverPane(boolean display){ - isHovering = display; - coverPanel.setVisible(display); - coverPanel.setBounds(1, 1, (int) editor.getBounds().getWidth(), (int) editor.getBounds().getHeight()); - editor.repaint(); - } - - @Override - public void paintBorder(Graphics g, Rectangle bounds){ - if (!isHovering) { - super.paintBorder(g, bounds); - } - } - - - /** - * 销毁帮助提示框 - */ - public void destroyHelpDialog(){ - coverPanel.destroyHelpDialog(); - } - - public JComponent getCoverPane(){ - return coverPanel; - } - - /** - * 初始化大小 - * @return 尺寸 - */ - public Dimension initEditorSize() { - return BORDER_PREFERRED_SIZE; - } - - /** - * 是否是报表块 - * @return 是 - */ - public boolean isReport() { - return true; - } - - /** - * 该组件是否可以拖入参数面板 - * @return 是则返回true - */ - public boolean canEnterIntoParaPane(){ - return false; - } - - /** - * 返回报表块对应的widget - * @return 返回ElementCaseEditor - */ - public ElementCaseEditor toData() { - return ((ElementCaseEditor) data); - } - - public FormElementCaseProvider getElementCase() { - return toData().getElementCase(); - } - - public String getElementCaseContainerName() { - return toData().getWidgetName(); - } - - public void setElementCase(FormElementCaseProvider el) { - toData().setElementCase(el); - } - - public void setBackground(BufferedImage image){ - toData().setECImage(image); - setEditorIcon(image); - } - - private void setEditorIcon(BufferedImage image){ - setLabelBackground(image, imageLable); - } - - public Dimension getSize(){ - return new Dimension(this.getWidth(), this.getHeight()); - } - - /** - * 响应点击事件 - * @param editingMouseListener 事件处理器 - * @param e 点击事件 - */ - public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){ - HelpDialogManager.getInstance().setPane(coverPanel); - super.respondClick(editingMouseListener, e); - if (this.isHelpBtnOnFocus()) { - coverPanel.setMsgDisplay(e); - } else { - switchTab(e, editingMouseListener); - } - } - - - private void switchTab(MouseEvent e,EditingMouseListener editingMouseListener){ - FormDesigner designer = editingMouseListener.getDesigner(); - if (e.getButton() == MouseEvent.BUTTON1 && - (e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR)){ - FormElementCaseContainerProvider component = (FormElementCaseContainerProvider) designer.getComponentAt(e); - //切换设计器 - designer.switchTab(component); - } - } - - @Override - public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { - return new WidgetPropertyUIProvider[]{ new ElementCasePropertyUI(this)}; - } - - @Override - public void setXDescrption(String msg) { - coverPanel.setHelpMsg(msg); - } - - /** - * data属性改变触发其他操作 - * - */ - public void firePropertyChange(){ - initStyle(); - } - - /** - * 是否支持设置可用 - * return boolean - */ - public boolean supportSetEnable(){ - return false; - } +package com.fr.design.designer.creator; + +import com.fr.base.BaseUtils; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.designer.properties.mobile.ElementCasePropertyUI; +import com.fr.design.form.util.XCreatorConstants; +import com.fr.design.fun.FormElementCaseEditorProcessor; +import com.fr.design.fun.FormElementCaseEditorProvider; +import com.fr.design.fun.WidgetPropertyUIProvider; +import com.fr.design.fun.impl.AbstractFormElementCaseEditorProvider; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.*; +import com.fr.design.mainframe.widget.editors.ElementCaseToolBarEditor; +import com.fr.design.mainframe.widget.editors.PaddingMarginEditor; +import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; +import com.fr.form.FormElementCaseContainerProvider; +import com.fr.form.FormElementCaseProvider; +import com.fr.form.FormProvider; +import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.ElementCaseEditorProvider; +import com.fr.general.Inter; +import com.fr.stable.ArrayUtils; +import com.fr.stable.CoreGraphHelper; +import com.fr.stable.core.PropertyChangeAdapter; +import com.fr.stable.fun.FitProvider; +import com.fr.stable.fun.ReportFitAttrProvider; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; +import java.beans.IntrospectionException; +import java.beans.PropertyDescriptor; +import java.util.Set; + +public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider{ + private UILabel imageLable; + private FormDesigner designer; + private static BufferedImage DEFAULT_BACKGROUND; + private boolean isHovering = false; + + static{ + try{ + DEFAULT_BACKGROUND = BaseUtils.readImageWithCache("com/fr/base/images/report/elementcase.png"); + }catch (Throwable e) { + //IBM jdk 1.5.0_22 并发下读取图片有时会异常(EOFException), 这个图片反正只有设计器用到, 捕获住 + DEFAULT_BACKGROUND = CoreGraphHelper.createBufferedImage(0, 0); + } + } + + public XElementCase(ElementCaseEditor widget, Dimension initSize) { + super(widget, initSize); + + + } + + protected void initXCreatorProperties() { + super.initXCreatorProperties(); + + // 报表块初始化时要加载对应的borderStyle + initBorderStyle(); + } + + /** + * 是否支持设置标题 + * @return 是返回true + */ + public boolean hasTitleStyle() { + return true; + } + + /** + * 返回组件属性值 + * @return 返回组件属性值 + * @throws IntrospectionException 异常 + */ + public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { + + CRPropertyDescriptor[] propertyTableEditor = new CRPropertyDescriptor[]{ + new CRPropertyDescriptor("widgetName", this.data.getClass()) + .setI18NName(Inter.getLocText("Form-Widget_Name")), + new CRPropertyDescriptor("visible", this.data.getClass()).setI18NName( + Inter.getLocText("FR-Designer_Widget-Visible")).setPropertyChangeListener(new PropertyChangeAdapter() { + + @Override + public void propertyChange() { + makeVisible(toData().isVisible()); + } + }), + new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( + WLayoutBorderStyleEditor.class).setI18NName( + Inter.getLocText("FR-Designer-Widget_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") + .setPropertyChangeListener(new PropertyChangeAdapter() { + + @Override + public void propertyChange() { + initStyle(); + } + }), + new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) + .setI18NName(Inter.getLocText("FR-Layout_Padding")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), + new CRPropertyDescriptor("toolBars", this.data.getClass()).setEditorClass(ElementCaseToolBarEditor.class) + .setI18NName(Inter.getLocText("Form-EC_toolbar")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") + }; + CRPropertyDescriptor[] extraTableEditor = getExtraTableEditor(); + return (CRPropertyDescriptor[]) ArrayUtils.addAll(propertyTableEditor, extraTableEditor); + } + + public CRPropertyDescriptor[] getExtraTableEditor(){ + CRPropertyDescriptor[] extraTableEditor = resolveCompatible(); + FormElementCaseEditorProcessor processor = ExtraDesignClassManager.getInstance().getSingle(FormElementCaseEditorProcessor.MARK_STRING); + if (processor == null) { + return extraTableEditor; + } + this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + FitProvider wbTpl = (FitProvider) designer.getTarget(); + ReportFitAttrProvider fitAttr = wbTpl.getFitAttr(); + ElementCaseEditor editor = this.toData(); + //兼容之前报表块(之前三个选项为:默认 横向 双向 现在是:横向 双向 不自适应) + if (editor.getFitStateInPC() == 0 || processor.getFitStateInPC(fitAttr) == 0 ) { + editor.setReportFitAttr(null); + } + + ReportFitAttrProvider reportFit = editor.getReportFitAttr(); + if(fitAttr != null){ + reportFit = fitAttr.fitInBrowser() ? editor.getReportFitAttr() : fitAttr; + } + ReportFitAttrProvider reportFitAttr = editor.getReportFitAttr() == null ? fitAttr : reportFit; + PropertyDescriptor[] extraEditor = processor.createPropertyDescriptor(this.data.getClass(), reportFitAttr); + if (editor.getReportFitAttr() == null) { + editor.setReportFitInPc(processor.getFitStateInPC(fitAttr)); + } + return (CRPropertyDescriptor[]) ArrayUtils.addAll(extraTableEditor, extraEditor); + } + + + private CRPropertyDescriptor[] resolveCompatible() { + CRPropertyDescriptor[] extraProperty = new CRPropertyDescriptor[0]; + //这边有个插件兼容问题,之后还是要改回process才行 + Set set = ExtraDesignClassManager.getInstance().getArray(AbstractFormElementCaseEditorProvider.MARK_STRING); + for (FormElementCaseEditorProvider provider : set) { + if (provider == null) { + continue; + } + this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + FormProvider formProvider = designer.getTarget(); + ElementCaseEditorProvider elementCaseEditorProvider = this.toData(); + PropertyDescriptor[] extraEditor = provider.createPropertyDescriptor(this.data.getClass(), formProvider, elementCaseEditorProvider); + extraProperty = (CRPropertyDescriptor[]) ArrayUtils.addAll(extraProperty, extraEditor); + } + return extraProperty; + } + + @Override + protected String getIconName() { + return "text_field_16.png"; + } + + /** + * 返回组件默认名 + * @return 组件类名(小写) + */ + public String createDefaultName() { + return "report"; + } + + @Override + protected JComponent initEditor() { + if (editor == null) { + setBorder(DEFALUTBORDER); + editor = new JPanel(); + editor.setBackground(null); + editor.setLayout(null); + imageLable = initImageBackground(); + + coverPanel = new CoverReportPane(); + coverPanel.setPreferredSize(imageLable.getPreferredSize()); + coverPanel.setBounds(imageLable.getBounds()); + + editor.add(coverPanel); + coverPanel.setVisible(false); + editor.add(imageLable); + } + return editor; + } + + /** + * 从data中获取到图片背景, 并设置到Label上 + */ + private UILabel initImageBackground(){ + UILabel imageLable = new UILabel(); + BufferedImage image = toData().getECImage(); + if (image == null) { + image = DEFAULT_BACKGROUND; + } + setLabelBackground(image, imageLable); + + return imageLable; + } + + /** + * 设置指定Label的背景 + */ + private void setLabelBackground(Image image, UILabel imageLable){ + ImageIcon icon = new ImageIcon(image); + imageLable.setIcon(icon); + imageLable.setOpaque(true); + imageLable.setLayout(null); + imageLable.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight()); + } + + /** + * 是否展现覆盖的pane + * @param display 是否 + */ + public void displayCoverPane(boolean display){ + isHovering = display; + coverPanel.setVisible(display); + coverPanel.setBounds(1, 1, (int) editor.getBounds().getWidth(), (int) editor.getBounds().getHeight()); + editor.repaint(); + } + + @Override + public void paintBorder(Graphics g, Rectangle bounds){ + if (!isHovering) { + super.paintBorder(g, bounds); + } + } + + /** + * 初始化大小 + * @return 尺寸 + */ + public Dimension initEditorSize() { + return BORDER_PREFERRED_SIZE; + } + + /** + * 是否是报表块 + * @return 是 + */ + public boolean isReport() { + return true; + } + + /** + * 该组件是否可以拖入参数面板 + * @return 是则返回true + */ + public boolean canEnterIntoParaPane(){ + return false; + } + + /** + * 返回报表块对应的widget + * @return 返回ElementCaseEditor + */ + public ElementCaseEditor toData() { + return ((ElementCaseEditor) data); + } + + public FormElementCaseProvider getElementCase() { + return toData().getElementCase(); + } + + public String getElementCaseContainerName() { + return toData().getWidgetName(); + } + + public void setElementCase(FormElementCaseProvider el) { + toData().setElementCase(el); + } + + public void setBackground(BufferedImage image){ + toData().setECImage(image); + setEditorIcon(image); + } + + private void setEditorIcon(BufferedImage image){ + setLabelBackground(image, imageLable); + } + + public Dimension getSize(){ + return new Dimension(this.getWidth(), this.getHeight()); + } + + /** + * 响应点击事件 + * @param editingMouseListener 事件处理器 + * @param e 点击事件 + */ + public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){ + HelpDialogManager.getInstance().setPane(coverPanel); + super.respondClick(editingMouseListener, e); + if (this.isHelpBtnOnFocus()) { + coverPanel.setMsgDisplay(e); + } else { + switchTab(e, editingMouseListener); + } + } + + + private void switchTab(MouseEvent e,EditingMouseListener editingMouseListener){ + FormDesigner designer = editingMouseListener.getDesigner(); + if (e.getButton() == MouseEvent.BUTTON1 && + (e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR)){ + FormElementCaseContainerProvider component = (FormElementCaseContainerProvider) designer.getComponentAt(e); + //切换设计器 + designer.switchTab(component); + } + } + + @Override + public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { + return new WidgetPropertyUIProvider[]{ new ElementCasePropertyUI(this)}; + } + + /** + * data属性改变触发其他操作 + * + */ + public void firePropertyChange(){ + initStyle(); + } + + /** + * 是否支持设置可用 + * return boolean + */ + public boolean supportSetEnable(){ + return false; + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java index c252060b89..76dd00e153 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -4,6 +4,8 @@ package com.fr.design.designer.creator; import com.fr.base.GraphHelper; +import com.fr.base.iofileattr.SharableAttrMark; +import com.fr.design.constants.UIConstants; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.LayoutAdapter; @@ -14,9 +16,12 @@ import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.form.layout.FRAbsoluteLayout; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.icon.IconPathConstants; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.WidgetHelpDialog; +import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.form.ui.Connector; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; @@ -25,6 +30,7 @@ import com.fr.form.ui.container.WLayout; import com.fr.general.FRScreen; import com.fr.general.IOUtils; import com.fr.general.Inter; +import com.fr.share.ShareConstants; import com.fr.stable.Constants; import java.awt.*; @@ -34,6 +40,7 @@ import java.awt.image.BufferedImage; import java.beans.IntrospectionException; import java.util.ArrayList; import java.util.HashMap; +import javax.swing.Icon; /** * @author richer @@ -41,17 +48,20 @@ import java.util.HashMap; */ public class XWAbsoluteLayout extends XLayoutContainer { - private static final int EDIT_BTN_WIDTH = 60; - private static final int EDIT_BTN_HEIGHT = 24; + private static final int EDIT_BTN_WIDTH = 75; + private static final int EDIT_BTN_HEIGHT = 20; private int minWidth = WLayout.MIN_WIDTH; private int minHeight = WLayout.MIN_HEIGHT; private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30); private static final Color INNER_BORDER_COLOR = new Color(65, 155, 249); private static final int BORDER_WIDTH = 1; + private Icon controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH); //由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算 protected double containerPercent = 1.0; + private boolean isHovering = false; + private HashMap xConnectorMap; public XWAbsoluteLayout() { @@ -442,9 +452,12 @@ public class XWAbsoluteLayout extends XLayoutContainer { g2d.setColor(XCreatorConstants.COVER_COLOR); g2d.fillRect(x, y, w, h); //画编辑按钮所在框 + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, formDesigner.getCursor().getType() != Cursor.DEFAULT_CURSOR ? 0.9f : 0.7f); + g2d.setColor(XCreatorConstants.EDIT_COLOR); + g2d.setComposite(alphaComposite); + g2d.fillRoundRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT, 4, 4); g2d.setComposite(oldComposite); - g2d.setColor(new Color(176, 196, 222)); - g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT); //画编辑按钮图标 BufferedImage image = IOUtils.readImage(IconPathConstants.EDIT_ICON_PATH); g2d.drawImage( @@ -456,13 +469,24 @@ public class XWAbsoluteLayout extends XLayoutContainer { null, this ); - g2d.setColor(Color.BLACK); + g2d.setColor(Color.WHITE); //画编辑文字 + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5); g.setColor(XCreatorConstants.FORM_BORDER_COLOR); GraphHelper.draw(g, new Rectangle(BORDER_WIDTH, BORDER_WIDTH, getWidth() - BORDER_WIDTH * 2, getHeight() - BORDER_WIDTH * 2), Constants.LINE_MEDIUM); + paintExtro(g); } + } + public void paintExtro(Graphics g) { + if (this.toData().getWidgetAttrMark(SharableAttrMark.XML_TAG) != null) { + int width = getWidth() - ShareConstants.SHARE_EL_CONTROL_BUTTON_HW; + g.setColor(UIConstants.NORMAL_BACKGROUND); + g.fillArc(width, 0, ShareConstants.SHARE_EL_CONTROL_BUTTON_HW, ShareConstants.SHARE_EL_CONTROL_BUTTON_HW, + 0, 360); + controlMode.paintIcon(this, g, width, 0); + } } @Override @@ -483,6 +507,11 @@ public class XWAbsoluteLayout extends XLayoutContainer { * @param e 鼠标点击事件 */ public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) { + //帮助弹窗 + if (this.isHelpBtnOnFocus()) { + new WidgetHelpDialog(DesignerContext.getDesignerFrame(), this.toData().getDescription()).showWindow(e); + return; + } FormDesigner designer = editingMouseListener.getDesigner(); SelectionModel selectionModel = editingMouseListener.getSelectionModel(); boolean isEditing = isEditable() || diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java index d8fdbce92f..604323d8e2 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java @@ -5,6 +5,7 @@ package com.fr.design.designer.creator.cardlayout; import com.fr.base.BaseUtils; import com.fr.base.GraphHelper; +import com.fr.base.background.ColorBackground; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.models.SelectionModel; @@ -322,7 +323,7 @@ public class XCardSwitchButton extends XButton { //画背景 private void drawBackground(CardSwitchButton button, WidgetTitle widgetTitle){ - Background background = widgetTitle.getBackground(); + Background background = widgetTitle.getBackground() == null ? ColorBackground.getInstance(NORMAL_GRAL) : widgetTitle.getBackground(); TemplateStyle templateStyle = ((WCardTagLayout) tagLayout.toData()).getTemplateStyle(); //获取当前tab的index CardSwitchButton currentButton = (CardSwitchButton) this.toData(); diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index ee82d5cf06..76d54d2ac5 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -4,6 +4,8 @@ package com.fr.design.designer.creator.cardlayout; import com.fr.base.GraphHelper; +import com.fr.base.iofileattr.SharableAttrMark; +import com.fr.design.constants.UIConstants; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.LayoutAdapter; @@ -16,8 +18,11 @@ import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWidgetCreator; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.icon.IconPathConstants; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.WidgetHelpDialog; +import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.form.event.Listener; import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.Widget; @@ -32,6 +37,7 @@ import com.fr.form.ui.container.cardlayout.WCardTitleLayout; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.general.Inter; +import com.fr.share.ShareConstants; import com.fr.stable.Constants; import java.awt.AlphaComposite; @@ -43,10 +49,12 @@ import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; +import java.awt.RenderingHints; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; +import javax.swing.Icon; /** * card布局主体框架 @@ -57,12 +65,13 @@ import java.util.List; */ public class XWCardMainBorderLayout extends XWBorderLayout{ + private Icon controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH); private static final int CENTER = 1; private static final int NORTH = 0; private static final int TITLE_STYLE = 2; - private static final int EDIT_BTN_WIDTH = 60; - private static final int EDIT_BTN_HEIGHT = 24; + private static final int EDIT_BTN_WIDTH = 75; + private static final int EDIT_BTN_HEIGHT = 20; private static final int BORDER_WIDTH = 1; private final int CARDMAINLAYOUT_CHILD_COUNT = 1; @@ -337,9 +346,12 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ g2d.setColor(XCreatorConstants.COVER_COLOR); g2d.fillRect(x, y, w, h); //画编辑按钮所在框 + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, formDesigner.getCursor().getType() != Cursor.DEFAULT_CURSOR ? 0.9f : 0.7f); + g2d.setColor(XCreatorConstants.EDIT_COLOR); + g2d.setComposite(alphaComposite); + g2d.fillRoundRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT, 4, 4); g2d.setComposite(oldComposite); - g2d.setColor(new Color(176, 196, 222)); - g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT); //画编辑按钮图标 BufferedImage image = IOUtils.readImage(IconPathConstants.EDIT_ICON_PATH); g2d.drawImage( @@ -351,11 +363,23 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ null, this ); - g2d.setColor(Color.BLACK); + g2d.setColor(Color.WHITE); //画编辑文字 + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5); g.setColor(XCreatorConstants.FORM_BORDER_COLOR); GraphHelper.draw(g, new Rectangle(BORDER_WIDTH, BORDER_WIDTH, getWidth() - BORDER_WIDTH * 2, getHeight() - BORDER_WIDTH * 2), Constants.LINE_MEDIUM); + paintExtro(g); + } + } + + public void paintExtro(Graphics g) { + if (this.toData().getWidgetAttrMark(SharableAttrMark.XML_TAG) != null) { + int width = getWidth() - ShareConstants.SHARE_EL_CONTROL_BUTTON_HW; + g.setColor(UIConstants.NORMAL_BACKGROUND); + g.fillArc(width, 0, ShareConstants.SHARE_EL_CONTROL_BUTTON_HW, ShareConstants.SHARE_EL_CONTROL_BUTTON_HW, + 0, 360); + controlMode.paintIcon(this, g, width, 0); } } @@ -374,6 +398,11 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ */ @Override public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e){ + //帮助弹窗 + if (this.isHelpBtnOnFocus()) { + new WidgetHelpDialog(DesignerContext.getDesignerFrame(), this.toData().getDescription()).showWindow(e); + return; + } FormDesigner designer = editingMouseListener.getDesigner(); SelectionModel selectionModel = editingMouseListener.getSelectionModel(); boolean isEditing = e.getButton() == MouseEvent.BUTTON1 && diff --git a/designer_form/src/com/fr/design/form/util/XCreatorConstants.java b/designer_form/src/com/fr/design/form/util/XCreatorConstants.java index 4cced61430..b18d0b5a5e 100644 --- a/designer_form/src/com/fr/design/form/util/XCreatorConstants.java +++ b/designer_form/src/com/fr/design/form/util/XCreatorConstants.java @@ -45,6 +45,8 @@ public class XCreatorConstants { public static final Color LAYOUT_SEP_COLOR = new Color(210, 210, 210); // 组件覆盖层颜色 public static final Color COVER_COLOR = new Color(216, 242, 253); + //组件编辑按钮颜色 + public static final Color EDIT_COLOR = new Color(51, 51, 52); // 伸缩表单操作条的颜色 public static final Color OP_COLOR = new Color(157,228,245); diff --git a/designer_form/src/com/fr/design/mainframe/CoverPane.java b/designer_form/src/com/fr/design/mainframe/CoverPane.java index 00e9f8b3b0..5b359b06c6 100644 --- a/designer_form/src/com/fr/design/mainframe/CoverPane.java +++ b/designer_form/src/com/fr/design/mainframe/CoverPane.java @@ -4,13 +4,23 @@ import com.fr.base.GraphHelper; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.icon.IconPathConstants; -import com.fr.design.utils.ComponentUtils; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.stable.Constants; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Component; +import java.awt.Composite; +import java.awt.Container; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.LayoutManager; +import java.awt.Rectangle; + /** * Created with IntelliJ IDEA. @@ -21,9 +31,11 @@ import java.awt.*; public class CoverPane extends JPanel { private UIButton editButton; - private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 50 / 100.0F); + private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f); private static final int BORDER_WIDTH = 2; private static final Color COVER_COLOR = new Color(216, 242, 253); + private static final int EDIT_BTN_WIDTH = 75; + private static final int EDIT_BTN_HEIGHT = 20; public CoverPane() { setLayout(getCoverLayout()); @@ -38,7 +50,7 @@ public class CoverPane extends JPanel { }; editButton.setBorderPainted(false); editButton.setExtraPainted(false); - editButton.setBackground(new Color(176, 196, 222)); + editButton.setForeground(Color.WHITE); add(editButton); } @@ -92,14 +104,26 @@ public class CoverPane extends JPanel { public void paint(Graphics g) { + int x = 0; + int y = 0; + int w = getWidth(); + int h = getHeight(); Graphics2D g2d = (Graphics2D) g; Composite oldComposite = g2d.getComposite(); g2d.setComposite(composite); g2d.setColor(COVER_COLOR); g2d.fillRect(0, 0, getWidth(), getHeight()); + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + g2d.setColor(XCreatorConstants.EDIT_COLOR); + boolean editHover = formDesigner.getCursor().getType() != Cursor.DEFAULT_CURSOR; + AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, editHover ? 0.9f : 0.7f); + g2d.setComposite(alphaComposite); + g2d.fillRoundRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT, 4, 4); g2d.setComposite(oldComposite); g.setColor(XCreatorConstants.FORM_BORDER_COLOR); GraphHelper.draw(g, getPaintBorderBounds(), Constants.LINE_MEDIUM); + + super.paint(g); } diff --git a/designer_form/src/com/fr/design/mainframe/CoverReportPane.java b/designer_form/src/com/fr/design/mainframe/CoverReportPane.java index 3578856d95..0944d98aec 100644 --- a/designer_form/src/com/fr/design/mainframe/CoverReportPane.java +++ b/designer_form/src/com/fr/design/mainframe/CoverReportPane.java @@ -35,7 +35,7 @@ public class CoverReportPane extends CoverPane implements HelpDialogHandler{ private String helpMsg;//帮助信息(后续帮助信息可能会变成标配,就直接放这边了) - private ElementCaseHelpDialog helpDialog = null; + private WidgetHelpDialog helpDialog = null; public CoverReportPane() { this(StringUtils.EMPTY); @@ -62,7 +62,7 @@ public class CoverReportPane extends CoverPane implements HelpDialogHandler{ if (helpDialog == null) { // controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_CLOSE_ICON_PATH); controlButton.setVisible(false); - helpDialog = new ElementCaseHelpDialog(DesignerContext.getDesignerFrame(), helpMsg); + helpDialog = new WidgetHelpDialog(DesignerContext.getDesignerFrame(), helpMsg); double screenValue = FRScreen.getByDimension(Toolkit.getDefaultToolkit().getScreenSize()).getValue(); int offsetX = 0; if (screenValue < FormArea.DEFAULT_SLIDER) { diff --git a/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java b/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java index 4738b565d8..259843ae6a 100644 --- a/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer_form/src/com/fr/design/mainframe/EditingMouseListener.java @@ -22,8 +22,10 @@ import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.LayoutUtils; import com.fr.general.Inter; +import com.fr.share.ShareConstants; import com.fr.stable.Constants; +import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.event.MouseInputAdapter; import java.awt.*; @@ -260,7 +262,7 @@ public class EditingMouseListener extends MouseInputAdapter { public void mouseMoved(MouseEvent e) { XCreator component = designer.getComponentAt(e); - setCoverPaneNotDisplay(e, false); + setCoverPaneNotDisplay(component, e, false); if (processTopLayoutMouseMove(component, e)) { return; @@ -313,23 +315,42 @@ public class EditingMouseListener extends MouseInputAdapter { designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } } - xElementCase.setHelpBtnOnFocus(false); - if (xElementCase.getCoverPane().getComponentCount() > 1) { - JComponent button1 = (JComponent) xElementCase.getCoverPane().getComponent(1); - int minX1 = button1.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue(); - int minY1 = button1.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue(); - if (e.getX() + GAP - xElementCase.getInsets().left > minX1 && e.getX() - GAP - xElementCase.getInsets().left < minX1 + button1.getWidth()) { - if (e.getY() + GAP - xElementCase.getInsets().top > minY1 && e.getY() - GAP - xElementCase.getInsets().top < minY1 + button1.getHeight()) { + setHelpBtnFocus(e, xElementCase); + } + + private void setHelpBtnFocus(MouseEvent e, XCreator component) { + component.setHelpBtnOnFocus(false); + if (component.getCoverPane() != null) { + if (component.getCoverPane().getComponentCount() > 1) { + JComponent button1 = (JComponent) component.getCoverPane().getComponent(1); + int minX1 = button1.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue(); + int minY1 = button1.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue(); + if (e.getX() + GAP - component.getInsets().left > minX1 && e.getX() - GAP - component.getInsets().left < minX1 + button1.getWidth()) { + if (e.getY() + GAP - component.getInsets().top > minY1 && e.getY() - GAP - component.getInsets().top < minY1 + button1.getHeight()) { + designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + component.setHelpBtnOnFocus(true); + } + } + } + component.displayCoverPane(true); + component.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT); + } else { + //没有帮助信息时,不显示帮助图标 + if (StringUtils.isEmpty(component.toData().getDescription())) { + return; + } + int minX1 = getParentPositionX(component, component.getX()) + component.getWidth() - ShareConstants.SHARE_EL_CONTROL_BUTTON_HW - designer.getArea().getHorizontalValue(); + int minY1 = getParentPositionY(component, component.getY()) - designer.getArea().getVerticalValue(); + if (e.getX() + GAP - component.getInsets().left > minX1 && e.getX() - GAP - component.getInsets().left < minX1 + ShareConstants.SHARE_EL_CONTROL_BUTTON_HW) { + if (e.getY() + GAP - component.getInsets().top > minY1 && e.getY() - GAP - component.getInsets().top < minY1 + ShareConstants.SHARE_EL_CONTROL_BUTTON_HW) { designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - xElementCase.setHelpBtnOnFocus(true); + component.setHelpBtnOnFocus(true); } } } - xElementCase.displayCoverPane(true); - xElementCase.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT); } - private void setCoverPaneNotDisplay(MouseEvent e, boolean isLinkedHelpDialog) { + private void setCoverPaneNotDisplay(XCreator component, MouseEvent e, boolean isLinkedHelpDialog) { if (xElementCase != null) { int x = getParentPositionX(xElementCase, 0) - designer.getArea().getHorizontalValue(); int y = getParentPositionY(xElementCase, 0) - designer.getArea().getVerticalValue(); @@ -337,15 +358,16 @@ public class EditingMouseListener extends MouseInputAdapter { if (rect.contains(e.getPoint())) { return; } - if (isLinkedHelpDialog) { - xElementCase.destroyHelpDialog(); - } + xElementCase.displayCoverPane(false); } if (xChartEditor != null) { xChartEditor.displayCoverPane(false); } - + if (isLinkedHelpDialog) { + component.destroyHelpDialog(); + } + component.displayCoverPane(false); if (xTopLayoutContainer != null) { xTopLayoutContainer.setMouseEnter(false); } @@ -371,6 +393,7 @@ public class EditingMouseListener extends MouseInputAdapter { designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } } + setHelpBtnFocus(e, xTopLayoutContainer); return true; } } @@ -391,8 +414,7 @@ public class EditingMouseListener extends MouseInputAdapter { designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } } - xChartEditor.displayCoverPane(true); - xChartEditor.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT); + setHelpBtnFocus(e, xChartEditor); designer.repaint(); } } @@ -562,9 +584,6 @@ public class EditingMouseListener extends MouseInputAdapter { if (designer.getCursor().getType() != Cursor.DEFAULT_CURSOR) { designer.setCursor(Cursor.getDefaultCursor()); } - - setCoverPaneNotDisplay(e, true); - cancelPromptWidgetForbidEnter(); } diff --git a/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java index 486ad26949..a9356fa260 100644 --- a/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -13,10 +13,9 @@ import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.icon.IconPathConstants; import com.fr.design.utils.ComponentUtils; +import com.fr.form.share.SharableEditorProvider; import com.fr.form.share.ShareLoader; -import com.fr.form.ui.ElCaseBindInfo; -import com.fr.form.ui.ElementCaseEditor; -import com.fr.form.ui.SharableElementCaseEditor; +import com.fr.form.ui.SharableWidgetBindInfo; import com.fr.form.ui.Widget; import com.fr.general.Inter; import com.fr.stable.Constants; @@ -84,14 +83,15 @@ public class FormCreatorDropTarget extends DropTarget { Widget widget = (addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData(); if (addingXCreator.isShared()) { String shareId = addingXCreator.getShareId(); - SharableElementCaseEditor sharableEditor = ShareLoader.getLoader().getSharedElCaseEditorById(shareId); - ElCaseBindInfo bindInfo = ShareLoader.getLoader().getElCaseBindInfoById(shareId); + SharableEditorProvider sharableEditor = ShareLoader.getLoader().getSharedElCaseEditorById(shareId); + SharableWidgetBindInfo bindInfo = ShareLoader.getLoader().getElCaseBindInfoById(shareId); if (sharableEditor != null && bindInfo != null) { Map tdNameMap = TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(bindInfo.getName(), sharableEditor.getTableDataSource()); //合并数据集之后,可能会有数据集名称变化,做一下联动 //共享的组件拿的时候都是克隆的,这边改拖拽中克隆的对象而非新克隆对象,上面这个新克隆的对象只是为了拿数据集 - ElementCaseEditor elementCaseEditor = (ElementCaseEditor) widget; - elementCaseEditor.batchRenameTdName(tdNameMap); + for (Map.Entry entry : tdNameMap.entrySet()) { + designer.getTarget().renameTableData(widget, entry.getKey(), entry.getValue()); + } } } designer.getSelectionModel().setSelectedCreators( diff --git a/designer_form/src/com/fr/design/mainframe/FormDesigner.java b/designer_form/src/com/fr/design/mainframe/FormDesigner.java index f0d5803b89..ed49beb319 100644 --- a/designer_form/src/com/fr/design/mainframe/FormDesigner.java +++ b/designer_form/src/com/fr/design/mainframe/FormDesigner.java @@ -475,7 +475,6 @@ public class FormDesigner extends TargetComponent

implements TreeSelection paraHeight = 0; paraComponent = null; formLayoutContainer.setSize(rootComponent.getWidth(), rootComponent.getHeight()); - EastRegionContainerPane.getInstance().replaceConfiguredRolesPane(this.getEastDownPane()); //atat //EastRegionContainerPane.getInstance().addTitlePane(ParameterPropertyPane.getInstance(FormDesigner.this)); //删除后重绘下 diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index d53bc04d5d..aad141d68c 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -3,13 +3,12 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.FRContext; import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.form.share.ShareLoader; -import com.fr.form.ui.ElCaseBindInfo; +import com.fr.form.ui.SharableWidgetBindInfo; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.general.SiteCenter; @@ -41,7 +40,7 @@ public class FormWidgetDetailPane extends FormDockView{ private UIScrollPane downPane; private JPanel reuWidgetPanel; private UIComboBox comboBox; - private ElCaseBindInfo[] elCaseBindInfoList; + private SharableWidgetBindInfo[] elCaseBindInfoList; private UIButton deleteButton; private UIButton resetButton; private JPanel editPanel; @@ -118,21 +117,7 @@ public class FormWidgetDetailPane extends FormDockView{ initReuWidgetPanel(); initMenuPanel(); - card = new CardLayout(); - tabbedPane = new JPanel(); - tabbedPane.setLayout(card); - tabbedPane.add(REPORT_TAB, reuWidgetPanel); - tabbedPane.add(CHART_TAB, new JPanel()); - UIHeadGroup tabsHeaderIconPane = new UIHeadGroup(new String[] {REPORT_TAB, CHART_TAB}) { - @Override - public void tabChanged(int index) { - card.show(tabbedPane, labelButtonList.get(index).getText()); - } - }; - tabsHeaderIconPane.setNeedLeftRightOutLine(false); - - add(tabsHeaderIconPane, BorderLayout.NORTH); - add(tabbedPane, BorderLayout.CENTER); + add(reuWidgetPanel, BorderLayout.CENTER); } diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index 87c575fd2b..5c969332aa 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -576,6 +576,7 @@ public class JForm extends JTemplate implements BaseJForm { this.reportComposite.setSelectedWidget(dataTable); //下面这句话是防止撤销之后直接退出编辑再编辑撤销的东西会回来,因为撤销不会保存EC formDesign.setElementCase(dataTable); + elementCaseDesign.refreshPropertyPane(); } } catch (CloneNotSupportedException e) { throw new RuntimeException(e); diff --git a/designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java b/designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java index 4379d517b3..4df1334b20 100644 --- a/designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java +++ b/designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java @@ -4,9 +4,11 @@ import com.fr.base.vcs.DesignerMode; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.gui.ilable.UILabel; +import com.fr.base.iofileattr.SharableAttrMark; +import com.fr.form.ui.AbstractBorderStyleWidget; import com.fr.share.ShareConstants; import com.fr.form.share.ShareLoader; -import com.fr.form.ui.ElCaseBindInfo; +import com.fr.form.ui.SharableWidgetBindInfo; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; @@ -31,7 +33,7 @@ import java.io.Serializable; * Time: 16:14 */ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMotionListener, Serializable { - private ElCaseBindInfo bindInfo; + private SharableWidgetBindInfo bindInfo; private MouseEvent lastPressEvent; private JPanel reportPane; private boolean isEdit; @@ -50,7 +52,7 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot } }; - public ShareWidgetButton(ElCaseBindInfo bindInfo) { + public ShareWidgetButton(SharableWidgetBindInfo bindInfo) { this.bindInfo = bindInfo; this.setPreferredSize(new Dimension(108, 68)); initUI(); @@ -127,11 +129,11 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot }; } - public ElCaseBindInfo getBindInfo() { + public SharableWidgetBindInfo getBindInfo() { return bindInfo; } - public void setBindInfo(ElCaseBindInfo bindInfo) { + public void setBindInfo(SharableWidgetBindInfo bindInfo) { this.bindInfo = bindInfo; } @@ -194,13 +196,15 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot } shareId = no.getBindInfo().getId(); creatorSource = ShareLoader.getLoader().getElCaseEditorById(shareId); - } - if (creatorSource != null) { - XCreator xCreator = XCreatorUtils.createXCreator(creatorSource); - xCreator.setShareId(shareId); - WidgetToolBarPane.getTarget().startDraggingBean(xCreator); - lastPressEvent = null; - this.setBorder(null); + if (creatorSource != null) { + ((AbstractBorderStyleWidget)creatorSource).addWidgetAttrMark(new SharableAttrMark(true)); + XCreator xCreator = XCreatorUtils.createXCreator(creatorSource, new Dimension(no.getBindInfo().getWidth(), no.getBindInfo().getHeight())); + xCreator.setBackupBound(xCreator.getBounds()); + xCreator.setShareId(shareId); + WidgetToolBarPane.getTarget().startDraggingBean(xCreator); + lastPressEvent = null; + this.setBorder(null); + } } } diff --git a/designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java b/designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java index c5659d9bc1..32ce586c72 100644 --- a/designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java +++ b/designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe; -import com.fr.form.ui.ElCaseBindInfo; +import com.fr.form.ui.SharableWidgetBindInfo; import javax.swing.*; import java.awt.*; @@ -12,12 +12,12 @@ import java.awt.*; */ public class ShareWidgetPane extends JPanel { - public ShareWidgetPane(ElCaseBindInfo[] elCaseBindInfoList, boolean isEdit) { + public ShareWidgetPane(SharableWidgetBindInfo[] elCaseBindInfoList, boolean isEdit) { this.setBorder(BorderFactory.createEmptyBorder(10, 3, 0, 0));// 设置面板的边框 ,距离上、左、下、右 的距离 if (elCaseBindInfoList != null) { int rowCount = (elCaseBindInfoList.length + 1) / 2; this.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 10)); - for (ElCaseBindInfo rbModuleInfo : elCaseBindInfoList) { + for (SharableWidgetBindInfo rbModuleInfo : elCaseBindInfoList) { ShareWidgetButton widgetButton = new ShareWidgetButton(rbModuleInfo); widgetButton.setElementCaseEdit(isEdit); this.add(widgetButton); diff --git a/designer_form/src/com/fr/design/mainframe/ElementCaseHelpDialog.java b/designer_form/src/com/fr/design/mainframe/WidgetHelpDialog.java similarity index 73% rename from designer_form/src/com/fr/design/mainframe/ElementCaseHelpDialog.java rename to designer_form/src/com/fr/design/mainframe/WidgetHelpDialog.java index 2f2c6e3b5d..a6f8d40ba6 100644 --- a/designer_form/src/com/fr/design/mainframe/ElementCaseHelpDialog.java +++ b/designer_form/src/com/fr/design/mainframe/WidgetHelpDialog.java @@ -5,6 +5,7 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itextarea.UITextArea; import com.fr.general.Inter; +import java.awt.event.MouseEvent; import javax.swing.*; import java.awt.*; @@ -13,17 +14,19 @@ import java.awt.*; * @date 2016-10-14 * @since 8.0 */ -public class ElementCaseHelpDialog extends UIDialog { +public class WidgetHelpDialog extends UIDialog { private static final int OUTER_WIDTH = 190; private static final int OUTER_HEIGHT = 280; + private static final int DIALOG_X = 227; + private static final int DIALOG_Y = 165; private String helpMsg; private UIScrollPane helpArea; - public ElementCaseHelpDialog(Frame parent, String helpMsg) { + public WidgetHelpDialog(Frame parent, String helpMsg) { super(parent); this.helpMsg = helpMsg; initHelpArea(); @@ -56,6 +59,17 @@ public class ElementCaseHelpDialog extends UIDialog { setVisible(true); } + /** + * 打开帮助框-e + */ + public void showWindow(MouseEvent e) { + int rX = WestRegionContainerPane.getInstance().getWidth() + e.getX() - DIALOG_X;//弹出框宽度190加上图标的宽度27加上10的偏移 + int rY = DIALOG_Y + e.getY();//165是设计器最上面几个面板的高度 + this.setLocationRelativeTo(DesignerContext.getDesignerFrame(), rX, rY); + this.setResizable(false); + setVisible(true); + } + /** * 略 */ diff --git a/designer_form/src/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java b/designer_form/src/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java index 0de1e2bdaf..87610840f0 100644 --- a/designer_form/src/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java +++ b/designer_form/src/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java @@ -4,18 +4,68 @@ import com.fr.base.FRContext; import com.fr.design.designer.creator.XCreator; import com.fr.design.gui.core.WidgetConstants; import com.fr.design.mainframe.FormDesigner; -import com.fr.design.widget.ui.designer.WidgetDefinePane; import com.fr.design.parameter.RootDesignDefinePane; -import com.fr.design.widget.ui.designer.*; -import com.fr.design.widget.ui.designer.layout.*; +import com.fr.design.widget.ui.designer.CheckBoxDefinePane; +import com.fr.design.widget.ui.designer.CheckBoxGroupDefinePane; +import com.fr.design.widget.ui.designer.ComboBoxDefinePane; +import com.fr.design.widget.ui.designer.ComboCheckBoxDefinePane; +import com.fr.design.widget.ui.designer.DateEditorDefinePane; +import com.fr.design.widget.ui.designer.FreeButtonDefinePane; +import com.fr.design.widget.ui.designer.IframeEditorDefinePane; +import com.fr.design.widget.ui.designer.LabelDefinePane; +import com.fr.design.widget.ui.designer.MultiFileEditorPane; +import com.fr.design.widget.ui.designer.NoneWidgetDefinePane; +import com.fr.design.widget.ui.designer.NumberEditorDefinePane; +import com.fr.design.widget.ui.designer.PasswordDefinePane; +import com.fr.design.widget.ui.designer.RadioDefinePane; +import com.fr.design.widget.ui.designer.RadioGroupDefinePane; +import com.fr.design.widget.ui.designer.TextAreaDefinePane; +import com.fr.design.widget.ui.designer.TextFieldEditorDefinePane; +import com.fr.design.widget.ui.designer.TreeComboBoxEditorDefinePane; +import com.fr.design.widget.ui.designer.TreeEditorDefinePane; +import com.fr.design.widget.ui.designer.UserEditorDefinePane; +import com.fr.design.widget.ui.designer.WidgetDefinePane; +import com.fr.design.widget.ui.designer.layout.BorderStyleWidgetDefinePane; +import com.fr.design.widget.ui.designer.layout.ElementEditorDefinePane; +import com.fr.design.widget.ui.designer.layout.FRAbsoluteBodyLayoutDefinePane; +import com.fr.design.widget.ui.designer.layout.FRAbsoluteLayoutDefinePane; +import com.fr.design.widget.ui.designer.layout.FRFitLayoutDefinePane; +import com.fr.design.widget.ui.designer.layout.WCardLayoutDefinePane; +import com.fr.design.widget.ui.designer.layout.WCardMainLayoutDefinePane; +import com.fr.design.widget.ui.designer.layout.WCardTagLayoutDefinePane; +import com.fr.design.widget.ui.designer.layout.WTabFitLayoutDefinePane; import com.fr.form.parameter.FormSubmitButton; -import com.fr.form.ui.*; -import com.fr.form.ui.container.*; +import com.fr.form.ui.Button; +import com.fr.form.ui.ChartEditor; +import com.fr.form.ui.CheckBox; +import com.fr.form.ui.CheckBoxGroup; +import com.fr.form.ui.ComboBox; +import com.fr.form.ui.ComboCheckBox; +import com.fr.form.ui.DateEditor; +import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.FreeButton; +import com.fr.form.ui.IframeEditor; +import com.fr.form.ui.Label; +import com.fr.form.ui.MultiFileEditor; +import com.fr.form.ui.NameWidget; +import com.fr.form.ui.NoneWidget; +import com.fr.form.ui.NumberEditor; +import com.fr.form.ui.Password; +import com.fr.form.ui.Radio; +import com.fr.form.ui.RadioGroup; +import com.fr.form.ui.TextArea; +import com.fr.form.ui.TextEditor; +import com.fr.form.ui.TreeComboBoxEditor; +import com.fr.form.ui.TreeEditor; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WAbsoluteBodyLayout; +import com.fr.form.ui.container.WAbsoluteLayout; +import com.fr.form.ui.container.WCardLayout; +import com.fr.form.ui.container.WFitLayout; +import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; -import com.fr.stable.bridge.BridgeMark; -import com.fr.stable.bridge.StableFactory; import java.lang.reflect.Constructor; import java.util.HashMap; @@ -56,10 +106,7 @@ public class FormWidgetDefinePaneFactoryBase { defineMap.put(FormSubmitButton.class, new Appearance(FreeButtonDefinePane.class, WidgetConstants.BUTTON + "")); defineMap.put(WFitLayout.class, new Appearance(FRFitLayoutDefinePane.class, "wFitLayout")); defineMap.put(WCardMainBorderLayout.class, new Appearance(WCardMainLayoutDefinePane.class, "wCardMainBorderLayout")); - if (StableFactory.getMarkedClass(BridgeMark.CHART_EDITOR, AbstractBorderStyleWidget.class) != null) { - defineMap.put(StableFactory.getMarkedClass(BridgeMark.CHART_EDITOR, AbstractBorderStyleWidget.class), new Appearance(BorderStyleWidgetDefinePane.class, "chartEditor")); - } - + defineMap.put(ChartEditor.class, new Appearance(BorderStyleWidgetDefinePane.class, "chartEditor")); defineMap.put(WAbsoluteLayout.class, new Appearance(FRAbsoluteLayoutDefinePane.class, "wAbsoluteLayout")); defineMap.put(ElementCaseEditor.class, new Appearance(ElementEditorDefinePane.class, "elementCaseEditor")); defineMap.put(WAbsoluteBodyLayout.class, new Appearance(FRAbsoluteBodyLayoutDefinePane.class, "wAbsoluteBodyLayout")); diff --git a/designer_form/src/com/fr/design/widget/ui/designer/component/PaddingBoundPane.java b/designer_form/src/com/fr/design/widget/ui/designer/component/PaddingBoundPane.java index 21dcb4b6e8..0214a5fc95 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/component/PaddingBoundPane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/component/PaddingBoundPane.java @@ -1,5 +1,6 @@ package com.fr.design.widget.ui.designer.component; +import com.fr.base.iofileattr.TemplateIdAttrMark; import com.fr.design.designer.IntervalConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ilable.UILabel; @@ -7,8 +8,8 @@ import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.form.ui.AbstractMarginWidget; import com.fr.form.ui.PaddingMargin; +import com.fr.form.ui.RichStyleWidgetProvider; import com.fr.general.Inter; import javax.swing.BorderFactory; @@ -75,7 +76,7 @@ public class PaddingBoundPane extends BasicPane{ } - public void update(AbstractMarginWidget marginWidget) { + public void update(RichStyleWidgetProvider marginWidget) { marginWidget.setMargin(new PaddingMargin((int)top.getValue(), (int)left.getValue(), (int)bottom.getValue(), (int)right.getValue() )); } @@ -83,7 +84,7 @@ public class PaddingBoundPane extends BasicPane{ return "PaddingBoundPane"; } - public void populate(AbstractMarginWidget marginWidget) { + public void populate(RichStyleWidgetProvider marginWidget) { PaddingMargin paddingMargin = marginWidget.getMargin(); top.setValue(paddingMargin.getTop()); bottom.setValue(paddingMargin.getBottom());