From 1c4cb5365546552ba02186396c883758bb2c7a3b Mon Sep 17 00:00:00 2001 From: plough Date: Tue, 15 Jan 2019 11:08:29 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-14057=2010.0=E6=97=A5=E6=96=87=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86=3D>?= =?UTF-8?q?=E8=A1=A8=E5=8D=95body=E8=87=AA=E9=80=82=E5=BA=94=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/utils/gui/UIComponentUtils.java | 26 +++++++++++++++++++ .../layout/FRFitLayoutDefinePane.java | 22 ++++++++++++---- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/utils/gui/UIComponentUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/UIComponentUtils.java index 676369e75c..a0dde09416 100644 --- a/designer-base/src/main/java/com/fr/design/utils/gui/UIComponentUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/gui/UIComponentUtils.java @@ -1,8 +1,13 @@ package com.fr.design.utils.gui; import com.fr.design.gui.core.UITextComponent; +import com.fr.design.layout.FRGUIPaneFactory; import com.fr.stable.StringUtils; +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; + /** * 包含 UI 组件相关的工具方法 * Created by plough on 2019/1/11. @@ -48,4 +53,25 @@ public class UIComponentUtils { } comp.setText(prefix + comp.getText()); } + + /** + * 将一个组件包装到 BorderLayout 布局的面板中 + * @param comp,待包装的组件 + * @param layoutConstraint,添加的方向,如 BorderLayout.NORTH + * @return 包装好的 JPanel + */ + public static JPanel wrapWithBorderLayoutPane(JComponent comp, String layoutConstraint) { + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.add(comp, layoutConstraint); + return panel; + } + + /** + * 将一个组件包装到 BorderLayout 布局的面板中 + * @param comp,待包装的组件 + * @return 包装好的 JPanel(布局方向为 BorderLayout.NORTH) + */ + public static JPanel wrapWithBorderLayoutPane(JComponent comp) { + return wrapWithBorderLayoutPane(comp, BorderLayout.NORTH); + } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java index dd19d7c812..6b0f1bbdc8 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java @@ -24,9 +24,9 @@ import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor; +import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.ui.designer.AbstractDataModify; import com.fr.design.widget.ui.designer.component.PaddingBoundPane; -import com.fr.form.main.Form; import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteBodyLayout; @@ -35,7 +35,6 @@ import com.fr.form.ui.container.WBodyLayoutType; import com.fr.form.ui.container.WFitLayout; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; - import com.fr.report.core.ReportUtils; import javax.swing.BorderFactory; @@ -49,6 +48,7 @@ import java.awt.Dimension; * Created by ibm on 2017/8/2. */ public class FRFitLayoutDefinePane extends AbstractDataModify { + private static final int ADAPT_LABEL_MAX_WIDTH = 80; private XWFitLayout xWFitLayout; private WFitLayout wFitLayout; private UIComboBox layoutComboBox; @@ -95,19 +95,31 @@ public class FRFitLayoutDefinePane extends AbstractDataModify { JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); layoutComboBox = initUIComboBox(FRLayoutTypeItems.ITEMS); adaptComboBox = initUIComboBox(FRFitConstraintsItems.ITEMS); + JPanel adaptComboBoxPane = UIComponentUtils.wrapWithBorderLayoutPane(adaptComboBox); componentIntervel = new UISpinner(0, Integer.MAX_VALUE, 1, 0); + JPanel componentIntervelPane = UIComponentUtils.wrapWithBorderLayoutPane(componentIntervel); + + UILabel adaptLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Scale")); + UIComponentUtils.setLineWrap(adaptLabel); + + UILabel intervalLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Interval")); + UIComponentUtils.setLineWrap(intervalLabel); + double f = TableLayout.FILL; double p = TableLayout.PREFERRED; double[] rowSize = {p, p}; - double[] columnSize = {p, f}; + double adaptLabelColumnWidth = adaptLabel.getPreferredSize().width > ADAPT_LABEL_MAX_WIDTH ? ADAPT_LABEL_MAX_WIDTH : p; + double[] columnSize = {adaptLabelColumnWidth, f}; int[][] rowCount = {{1, 1}, {1, 1}}; JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")), layoutComboBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); northPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); + + Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Scale")), adaptComboBox}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Interval")), componentIntervel} + new Component[]{adaptLabel, adaptComboBoxPane}, + new Component[]{intervalLabel, componentIntervelPane} }; JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); centerPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L5, 0, 0));