From f437038ed47075e8805a98bd56674fe2df980a00 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 6 Jan 2022 17:12:45 +0800 Subject: [PATCH 1/7] =?UTF-8?q?REPORT-64445=20=E6=96=B0=E8=80=81=E8=87=AA?= =?UTF-8?q?=E9=80=82=E5=BA=94=E9=85=8D=E7=BD=AE=E9=9D=A2=E6=9D=BF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/ilable/UIAutoChangeLineLabel.java | 78 ++++ .../report/fit/AdaptiveFrmFitAttrModel.java | 6 +- .../fr/design/report/fit/BaseFitAttrPane.java | 130 +----- .../fr/design/report/fit/FitAttrModel.java | 9 + .../com/fr/design/report/fit/FitType.java | 11 + .../report/fit/FormFitAttrModelType.java | 128 ++++++ .../design/report/fit/FormFitConfigPane.java | 59 +++ .../fr/design/report/fit/FrmFitAttrModel.java | 9 +- .../design/report/fit/NewFitPreviewPane.java | 71 ++++ .../report/fit/ReportFitConfigPane.java | 172 ++++++++ .../com/fr/design/fit/FormFitAttrAction.java | 85 ++++ .../com/fr/design/fit/FormFitAttrPane.java | 377 ++++++++++++++++++ .../java/com/fr/design/mainframe/JForm.java | 14 +- .../FRAbsoluteBodyLayoutDefinePane.java | 110 +---- .../layout/FRAbsoluteLayoutDefinePane.java | 54 +-- .../layout/FRFitLayoutDefinePane.java | 118 +----- 16 files changed, 1032 insertions(+), 399 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/gui/ilable/UIAutoChangeLineLabel.java create mode 100644 designer-base/src/main/java/com/fr/design/report/fit/FormFitAttrModelType.java create mode 100644 designer-base/src/main/java/com/fr/design/report/fit/FormFitConfigPane.java create mode 100644 designer-base/src/main/java/com/fr/design/report/fit/NewFitPreviewPane.java create mode 100644 designer-base/src/main/java/com/fr/design/report/fit/ReportFitConfigPane.java create mode 100644 designer-form/src/main/java/com/fr/design/fit/FormFitAttrAction.java create mode 100644 designer-form/src/main/java/com/fr/design/fit/FormFitAttrPane.java diff --git a/designer-base/src/main/java/com/fr/design/gui/ilable/UIAutoChangeLineLabel.java b/designer-base/src/main/java/com/fr/design/gui/ilable/UIAutoChangeLineLabel.java new file mode 100644 index 0000000000..d2bb0450b1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ilable/UIAutoChangeLineLabel.java @@ -0,0 +1,78 @@ +package com.fr.design.gui.ilable; + +import javax.swing.JLabel; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.util.ArrayList; +import java.util.List; + +public class UIAutoChangeLineLabel extends JLabel { + private final String text; + private final int width; + + + public UIAutoChangeLineLabel(String text, int width) { + super(text); + this.text = text; + this.width = width; + } + + + @Override + public void doLayout() { + super.doLayout(); + this.setText(wrapperHtmlText()); + } + + private String wrapperHtmlText() { + List stringList = autoChangeLine(this.getWidth()); + StringBuilder builder = new StringBuilder(""); + for (String s : stringList) { + //用THML标签进行拼接,以实现自动换行 + builder.append(s).append("
"); + } + builder.append(""); + return builder.toString(); + } + + private List autoChangeLine(int width) { + List result = new ArrayList<>(); + if (width <= 0) { + result.add(this.text); + } else { + + char[] chars = this.text.toCharArray(); + //获取字体计算大小 + FontMetrics fontMetrics = this.getFontMetrics(this.getFont()); + int start = 0; + int len = 0; + while (start + len < this.text.length()) { + while (true) { + len++; + if (start + len > this.text.length()) + break; + if (fontMetrics.charsWidth(chars, start, len) + > width) { + break; + } + } + result.add(String.copyValueOf(chars, start, len - 1)); + start = start + len - 1; + len = 0; + } + if (this.text.length() - start > 0) { + result.add(String.copyValueOf(chars, start, this.text.length() - start)); + } + } + return result; + } + + + @Override + public Dimension getPreferredSize() { + Dimension preferredSize = super.getPreferredSize(); + List stringList = autoChangeLine(width); + FontMetrics fontMetrics = this.getFontMetrics(this.getFont()); + return new Dimension(preferredSize.width, fontMetrics.getHeight() * stringList.size()); + } +} 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 index 9e60c6cc84..8c5e8858ac 100644 --- 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 @@ -13,11 +13,7 @@ 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 - }; + return new FitType[0]; } public String getFitName() { 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 index 2c38d597c4..48d6a5686e 100644 --- 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 @@ -2,27 +2,17 @@ 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.i18n.DesignSizeI18nManager; 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 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; @@ -35,11 +25,8 @@ public abstract class BaseFitAttrPane extends BasicBeanPane { protected UILabel belowSetLabel; protected UIComboBox itemChoose; protected java.util.List fitAttrModelList = new ArrayList<>(); + private ReportFitConfigPane fitConfigPane; - public FontRadioGroup fontRadioGroup; - public FitRadioGroup adaptRadioGroup; - public JPanel attrJPanel; - public FitPreviewPane previewJPanel; public FitAttrModel fitAttrModel; private static final int BELOW_SET_COMPONENT_HSPACE = 8; @@ -64,128 +51,27 @@ public abstract class BaseFitAttrPane extends BasicBeanPane { protected void populateModel(FitAttrModel fitAttrModel) { this.fitAttrModel = fitAttrModel; - if (attrJPanel != null) { - contentJPanel.remove(attrJPanel); + if (fitConfigPane != null) { + contentJPanel.remove(fitConfigPane); } - if (previewJPanel != null) { - contentJPanel.remove(previewJPanel); - } - - fontRadioGroup = new FontRadioGroup(); - adaptRadioGroup = new FitRadioGroup(); - initAttrJPanel(); - initPreviewJPanel(); + this.fitConfigPane = fitAttrModel instanceof CptFitAttrModel ? new ReportFitConfigPane(fitAttrModel, true) : new FormFitConfigPane(fitAttrModel, true); + contentJPanel.add(fitConfigPane); } - - 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] = DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.fit.firstColumn").getWidth(); - } else { - columnSize[i] = DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.fit.column").getWidth(); - } - } - - attrJPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - attrJPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0)); - 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(); - previewJPanel.setBorder(BorderFactory.createEmptyBorder(0, getPreviewJPanelLeft(), 0, 0)); - contentJPanel.add(previewJPanel); - } - - private int getPreviewJPanelLeft() { - int left = 0; - if (belowSetLabel.getPreferredSize() != null) { - left = belowSetLabel.getPreferredSize().width + BELOW_SET_COMPONENT_HSPACE; - } - return left; - } - - 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(); + this.fitConfigPane.populateBean(ob); } @Override public ReportFitAttr updateBean() { - ReportFitAttr reportFitAttr = new ReportFitAttr(); - reportFitAttr.setFitFont(fontRadioGroup.isFontFit()); - reportFitAttr.setFitStateInPC(getStateInPC(adaptRadioGroup.getSelectRadioIndex())); - return reportFitAttr; + return this.fitConfigPane.updateBean(); } public void setEnabled(boolean enabled) { super.setEnabled(enabled); - fontRadioGroup.setEnabled(enabled); - adaptRadioGroup.setEnabled(enabled); - refreshPreviewJPanel(); + this.fitConfigPane.setEnabled(enabled); } @Override 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 index 1d1ac02f0d..2a834eebd8 100644 --- 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 @@ -3,6 +3,8 @@ package com.fr.design.report.fit; import com.fr.design.mainframe.JTemplate; import com.fr.report.fit.ReportFitAttr; +import java.util.Arrays; + public interface FitAttrModel { /** * @Description 名称,比如:普通报表、决策报表等 @@ -19,6 +21,12 @@ public interface FitAttrModel { **/ FitType[] getFitTypes(); + /** + * @Description 表格自适应选项名称集合 + **/ + default String[] getFitTypeNames(){ + return Arrays.stream(getFitTypes()).map(FitType::description).toArray(String[]::new); + } /** * @Description 获取全局的自适应属性 @@ -41,4 +49,5 @@ public interface FitAttrModel { * @param: jTemplate **/ boolean isAvailable(JTemplate jTemplate); + } diff --git a/designer-base/src/main/java/com/fr/design/report/fit/FitType.java b/designer-base/src/main/java/com/fr/design/report/fit/FitType.java index 00aceb6eb1..dd4888b4e5 100644 --- a/designer-base/src/main/java/com/fr/design/report/fit/FitType.java +++ b/designer-base/src/main/java/com/fr/design/report/fit/FitType.java @@ -60,6 +60,17 @@ public enum FitType { return DEFAULT; } + public static FitType parseByFitState(int state) { + + for (FitType attrState : values()) { + if (attrState.state == state) { + return attrState; + } + } + + return DEFAULT; + } + public int getState() { return this.state; } diff --git a/designer-base/src/main/java/com/fr/design/report/fit/FormFitAttrModelType.java b/designer-base/src/main/java/com/fr/design/report/fit/FormFitAttrModelType.java new file mode 100644 index 0000000000..a77566442d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/report/fit/FormFitAttrModelType.java @@ -0,0 +1,128 @@ +package com.fr.design.report.fit; + + +import com.fr.design.designer.properties.items.Item; +import com.fr.form.fit.common.LightTool; +import com.fr.form.main.BodyScaleAttrTransformer; +import com.fr.form.main.Form; +import com.fr.form.ui.container.WAbsoluteLayout; +import com.fr.form.ui.container.WBodyLayoutType; +import com.fr.form.ui.container.WFitLayout; + +public enum FormFitAttrModelType { + PLAIN_FORM_FIT_ATTR_MODEL { + @Override + public FitAttrModel getFitAttrModel() { + return new FrmFitAttrModel(); + } + + @Override + public Item[] getFitLayoutScaleAttr() { + return new Item[]{ + new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Bidirectional_Adaptive"), WFitLayout.STATE_FULL), + new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Horizontal_Adaptive"), WFitLayout.STATE_ORIGIN)}; + + } + + @Override + public Item[] getAbsoluteLayoutSaleAttr() { + return new Item[]{ + new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fit"), WAbsoluteLayout.STATE_FIT), + new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fixed"), WAbsoluteLayout.STATE_FIXED) + }; + } + + + @Override + public int getScaleAttrShowIndex(WFitLayout wFitLayout) { + int scale = wFitLayout.getScaleAttr(); + if (wFitLayout.getBodyLayoutType() == WBodyLayoutType.FIT) { + return BodyScaleAttrTransformer.getFitBodyCompStateFromScaleAttr(scale); + } else { + return BodyScaleAttrTransformer.getAbsoluteBodyCompStateFromScaleAttr(scale); + } + } + + @Override + public int parseScaleAttrFromShowIndex(int showIndex, WBodyLayoutType wBodyLayoutType) { + if (wBodyLayoutType == WBodyLayoutType.FIT) { + if (showIndex == 0) { + return WFitLayout.SCALE_FULL; + } else { + return WFitLayout.SCALE_HOR; + } + } else { + if (showIndex == 0) { + return WFitLayout.SCALE_FULL; + } else { + return WFitLayout.SCALE_NO; + } + } + } + + + }, + NEW_FORM_FIT_ATTR_MODEL { + @Override + public FitAttrModel getFitAttrModel() { + return new AdaptiveFrmFitAttrModel(); + } + + @Override + public Item[] getFitLayoutScaleAttr() { + return new Item[]{ + new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Bidirectional_Adaptive"), WFitLayout.STATE_FULL), + new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Horizontal_Adaptive"), WFitLayout.STATE_ORIGIN), + new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fixed"), 2)}; + } + + @Override + public Item[] getAbsoluteLayoutSaleAttr() { + return new Item[]{ + new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Bidirectional_Adaptive"), WFitLayout.STATE_FULL), + new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Horizontal_Adaptive"), WFitLayout.STATE_ORIGIN), + new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fixed"), 2)}; + } + + + @Override + public int getScaleAttrShowIndex(WFitLayout wFitLayout) { + int scale = wFitLayout.getScaleAttr(); + if (scale == WFitLayout.SCALE_NO) { + return 2; + } else if (scale == WFitLayout.SCALE_HOR) { + return 1; + } else { + return 0; + } + } + + @Override + public int parseScaleAttrFromShowIndex(int showIndex, WBodyLayoutType wBodyLayoutType) { + if (showIndex == 0) { + return WFitLayout.SCALE_FULL; + } else if (showIndex == 1) { + return WFitLayout.SCALE_HOR; + } else { + return WFitLayout.SCALE_NO; + } + } + + + }; + + public abstract FitAttrModel getFitAttrModel(); + + public abstract Item[] getFitLayoutScaleAttr(); + + public abstract Item[] getAbsoluteLayoutSaleAttr(); + + public abstract int getScaleAttrShowIndex(WFitLayout wFitLayout); + + public abstract int parseScaleAttrFromShowIndex(int showIndex, WBodyLayoutType wBodyLayoutType); + + + public static FormFitAttrModelType parse(Form form) { + return LightTool.containNewFormFlag(form) ? NEW_FORM_FIT_ATTR_MODEL : PLAIN_FORM_FIT_ATTR_MODEL; + } +} diff --git a/designer-base/src/main/java/com/fr/design/report/fit/FormFitConfigPane.java b/designer-base/src/main/java/com/fr/design/report/fit/FormFitConfigPane.java new file mode 100644 index 0000000000..08b70cb772 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/report/fit/FormFitConfigPane.java @@ -0,0 +1,59 @@ +package com.fr.design.report.fit; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.report.fit.ReportFitAttr; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; + +public class FormFitConfigPane extends ReportFitConfigPane { + private static final int DEFAULT_ITEM = 0; + private static final int CUSTOM_ITEM = 1; + + public FormFitConfigPane(FitAttrModel fitAttrModel) { + this(fitAttrModel, false); + } + + public FormFitConfigPane(FitAttrModel fitAttrModel, boolean globalConfig) { + super(fitAttrModel, globalConfig); + } + + protected JPanel initECConfigPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + if (fitAttrModel.getFitTypeNames().length != 0) { + Component[] ecComponents = new Component[fitAttrModel.getFitTypeNames().length + 1]; + initRadioGroup(ecConfigRadioGroup, fitAttrModel.getFitName(), fitAttrModel.getFitTypeNames(), ecComponents); + jPanel.add(createSubAttrPane(ecComponents), BorderLayout.CENTER); + jPanel.add(createTipPane(), BorderLayout.SOUTH); + } + return jPanel; + } + + private JPanel createTipPane() { + JPanel jPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); + UILabel label1 = new UILabel(Toolkit.i18nText("Fine-Design_Form_PC_FIT_Config_Tip1")); + jPanel.add(label1); + label1.setForeground(Color.lightGray); + UILabel label2 = new UILabel(Toolkit.i18nText("Fine-Design_Form_PC_FIT_Config_Tip2")); + jPanel.add(label2); + label2.setForeground(Color.lightGray); + return jPanel; + } + + protected void refreshPreviewJPanel() { + previewJPanel.refreshPreview(fontRadioGroup.isFontFit()); + } + + protected void populateECConfigRadioGroup(int fitStateInPC) { + ecConfigRadioGroup.selectIndexButton(fitStateInPC == 0 ? DEFAULT_ITEM : CUSTOM_ITEM); + } + + protected void updateECConfigRadioGroup(ReportFitAttr reportFitAttr) { + reportFitAttr.setFitStateInPC(ecConfigRadioGroup.getSelectRadioIndex()); + } + +} 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 index c4bdaf6de2..81ee474de1 100644 --- 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 @@ -17,7 +17,7 @@ public class FrmFitAttrModel implements FitAttrModel { @Override public String getFitName() { - return Toolkit.i18nText("Fine-Designer_Fit-Element"); + return Toolkit.i18nText("Fine-Design_Form_PC_FIT_Config_EC_Label"); } public FitType[] getFitTypes() { @@ -29,6 +29,13 @@ public class FrmFitAttrModel implements FitAttrModel { }; } + @Override + public String[] getFitTypeNames() { + return new String[]{ + Toolkit.i18nText("Fine-Designer_Fit-Default"), Toolkit.i18nText("Fine-Design_Basic_Custom") + }; + } + @Override public ReportFitAttr getGlobalReportFitAttr() { return ReportFitConfig.getInstance().getFrmFitAttr(); diff --git a/designer-base/src/main/java/com/fr/design/report/fit/NewFitPreviewPane.java b/designer-base/src/main/java/com/fr/design/report/fit/NewFitPreviewPane.java new file mode 100644 index 0000000000..8b0710de3f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/report/fit/NewFitPreviewPane.java @@ -0,0 +1,71 @@ +package com.fr.design.report.fit; + +import com.fr.base.GraphHelper; +import com.fr.general.FRFont; + +import javax.swing.JPanel; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; + + +public class NewFitPreviewPane extends JPanel { + private boolean fitFont = false; + private FitType fitType = FitType.DOUBLE_FIT; + private static final Color DEFAULT_PAINT_COLOR = Color.decode("#419BF9"); + private static final int FIT_FONT_SIZE = 15; + private static final int NO_FIT_FONT_SIZE = 9; + private static final Dimension NO_FIT_CONTAINER_DIMENSION = new Dimension(200, 136); + + @Override + public void paint(Graphics g) { + super.paint(g); + g.setColor(Color.GRAY); + GraphHelper.drawRect(g, 1, 1, this.getWidth() - 2, this.getHeight() - 2); + g.setColor(DEFAULT_PAINT_COLOR); + FRFont textFont = FRFont.getInstance(FRFont.DEFAULT_FONTNAME, Font.PLAIN, fitFont ? FIT_FONT_SIZE : NO_FIT_FONT_SIZE); + g.setFont(textFont); + Dimension dimension = calculateCellDimension(); + GraphHelper.drawLine(g, 1, dimension.height, dimension.width * 2 - 1, dimension.height); + GraphHelper.drawLine(g, dimension.width, 1, dimension.width, dimension.height * 2 - 1); + GraphHelper.drawRect(g, 1, 1, dimension.width * 2 - 2, dimension.height * 2 - 2); + double startX = calculateTextDrawStartX(dimension.width, this.getFontMetrics(textFont), "text1"); + double startY = calculateTextDrawStartY(dimension.height); + GraphHelper.drawString(g, "text1", startX, startY); + GraphHelper.drawString(g, "text2", dimension.width + startX, startY); + GraphHelper.drawString(g, "text3", startX, dimension.height + startY); + GraphHelper.drawString(g, "text4", dimension.width + startX, dimension.height + startY); + } + + private Dimension calculateCellDimension() { + if (fitType == FitType.DOUBLE_FIT) { + return new Dimension(this.getWidth() / 2, this.getHeight() / 2); + } else if (fitType == FitType.NOT_FIT) { + return new Dimension(NO_FIT_CONTAINER_DIMENSION.width / 2, NO_FIT_CONTAINER_DIMENSION.height / 2); + } else { + return new Dimension(this.getWidth() / 2, NO_FIT_CONTAINER_DIMENSION.height / 2); + } + } + + private double calculateTextDrawStartX(int containerWidth, FontMetrics fontMetrics, String text) { + return (containerWidth - fontMetrics.stringWidth(text)) / 2.0D; + } + + private double calculateTextDrawStartY(int containerHeight) { + return containerHeight / 2.0D; + } + + public void refreshPreview(boolean fitFont, FitType fitType) { + this.fitFont = fitFont; + this.fitType = fitType; + repaint(); + } + + public void refreshPreview(boolean fitFont) { + this.fitFont = fitFont; + repaint(); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/report/fit/ReportFitConfigPane.java b/designer-base/src/main/java/com/fr/design/report/fit/ReportFitConfigPane.java new file mode 100644 index 0000000000..399e7fef93 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/report/fit/ReportFitConfigPane.java @@ -0,0 +1,172 @@ +package com.fr.design.report.fit; + +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.DesignSizeI18nManager; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.report.fit.menupane.FitRadioGroup; +import com.fr.design.report.fit.menupane.FontRadioGroup; +import com.fr.general.ComparatorUtils; +import com.fr.report.fit.ReportFitAttr; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import static com.fr.design.i18n.Toolkit.i18nText; + +public class ReportFitConfigPane extends JPanel { + public FontRadioGroup fontRadioGroup; + public FitRadioGroup ecConfigRadioGroup; + protected NewFitPreviewPane previewJPanel; + protected FitAttrModel fitAttrModel; + protected boolean globalConfig; + + + public ReportFitConfigPane(FitAttrModel fitAttrModel, boolean globalConfig) { + this.fitAttrModel = fitAttrModel; + this.globalConfig = globalConfig; + initComponent(); + } + + private void initComponent() { + JPanel contentJPanel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(false, FlowLayout.LEFT, 0, 0); + this.add(contentJPanel); + fontRadioGroup = new FontRadioGroup(); + ecConfigRadioGroup = new FitRadioGroup(); + contentJPanel.add(initAttrJPanel()); + contentJPanel.add(initPreviewJPanel()); + } + + private JPanel initAttrJPanel() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + Component[] fontComponents = new Component[3]; + initRadioGroup(fontRadioGroup, i18nText("Fine-Designer_Fit-Font"), new String[]{i18nText("Fine-Designer_Fit"), i18nText("Fine-Designer_Fit-No")}, fontComponents); + jPanel.add(createSubAttrPane(fontComponents), BorderLayout.NORTH); + jPanel.add(initECConfigPane(), BorderLayout.CENTER); + return jPanel; + } + + protected JPanel initECConfigPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + Component[] ecComponents = new Component[fitAttrModel.getFitTypeNames().length + 1]; + initRadioGroup(ecConfigRadioGroup, fitAttrModel.getFitName(), fitAttrModel.getFitTypeNames(), ecComponents); + jPanel.add(createSubAttrPane(ecComponents), BorderLayout.CENTER); + return jPanel; + } + + + protected JPanel createSubAttrPane(Component[] components) { + double[] rowSize = new double[]{20}; + double[] columnSize = new double[components.length]; + for (int i = 0; i < columnSize.length; i++) { + if (i == 0) { + columnSize[i] = DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.fit.firstColumn").getWidth(); + } else { + columnSize[i] = DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.fit.column").getWidth(); + } + } + + JPanel attrJPanel = TableLayoutHelper.createTableLayoutPane(new Component[][]{components}, rowSize, columnSize); + attrJPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0)); + return attrJPanel; + } + + protected void initRadioGroup(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()); + } + + private ActionListener getPreviewActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + refreshPreviewJPanel(); + } + }; + } + + public void refreshPreviewJPanel(FitType fitType) { + previewJPanel.refreshPreview(fontRadioGroup.isFontFit(), fitType); + } + + protected void refreshPreviewJPanel() { + previewJPanel.refreshPreview(fontRadioGroup.isFontFit(), FitType.parse(updateBean())); + } + + private JPanel initPreviewJPanel() { + JPanel wrapperPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + previewJPanel = new NewFitPreviewPane(); + wrapperPane.add(previewJPanel, BorderLayout.CENTER); + int leftIndent = globalConfig ? (int) DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.fit.firstColumn").getWidth() : 0; + wrapperPane.setBorder(BorderFactory.createEmptyBorder(0, leftIndent, 0, 0)); + wrapperPane.setPreferredSize(new Dimension(300 + leftIndent, 204)); + return wrapperPane; + } + + + public void populateBean(ReportFitAttr ob) { + fontRadioGroup.selectIndexButton(ob.isFitFont() ? 0 : 1); + populateECConfigRadioGroup(ob.fitStateInPC()); + refreshPreviewJPanel(); + } + + protected void populateECConfigRadioGroup(int fitStateInPC){ + ecConfigRadioGroup.selectIndexButton(getOptionIndex(fitStateInPC)); + } + + + protected void updateECConfigRadioGroup(ReportFitAttr reportFitAttr){ + reportFitAttr.setFitStateInPC(getStateInPC(ecConfigRadioGroup.getSelectRadioIndex())); + } + + public ReportFitAttr updateBean() { + ReportFitAttr reportFitAttr = new ReportFitAttr(); + reportFitAttr.setFitFont(fontRadioGroup.isFontFit()); + updateECConfigRadioGroup(reportFitAttr); + return reportFitAttr; + } + + + protected int getStateInPC(int index) { + FitType[] fitTypes = fitAttrModel.getFitTypes(); + if (index > fitTypes.length - 1) { + return index; + } + 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; + } + + + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + fontRadioGroup.setEnabled(enabled); + ecConfigRadioGroup.setEnabled(enabled); + } + +} diff --git a/designer-form/src/main/java/com/fr/design/fit/FormFitAttrAction.java b/designer-form/src/main/java/com/fr/design/fit/FormFitAttrAction.java new file mode 100644 index 0000000000..dad6e9be9c --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/fit/FormFitAttrAction.java @@ -0,0 +1,85 @@ +package com.fr.design.fit; + +import com.fr.design.actions.JTemplateAction; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.UIDialog; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JForm; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.menu.MenuKeySet; +import com.fr.design.report.fit.FormFitAttrModelType; +import com.fr.form.main.Form; +import com.fr.report.fit.FitProvider; +import com.fr.report.fit.ReportFitAttr; + +import javax.swing.KeyStroke; +import java.awt.Dimension; +import java.awt.event.ActionEvent; + +public class FormFitAttrAction extends JTemplateAction { + private static final MenuKeySet REPORT_FIT_ATTR = new MenuKeySet() { + @Override + public char getMnemonic() { + return 'T'; + } + + @Override + public String getMenuName() { + return Toolkit.i18nText("Fine-Designer_PC_Fit_Attr"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; + + public FormFitAttrAction(JTemplate jTemplate) { + super(jTemplate); + initMenuStyle(); + } + + private void initMenuStyle() { + this.setMenuKeySet(REPORT_FIT_ATTR); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon("/com/fr/design/images/reportfit/fit"); + } + + /** + * Action触发事件 + * + * @param e 事件 + */ + @Override + public void actionPerformed(ActionEvent e) { + final JTemplate jwb = getEditingComponent(); + if (jwb == null || !(jwb.getTarget() instanceof Form)) { + return; + } + JForm jForm = (JForm) jwb; + Form wbTpl = jForm.getTarget(); + ReportFitAttr fitAttr = wbTpl.getReportFitAttr(); + FormFitAttrPane formFitAttrPane = new FormFitAttrPane(jForm, FormFitAttrModelType.parse(wbTpl)); + showReportFitDialog(fitAttr, jwb, wbTpl, formFitAttrPane); + } + + private void showReportFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane attrPane) { + attrPane.populateBean(fitAttr); + UIDialog dialog = attrPane.showWindowWithCustomSize(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + fireEditingOk(jwb, wbTpl, attrPane.updateBean(), fitAttr); + } + }, new Dimension(660, 600)); + dialog.setVisible(true); + } + + private void fireEditingOk(final JTemplate jwb, final FitProvider wbTpl, ReportFitAttr newReportFitAttr, ReportFitAttr oldReportFitAttr) { + wbTpl.setReportFitAttr(newReportFitAttr); + jwb.fireTargetModified(); + } + +} diff --git a/designer-form/src/main/java/com/fr/design/fit/FormFitAttrPane.java b/designer-form/src/main/java/com/fr/design/fit/FormFitAttrPane.java new file mode 100644 index 0000000000..51eda6d36e --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/fit/FormFitAttrPane.java @@ -0,0 +1,377 @@ +package com.fr.design.fit; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XOccupiedLayout; +import com.fr.design.designer.creator.XWAbsoluteBodyLayout; +import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.XWScaleLayout; +import com.fr.design.designer.properties.items.FRLayoutTypeItems; +import com.fr.design.designer.properties.items.Item; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.FormSelectionUtils; +import com.fr.design.mainframe.JForm; +import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.report.fit.FitType; +import com.fr.design.report.fit.FormFitAttrModelType; +import com.fr.design.report.fit.FormFitConfigPane; +import com.fr.design.report.fit.ReportFitConfigPane; +import com.fr.design.widget.FRWidgetFactory; +import com.fr.form.main.Form; +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.WBodyLayoutType; +import com.fr.form.ui.container.WFitLayout; +import com.fr.form.ui.container.WSortLayout; +import com.fr.general.ComparatorUtils; +import com.fr.general.act.BorderPacker; +import com.fr.log.FineLoggerFactory; +import com.fr.report.fit.ReportFitAttr; + +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +import static com.fr.design.i18n.Toolkit.i18nText; +import static javax.swing.JOptionPane.*; + +public class FormFitAttrPane extends BasicBeanPane { + + private UIComboBox layoutComboBox; + private UIComboBox scaleComboBox; + private FormFitAttrModelType fitAttrModelType; + + protected UIComboBox itemChoose; + + private JForm jForm; + private ReportFitConfigPane fitConfigPane; + + public FormFitAttrPane(JForm jForm, FormFitAttrModelType fitAttrModelType) { + this.fitAttrModelType = fitAttrModelType; + this.jForm = jForm; + initComponents(); + } + + + private void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(12, 5, 0, 5)); + this.add(createReportFitSettingPane(), BorderLayout.CENTER); + this.add(createReportLayoutSettingPane(), BorderLayout.NORTH); + + } + + + private JPanel createReportLayoutSettingPane() { + JPanel jPanel = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Form_PC_Fit_Config_Layout")); + jPanel.add(createAreaScalePane(), BorderLayout.CENTER); + jPanel.setPreferredSize(new Dimension(640, 84)); + return jPanel; + } + + 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")}; + } + + + private JPanel createReportFitSettingPane() { + JPanel jPanel = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Form_PC_Fit_Config_Content_Attr")); + JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + jPanel.add(contentPane, BorderLayout.CENTER); + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Form_PC_Fit_Config_Settings")); + label.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0)); + contentPane.add(label, BorderLayout.WEST); + label.setPreferredSize(new Dimension(100, 0)); + label.setVerticalAlignment(SwingConstants.TOP); + itemChoose = new UIComboBox(getItemNames()); + itemChoose.setPreferredSize(new Dimension(160, 20)); + Form form = jForm.getTarget(); + itemChoose.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + if (isTemplateSingleSet()) { + if (form != null) { + ReportFitAttr fitAttr = form.getReportFitAttr(); + populate(fitAttr); + } + } else { + populate(fitAttrModelType.getFitAttrModel().getGlobalReportFitAttr()); + } + } + } + }); + JPanel centerPane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); + centerPane.add(itemChoose); + centerPane.add(fitConfigPane = new FormFitConfigPane(this.fitAttrModelType.getFitAttrModel())); + contentPane.add(centerPane, BorderLayout.CENTER); + return jPanel; + } + + public void populate(ReportFitAttr reportFitAttr) { + if (reportFitAttr == null) { + reportFitAttr = fitAttrModelType.getFitAttrModel().getGlobalReportFitAttr(); + } + + this.setEnabled(isTemplateSingleSet()); + fitConfigPane.populateBean(reportFitAttr); + } + + + public ReportFitAttr updateBean() { + updateLayoutType(); + if (!isTemplateSingleSet()) { + return null; + } else { + return fitConfigPane.updateBean(); + } + } + + private void updateLayoutType() { + XLayoutContainer xLayoutContainer = this.jForm.getRootComponent(); + if (xLayoutContainer == null || !xLayoutContainer.acceptType(XWFitLayout.class)) { + return; + } + XWFitLayout xwFitLayout = (XWFitLayout) xLayoutContainer; + WFitLayout wFitLayout = xwFitLayout.toData(); + int state = layoutComboBox.getSelectedIndex(); + WBodyLayoutType selectType = WBodyLayoutType.parse(state); + if (selectType != wFitLayout.getBodyLayoutType()) { + wFitLayout.setLayoutType(selectType); + //从自适应布局切换到绝对布局 + if (selectType == WBodyLayoutType.ABSOLUTE) { + switchLayoutFromFit2Absolute(xwFitLayout); + } else { + //从绝对布局切换到自适应布局 + switchLayoutFromAbsolute2Fit(xwFitLayout); + } + } + wFitLayout.setCompatibleScaleAttr(fitAttrModelType.parseScaleAttrFromShowIndex(this.scaleComboBox.getSelectedIndex(), wFitLayout.getBodyLayoutType())); + } + + + private void switchLayoutFromFit2Absolute(XWFitLayout xWFitLayout) { + try { + WFitLayout layout = xWFitLayout.toData(); + WAbsoluteBodyLayout wAbsoluteBodyLayout = new WAbsoluteBodyLayout("body"); + wAbsoluteBodyLayout.setCompState(WAbsoluteLayout.STATE_FIXED); + // 切换布局类型时,保留body背景样式 + wAbsoluteBodyLayout.setBorderStyleFollowingTheme(layout.isBorderStyleFollowingTheme()); + wAbsoluteBodyLayout.setBorderStyle((BorderPacker) (layout.getBorderStyle().clone())); + Component[] components = xWFitLayout.getComponents(); + Rectangle[] backupBounds = getBackupBoundsFromFitLayout(xWFitLayout); + xWFitLayout.removeAll(); + layout.resetStyle(); + XWAbsoluteBodyLayout xwAbsoluteBodyLayout = xWFitLayout.getBackupParent() == null ? new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0, 0)) : (XWAbsoluteBodyLayout) xWFitLayout.getBackupParent(); + xWFitLayout.setFixLayout(false); + xWFitLayout.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0); + for (int i = 0; i < components.length; i++) { + XCreator xCreator = (XCreator) components[i]; + xCreator.setBounds(backupBounds[i]); + //部分控件被ScaleLayout包裹着,绝对布局里面要放出来 + if (xCreator.acceptType(XWScaleLayout.class)) { + if (xCreator.getComponentCount() > 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator()) { + Component component = xCreator.getComponent(0); + component.setBounds(xCreator.getBounds()); + } + } + if (!xCreator.acceptType(XOccupiedLayout.class)) { + xwAbsoluteBodyLayout.add(xCreator); + } + + } + copyLayoutAttr(layout, xwAbsoluteBodyLayout.toData()); + xWFitLayout.setBackupParent(xwAbsoluteBodyLayout); + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + formDesigner.getSelectionModel().setSelectedCreators( + FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout})); + if (xwAbsoluteBodyLayout.toData() != null) { + xwAbsoluteBodyLayout.toData().setBorderStyleFollowingTheme(wAbsoluteBodyLayout.isBorderStyleFollowingTheme()); + xwAbsoluteBodyLayout.toData().setBorderStyle(wAbsoluteBodyLayout.getBorderStyle()); + } + xwAbsoluteBodyLayout.refreshStylePreviewEffect(); + if (xWFitLayout.toData() != null) { + xWFitLayout.toData().resetStyle(); + } + xWFitLayout.refreshStylePreviewEffect(); + formDesigner.switchBodyLayout(xwAbsoluteBodyLayout); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + + } + } + + private Rectangle[] getBackupBoundsFromFitLayout(XWFitLayout xWFitLayout) { + int count = xWFitLayout.getComponentCount(); + Rectangle[] rectangles = new Rectangle[count]; + for (int i = 0; i < count; i++) { + rectangles[i] = xWFitLayout.getComponent(i).getBounds(); + } + return rectangles; + } + + protected void copyLayoutAttr(WSortLayout srcLayout, WSortLayout destLayout) { + destLayout.clearListeners(); + destLayout.clearMobileWidgetList(); + for (int i = 0, len = srcLayout.getMobileWidgetListSize(); i < len; i++) { + destLayout.addMobileWidget(srcLayout.getMobileWidget(i)); + } + destLayout.setSorted(true); + for (int i = 0, len = srcLayout.getListenerSize(); i < len; i++) { + destLayout.addListener(srcLayout.getListener(i)); + } + srcLayout.clearListeners(); + srcLayout.clearMobileWidgetList(); + } + + + private void switchLayoutFromAbsolute2Fit(XWFitLayout xwFitLayout) { + XWAbsoluteBodyLayout xwAbsoluteBodyLayout = getAbsoluteBodyLayout(xwFitLayout); + if (xwAbsoluteBodyLayout == null) { + return; + } + WAbsoluteBodyLayout layout = xwAbsoluteBodyLayout.toData(); + WFitLayout wFitLayout = xwFitLayout.toData(); + wFitLayout.resetStyle(); + xwFitLayout.switch2FitBodyLayout(xwAbsoluteBodyLayout); + // 切换布局类型时,保留body背景样式 + if (wFitLayout != null) { + wFitLayout.setBorderStyleFollowingTheme(layout.isBorderStyleFollowingTheme()); + wFitLayout.setBorderStyle(layout.getBorderStyle()); + } + copyLayoutAttr(layout, xwFitLayout.toData()); + + copyLayoutAttr(layout, xwFitLayout.toData()); + xwFitLayout.refreshStylePreviewEffect(); + } + + private XWAbsoluteBodyLayout getAbsoluteBodyLayout(XWFitLayout xwFitLayout) { + if (xwFitLayout != null && xwFitLayout.getComponentCount() > 0) { + Component component = xwFitLayout.getComponent(0); + if (component instanceof XWAbsoluteBodyLayout) { + return (XWAbsoluteBodyLayout) component; + } + } + return null; + } + + private JPanel createAreaScalePane() { + initLayoutComboBox(); + + UILabel layoutTypeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")); + UILabel scaleModeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_PC_Fit_Config_Scale_Setting")); + Component[][] components = new Component[][]{ + {layoutTypeLabel, layoutComboBox}, + {scaleModeLabel, scaleComboBox} + }; + JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(components, + TableLayoutHelper.FILL_LASTCOLUMN, 20, IntervalConstants.INTERVAL_L1); + JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + containerPane.add(contentPane, BorderLayout.CENTER); + + return containerPane; + } + + + public void initLayoutComboBox() { + Item[] items = FRLayoutTypeItems.ITEMS; + DefaultComboBoxModel model = new DefaultComboBoxModel(); + for (Item item : items) { + model.addElement(item); + } + scaleComboBox = new UIComboBox(model); + scaleComboBox.setModel(new DefaultComboBoxModel(fitAttrModelType.getFitLayoutScaleAttr())); + layoutComboBox = new UIComboBox(model); + layoutComboBox.setPreferredSize(new Dimension(160, 20)); + scaleComboBox.setPreferredSize(new Dimension(160, 20)); + WFitLayout wFitLayout = jForm.getTarget().getWFitLayout(); + layoutComboBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int selectIndex = layoutComboBox.getSelectedIndex(); + if (selectIndex == 0) { + if (wFitLayout.getBodyLayoutType() == WBodyLayoutType.ABSOLUTE) { + int selVal = FineJOptionPane.showConfirmDialog( + FormFitAttrPane.this, + Toolkit.i18nText("Fine-Design_Form_Layout_Switch_Tip"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), + OK_CANCEL_OPTION, + WARNING_MESSAGE + ); + if (OK_OPTION != selVal) { + layoutComboBox.setSelectedIndex(1); + return; + } + } + scaleComboBox.setModel(new DefaultComboBoxModel(fitAttrModelType.getFitLayoutScaleAttr())); + } else { + scaleComboBox.setModel(new DefaultComboBoxModel(fitAttrModelType.getAbsoluteLayoutSaleAttr())); + } + scaleComboBox.setSelectedIndex(0); + } + }); + + scaleComboBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + WBodyLayoutType selectBodyType = WBodyLayoutType.parse(layoutComboBox.getSelectedIndex()); + int state = fitAttrModelType.parseScaleAttrFromShowIndex(scaleComboBox.getSelectedIndex(), selectBodyType); + fitConfigPane.refreshPreviewJPanel(FitType.parseByFitState(state)); + } + }); + } + + + @Override + public void populateBean(ReportFitAttr reportFitAttr) { + WFitLayout wFitLayout = jForm.getTarget().getWFitLayout(); + layoutComboBox.setSelectedIndex(wFitLayout.getBodyLayoutType().getTypeValue()); + scaleComboBox.setSelectedIndex(fitAttrModelType.getScaleAttrShowIndex(wFitLayout)); + + 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")); + } + if (reportFitAttr == null) { + reportFitAttr = fitAttrModelType.getFitAttrModel().getGlobalReportFitAttr(); + } + setEnabled(isTemplateSingleSet()); + fitConfigPane.populateBean(reportFitAttr); + } + + private boolean isTemplateSingleSet() { + return ComparatorUtils.equals(Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single"), itemChoose.getSelectedItem()); + } + + + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + fitConfigPane.setEnabled(enabled); + } + + @Override + protected String title4PopupWindow() { + return i18nText("Fine-Designer_PC_Fit_Attr"); + } + +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 8d2748eb39..ec3852437b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -14,7 +14,6 @@ import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; -import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.FormMobileAttrAction; import com.fr.design.actions.TemplateParameterAction; import com.fr.design.actions.core.WorkBookSupportable; @@ -37,7 +36,7 @@ import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.fun.FormAdaptiveConfigUIProcessor; +import com.fr.design.fit.FormFitAttrAction; import com.fr.design.fun.PreviewProvider; import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; @@ -66,7 +65,6 @@ import com.fr.design.menu.ToolBarDef; import com.fr.design.parameter.ParameterPropertyPane; import com.fr.design.preview.FormPreview; import com.fr.design.preview.MobilePreview; -import com.fr.design.report.fit.menupane.ReportFitAttrAction; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.utils.gui.LayoutUtils; import com.fr.file.FILE; @@ -597,11 +595,7 @@ public class JForm extends JTemplate implements BaseJForm implements BaseJForm { - protected UIComboBox comboBox; public FRAbsoluteLayoutDefinePane(XCreator xCreator) { super(xCreator); @@ -34,40 +19,8 @@ public class FRAbsoluteLayoutDefinePane extends AbstractFRLayoutDefinePane { - private static final int ADAPT_LABEL_MAX_WIDTH = 80; private XWFitLayout xWFitLayout; private WFitLayout wFitLayout; - private UIComboBox layoutComboBox; - private UIComboBox adaptComboBox; private UISpinner componentIntervel; private PaddingBoundPane paddingBound; private FollowingThemePane themePane; @@ -119,11 +106,7 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator()) { - Component component = xCreator.getComponent(0); - component.setBounds(xCreator.getBounds()); - } - } - if (!xCreator.acceptType(XOccupiedLayout.class)){ - xwAbsoluteBodyLayout.add(xCreator); - } - - } - copyLayoutAttr(wFitLayout, xwAbsoluteBodyLayout.toData()); - xWFitLayout.setBackupParent(xwAbsoluteBodyLayout); - FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - formDesigner.getSelectionModel().setSelectedCreators( - FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout})); - if (xwAbsoluteBodyLayout.toData() != null) { - xwAbsoluteBodyLayout.toData().setBorderStyleFollowingTheme(wAbsoluteBodyLayout.isBorderStyleFollowingTheme()); - xwAbsoluteBodyLayout.toData().setBorderStyle(wAbsoluteBodyLayout.getBorderStyle()); - } - xwAbsoluteBodyLayout.refreshStylePreviewEffect(); - if (xWFitLayout.toData() != null) { - xWFitLayout.toData().resetStyle(); - } - xWFitLayout.refreshStylePreviewEffect(); - formDesigner.switchBodyLayout(xwAbsoluteBodyLayout); - return layout; - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - - } - int intervelValue = (int) componentIntervel.getValue(); if (xWFitLayout.canAddInterval(intervelValue)) { // 设置完间隔后,要同步处理界面组件,容器刷新后显示出对应效果 @@ -302,14 +210,6 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane Date: Thu, 6 Jan 2022 17:19:17 +0800 Subject: [PATCH 2/7] =?UTF-8?q?Revert=20"REPORT-64445=20=E6=96=B0=E8=80=81?= =?UTF-8?q?=E8=87=AA=E9=80=82=E5=BA=94=E9=85=8D=E7=BD=AE=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 510117c2a75a9bcb6229832a3bc84f08c047e92c. --- .../gui/ilable/UIAutoChangeLineLabel.java | 78 ---- .../report/fit/AdaptiveFrmFitAttrModel.java | 6 +- .../fr/design/report/fit/BaseFitAttrPane.java | 130 +++++- .../fr/design/report/fit/FitAttrModel.java | 9 - .../com/fr/design/report/fit/FitType.java | 11 - .../report/fit/FormFitAttrModelType.java | 128 ------ .../design/report/fit/FormFitConfigPane.java | 59 --- .../fr/design/report/fit/FrmFitAttrModel.java | 9 +- .../design/report/fit/NewFitPreviewPane.java | 71 ---- .../report/fit/ReportFitConfigPane.java | 172 -------- .../com/fr/design/fit/FormFitAttrAction.java | 85 ---- .../com/fr/design/fit/FormFitAttrPane.java | 377 ------------------ .../java/com/fr/design/mainframe/JForm.java | 14 +- .../FRAbsoluteBodyLayoutDefinePane.java | 110 ++++- .../layout/FRAbsoluteLayoutDefinePane.java | 54 ++- .../layout/FRFitLayoutDefinePane.java | 118 +++++- 16 files changed, 399 insertions(+), 1032 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/gui/ilable/UIAutoChangeLineLabel.java delete mode 100644 designer-base/src/main/java/com/fr/design/report/fit/FormFitAttrModelType.java delete mode 100644 designer-base/src/main/java/com/fr/design/report/fit/FormFitConfigPane.java delete mode 100644 designer-base/src/main/java/com/fr/design/report/fit/NewFitPreviewPane.java delete mode 100644 designer-base/src/main/java/com/fr/design/report/fit/ReportFitConfigPane.java delete mode 100644 designer-form/src/main/java/com/fr/design/fit/FormFitAttrAction.java delete mode 100644 designer-form/src/main/java/com/fr/design/fit/FormFitAttrPane.java diff --git a/designer-base/src/main/java/com/fr/design/gui/ilable/UIAutoChangeLineLabel.java b/designer-base/src/main/java/com/fr/design/gui/ilable/UIAutoChangeLineLabel.java deleted file mode 100644 index d2bb0450b1..0000000000 --- a/designer-base/src/main/java/com/fr/design/gui/ilable/UIAutoChangeLineLabel.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.fr.design.gui.ilable; - -import javax.swing.JLabel; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.util.ArrayList; -import java.util.List; - -public class UIAutoChangeLineLabel extends JLabel { - private final String text; - private final int width; - - - public UIAutoChangeLineLabel(String text, int width) { - super(text); - this.text = text; - this.width = width; - } - - - @Override - public void doLayout() { - super.doLayout(); - this.setText(wrapperHtmlText()); - } - - private String wrapperHtmlText() { - List stringList = autoChangeLine(this.getWidth()); - StringBuilder builder = new StringBuilder(""); - for (String s : stringList) { - //用THML标签进行拼接,以实现自动换行 - builder.append(s).append("
"); - } - builder.append(""); - return builder.toString(); - } - - private List autoChangeLine(int width) { - List result = new ArrayList<>(); - if (width <= 0) { - result.add(this.text); - } else { - - char[] chars = this.text.toCharArray(); - //获取字体计算大小 - FontMetrics fontMetrics = this.getFontMetrics(this.getFont()); - int start = 0; - int len = 0; - while (start + len < this.text.length()) { - while (true) { - len++; - if (start + len > this.text.length()) - break; - if (fontMetrics.charsWidth(chars, start, len) - > width) { - break; - } - } - result.add(String.copyValueOf(chars, start, len - 1)); - start = start + len - 1; - len = 0; - } - if (this.text.length() - start > 0) { - result.add(String.copyValueOf(chars, start, this.text.length() - start)); - } - } - return result; - } - - - @Override - public Dimension getPreferredSize() { - Dimension preferredSize = super.getPreferredSize(); - List stringList = autoChangeLine(width); - FontMetrics fontMetrics = this.getFontMetrics(this.getFont()); - return new Dimension(preferredSize.width, fontMetrics.getHeight() * stringList.size()); - } -} 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 index 8c5e8858ac..9e60c6cc84 100644 --- 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 @@ -13,7 +13,11 @@ import com.fr.report.fit.ReportFitAttr; public class AdaptiveFrmFitAttrModel extends AbstractFitAttrModelProvider { public FitType[] getFitTypes() { - return new FitType[0]; + return new FitType[]{ + FitType.DOUBLE_FIT, + FitType.HORIZONTAL_FIT, + FitType.NOT_FIT + }; } public String getFitName() { 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 index 48d6a5686e..2c38d597c4 100644 --- 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 @@ -2,17 +2,27 @@ 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.i18n.DesignSizeI18nManager; 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 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; @@ -25,8 +35,11 @@ public abstract class BaseFitAttrPane extends BasicBeanPane { protected UILabel belowSetLabel; protected UIComboBox itemChoose; protected java.util.List fitAttrModelList = new ArrayList<>(); - private ReportFitConfigPane fitConfigPane; + public FontRadioGroup fontRadioGroup; + public FitRadioGroup adaptRadioGroup; + public JPanel attrJPanel; + public FitPreviewPane previewJPanel; public FitAttrModel fitAttrModel; private static final int BELOW_SET_COMPONENT_HSPACE = 8; @@ -51,27 +64,128 @@ public abstract class BaseFitAttrPane extends BasicBeanPane { protected void populateModel(FitAttrModel fitAttrModel) { this.fitAttrModel = fitAttrModel; - if (fitConfigPane != null) { - contentJPanel.remove(fitConfigPane); + if (attrJPanel != null) { + contentJPanel.remove(attrJPanel); } - this.fitConfigPane = fitAttrModel instanceof CptFitAttrModel ? new ReportFitConfigPane(fitAttrModel, true) : new FormFitConfigPane(fitAttrModel, true); - contentJPanel.add(fitConfigPane); + 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] = DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.fit.firstColumn").getWidth(); + } else { + columnSize[i] = DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.fit.column").getWidth(); + } + } + + attrJPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + attrJPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0)); + 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(); + previewJPanel.setBorder(BorderFactory.createEmptyBorder(0, getPreviewJPanelLeft(), 0, 0)); + contentJPanel.add(previewJPanel); + } + + private int getPreviewJPanelLeft() { + int left = 0; + if (belowSetLabel.getPreferredSize() != null) { + left = belowSetLabel.getPreferredSize().width + BELOW_SET_COMPONENT_HSPACE; + } + return left; + } + + 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) { - this.fitConfigPane.populateBean(ob); + fontRadioGroup.selectIndexButton(ob.isFitFont() ? 0 : 1); + adaptRadioGroup.selectIndexButton(getOptionIndex(ob.fitStateInPC())); + refreshPreviewJPanel(); } @Override public ReportFitAttr updateBean() { - return this.fitConfigPane.updateBean(); + ReportFitAttr reportFitAttr = new ReportFitAttr(); + reportFitAttr.setFitFont(fontRadioGroup.isFontFit()); + reportFitAttr.setFitStateInPC(getStateInPC(adaptRadioGroup.getSelectRadioIndex())); + return reportFitAttr; } public void setEnabled(boolean enabled) { super.setEnabled(enabled); - this.fitConfigPane.setEnabled(enabled); + fontRadioGroup.setEnabled(enabled); + adaptRadioGroup.setEnabled(enabled); + refreshPreviewJPanel(); } @Override 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 index 2a834eebd8..1d1ac02f0d 100644 --- 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 @@ -3,8 +3,6 @@ package com.fr.design.report.fit; import com.fr.design.mainframe.JTemplate; import com.fr.report.fit.ReportFitAttr; -import java.util.Arrays; - public interface FitAttrModel { /** * @Description 名称,比如:普通报表、决策报表等 @@ -21,12 +19,6 @@ public interface FitAttrModel { **/ FitType[] getFitTypes(); - /** - * @Description 表格自适应选项名称集合 - **/ - default String[] getFitTypeNames(){ - return Arrays.stream(getFitTypes()).map(FitType::description).toArray(String[]::new); - } /** * @Description 获取全局的自适应属性 @@ -49,5 +41,4 @@ public interface FitAttrModel { * @param: jTemplate **/ boolean isAvailable(JTemplate jTemplate); - } diff --git a/designer-base/src/main/java/com/fr/design/report/fit/FitType.java b/designer-base/src/main/java/com/fr/design/report/fit/FitType.java index dd4888b4e5..00aceb6eb1 100644 --- a/designer-base/src/main/java/com/fr/design/report/fit/FitType.java +++ b/designer-base/src/main/java/com/fr/design/report/fit/FitType.java @@ -60,17 +60,6 @@ public enum FitType { return DEFAULT; } - public static FitType parseByFitState(int state) { - - for (FitType attrState : values()) { - if (attrState.state == state) { - return attrState; - } - } - - return DEFAULT; - } - public int getState() { return this.state; } diff --git a/designer-base/src/main/java/com/fr/design/report/fit/FormFitAttrModelType.java b/designer-base/src/main/java/com/fr/design/report/fit/FormFitAttrModelType.java deleted file mode 100644 index a77566442d..0000000000 --- a/designer-base/src/main/java/com/fr/design/report/fit/FormFitAttrModelType.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.fr.design.report.fit; - - -import com.fr.design.designer.properties.items.Item; -import com.fr.form.fit.common.LightTool; -import com.fr.form.main.BodyScaleAttrTransformer; -import com.fr.form.main.Form; -import com.fr.form.ui.container.WAbsoluteLayout; -import com.fr.form.ui.container.WBodyLayoutType; -import com.fr.form.ui.container.WFitLayout; - -public enum FormFitAttrModelType { - PLAIN_FORM_FIT_ATTR_MODEL { - @Override - public FitAttrModel getFitAttrModel() { - return new FrmFitAttrModel(); - } - - @Override - public Item[] getFitLayoutScaleAttr() { - return new Item[]{ - new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Bidirectional_Adaptive"), WFitLayout.STATE_FULL), - new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Horizontal_Adaptive"), WFitLayout.STATE_ORIGIN)}; - - } - - @Override - public Item[] getAbsoluteLayoutSaleAttr() { - return new Item[]{ - new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fit"), WAbsoluteLayout.STATE_FIT), - new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fixed"), WAbsoluteLayout.STATE_FIXED) - }; - } - - - @Override - public int getScaleAttrShowIndex(WFitLayout wFitLayout) { - int scale = wFitLayout.getScaleAttr(); - if (wFitLayout.getBodyLayoutType() == WBodyLayoutType.FIT) { - return BodyScaleAttrTransformer.getFitBodyCompStateFromScaleAttr(scale); - } else { - return BodyScaleAttrTransformer.getAbsoluteBodyCompStateFromScaleAttr(scale); - } - } - - @Override - public int parseScaleAttrFromShowIndex(int showIndex, WBodyLayoutType wBodyLayoutType) { - if (wBodyLayoutType == WBodyLayoutType.FIT) { - if (showIndex == 0) { - return WFitLayout.SCALE_FULL; - } else { - return WFitLayout.SCALE_HOR; - } - } else { - if (showIndex == 0) { - return WFitLayout.SCALE_FULL; - } else { - return WFitLayout.SCALE_NO; - } - } - } - - - }, - NEW_FORM_FIT_ATTR_MODEL { - @Override - public FitAttrModel getFitAttrModel() { - return new AdaptiveFrmFitAttrModel(); - } - - @Override - public Item[] getFitLayoutScaleAttr() { - return new Item[]{ - new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Bidirectional_Adaptive"), WFitLayout.STATE_FULL), - new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Horizontal_Adaptive"), WFitLayout.STATE_ORIGIN), - new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fixed"), 2)}; - } - - @Override - public Item[] getAbsoluteLayoutSaleAttr() { - return new Item[]{ - new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Bidirectional_Adaptive"), WFitLayout.STATE_FULL), - new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Horizontal_Adaptive"), WFitLayout.STATE_ORIGIN), - new Item(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode_Fixed"), 2)}; - } - - - @Override - public int getScaleAttrShowIndex(WFitLayout wFitLayout) { - int scale = wFitLayout.getScaleAttr(); - if (scale == WFitLayout.SCALE_NO) { - return 2; - } else if (scale == WFitLayout.SCALE_HOR) { - return 1; - } else { - return 0; - } - } - - @Override - public int parseScaleAttrFromShowIndex(int showIndex, WBodyLayoutType wBodyLayoutType) { - if (showIndex == 0) { - return WFitLayout.SCALE_FULL; - } else if (showIndex == 1) { - return WFitLayout.SCALE_HOR; - } else { - return WFitLayout.SCALE_NO; - } - } - - - }; - - public abstract FitAttrModel getFitAttrModel(); - - public abstract Item[] getFitLayoutScaleAttr(); - - public abstract Item[] getAbsoluteLayoutSaleAttr(); - - public abstract int getScaleAttrShowIndex(WFitLayout wFitLayout); - - public abstract int parseScaleAttrFromShowIndex(int showIndex, WBodyLayoutType wBodyLayoutType); - - - public static FormFitAttrModelType parse(Form form) { - return LightTool.containNewFormFlag(form) ? NEW_FORM_FIT_ATTR_MODEL : PLAIN_FORM_FIT_ATTR_MODEL; - } -} diff --git a/designer-base/src/main/java/com/fr/design/report/fit/FormFitConfigPane.java b/designer-base/src/main/java/com/fr/design/report/fit/FormFitConfigPane.java deleted file mode 100644 index 08b70cb772..0000000000 --- a/designer-base/src/main/java/com/fr/design/report/fit/FormFitConfigPane.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.fr.design.report.fit; - -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.report.fit.ReportFitAttr; - -import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; - -public class FormFitConfigPane extends ReportFitConfigPane { - private static final int DEFAULT_ITEM = 0; - private static final int CUSTOM_ITEM = 1; - - public FormFitConfigPane(FitAttrModel fitAttrModel) { - this(fitAttrModel, false); - } - - public FormFitConfigPane(FitAttrModel fitAttrModel, boolean globalConfig) { - super(fitAttrModel, globalConfig); - } - - protected JPanel initECConfigPane() { - JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - if (fitAttrModel.getFitTypeNames().length != 0) { - Component[] ecComponents = new Component[fitAttrModel.getFitTypeNames().length + 1]; - initRadioGroup(ecConfigRadioGroup, fitAttrModel.getFitName(), fitAttrModel.getFitTypeNames(), ecComponents); - jPanel.add(createSubAttrPane(ecComponents), BorderLayout.CENTER); - jPanel.add(createTipPane(), BorderLayout.SOUTH); - } - return jPanel; - } - - private JPanel createTipPane() { - JPanel jPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); - UILabel label1 = new UILabel(Toolkit.i18nText("Fine-Design_Form_PC_FIT_Config_Tip1")); - jPanel.add(label1); - label1.setForeground(Color.lightGray); - UILabel label2 = new UILabel(Toolkit.i18nText("Fine-Design_Form_PC_FIT_Config_Tip2")); - jPanel.add(label2); - label2.setForeground(Color.lightGray); - return jPanel; - } - - protected void refreshPreviewJPanel() { - previewJPanel.refreshPreview(fontRadioGroup.isFontFit()); - } - - protected void populateECConfigRadioGroup(int fitStateInPC) { - ecConfigRadioGroup.selectIndexButton(fitStateInPC == 0 ? DEFAULT_ITEM : CUSTOM_ITEM); - } - - protected void updateECConfigRadioGroup(ReportFitAttr reportFitAttr) { - reportFitAttr.setFitStateInPC(ecConfigRadioGroup.getSelectRadioIndex()); - } - -} 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 index 81ee474de1..c4bdaf6de2 100644 --- 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 @@ -17,7 +17,7 @@ public class FrmFitAttrModel implements FitAttrModel { @Override public String getFitName() { - return Toolkit.i18nText("Fine-Design_Form_PC_FIT_Config_EC_Label"); + return Toolkit.i18nText("Fine-Designer_Fit-Element"); } public FitType[] getFitTypes() { @@ -29,13 +29,6 @@ public class FrmFitAttrModel implements FitAttrModel { }; } - @Override - public String[] getFitTypeNames() { - return new String[]{ - Toolkit.i18nText("Fine-Designer_Fit-Default"), Toolkit.i18nText("Fine-Design_Basic_Custom") - }; - } - @Override public ReportFitAttr getGlobalReportFitAttr() { return ReportFitConfig.getInstance().getFrmFitAttr(); diff --git a/designer-base/src/main/java/com/fr/design/report/fit/NewFitPreviewPane.java b/designer-base/src/main/java/com/fr/design/report/fit/NewFitPreviewPane.java deleted file mode 100644 index 8b0710de3f..0000000000 --- a/designer-base/src/main/java/com/fr/design/report/fit/NewFitPreviewPane.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.fr.design.report.fit; - -import com.fr.base.GraphHelper; -import com.fr.general.FRFont; - -import javax.swing.JPanel; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; - - -public class NewFitPreviewPane extends JPanel { - private boolean fitFont = false; - private FitType fitType = FitType.DOUBLE_FIT; - private static final Color DEFAULT_PAINT_COLOR = Color.decode("#419BF9"); - private static final int FIT_FONT_SIZE = 15; - private static final int NO_FIT_FONT_SIZE = 9; - private static final Dimension NO_FIT_CONTAINER_DIMENSION = new Dimension(200, 136); - - @Override - public void paint(Graphics g) { - super.paint(g); - g.setColor(Color.GRAY); - GraphHelper.drawRect(g, 1, 1, this.getWidth() - 2, this.getHeight() - 2); - g.setColor(DEFAULT_PAINT_COLOR); - FRFont textFont = FRFont.getInstance(FRFont.DEFAULT_FONTNAME, Font.PLAIN, fitFont ? FIT_FONT_SIZE : NO_FIT_FONT_SIZE); - g.setFont(textFont); - Dimension dimension = calculateCellDimension(); - GraphHelper.drawLine(g, 1, dimension.height, dimension.width * 2 - 1, dimension.height); - GraphHelper.drawLine(g, dimension.width, 1, dimension.width, dimension.height * 2 - 1); - GraphHelper.drawRect(g, 1, 1, dimension.width * 2 - 2, dimension.height * 2 - 2); - double startX = calculateTextDrawStartX(dimension.width, this.getFontMetrics(textFont), "text1"); - double startY = calculateTextDrawStartY(dimension.height); - GraphHelper.drawString(g, "text1", startX, startY); - GraphHelper.drawString(g, "text2", dimension.width + startX, startY); - GraphHelper.drawString(g, "text3", startX, dimension.height + startY); - GraphHelper.drawString(g, "text4", dimension.width + startX, dimension.height + startY); - } - - private Dimension calculateCellDimension() { - if (fitType == FitType.DOUBLE_FIT) { - return new Dimension(this.getWidth() / 2, this.getHeight() / 2); - } else if (fitType == FitType.NOT_FIT) { - return new Dimension(NO_FIT_CONTAINER_DIMENSION.width / 2, NO_FIT_CONTAINER_DIMENSION.height / 2); - } else { - return new Dimension(this.getWidth() / 2, NO_FIT_CONTAINER_DIMENSION.height / 2); - } - } - - private double calculateTextDrawStartX(int containerWidth, FontMetrics fontMetrics, String text) { - return (containerWidth - fontMetrics.stringWidth(text)) / 2.0D; - } - - private double calculateTextDrawStartY(int containerHeight) { - return containerHeight / 2.0D; - } - - public void refreshPreview(boolean fitFont, FitType fitType) { - this.fitFont = fitFont; - this.fitType = fitType; - repaint(); - } - - public void refreshPreview(boolean fitFont) { - this.fitFont = fitFont; - repaint(); - } - -} diff --git a/designer-base/src/main/java/com/fr/design/report/fit/ReportFitConfigPane.java b/designer-base/src/main/java/com/fr/design/report/fit/ReportFitConfigPane.java deleted file mode 100644 index 399e7fef93..0000000000 --- a/designer-base/src/main/java/com/fr/design/report/fit/ReportFitConfigPane.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.fr.design.report.fit; - -import com.fr.design.gui.ibutton.UIRadioButton; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.DesignSizeI18nManager; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.report.fit.menupane.FitRadioGroup; -import com.fr.design.report.fit.menupane.FontRadioGroup; -import com.fr.general.ComparatorUtils; -import com.fr.report.fit.ReportFitAttr; - -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import static com.fr.design.i18n.Toolkit.i18nText; - -public class ReportFitConfigPane extends JPanel { - public FontRadioGroup fontRadioGroup; - public FitRadioGroup ecConfigRadioGroup; - protected NewFitPreviewPane previewJPanel; - protected FitAttrModel fitAttrModel; - protected boolean globalConfig; - - - public ReportFitConfigPane(FitAttrModel fitAttrModel, boolean globalConfig) { - this.fitAttrModel = fitAttrModel; - this.globalConfig = globalConfig; - initComponent(); - } - - private void initComponent() { - JPanel contentJPanel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(false, FlowLayout.LEFT, 0, 0); - this.add(contentJPanel); - fontRadioGroup = new FontRadioGroup(); - ecConfigRadioGroup = new FitRadioGroup(); - contentJPanel.add(initAttrJPanel()); - contentJPanel.add(initPreviewJPanel()); - } - - private JPanel initAttrJPanel() { - JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - Component[] fontComponents = new Component[3]; - initRadioGroup(fontRadioGroup, i18nText("Fine-Designer_Fit-Font"), new String[]{i18nText("Fine-Designer_Fit"), i18nText("Fine-Designer_Fit-No")}, fontComponents); - jPanel.add(createSubAttrPane(fontComponents), BorderLayout.NORTH); - jPanel.add(initECConfigPane(), BorderLayout.CENTER); - return jPanel; - } - - protected JPanel initECConfigPane() { - JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - Component[] ecComponents = new Component[fitAttrModel.getFitTypeNames().length + 1]; - initRadioGroup(ecConfigRadioGroup, fitAttrModel.getFitName(), fitAttrModel.getFitTypeNames(), ecComponents); - jPanel.add(createSubAttrPane(ecComponents), BorderLayout.CENTER); - return jPanel; - } - - - protected JPanel createSubAttrPane(Component[] components) { - double[] rowSize = new double[]{20}; - double[] columnSize = new double[components.length]; - for (int i = 0; i < columnSize.length; i++) { - if (i == 0) { - columnSize[i] = DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.fit.firstColumn").getWidth(); - } else { - columnSize[i] = DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.fit.column").getWidth(); - } - } - - JPanel attrJPanel = TableLayoutHelper.createTableLayoutPane(new Component[][]{components}, rowSize, columnSize); - attrJPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0)); - return attrJPanel; - } - - protected void initRadioGroup(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()); - } - - private ActionListener getPreviewActionListener() { - return new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - refreshPreviewJPanel(); - } - }; - } - - public void refreshPreviewJPanel(FitType fitType) { - previewJPanel.refreshPreview(fontRadioGroup.isFontFit(), fitType); - } - - protected void refreshPreviewJPanel() { - previewJPanel.refreshPreview(fontRadioGroup.isFontFit(), FitType.parse(updateBean())); - } - - private JPanel initPreviewJPanel() { - JPanel wrapperPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - previewJPanel = new NewFitPreviewPane(); - wrapperPane.add(previewJPanel, BorderLayout.CENTER); - int leftIndent = globalConfig ? (int) DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.fit.firstColumn").getWidth() : 0; - wrapperPane.setBorder(BorderFactory.createEmptyBorder(0, leftIndent, 0, 0)); - wrapperPane.setPreferredSize(new Dimension(300 + leftIndent, 204)); - return wrapperPane; - } - - - public void populateBean(ReportFitAttr ob) { - fontRadioGroup.selectIndexButton(ob.isFitFont() ? 0 : 1); - populateECConfigRadioGroup(ob.fitStateInPC()); - refreshPreviewJPanel(); - } - - protected void populateECConfigRadioGroup(int fitStateInPC){ - ecConfigRadioGroup.selectIndexButton(getOptionIndex(fitStateInPC)); - } - - - protected void updateECConfigRadioGroup(ReportFitAttr reportFitAttr){ - reportFitAttr.setFitStateInPC(getStateInPC(ecConfigRadioGroup.getSelectRadioIndex())); - } - - public ReportFitAttr updateBean() { - ReportFitAttr reportFitAttr = new ReportFitAttr(); - reportFitAttr.setFitFont(fontRadioGroup.isFontFit()); - updateECConfigRadioGroup(reportFitAttr); - return reportFitAttr; - } - - - protected int getStateInPC(int index) { - FitType[] fitTypes = fitAttrModel.getFitTypes(); - if (index > fitTypes.length - 1) { - return index; - } - 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; - } - - - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - fontRadioGroup.setEnabled(enabled); - ecConfigRadioGroup.setEnabled(enabled); - } - -} diff --git a/designer-form/src/main/java/com/fr/design/fit/FormFitAttrAction.java b/designer-form/src/main/java/com/fr/design/fit/FormFitAttrAction.java deleted file mode 100644 index dad6e9be9c..0000000000 --- a/designer-form/src/main/java/com/fr/design/fit/FormFitAttrAction.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.fr.design.fit; - -import com.fr.design.actions.JTemplateAction; -import com.fr.design.beans.BasicBeanPane; -import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.dialog.UIDialog; -import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.JForm; -import com.fr.design.mainframe.JTemplate; -import com.fr.design.menu.MenuKeySet; -import com.fr.design.report.fit.FormFitAttrModelType; -import com.fr.form.main.Form; -import com.fr.report.fit.FitProvider; -import com.fr.report.fit.ReportFitAttr; - -import javax.swing.KeyStroke; -import java.awt.Dimension; -import java.awt.event.ActionEvent; - -public class FormFitAttrAction extends JTemplateAction { - private static final MenuKeySet REPORT_FIT_ATTR = new MenuKeySet() { - @Override - public char getMnemonic() { - return 'T'; - } - - @Override - public String getMenuName() { - return Toolkit.i18nText("Fine-Designer_PC_Fit_Attr"); - } - - @Override - public KeyStroke getKeyStroke() { - return null; - } - }; - - public FormFitAttrAction(JTemplate jTemplate) { - super(jTemplate); - initMenuStyle(); - } - - private void initMenuStyle() { - this.setMenuKeySet(REPORT_FIT_ATTR); - this.setName(getMenuKeySet().getMenuKeySetName() + "..."); - this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon("/com/fr/design/images/reportfit/fit"); - } - - /** - * Action触发事件 - * - * @param e 事件 - */ - @Override - public void actionPerformed(ActionEvent e) { - final JTemplate jwb = getEditingComponent(); - if (jwb == null || !(jwb.getTarget() instanceof Form)) { - return; - } - JForm jForm = (JForm) jwb; - Form wbTpl = jForm.getTarget(); - ReportFitAttr fitAttr = wbTpl.getReportFitAttr(); - FormFitAttrPane formFitAttrPane = new FormFitAttrPane(jForm, FormFitAttrModelType.parse(wbTpl)); - showReportFitDialog(fitAttr, jwb, wbTpl, formFitAttrPane); - } - - private void showReportFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane attrPane) { - attrPane.populateBean(fitAttr); - UIDialog dialog = attrPane.showWindowWithCustomSize(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - @Override - public void doOk() { - fireEditingOk(jwb, wbTpl, attrPane.updateBean(), fitAttr); - } - }, new Dimension(660, 600)); - dialog.setVisible(true); - } - - private void fireEditingOk(final JTemplate jwb, final FitProvider wbTpl, ReportFitAttr newReportFitAttr, ReportFitAttr oldReportFitAttr) { - wbTpl.setReportFitAttr(newReportFitAttr); - jwb.fireTargetModified(); - } - -} diff --git a/designer-form/src/main/java/com/fr/design/fit/FormFitAttrPane.java b/designer-form/src/main/java/com/fr/design/fit/FormFitAttrPane.java deleted file mode 100644 index 51eda6d36e..0000000000 --- a/designer-form/src/main/java/com/fr/design/fit/FormFitAttrPane.java +++ /dev/null @@ -1,377 +0,0 @@ -package com.fr.design.fit; - -import com.fr.design.beans.BasicBeanPane; -import com.fr.design.designer.IntervalConstants; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XOccupiedLayout; -import com.fr.design.designer.creator.XWAbsoluteBodyLayout; -import com.fr.design.designer.creator.XWFitLayout; -import com.fr.design.designer.creator.XWScaleLayout; -import com.fr.design.designer.properties.items.FRLayoutTypeItems; -import com.fr.design.designer.properties.items.Item; -import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.FormDesigner; -import com.fr.design.mainframe.FormSelectionUtils; -import com.fr.design.mainframe.JForm; -import com.fr.design.mainframe.WidgetPropertyPane; -import com.fr.design.report.fit.FitType; -import com.fr.design.report.fit.FormFitAttrModelType; -import com.fr.design.report.fit.FormFitConfigPane; -import com.fr.design.report.fit.ReportFitConfigPane; -import com.fr.design.widget.FRWidgetFactory; -import com.fr.form.main.Form; -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.WBodyLayoutType; -import com.fr.form.ui.container.WFitLayout; -import com.fr.form.ui.container.WSortLayout; -import com.fr.general.ComparatorUtils; -import com.fr.general.act.BorderPacker; -import com.fr.log.FineLoggerFactory; -import com.fr.report.fit.ReportFitAttr; - -import javax.swing.BorderFactory; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JPanel; -import javax.swing.SwingConstants; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - -import static com.fr.design.i18n.Toolkit.i18nText; -import static javax.swing.JOptionPane.*; - -public class FormFitAttrPane extends BasicBeanPane { - - private UIComboBox layoutComboBox; - private UIComboBox scaleComboBox; - private FormFitAttrModelType fitAttrModelType; - - protected UIComboBox itemChoose; - - private JForm jForm; - private ReportFitConfigPane fitConfigPane; - - public FormFitAttrPane(JForm jForm, FormFitAttrModelType fitAttrModelType) { - this.fitAttrModelType = fitAttrModelType; - this.jForm = jForm; - initComponents(); - } - - - private void initComponents() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.setBorder(BorderFactory.createEmptyBorder(12, 5, 0, 5)); - this.add(createReportFitSettingPane(), BorderLayout.CENTER); - this.add(createReportLayoutSettingPane(), BorderLayout.NORTH); - - } - - - private JPanel createReportLayoutSettingPane() { - JPanel jPanel = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Form_PC_Fit_Config_Layout")); - jPanel.add(createAreaScalePane(), BorderLayout.CENTER); - jPanel.setPreferredSize(new Dimension(640, 84)); - return jPanel; - } - - 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")}; - } - - - private JPanel createReportFitSettingPane() { - JPanel jPanel = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Form_PC_Fit_Config_Content_Attr")); - JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - jPanel.add(contentPane, BorderLayout.CENTER); - UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Form_PC_Fit_Config_Settings")); - label.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0)); - contentPane.add(label, BorderLayout.WEST); - label.setPreferredSize(new Dimension(100, 0)); - label.setVerticalAlignment(SwingConstants.TOP); - itemChoose = new UIComboBox(getItemNames()); - itemChoose.setPreferredSize(new Dimension(160, 20)); - Form form = jForm.getTarget(); - itemChoose.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - if (isTemplateSingleSet()) { - if (form != null) { - ReportFitAttr fitAttr = form.getReportFitAttr(); - populate(fitAttr); - } - } else { - populate(fitAttrModelType.getFitAttrModel().getGlobalReportFitAttr()); - } - } - } - }); - JPanel centerPane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); - centerPane.add(itemChoose); - centerPane.add(fitConfigPane = new FormFitConfigPane(this.fitAttrModelType.getFitAttrModel())); - contentPane.add(centerPane, BorderLayout.CENTER); - return jPanel; - } - - public void populate(ReportFitAttr reportFitAttr) { - if (reportFitAttr == null) { - reportFitAttr = fitAttrModelType.getFitAttrModel().getGlobalReportFitAttr(); - } - - this.setEnabled(isTemplateSingleSet()); - fitConfigPane.populateBean(reportFitAttr); - } - - - public ReportFitAttr updateBean() { - updateLayoutType(); - if (!isTemplateSingleSet()) { - return null; - } else { - return fitConfigPane.updateBean(); - } - } - - private void updateLayoutType() { - XLayoutContainer xLayoutContainer = this.jForm.getRootComponent(); - if (xLayoutContainer == null || !xLayoutContainer.acceptType(XWFitLayout.class)) { - return; - } - XWFitLayout xwFitLayout = (XWFitLayout) xLayoutContainer; - WFitLayout wFitLayout = xwFitLayout.toData(); - int state = layoutComboBox.getSelectedIndex(); - WBodyLayoutType selectType = WBodyLayoutType.parse(state); - if (selectType != wFitLayout.getBodyLayoutType()) { - wFitLayout.setLayoutType(selectType); - //从自适应布局切换到绝对布局 - if (selectType == WBodyLayoutType.ABSOLUTE) { - switchLayoutFromFit2Absolute(xwFitLayout); - } else { - //从绝对布局切换到自适应布局 - switchLayoutFromAbsolute2Fit(xwFitLayout); - } - } - wFitLayout.setCompatibleScaleAttr(fitAttrModelType.parseScaleAttrFromShowIndex(this.scaleComboBox.getSelectedIndex(), wFitLayout.getBodyLayoutType())); - } - - - private void switchLayoutFromFit2Absolute(XWFitLayout xWFitLayout) { - try { - WFitLayout layout = xWFitLayout.toData(); - WAbsoluteBodyLayout wAbsoluteBodyLayout = new WAbsoluteBodyLayout("body"); - wAbsoluteBodyLayout.setCompState(WAbsoluteLayout.STATE_FIXED); - // 切换布局类型时,保留body背景样式 - wAbsoluteBodyLayout.setBorderStyleFollowingTheme(layout.isBorderStyleFollowingTheme()); - wAbsoluteBodyLayout.setBorderStyle((BorderPacker) (layout.getBorderStyle().clone())); - Component[] components = xWFitLayout.getComponents(); - Rectangle[] backupBounds = getBackupBoundsFromFitLayout(xWFitLayout); - xWFitLayout.removeAll(); - layout.resetStyle(); - XWAbsoluteBodyLayout xwAbsoluteBodyLayout = xWFitLayout.getBackupParent() == null ? new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0, 0)) : (XWAbsoluteBodyLayout) xWFitLayout.getBackupParent(); - xWFitLayout.setFixLayout(false); - xWFitLayout.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0); - for (int i = 0; i < components.length; i++) { - XCreator xCreator = (XCreator) components[i]; - xCreator.setBounds(backupBounds[i]); - //部分控件被ScaleLayout包裹着,绝对布局里面要放出来 - if (xCreator.acceptType(XWScaleLayout.class)) { - if (xCreator.getComponentCount() > 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator()) { - Component component = xCreator.getComponent(0); - component.setBounds(xCreator.getBounds()); - } - } - if (!xCreator.acceptType(XOccupiedLayout.class)) { - xwAbsoluteBodyLayout.add(xCreator); - } - - } - copyLayoutAttr(layout, xwAbsoluteBodyLayout.toData()); - xWFitLayout.setBackupParent(xwAbsoluteBodyLayout); - FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - formDesigner.getSelectionModel().setSelectedCreators( - FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout})); - if (xwAbsoluteBodyLayout.toData() != null) { - xwAbsoluteBodyLayout.toData().setBorderStyleFollowingTheme(wAbsoluteBodyLayout.isBorderStyleFollowingTheme()); - xwAbsoluteBodyLayout.toData().setBorderStyle(wAbsoluteBodyLayout.getBorderStyle()); - } - xwAbsoluteBodyLayout.refreshStylePreviewEffect(); - if (xWFitLayout.toData() != null) { - xWFitLayout.toData().resetStyle(); - } - xWFitLayout.refreshStylePreviewEffect(); - formDesigner.switchBodyLayout(xwAbsoluteBodyLayout); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - - } - } - - private Rectangle[] getBackupBoundsFromFitLayout(XWFitLayout xWFitLayout) { - int count = xWFitLayout.getComponentCount(); - Rectangle[] rectangles = new Rectangle[count]; - for (int i = 0; i < count; i++) { - rectangles[i] = xWFitLayout.getComponent(i).getBounds(); - } - return rectangles; - } - - protected void copyLayoutAttr(WSortLayout srcLayout, WSortLayout destLayout) { - destLayout.clearListeners(); - destLayout.clearMobileWidgetList(); - for (int i = 0, len = srcLayout.getMobileWidgetListSize(); i < len; i++) { - destLayout.addMobileWidget(srcLayout.getMobileWidget(i)); - } - destLayout.setSorted(true); - for (int i = 0, len = srcLayout.getListenerSize(); i < len; i++) { - destLayout.addListener(srcLayout.getListener(i)); - } - srcLayout.clearListeners(); - srcLayout.clearMobileWidgetList(); - } - - - private void switchLayoutFromAbsolute2Fit(XWFitLayout xwFitLayout) { - XWAbsoluteBodyLayout xwAbsoluteBodyLayout = getAbsoluteBodyLayout(xwFitLayout); - if (xwAbsoluteBodyLayout == null) { - return; - } - WAbsoluteBodyLayout layout = xwAbsoluteBodyLayout.toData(); - WFitLayout wFitLayout = xwFitLayout.toData(); - wFitLayout.resetStyle(); - xwFitLayout.switch2FitBodyLayout(xwAbsoluteBodyLayout); - // 切换布局类型时,保留body背景样式 - if (wFitLayout != null) { - wFitLayout.setBorderStyleFollowingTheme(layout.isBorderStyleFollowingTheme()); - wFitLayout.setBorderStyle(layout.getBorderStyle()); - } - copyLayoutAttr(layout, xwFitLayout.toData()); - - copyLayoutAttr(layout, xwFitLayout.toData()); - xwFitLayout.refreshStylePreviewEffect(); - } - - private XWAbsoluteBodyLayout getAbsoluteBodyLayout(XWFitLayout xwFitLayout) { - if (xwFitLayout != null && xwFitLayout.getComponentCount() > 0) { - Component component = xwFitLayout.getComponent(0); - if (component instanceof XWAbsoluteBodyLayout) { - return (XWAbsoluteBodyLayout) component; - } - } - return null; - } - - private JPanel createAreaScalePane() { - initLayoutComboBox(); - - UILabel layoutTypeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")); - UILabel scaleModeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_PC_Fit_Config_Scale_Setting")); - Component[][] components = new Component[][]{ - {layoutTypeLabel, layoutComboBox}, - {scaleModeLabel, scaleComboBox} - }; - JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(components, - TableLayoutHelper.FILL_LASTCOLUMN, 20, IntervalConstants.INTERVAL_L1); - JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - containerPane.add(contentPane, BorderLayout.CENTER); - - return containerPane; - } - - - public void initLayoutComboBox() { - Item[] items = FRLayoutTypeItems.ITEMS; - DefaultComboBoxModel model = new DefaultComboBoxModel(); - for (Item item : items) { - model.addElement(item); - } - scaleComboBox = new UIComboBox(model); - scaleComboBox.setModel(new DefaultComboBoxModel(fitAttrModelType.getFitLayoutScaleAttr())); - layoutComboBox = new UIComboBox(model); - layoutComboBox.setPreferredSize(new Dimension(160, 20)); - scaleComboBox.setPreferredSize(new Dimension(160, 20)); - WFitLayout wFitLayout = jForm.getTarget().getWFitLayout(); - layoutComboBox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - int selectIndex = layoutComboBox.getSelectedIndex(); - if (selectIndex == 0) { - if (wFitLayout.getBodyLayoutType() == WBodyLayoutType.ABSOLUTE) { - int selVal = FineJOptionPane.showConfirmDialog( - FormFitAttrPane.this, - Toolkit.i18nText("Fine-Design_Form_Layout_Switch_Tip"), - Toolkit.i18nText("Fine-Design_Basic_Alert"), - OK_CANCEL_OPTION, - WARNING_MESSAGE - ); - if (OK_OPTION != selVal) { - layoutComboBox.setSelectedIndex(1); - return; - } - } - scaleComboBox.setModel(new DefaultComboBoxModel(fitAttrModelType.getFitLayoutScaleAttr())); - } else { - scaleComboBox.setModel(new DefaultComboBoxModel(fitAttrModelType.getAbsoluteLayoutSaleAttr())); - } - scaleComboBox.setSelectedIndex(0); - } - }); - - scaleComboBox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - WBodyLayoutType selectBodyType = WBodyLayoutType.parse(layoutComboBox.getSelectedIndex()); - int state = fitAttrModelType.parseScaleAttrFromShowIndex(scaleComboBox.getSelectedIndex(), selectBodyType); - fitConfigPane.refreshPreviewJPanel(FitType.parseByFitState(state)); - } - }); - } - - - @Override - public void populateBean(ReportFitAttr reportFitAttr) { - WFitLayout wFitLayout = jForm.getTarget().getWFitLayout(); - layoutComboBox.setSelectedIndex(wFitLayout.getBodyLayoutType().getTypeValue()); - scaleComboBox.setSelectedIndex(fitAttrModelType.getScaleAttrShowIndex(wFitLayout)); - - 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")); - } - if (reportFitAttr == null) { - reportFitAttr = fitAttrModelType.getFitAttrModel().getGlobalReportFitAttr(); - } - setEnabled(isTemplateSingleSet()); - fitConfigPane.populateBean(reportFitAttr); - } - - private boolean isTemplateSingleSet() { - return ComparatorUtils.equals(Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single"), itemChoose.getSelectedItem()); - } - - - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - fitConfigPane.setEnabled(enabled); - } - - @Override - protected String title4PopupWindow() { - return i18nText("Fine-Designer_PC_Fit_Attr"); - } - -} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index ec3852437b..8d2748eb39 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -14,6 +14,7 @@ import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.FormMobileAttrAction; import com.fr.design.actions.TemplateParameterAction; import com.fr.design.actions.core.WorkBookSupportable; @@ -36,7 +37,7 @@ import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.fit.FormFitAttrAction; +import com.fr.design.fun.FormAdaptiveConfigUIProcessor; import com.fr.design.fun.PreviewProvider; import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; @@ -65,6 +66,7 @@ import com.fr.design.menu.ToolBarDef; import com.fr.design.parameter.ParameterPropertyPane; import com.fr.design.preview.FormPreview; import com.fr.design.preview.MobilePreview; +import com.fr.design.report.fit.menupane.ReportFitAttrAction; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.utils.gui.LayoutUtils; import com.fr.file.FILE; @@ -595,7 +597,11 @@ public class JForm extends JTemplate implements BaseJForm implements BaseJForm { + protected UIComboBox comboBox; public FRAbsoluteLayoutDefinePane(XCreator xCreator) { super(xCreator); @@ -19,8 +34,40 @@ public class FRAbsoluteLayoutDefinePane extends AbstractFRLayoutDefinePane { + private static final int ADAPT_LABEL_MAX_WIDTH = 80; private XWFitLayout xWFitLayout; private WFitLayout wFitLayout; + private UIComboBox layoutComboBox; + private UIComboBox adaptComboBox; private UISpinner componentIntervel; private PaddingBoundPane paddingBound; private FollowingThemePane themePane; @@ -106,7 +119,11 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator()) { + Component component = xCreator.getComponent(0); + component.setBounds(xCreator.getBounds()); + } + } + if (!xCreator.acceptType(XOccupiedLayout.class)){ + xwAbsoluteBodyLayout.add(xCreator); + } + + } + copyLayoutAttr(wFitLayout, xwAbsoluteBodyLayout.toData()); + xWFitLayout.setBackupParent(xwAbsoluteBodyLayout); + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + formDesigner.getSelectionModel().setSelectedCreators( + FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout})); + if (xwAbsoluteBodyLayout.toData() != null) { + xwAbsoluteBodyLayout.toData().setBorderStyleFollowingTheme(wAbsoluteBodyLayout.isBorderStyleFollowingTheme()); + xwAbsoluteBodyLayout.toData().setBorderStyle(wAbsoluteBodyLayout.getBorderStyle()); + } + xwAbsoluteBodyLayout.refreshStylePreviewEffect(); + if (xWFitLayout.toData() != null) { + xWFitLayout.toData().resetStyle(); + } + xWFitLayout.refreshStylePreviewEffect(); + formDesigner.switchBodyLayout(xwAbsoluteBodyLayout); + return layout; + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + + } + int intervelValue = (int) componentIntervel.getValue(); if (xWFitLayout.canAddInterval(intervelValue)) { // 设置完间隔后,要同步处理界面组件,容器刷新后显示出对应效果 @@ -210,6 +302,14 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane Date: Wed, 19 Jan 2022 11:46:00 +0800 Subject: [PATCH 3/7] =?UTF-8?q?REPORT-65976=20=E5=A4=8D=E7=94=A8=E7=BB=84?= =?UTF-8?q?=E4=BB=B6-=E7=BB=9D=E5=AF=B9=E5=B8=83=E5=B1=80=E6=8B=96?= =?UTF-8?q?=E5=85=A5=E7=BB=9D=E5=AF=B9=E7=94=BB=E5=B8=83=E5=9D=97=E7=9A=84?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=EF=BC=8C=E7=BB=9D=E5=AF=B9=E7=94=BB=E5=B8=83?= =?UTF-8?q?=E5=9D=97=E9=87=8C=E7=9A=84=E5=AD=90=E7=BB=84=E4=BB=B6=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E9=9A=8F=E7=9D=80=E7=BB=9D=E5=AF=B9=E7=94=BB=E5=B8=83?= =?UTF-8?q?=E5=9D=97=E7=9A=84=E5=B0=BA=E5=AF=B8=E8=BF=9B=E8=A1=8C=E7=BC=A9?= =?UTF-8?q?=E6=94=BE=EF=BC=8C=E6=AF=94=E7=BB=9D=E5=AF=B9=E7=94=BB=E5=B8=83?= =?UTF-8?q?=E5=9D=97=E5=B0=8F=EF=BC=9B=E6=8B=96=E5=85=A5=E5=88=B0=E5=8D=A0?= =?UTF-8?q?=E4=BD=8D=E5=9D=97=E9=87=8C=E6=98=AF=E6=AD=A3=E5=B8=B8=E5=85=85?= =?UTF-8?q?=E6=BB=A1=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../share/ui/block/LocalWidgetBlock.java | 1 + .../share/ui/block/OnlineWidgetBlock.java | 1 + .../share/ui/block/PreviewWidgetBlock.java | 24 +++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java index 72eb35d000..c23c82f109 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java @@ -252,6 +252,7 @@ public class LocalWidgetBlock extends PreviewWidgetBlock ShareUIUtils.showErrorMessageDialog(Toolkit.i18nText("Fine-Design_Share_Drag_Error_Info")); return null; } + compatibleProcessAbsoluteLayoutResolution(creatorSource); creatorSource.setWidgetID(UUID.randomUUID().toString()); ((AbstractBorderStyleWidget) creatorSource).addWidgetAttrMark(new SharableAttrMark(true)); //tab布局WCardMainBorderLayout通过反射出来的大小是960*480 diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java index 38bcd99826..7f0e369f90 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java @@ -189,6 +189,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock { ShareUIUtils.showErrorMessageDialog(Toolkit.i18nText("Fine-Design_Share_Drag_Error_Info")); return; } + compatibleProcessAbsoluteLayoutResolution(creatorSource); creatorSource.setWidgetID(UUID.randomUUID().toString()); ((AbstractBorderStyleWidget) creatorSource).addWidgetAttrMark(new SharableAttrMark(true)); SharableWidgetProvider bindInfo = ShareUtils.getElCaseBindInfoById(shareId); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java index 5a19d0216f..6024a0b709 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe.share.ui.block; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; +import com.fr.design.fit.common.TemplateTool; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.EastRegionContainerPane; @@ -12,7 +13,12 @@ import com.fr.design.mainframe.share.collect.ComponentCollector; import com.fr.design.mainframe.share.ui.online.CarouselStateManger; import com.fr.design.mainframe.share.ui.online.embed.AnimatePopupDialog; import com.fr.design.mainframe.share.ui.online.embed.FirstDragAnimateStateManager; +import com.fr.form.main.Form; +import com.fr.form.main.WidgetGather; import com.fr.form.share.constants.ShareComponentConstants; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WAbsoluteLayout; +import com.fr.general.FRScreen; import com.fr.module.ModuleContext; import org.jetbrains.annotations.NotNull; import javax.swing.ImageIcon; @@ -285,4 +291,22 @@ public abstract class PreviewWidgetBlock extends JPanel implements MouseListe } + //新自适应的模板由于内部的尺寸都是未经过缩放过的值,所以对应的设计分辨率值也要保持正常分辨率p1440 + protected void compatibleProcessAbsoluteLayoutResolution(Widget widget) { + if (!TemplateTool.isCurrentEditingNewJForm()) { + return; + } + Form.traversalWidget(widget, new WidgetGather() { + @Override + public void dealWith(Widget widget) { + ((WAbsoluteLayout) widget).setDesigningResolution(FRScreen.p1440.getDimension()); + } + + @Override + public boolean dealWithAllCards() { + return true; + } + }, WAbsoluteLayout.class); + } + } From f2810dff76fc321ce69f1fa6c5be283399b95e24 Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 19 Jan 2022 18:05:57 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/share/ui/block/PreviewWidgetBlock.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java index 6024a0b709..93b9f93403 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java @@ -2,7 +2,6 @@ package com.fr.design.mainframe.share.ui.block; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; -import com.fr.design.fit.common.TemplateTool; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.EastRegionContainerPane; @@ -291,11 +290,7 @@ public abstract class PreviewWidgetBlock extends JPanel implements MouseListe } - //新自适应的模板由于内部的尺寸都是未经过缩放过的值,所以对应的设计分辨率值也要保持正常分辨率p1440 protected void compatibleProcessAbsoluteLayoutResolution(Widget widget) { - if (!TemplateTool.isCurrentEditingNewJForm()) { - return; - } Form.traversalWidget(widget, new WidgetGather() { @Override public void dealWith(Widget widget) { From f949a8e54cd25f8f86ff982b4e74e4b51778dbe7 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 20 Jan 2022 11:10:16 +0800 Subject: [PATCH 5/7] =?UTF-8?q?REPORT-65976=20final=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E4=BC=A0=E4=B8=80=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../share/ui/block/LocalWidgetBlock.java | 1 + .../share/ui/block/OnlineWidgetBlock.java | 1 + .../share/ui/block/PreviewWidgetBlock.java | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java index 72eb35d000..c23c82f109 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java @@ -252,6 +252,7 @@ public class LocalWidgetBlock extends PreviewWidgetBlock ShareUIUtils.showErrorMessageDialog(Toolkit.i18nText("Fine-Design_Share_Drag_Error_Info")); return null; } + compatibleProcessAbsoluteLayoutResolution(creatorSource); creatorSource.setWidgetID(UUID.randomUUID().toString()); ((AbstractBorderStyleWidget) creatorSource).addWidgetAttrMark(new SharableAttrMark(true)); //tab布局WCardMainBorderLayout通过反射出来的大小是960*480 diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java index 38bcd99826..7f0e369f90 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java @@ -189,6 +189,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock { ShareUIUtils.showErrorMessageDialog(Toolkit.i18nText("Fine-Design_Share_Drag_Error_Info")); return; } + compatibleProcessAbsoluteLayoutResolution(creatorSource); creatorSource.setWidgetID(UUID.randomUUID().toString()); ((AbstractBorderStyleWidget) creatorSource).addWidgetAttrMark(new SharableAttrMark(true)); SharableWidgetProvider bindInfo = ShareUtils.getElCaseBindInfoById(shareId); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java index 5a19d0216f..93b9f93403 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java @@ -12,7 +12,12 @@ import com.fr.design.mainframe.share.collect.ComponentCollector; import com.fr.design.mainframe.share.ui.online.CarouselStateManger; import com.fr.design.mainframe.share.ui.online.embed.AnimatePopupDialog; import com.fr.design.mainframe.share.ui.online.embed.FirstDragAnimateStateManager; +import com.fr.form.main.Form; +import com.fr.form.main.WidgetGather; import com.fr.form.share.constants.ShareComponentConstants; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WAbsoluteLayout; +import com.fr.general.FRScreen; import com.fr.module.ModuleContext; import org.jetbrains.annotations.NotNull; import javax.swing.ImageIcon; @@ -285,4 +290,18 @@ public abstract class PreviewWidgetBlock extends JPanel implements MouseListe } + protected void compatibleProcessAbsoluteLayoutResolution(Widget widget) { + Form.traversalWidget(widget, new WidgetGather() { + @Override + public void dealWith(Widget widget) { + ((WAbsoluteLayout) widget).setDesigningResolution(FRScreen.p1440.getDimension()); + } + + @Override + public boolean dealWithAllCards() { + return true; + } + }, WAbsoluteLayout.class); + } + } From eaf85709ca1703c142d669e6d26ffe85c1e169c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Thu, 20 Jan 2022 16:36:08 +0800 Subject: [PATCH 6/7] =?UTF-8?q?CHART-22545=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E8=8B=B1=E8=AF=AD-=E7=94=98=E7=89=B9?= =?UTF-8?q?=E5=9B=BE-=E6=A0=87=E7=AD=BE=E6=A0=BC=E5=BC=8F-=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E5=AE=BD=E5=BA=A6=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../style/tooltip/VanChartFormatComBoxWithCheckBox.java | 2 +- .../java/com/fr/design/report/NewReportBackgroundPane.java | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartFormatComBoxWithCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartFormatComBoxWithCheckBox.java index 95da8ea986..f17d07a249 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartFormatComBoxWithCheckBox.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartFormatComBoxWithCheckBox.java @@ -53,7 +53,7 @@ public class VanChartFormatComBoxWithCheckBox extends JPanel { } }); - formatComBox.setPreferredSize(new Dimension(40, 20)); + formatComBox.setPreferredSize(new Dimension(55, 20)); if (showSelectBox()) { this.add(isSelectedBox, BorderLayout.CENTER); diff --git a/designer-realize/src/main/java/com/fr/design/report/NewReportBackgroundPane.java b/designer-realize/src/main/java/com/fr/design/report/NewReportBackgroundPane.java index cf514512da..928d863656 100644 --- a/designer-realize/src/main/java/com/fr/design/report/NewReportBackgroundPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/NewReportBackgroundPane.java @@ -2,7 +2,6 @@ package com.fr.design.report; import com.fr.base.theme.ReportTheme; import com.fr.base.theme.TemplateTheme; -import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.base.theme.settings.ThemedReportBodyStyle; import com.fr.design.designer.IntervalConstants; import com.fr.design.dialog.BasicPane; @@ -10,21 +9,19 @@ import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.style.ReportBackgroundSpecialPane; import com.fr.design.gui.style.FollowingThemePane; +import com.fr.design.gui.style.ReportBackgroundSpecialPane; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.theme.ui.BorderUtils; -import com.fr.form.ui.PaddingMargin; import com.fr.general.Background; import com.fr.page.ReportSettingsProvider; import com.fr.report.stable.ReportSettings; import javax.swing.BorderFactory; import javax.swing.JPanel; -import javax.swing.SwingConstants; import javax.swing.border.CompoundBorder; import java.awt.BorderLayout; import java.awt.Color; @@ -168,7 +165,7 @@ public class NewReportBackgroundPane extends BasicPane { container.setBorder(BorderFactory.createEmptyBorder()); JPanel titledPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); titledPane.setBorder(new CompoundBorder( - BorderUtils.createTitleBorder("预览", 12), + BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Preview"), 12), BorderFactory.createEmptyBorder(5, 5, 4, 5) )); titledPane.setPreferredSize(new Dimension(377, 502)); From dbd5cd66491a32c96375a64092491a991f9cea7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Thu, 20 Jan 2022 17:38:52 +0800 Subject: [PATCH 7/7] =?UTF-8?q?REPORT-65373=20JDK11=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8-=E8=8F=9C=E5=8D=95=E6=A0=8F-=E6=96=87=E4=BB=B6-?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E5=BC=B9=E7=AA=97=E8=BE=B9=E6=A1=86=E8=A2=AB?= =?UTF-8?q?=E6=88=AA=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/actions/file/PreferencePane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 5a777b895d..2fa06a5642 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -108,7 +108,7 @@ public class PreferencePane extends BasicPane { private static final int CACHING_DEFAULT = 5; private static final int CACHING_GAP = 5; private static final int MEMORY_TIP_LABEL_MAX_WIDTH = 230; - private static final int OFFSET_HEIGHT = 50; + private static final int OFFSET_HEIGHT = 60; private static final String TYPE = "pressed"; private static final String DISPLAY_TYPE = "+";