From 2e06f2d7f185ac8aff95b1031837cd31829a92ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levy=2EXie-=E8=A7=A3=E5=AE=89=E6=A3=AE?= Date: Tue, 30 Jan 2024 15:44:13 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-111995=20=E3=80=90UI=E7=BF=BB=E6=96=B0?= =?UTF-8?q?=E3=80=91=E6=BB=9A=E5=8A=A8=E9=9D=A2=E6=9D=BF=E8=A1=A5=E5=85=85?= =?UTF-8?q?storyboard&=E8=A7=A3=E5=86=B3=E6=8E=A7=E4=BB=B6=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E4=B8=80=E4=BA=9B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fine/theme/utils/FineUIUtils.java | 14 +++- .../components/UIScrollPaneStoryBoard.java | 77 +++++++++++++++++++ .../ui/designer/ButtonGroupDictPane.java | 20 ++--- .../ui/designer/FieldEditorDefinePane.java | 4 +- 4 files changed, 103 insertions(+), 12 deletions(-) create mode 100644 designer-base/src/test/java/com/fr/design/gui/storybook/components/UIScrollPaneStoryBoard.java diff --git a/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java b/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java index 46891db208..058416fa15 100644 --- a/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java +++ b/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java @@ -381,7 +381,7 @@ public class FineUIUtils { } /** - * 创建一个UIScrollPane的装饰层,内部的ScrollPane仅当悬浮时显示滚动条 + * 基于组件创建一个UIScrollPane的装饰层,内部的ScrollPane仅当悬浮时显示滚动条 * * @param c 组件 * @return UIScrollPane的装饰层 @@ -391,4 +391,16 @@ public class FineUIUtils { new CollapsibleScrollBarLayerUI()); } + /** + * 基于组件创建一个UIScrollPane的装饰层,内部的ScrollPane仅当悬浮时显示滚动条 + * + * @param c 组件 + * @param verticalPolicy 滚动条垂直显示策略 + * @param horizontalPolicy 滚动条水平显示策略 + * @return UIScrollPane的装饰层 + */ + public static JLayer createCollapsibleScrollBarLayer(Component c, int verticalPolicy, int horizontalPolicy) { + return new JLayer<>(new UIScrollPane(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), + new CollapsibleScrollBarLayerUI(verticalPolicy, horizontalPolicy)); + } } diff --git a/designer-base/src/test/java/com/fr/design/gui/storybook/components/UIScrollPaneStoryBoard.java b/designer-base/src/test/java/com/fr/design/gui/storybook/components/UIScrollPaneStoryBoard.java new file mode 100644 index 0000000000..a485942422 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/gui/storybook/components/UIScrollPaneStoryBoard.java @@ -0,0 +1,77 @@ +package com.fr.design.gui.storybook.components; + +import com.fine.swing.ui.layout.Column; +import com.fine.theme.light.ui.FineRoundBorder; +import com.fine.theme.utils.FineUIUtils; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.storybook.StoryBoard; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.ScrollPaneConstants; +import java.awt.Dimension; +import java.util.Collections; + +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.row; + +/** + * 滚动面板 + * + * @author Levy.Xie + * @since 11.0 + * Created on 2024/01/25 + */ +public class UIScrollPaneStoryBoard extends StoryBoard { + public UIScrollPaneStoryBoard() { + super("滚动面板"); + add( + row(20, + column( + cell(new UILabel("滚动条常驻显示")).with(this::h2), + cell(new UILabel("水平/纵向")).with(this::h2), + cell(new UIScrollPane(createMultiLabelPane())).with(this::setFixSize), + cell(new UILabel("水平")).with(this::h3), + cell(new UIScrollPane(createMultiLabelPane(), + ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED)) + .with(this::setFixSize), + cell(new UILabel("纵向")).with(this::h3), + cell(new UIScrollPane(createMultiLabelPane(), + ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)) + .with(this::setFixSize) + ).weight(1), + + column( + cell(new UILabel("滚动条悬浮显示")).with(this::h2), + cell(new UILabel("水平/纵向")).with(this::h3), + cell(FineUIUtils.createCollapsibleScrollBarLayer(createMultiLabelPane())).with(it -> setFixSize(it.getView())), + cell(new UILabel("水平")).with(this::h3), + cell(FineUIUtils.createCollapsibleScrollBarLayer(createMultiLabelPane(), + ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED + )).with(it -> setFixSize(it.getView())), + cell(new UILabel("纵向")).with(this::h3), + cell(FineUIUtils.createCollapsibleScrollBarLayer(createMultiLabelPane(), + ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER + )).with(it -> setFixSize(it.getView()) + ) + ).weight(1) + ) + ); + } + + private JPanel createMultiLabelPane() { + Column column = new Column(); + for (int i = 0; i < 10; i++) { + column.add(new UILabel(String.join(" ", Collections.nCopies(20, "test")))); + } + return column; + } + + private void setFixSize(JComponent component) { + component.setPreferredSize(new Dimension(component.getWidth(), 100)); + component.setBorder(new FineRoundBorder()); + } + +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonGroupDictPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonGroupDictPane.java index 733317eb1d..86238df132 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonGroupDictPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonGroupDictPane.java @@ -1,6 +1,7 @@ package com.fr.design.widget.ui.designer; +import com.fine.swing.ui.layout.Row; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UIBasicSpinner; @@ -22,7 +23,7 @@ import static com.fr.design.constants.LayoutConstants.VERTICAL_GAP; public class ButtonGroupDictPane extends JPanel { private UIBasicSpinner columnSpinner; private UICheckBox adaptiveCheckbox; - private UILabel columnLabel; + private Row columnSettingRow; public ButtonGroupDictPane() { this.initComponents(); @@ -35,27 +36,26 @@ public class ButtonGroupDictPane extends JPanel { this.setLayout(FRGUIPaneFactory.createBorderLayout()); adaptiveCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Adaptive"), true); UILabel dictLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_DS_Dictionary")); - this.columnLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Group_Display_Columns") + ":", dictLabel.getPreferredSize().width); + UILabel columnLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Group_Display_Columns") + ":", dictLabel.getPreferredSize().width); columnSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1)); - + columnSettingRow = row( + cell(columnLabel).weight(LEFT_WEIGHT), cell(columnSpinner).weight(RIGHT_WEIGHT) + ).getComponent(); this.add(column(VERTICAL_GAP, cell(adaptiveCheckbox), - row( - cell(columnLabel).weight(LEFT_WEIGHT), cell(columnSpinner).weight(RIGHT_WEIGHT) - ) + cell(columnSettingRow) + ).getComponent()); } public void populate(ButtonGroup buttonGroup) { adaptiveCheckbox.setSelected(buttonGroup.isAdaptive()); - columnSpinner.setVisible(!adaptiveCheckbox.isSelected()); - columnLabel.setVisible(!adaptiveCheckbox.isSelected()); + columnSettingRow.setVisible(!adaptiveCheckbox.isSelected()); columnSpinner.setValue(buttonGroup.getColumnsInRow()); } public void update(ButtonGroup buttonGroup) { - columnSpinner.setVisible(!adaptiveCheckbox.isSelected()); - columnLabel.setVisible(!adaptiveCheckbox.isSelected()); + columnSettingRow.setVisible(!adaptiveCheckbox.isSelected()); buttonGroup.setAdaptive(adaptiveCheckbox.isSelected()); buttonGroup.setColumnsInRow((Integer)(columnSpinner.getValue())); } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/FieldEditorDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/FieldEditorDefinePane.java index 09fd42ee5d..e847f7dac3 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/FieldEditorDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/FieldEditorDefinePane.java @@ -5,6 +5,7 @@ import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.ErrorMsgTextFieldAdapter; import com.fr.design.beans.UITextFieldAdapter; +import com.fr.design.border.FineBorderFactory; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XLayoutContainer; @@ -162,7 +163,8 @@ public abstract class FieldEditorDefinePane extends Abstr validatePane.add(contentPane); } UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Validate"), 280, 20, validatePane); - this.add(uiExpandablePane, BorderLayout.CENTER); + uiExpandablePane.setBorder(FineBorderFactory.createDefaultTopBorder()); + corePane.add(uiExpandablePane); }