From 5160ced244fb84d2d512522a23914e6146d05e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Wed, 29 Sep 2021 17:53:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-60134=20=E8=A1=A8=E5=8D=95=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=B1=9E=E6=80=A7=E5=9B=BD=E9=99=85=E5=8C=96-?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractTranslucentBackgroundSpecialPane.java | 8 ++++---- .../design/gui/style/ComponentIntegralStylePane.java | 6 +++--- .../fr/design/gui/style/ComponentTitleStylePane.java | 10 +++++----- .../com/fr/design/gui/style/FollowingThemePane.java | 9 +++------ .../java/com/fr/design/layout/FRGUIPaneFactory.java | 7 +++++++ 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/style/AbstractTranslucentBackgroundSpecialPane.java b/designer-base/src/main/java/com/fr/design/gui/style/AbstractTranslucentBackgroundSpecialPane.java index fe6318ad3..0b814f284 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/AbstractTranslucentBackgroundSpecialPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/AbstractTranslucentBackgroundSpecialPane.java @@ -2,13 +2,13 @@ package com.fr.design.gui.style; import com.fr.design.designer.IntervalConstants; import com.fr.design.dialog.BasicPane; -import com.fr.design.dialog.BasicScrollPane; import com.fr.design.gui.frpane.UIPercentDragPane; 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.mainframe.backgroundpane.GradientBackgroundQuickPane; +import com.fr.design.widget.FRWidgetFactory; import com.fr.general.Background; import com.fr.general.act.BackgroundPacker; @@ -51,8 +51,8 @@ public abstract class AbstractTranslucentBackgroundSpecialPane 0 ? this.uiSettingWidth : f}; JPanel content = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo}, + {FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), FRGUIPaneFactory.createBorderLayoutNorthPaneWithComponent(borderStyleCombo)}, {this.borderPane, null}, - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner}, + {FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner}, }, rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); diff --git a/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java b/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java index 8f9a8503d..33af029ad 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java @@ -9,10 +9,10 @@ import com.fr.design.gui.ibutton.UIColorButton; 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.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.widget.FRWidgetFactory; import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.WidgetTitle; import com.fr.general.FRFont; @@ -168,7 +168,7 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane { visibleCheckbox.setSelected(false); container.add(visibleCheckbox, BorderLayout.WEST); - container.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Visible")), BorderLayout.CENTER); + container.add(FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Visible")), BorderLayout.CENTER); visibleCheckbox.addChangeListener(new ChangeListener() { @Override @@ -192,7 +192,7 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane { double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f}; return TableLayoutHelper.createCommonTableLayoutPane( - new JComponent[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")), textContentPane}}, + new JComponent[][]{{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")), textContentPane}}, rowSize, columnSize, IntervalConstants.INTERVAL_L1); } @@ -203,10 +203,10 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane { double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f}; JComponent[][] components = new JComponent[][]{ - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Format")), fontFamilyComboBox}, + {FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Format")), FRGUIPaneFactory.createBorderLayoutNorthPaneWithComponent(fontFamilyComboBox)}, {null, createTitleFontButtonPane()}, {insetImagePane, null}, - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Text_Align")), alignPane}, + {FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Text_Align")), alignPane}, {backgroundPane, null} }; diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java b/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java index 55f4612a2..f9f556b3d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java @@ -1,10 +1,7 @@ package com.fr.design.gui.style; -import com.fr.base.theme.FormTheme; import com.fr.base.theme.TemplateTheme; import com.fr.design.dialog.BasicPane; -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.design.file.HistoryTemplateListCache; @@ -15,12 +12,12 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.JTemplate; +import com.fr.design.widget.FRWidgetFactory; import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; -import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; @@ -66,12 +63,12 @@ public class FollowingThemePane extends BasicPane implements UIObserver { } }); - UILabel followingThemeLabel = new UILabel(name); + UILabel followingThemeLabel = FRWidgetFactory.createLineWrapLabel(name); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; JPanel followingThemePane = - TableLayoutHelper.createGapTableLayoutPane( new Component[][]{new Component[] { followingThemeLabel, followingThemeButtonGroup}}, + TableLayoutHelper.createGapTableLayoutPane( new Component[][]{new Component[] { followingThemeLabel, FRGUIPaneFactory.createBorderLayoutNorthPaneWithComponent(followingThemeButtonGroup)}}, new double[] { p }, new double[] { SETTING_LABEL_WIDTH, f }, 10, 0); followingThemePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); followingThemePane.setVisible(false); diff --git a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java index 0077f9b87..071feee6a 100644 --- a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java @@ -7,6 +7,7 @@ import com.fr.stable.AssistUtils; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.Icon; +import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JRadioButton; import java.awt.BorderLayout; @@ -631,6 +632,12 @@ public class FRGUIPaneFactory { return iconRadioPane; } + public static JPanel createBorderLayoutNorthPaneWithComponent(JComponent content) { + JPanel jPanel = new JPanel(new BorderLayout()); + jPanel.add(content, BorderLayout.NORTH); + return jPanel; + } + /** * 计算宽度 * From 511d6e6aa63598e71f49cfbb4241fcf099f83419 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Thu, 30 Sep 2021 10:22:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-59681=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E6=8E=A7=E5=88=B6=E6=A8=A1=E6=9D=BF=E8=87=AA=E9=80=82?= =?UTF-8?q?=E5=BA=94=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/fit/AdaptiveFrmFitAttrModel.java | 55 +++++ .../fr/design/report/fit/BaseFitAttrPane.java | 228 ++++++++++++++++++ .../fr/design/report/fit/CptFitAttrModel.java | 51 ++++ .../fr/design/report/fit/FitAttrModel.java | 44 ++++ .../fr/design/report/fit/FrmFitAttrModel.java | 53 ++++ .../fit/menupane/ReportFitAttrAction.java | 10 +- .../fit/menupane/TemplateFitAttrPane.java | 104 +++++--- .../AbstractFitAttrModelProvider.java | 18 ++ .../fit/provider/FitAttrModelProvider.java | 11 + .../fr/design/actions/FormFitAttrAction.java | 17 +- .../EditReportServerParameterPane.java | 35 ++- .../fr/design/webattr/ServerFitAttrPane.java | 78 ++++++ 12 files changed, 640 insertions(+), 64 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/report/fit/AdaptiveFrmFitAttrModel.java create mode 100644 designer-base/src/main/java/com/fr/design/report/fit/BaseFitAttrPane.java create mode 100644 designer-base/src/main/java/com/fr/design/report/fit/CptFitAttrModel.java create mode 100644 designer-base/src/main/java/com/fr/design/report/fit/FitAttrModel.java create mode 100644 designer-base/src/main/java/com/fr/design/report/fit/FrmFitAttrModel.java create mode 100644 designer-base/src/main/java/com/fr/design/report/fit/provider/AbstractFitAttrModelProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/report/fit/provider/FitAttrModelProvider.java create mode 100644 designer-realize/src/main/java/com/fr/design/webattr/ServerFitAttrPane.java diff --git a/designer-base/src/main/java/com/fr/design/report/fit/AdaptiveFrmFitAttrModel.java b/designer-base/src/main/java/com/fr/design/report/fit/AdaptiveFrmFitAttrModel.java new file mode 100644 index 000000000..2196b1d40 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/report/fit/AdaptiveFrmFitAttrModel.java @@ -0,0 +1,55 @@ +package com.fr.design.report.fit; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.report.fit.provider.AbstractFitAttrModelProvider; + +import com.fr.form.fit.common.LightTool; +import com.fr.form.fit.config.FormFitConfig; +import com.fr.form.main.Form; +import com.fr.report.fit.ReportFitAttr; + + +public class AdaptiveFrmFitAttrModel extends AbstractFitAttrModelProvider { + + public FitType[] getFitTypes() { + return new FitType[]{ + FitType.DOUBLE_FIT, + FitType.HORIZONTAL_FIT, + FitType.NOT_FIT + }; + } + + public String getFitName() { + return Toolkit.i18nText("Fine-Designer_Fit_Report_Scale_Method"); + } + + @Override + public String getModelName() { + return Toolkit.i18nText("Fine-Design_New_Decision_Report"); + } + + @Override + public ReportFitAttr getGlobalReportFitAttr() { + return FormFitConfig.getInstance().getNewFitAttr(); + } + + @Override + public void setGlobalReportFitAttr(ReportFitAttr reportFitAttr) { + FormFitConfig.getInstance().setNewFitAttr(reportFitAttr); + } + + @Override + public int getPriority() { + return 2; + } + + @Override + public boolean isAvailable(JTemplate jTemplate) { + if (jTemplate.getTarget() instanceof Form) { + return LightTool.containNewFormFlag((Form) jTemplate.getTarget()); + } + return false; + } + +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/report/fit/BaseFitAttrPane.java b/designer-base/src/main/java/com/fr/design/report/fit/BaseFitAttrPane.java new file mode 100644 index 000000000..940e29cb1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/report/fit/BaseFitAttrPane.java @@ -0,0 +1,228 @@ +package com.fr.design.report.fit; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.report.fit.menupane.FitPreviewPane; +import com.fr.design.report.fit.menupane.FitRadioGroup; +import com.fr.design.report.fit.menupane.FontRadioGroup; +import com.fr.design.report.fit.provider.FitAttrModelProvider; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.ComparatorUtils; +import com.fr.report.fit.ReportFitAttr; + +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Set; +import java.util.stream.Collectors; + +import static com.fr.design.i18n.Toolkit.i18nText; + +public abstract class BaseFitAttrPane extends BasicBeanPane { + + protected JPanel contentJPanel; + protected UIComboBox itemChoose; + protected java.util.List fitAttrModelList = new ArrayList<>(); + + public FontRadioGroup fontRadioGroup; + public FitRadioGroup adaptRadioGroup; + public JPanel attrJPanel; + public FitPreviewPane previewJPanel; + public FitAttrModel fitAttrModel; + + + protected BaseFitAttrPane() { + initFitAttrModel(); + } + + private void initFitAttrModel() { + fitAttrModelList.add(new FrmFitAttrModel()); + fitAttrModelList.add(new CptFitAttrModel()); + fitAttrModelList.add(new AdaptiveFrmFitAttrModel()); + + Set fitAttrModelProviders = ExtraDesignClassManager.getInstance().getArray(FitAttrModelProvider.XML_TAG); + + for (FitAttrModelProvider fitAttrModelProvider : fitAttrModelProviders) { + fitAttrModelList.add(fitAttrModelProvider); + } + + fitAttrModelList = fitAttrModelList.stream().sorted(Comparator.comparing(FitAttrModel::getPriority).reversed()).collect(Collectors.toList()); + } + + protected void populateModel(FitAttrModel fitAttrModel) { + this.fitAttrModel = fitAttrModel; + if (attrJPanel != null) { + contentJPanel.remove(attrJPanel); + } + if (previewJPanel != null) { + contentJPanel.remove(previewJPanel); + } + + fontRadioGroup = new FontRadioGroup(); + adaptRadioGroup = new FitRadioGroup(); + initAttrJPanel(); + initPreviewJPanel(); + } + + + protected void initAttrJPanel() { + int colCount = fitAttrModel.getFitTypes().length + 1; + Component[][] components = new Component[2][colCount]; + initFitRadioGroup(fontRadioGroup, i18nText("Fine-Designer_Fit-Font"), new String[]{i18nText("Fine-Designer_Fit"), i18nText("Fine-Designer_Fit-No")}, components[0]); + initFitRadioGroup(adaptRadioGroup, fitAttrModel.getFitName(), Arrays.stream(fitAttrModel.getFitTypes()).map(FitType::description).toArray(String[]::new), components[1]); + + double[] rowSize = new double[2]; + double[] columnSize = new double[colCount]; + for (int i = 0; i < rowSize.length; i++) { + rowSize[i] = 20; + } + for (int i = 0; i < columnSize.length; i++) { + if (i == 0) { + columnSize[i] = 80; + } else { + columnSize[i] = 100; + } + } + + attrJPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + attrJPanel.setBorder(new EmptyBorder(0, 100, 10, 100)); + contentJPanel.add(attrJPanel); + } + + private void initFitRadioGroup(FitRadioGroup fitRadioGroup, String name, String[] options, Component[] components) { + components[0] = new UILabel(name); + for (int i = 0; i < options.length; i++) { + + if (options[i] != null) { + UIRadioButton fontFitRadio = new UIRadioButton(options[i]); + fitRadioGroup.add(fontFitRadio); + components[i + 1] = fontFitRadio; + } else { + components[i + 1] = null; + } + } + fitRadioGroup.addActionListener(getPreviewActionListener()); + } + + protected ActionListener getPreviewActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + refreshPreviewJPanel(); + } + }; + } + + protected void refreshPreviewJPanel() { + String previewIndex = getPreviewIndex(); + previewJPanel.refreshPreview(previewIndex, fontRadioGroup.isEnabled()); + } + + protected String getPreviewIndex() { + return getStateInPC(adaptRadioGroup.getSelectRadioIndex()) + "" + fontRadioGroup.getSelectRadioIndex(); + } + + protected void initPreviewJPanel() { + previewJPanel = new FitPreviewPane(); + contentJPanel.add(previewJPanel); + } + + protected int getStateInPC(int index) { + FitType[] fitTypes = fitAttrModel.getFitTypes(); + return fitTypes[index].getState(); + } + + protected int getOptionIndex(int state) { + FitType[] fitTypes = fitAttrModel.getFitTypes(); + for (int i = 0; i < fitTypes.length; i++) { + if (ComparatorUtils.equals(state, fitTypes[i].getState())) { + return i; + } + } + return 0; + } + + + @Override + public void populateBean(ReportFitAttr ob) { + fontRadioGroup.selectIndexButton(ob.isFitFont() ? 0 : 1); + adaptRadioGroup.selectIndexButton(getOptionIndex(ob.fitStateInPC())); + refreshPreviewJPanel(); + } + + @Override + public ReportFitAttr updateBean() { + ReportFitAttr reportFitAttr = new ReportFitAttr(); + reportFitAttr.setFitFont(fontRadioGroup.isFontFit()); + reportFitAttr.setFitStateInPC(getStateInPC(adaptRadioGroup.getSelectRadioIndex())); + return reportFitAttr; + } + + + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + fontRadioGroup.setEnabled(enabled); + adaptRadioGroup.setEnabled(enabled); + refreshPreviewJPanel(); + } + + @Override + protected String title4PopupWindow() { + return i18nText("Fine-Designer_PC_Element_Case_Fit_Attr"); + } + + protected abstract String[] getItemNames(); + + protected void initComponents() { + this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + contentJPanel = new JPanel(); + contentJPanel.setLayout(FRGUIPaneFactory.createCenterFlowLayout()); + this.add(contentJPanel); + initItemChoose(); + } + + + private void initItemChoose() { + JPanel chooseJPanel = new JPanel(); + chooseJPanel.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); + ItemListener itemListener = getItemListener(); + itemChoose = new UIComboBox(getItemNames()); + itemChoose.addItemListener(itemListener); + UILabel belowSetLabel = new UILabel(i18nText("Fine-Design_Report_Blow_Set")); + JPanel buttonPane = GUICoreUtils.createFlowPane(new Component[]{ + belowSetLabel, itemChoose}, FlowLayout.LEFT, 0, 0); + chooseJPanel.add(buttonPane); + chooseJPanel.setPreferredSize(new Dimension(500, 50)); + JPanel jPanel = new JPanel(); + jPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); + jPanel.add(chooseJPanel, BorderLayout.WEST); + + contentJPanel.add(jPanel); + } + + + protected abstract ItemListener getItemListener(); + + + public void populate(ReportFitAttr reportFitAttr) { + + } + + protected void refresh() { + validate(); + repaint(); + revalidate(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/report/fit/CptFitAttrModel.java b/designer-base/src/main/java/com/fr/design/report/fit/CptFitAttrModel.java new file mode 100644 index 000000000..176f2cee1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/report/fit/CptFitAttrModel.java @@ -0,0 +1,51 @@ +package com.fr.design.report.fit; + + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.report.fit.ReportFitAttr; +import com.fr.report.fit.ReportFitConfig; + + +public class CptFitAttrModel implements FitAttrModel { + + @Override + public FitType[] getFitTypes() { + return new FitType[]{ + FitType.HORIZONTAL_FIT, + FitType.DOUBLE_FIT, + FitType.NOT_FIT + }; + } + + @Override + public String getFitName() { + return Toolkit.i18nText("Fine-Designer_Fit-Element"); + } + + + @Override + public String getModelName() { + return Toolkit.i18nText("Fine-Design_Basic_Plain_Report"); + } + + @Override + public ReportFitAttr getGlobalReportFitAttr() { + return ReportFitConfig.getInstance().getCptFitAttr(); + } + + @Override + public void setGlobalReportFitAttr(ReportFitAttr reportFitAttr) { + ReportFitConfig.getInstance().setCptFitAttr(reportFitAttr); + } + + @Override + public int getPriority() { + return 0; + } + + @Override + public boolean isAvailable(JTemplate jTemplate) { + return jTemplate.isJWorkBook(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/report/fit/FitAttrModel.java b/designer-base/src/main/java/com/fr/design/report/fit/FitAttrModel.java new file mode 100644 index 000000000..1d1ac02f0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/report/fit/FitAttrModel.java @@ -0,0 +1,44 @@ +package com.fr.design.report.fit; + +import com.fr.design.mainframe.JTemplate; +import com.fr.report.fit.ReportFitAttr; + +public interface FitAttrModel { + /** + * @Description 名称,比如:普通报表、决策报表等 + **/ + String getModelName(); + + /** + * @Description 自适应选项的名称,比如返回:表格 + **/ + String getFitName(); + + /** + * @Description 自适应选项 + **/ + FitType[] getFitTypes(); + + + /** + * @Description 获取全局的自适应属性 + **/ + ReportFitAttr getGlobalReportFitAttr(); + + /** + * @Description 设置全局的自适应属性 + * @param: reportFitAttr + **/ + void setGlobalReportFitAttr(ReportFitAttr reportFitAttr); + + /** + * @Description 优先级 + **/ + int getPriority(); + + /** + * @Description 是否可用 + * @param: jTemplate + **/ + boolean isAvailable(JTemplate jTemplate); +} diff --git a/designer-base/src/main/java/com/fr/design/report/fit/FrmFitAttrModel.java b/designer-base/src/main/java/com/fr/design/report/fit/FrmFitAttrModel.java new file mode 100644 index 000000000..258dfbf49 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/report/fit/FrmFitAttrModel.java @@ -0,0 +1,53 @@ +package com.fr.design.report.fit; + + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.report.fit.ReportFitAttr; +import com.fr.report.fit.ReportFitConfig; + + +public class FrmFitAttrModel implements FitAttrModel { + + + @Override + public String getModelName() { + return Toolkit.i18nText("Fine-Design_Basic_Decision_Report"); + } + + @Override + public String getFitName() { + return Toolkit.i18nText("Fine-Designer_Fit-Element"); + } + + public FitType[] getFitTypes() { + return new FitType[]{ + FitType.DEFAULT, + FitType.HORIZONTAL_FIT, + FitType.DOUBLE_FIT, + FitType.NOT_FIT + }; + } + + @Override + public ReportFitAttr getGlobalReportFitAttr() { + return ReportFitConfig.getInstance().getFrmFitAttr(); + } + + @Override + public void setGlobalReportFitAttr(ReportFitAttr reportFitAttr) { + ReportFitConfig.getInstance().setFrmFitAttr(reportFitAttr); + } + + @Override + public int getPriority() { + return 1; + } + + @Override + public boolean isAvailable(JTemplate jTemplate) { + return !jTemplate.isJWorkBook(); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java b/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java index ae0cfd2b6..7f66596a9 100644 --- a/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java +++ b/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java @@ -1,6 +1,5 @@ package com.fr.design.report.fit.menupane; -import com.fr.base.svg.IconUtils; import com.fr.design.actions.JTemplateAction; import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.DialogActionAdapter; @@ -82,13 +81,8 @@ public class ReportFitAttrAction extends JTemplateAction { } final FitProvider wbTpl = (FitProvider) jwb.getTarget(); ReportFitAttr fitAttr = wbTpl.getReportFitAttr(); - if (jwb.isJWorkBook()) { - final TemplateFitAttrPane attrPane = new TemplateFitAttrPane(); - showReportFitDialog(fitAttr, jwb, wbTpl, attrPane); - } else { - final ReportFitAttrPane attrPane = new ReportFitAttrPane(); - showReportFitDialog(fitAttr, jwb, wbTpl, attrPane); - } + TemplateFitAttrPane templateFitAttrPane = new TemplateFitAttrPane(); + showReportFitDialog(fitAttr, jwb, wbTpl, templateFitAttrPane); } private void showReportFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane attrPane) { diff --git a/designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateFitAttrPane.java b/designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateFitAttrPane.java index 66673fc5f..393cbfc71 100644 --- a/designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateFitAttrPane.java +++ b/designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateFitAttrPane.java @@ -1,55 +1,91 @@ package com.fr.design.report.fit.menupane; -import com.fr.design.beans.BasicBeanPane; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.report.fit.BaseFitAttrPane; +import com.fr.design.report.fit.FitAttrModel; +import com.fr.general.ComparatorUtils; +import com.fr.report.fit.FitProvider; import com.fr.report.fit.ReportFitAttr; -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; -/** - * Created by 夏翔 on 2016/6/24. - */ -public class TemplateFitAttrPane extends BasicBeanPane { - private TemplateBrowserFitAttrPane attrPane; +public class TemplateFitAttrPane extends BaseFitAttrPane { public TemplateFitAttrPane() { initComponents(); } - private void initComponents() { - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - attrPane = new TemplateBrowserFitAttrPane(); - this.add(attrPane); + @Override + protected void initComponents() { + super.initComponents(); + for (FitAttrModel fitAttrModel : fitAttrModelList) { + if (fitAttrModel.isAvailable(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) { + populateModel(fitAttrModel); + break; + } + } + } + @Override + public void populateBean(ReportFitAttr reportFitAttr) { + if (reportFitAttr == null) { + itemChoose.setSelectedItem(Toolkit.i18nText("Fine-Design_Report_Using_Server_Report_View_Settings")); + } else { + itemChoose.setSelectedItem(Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single")); + } + populate(reportFitAttr); } - /** - * 展示界面 - * - * @param fitAttr 自适应属性 - */ - public void populateBean(ReportFitAttr fitAttr) { - attrPane.populateBean(fitAttr); + public void populate(ReportFitAttr reportFitAttr) { + if (reportFitAttr == null) { + reportFitAttr = fitAttrModel.getGlobalReportFitAttr(); + } + + super.setEnabled(isTemplateSingleSet()); + super.populateBean(reportFitAttr); } - /** - * 提交数据 - * - * @return 界面上的更新数据 - */ public ReportFitAttr updateBean() { - return attrPane.updateBean(); + if (!isTemplateSingleSet()) { + return null; + } else { + return super.updateBean(); + } + } + + @Override + protected String[] getItemNames() { + return new String[]{Toolkit.i18nText("Fine-Design_Report_Using_Server_Report_View_Settings"), + Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single")}; + } + + @Override + protected ItemListener getItemListener() { + return new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + if(isTemplateSingleSet()){ + JTemplate jwb = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jwb != null) { + FitProvider wbTpl = (FitProvider) jwb.getTarget(); + ReportFitAttr fitAttr = wbTpl.getReportFitAttr(); + populate(fitAttr); + } + }else { + populate(fitAttrModel.getGlobalReportFitAttr()); + } + } + } + }; } - /** - * 标题 - * - * @return 标题 - */ - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_PC_Fit_Attr"); + private boolean isTemplateSingleSet() { + return ComparatorUtils.equals(Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single"), itemChoose.getSelectedItem()); } -} +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/report/fit/provider/AbstractFitAttrModelProvider.java b/designer-base/src/main/java/com/fr/design/report/fit/provider/AbstractFitAttrModelProvider.java new file mode 100644 index 000000000..44d048b7d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/report/fit/provider/AbstractFitAttrModelProvider.java @@ -0,0 +1,18 @@ +package com.fr.design.report.fit.provider; + +import com.fr.stable.fun.mark.API; + + +@API(level = FitAttrModelProvider.CURRENT_LEVEL) +public abstract class AbstractFitAttrModelProvider implements FitAttrModelProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/report/fit/provider/FitAttrModelProvider.java b/designer-base/src/main/java/com/fr/design/report/fit/provider/FitAttrModelProvider.java new file mode 100644 index 000000000..88f7335d4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/report/fit/provider/FitAttrModelProvider.java @@ -0,0 +1,11 @@ +package com.fr.design.report.fit.provider; + + +import com.fr.design.report.fit.FitAttrModel; +import com.fr.stable.fun.mark.Mutable; + + +public interface FitAttrModelProvider extends Mutable, FitAttrModel { + String XML_TAG = "FitAttrModelProvider"; + int CURRENT_LEVEL = 1; +} diff --git a/designer-form/src/main/java/com/fr/design/actions/FormFitAttrAction.java b/designer-form/src/main/java/com/fr/design/actions/FormFitAttrAction.java index 2828abef2..30f8b3c60 100644 --- a/designer-form/src/main/java/com/fr/design/actions/FormFitAttrAction.java +++ b/designer-form/src/main/java/com/fr/design/actions/FormFitAttrAction.java @@ -8,6 +8,7 @@ import com.fr.design.fit.NewJForm; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.MenuKeySet; +import com.fr.design.report.fit.menupane.TemplateFitAttrPane; import com.fr.report.fit.FitProvider; import com.fr.report.fit.ReportFitAttr; @@ -47,26 +48,20 @@ public class FormFitAttrAction extends JTemplateAction { this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(DesignerUIModeConfig.getInstance().newUIMode() ? - "/com/fr/design/images/reportfit/fit.png": - "/com/fr/design/images/reportfit/fit"); + "/com/fr/design/images/reportfit/fit.png" : + "/com/fr/design/images/reportfit/fit"); } - /** - * Action触发事件 - * - * @param e 事件 - */ @Override public void actionPerformed(ActionEvent e) { final JTemplate jwb = getEditingComponent(); - if (jwb == null || !(jwb instanceof NewJForm)) { + if (jwb == null) { return; } final FitProvider wbTpl = (FitProvider) jwb.getTarget(); ReportFitAttr fitAttr = wbTpl.getReportFitAttr(); - NewJForm newJForm = (NewJForm) jwb; - BasicBeanPane attrPane = newJForm.getJFormType().obtainAttrPane(newJForm); - showFitDialog(fitAttr, jwb, wbTpl, attrPane); + TemplateFitAttrPane templateFitAttrPane = new TemplateFitAttrPane(); + showFitDialog(fitAttr, jwb, wbTpl, templateFitAttrPane); } private void showFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane attrPane) { diff --git a/designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java b/designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java index 18d110400..92885a3b3 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java @@ -9,6 +9,7 @@ import com.fr.config.PrintConfig; import com.fr.config.ServerPreferenceConfig; import com.fr.design.gui.frpane.LoadingBasicPane; import com.fr.design.gui.frpane.UITabbedPane; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.webattr.printsettings.GlobalNativePrintSettingPane; import com.fr.design.webattr.printsettings.PrintSettingPane; @@ -17,6 +18,7 @@ import com.fr.report.web.WebPage; import com.fr.report.web.WebView; import com.fr.report.web.WebWrite; import com.fr.web.attr.ReportWebAttr; +import com.fr.workspace.WorkContext; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -35,18 +37,20 @@ public class EditReportServerParameterPane extends LoadingBasicPane { private WriteToolBarPane writePane; private ReportWebAttr webAttr; private PrintSettingsAttrMark printSettings; - + private WebCssPane cssPane; - + private WebJsPane jsPane; - + private ErrorTemplatePane errorTemplatePane; private PrintSettingPane printSettingPane; + private ServerFitAttrPane serverFitAttrPane; + @Override - protected synchronized void initComponents(JPanel container) { + protected synchronized void initComponents(JPanel container) { JPanel defaultPane = container; defaultPane.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -61,11 +65,14 @@ public class EditReportServerParameterPane extends LoadingBasicPane { tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportServerP_Import_JavaScript"), jsPane = new WebJsPane()); tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Error_Handler_Template"), errorTemplatePane = new ErrorTemplatePane()); tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Print_Setting"), printSettingPane = new PrintSettingPane(new GlobalNativePrintSettingPane())); + if (WorkContext.getCurrent().isRoot()) { + tabbedPane.addTab(Toolkit.i18nText("Fine-Designer_PC_Fit_Attr"), serverFitAttrPane = new ServerFitAttrPane()); + } } - + @Override protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportServerP_Report_Server_Parameter"); + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportServerP_Report_Server_Parameter"); } public void populate(ServerPreferenceConfig reportServerPreferenceConfig) { @@ -78,28 +85,31 @@ public class EditReportServerParameterPane extends LoadingBasicPane { WebPage webPage = webAttr.getWebPage(); WebView webView = webAttr.getWebView(); WebWrite webWrite = webAttr.getWebWrite(); - if(webPage != null){ + if (webPage != null) { pagePane.populateBean(webPage); } - if(webView != null){ + if (webView != null) { viewPane.populateBean(webView); } - if(webWrite != null){ + if (webWrite != null) { writePane.populateBean(webWrite); } cssPane.populate(webAttr); jsPane.populate(webAttr); printSettings = ReportUtils.getPrintSettingsFromServerConfig(); printSettingPane.populate(printSettings); - + this.errorTemplatePane.populateBean(reportServerPreferenceConfig.getErrorTemplate()); + if (serverFitAttrPane != null) { + serverFitAttrPane.populateBean(null); + } } /** * Update. */ public void update(ServerPreferenceConfig reportServerPreferenceConfig) { - ReportWebAttr webAttr = ((ReportWebAttr)ConfigManager.getProviderInstance().getGlobalAttribute(ReportWebAttr.class)); + ReportWebAttr webAttr = ((ReportWebAttr) ConfigManager.getProviderInstance().getGlobalAttribute(ReportWebAttr.class)); webAttr.setWebPage(pagePane.updateBean()); webAttr.setWebView(viewPane.updateBean()); webAttr.setWebWrite(writePane.updateBean()); @@ -110,5 +120,8 @@ public class EditReportServerParameterPane extends LoadingBasicPane { PrintConfig.getInstance().setPrintSettings(printSettings); reportServerPreferenceConfig.setErrorTemplate(this.errorTemplatePane.updateBean()); + if (serverFitAttrPane != null) { + serverFitAttrPane.updateBean(); + } } } diff --git a/designer-realize/src/main/java/com/fr/design/webattr/ServerFitAttrPane.java b/designer-realize/src/main/java/com/fr/design/webattr/ServerFitAttrPane.java new file mode 100644 index 000000000..bbe52ae99 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/webattr/ServerFitAttrPane.java @@ -0,0 +1,78 @@ +package com.fr.design.webattr; + +import com.fr.config.Configuration; +import com.fr.design.report.fit.BaseFitAttrPane; +import com.fr.design.report.fit.FitAttrModel; +import com.fr.general.ComparatorUtils; +import com.fr.report.fit.ReportFitAttr; +import com.fr.report.fit.ReportFitConfig; +import com.fr.transaction.Configurations; +import com.fr.transaction.Worker; + +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + + +public class ServerFitAttrPane extends BaseFitAttrPane { + + public ServerFitAttrPane() { + super(); + initComponents(); + } + + @Override + protected void initComponents() { + super.initComponents(); + populateModel(fitAttrModelList.get(0)); + } + + + @Override + public void populateBean(ReportFitAttr reportFitAttr) { + reportFitAttr = fitAttrModel.getGlobalReportFitAttr(); + super.populateBean(reportFitAttr); + } + + + public ReportFitAttr updateBean() { + ReportFitAttr reportFitAttr = super.updateBean(); + Configurations.update(new Worker() { + @Override + public void run() { + fitAttrModel.setGlobalReportFitAttr(reportFitAttr); + } + + @Override + public Class[] targets() { + return new Class[]{ReportFitConfig.class}; + } + }); + return null; + + } + + @Override + protected String[] getItemNames() { + return fitAttrModelList.stream().map(FitAttrModel::getModelName).toArray(String[]::new); + } + + @Override + protected ItemListener getItemListener() { + ServerFitAttrPane self = this; + return new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + for (FitAttrModel fitAttrModel : fitAttrModelList) { + if (ComparatorUtils.equals(e.getItem(), fitAttrModel.getModelName())) { + self.populateModel(fitAttrModel); + populateBean(null); + refresh(); + } + } + } + } + }; + } +} +