From a3ec34c7e535168f699a6aa0d79504adf1ce9ff6 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 6 Jan 2022 17:19:17 +0800 Subject: [PATCH] =?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