From f3bd8ca44bfec61f7847b60fd1c157c12035d0f9 Mon Sep 17 00:00:00 2001 From: nmwei <254060001@qq.com> Date: Tue, 16 Jun 2020 15:00:08 +0800 Subject: [PATCH] =?UTF-8?q?MOBILE-27532=20=E5=8D=95=E9=80=89=EF=BC=8F?= =?UTF-8?q?=E5=A4=8D=E9=80=89=E6=8C=89=E9=92=AE=E7=BB=84=E8=87=AA=E9=80=82?= =?UTF-8?q?=E5=BA=94=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/creator/XCheckBoxGroup.java | 7 ++ .../design/designer/creator/XRadioGroup.java | 7 ++ .../mobile/ButtonGroupPropertyUI.java | 32 +++++++ .../mobile/ButtonGroupDefinePane.java | 84 +++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 designer-form/src/main/java/com/fr/design/designer/properties/mobile/ButtonGroupPropertyUI.java create mode 100644 designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ButtonGroupDefinePane.java diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCheckBoxGroup.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCheckBoxGroup.java index 26f1421a6..086b8c3e7 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCheckBoxGroup.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCheckBoxGroup.java @@ -3,7 +3,9 @@ */ package com.fr.design.designer.creator; +import com.fr.design.designer.properties.mobile.ButtonGroupPropertyUI; import com.fr.design.form.util.XCreatorConstants; +import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.widget.editors.DictionaryEditor; @@ -87,4 +89,9 @@ public class XCheckBoxGroup extends XFieldEditor { protected String getIconName() { return "checkbox_group_16.png"; } + + @Override + public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { + return new WidgetPropertyUIProvider[] {new ButtonGroupPropertyUI(this)}; + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XRadioGroup.java b/designer-form/src/main/java/com/fr/design/designer/creator/XRadioGroup.java index af10fbc17..879c83399 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XRadioGroup.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XRadioGroup.java @@ -12,6 +12,8 @@ import javax.swing.ButtonGroup; import javax.swing.JComponent; import javax.swing.JRadioButton; +import com.fr.design.designer.properties.mobile.ButtonGroupPropertyUI; +import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.widget.editors.DictionaryEditor; import com.fr.design.mainframe.widget.editors.InChangeBooleanEditor; @@ -83,4 +85,9 @@ public class XRadioGroup extends XFieldEditor { protected String getIconName() { return "button_group_16.png"; } + + @Override + public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { + return new WidgetPropertyUIProvider[] {new ButtonGroupPropertyUI(this)}; + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/properties/mobile/ButtonGroupPropertyUI.java b/designer-form/src/main/java/com/fr/design/designer/properties/mobile/ButtonGroupPropertyUI.java new file mode 100644 index 000000000..2c6b85c85 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/properties/mobile/ButtonGroupPropertyUI.java @@ -0,0 +1,32 @@ +package com.fr.design.designer.properties.mobile; + +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XFieldEditor; +import com.fr.design.dialog.BasicPane; +import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; +import com.fr.design.gui.itable.AbstractPropertyTable; +import com.fr.design.widget.ui.designer.mobile.ButtonGroupDefinePane; + +public class ButtonGroupPropertyUI extends AbstractWidgetPropertyUIProvider { + + private XCreator xCreator; + + public ButtonGroupPropertyUI(XFieldEditor xButtonGroupEditor) { + this.xCreator = xButtonGroupEditor; + } + + @Override + public AbstractPropertyTable createWidgetAttrTable() { + return null; + } + + @Override + public BasicPane createWidgetAttrPane() { + return new ButtonGroupDefinePane(xCreator); + } + + @Override + public String tableTitle() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Attr"); + } +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ButtonGroupDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ButtonGroupDefinePane.java new file mode 100644 index 000000000..8ef010739 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ButtonGroupDefinePane.java @@ -0,0 +1,84 @@ +package com.fr.design.widget.ui.designer.mobile; + +import com.fr.base.mobile.ButtonGroupMaxRowsMobileAttr; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.FormDesigner; +import com.fr.form.ui.ButtonGroup; + +import javax.swing.*; +import java.awt.*; + + +public class ButtonGroupDefinePane extends MobileWidgetDefinePane { + + private XCreator xCreator; // 当前选中控件的xCreator + private UISpinner maxShowRowsSpinner; + + public ButtonGroupDefinePane(XCreator xCreator) { + this.xCreator = xCreator; + } + + @Override + public void initPropertyGroups(Object source) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + UILabel maxShowRowsLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design-Mobile_Max_Show_Rows"), SwingConstants.LEFT); + this.maxShowRowsSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 5); + Component[][] components = new Component[][]{ + new Component[] {maxShowRowsLabel, maxShowRowsSpinner} + }; + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + double[] rowSize = {p}; + double[] columnSize = {p,f}; + int[][] rowCount = {{1, 1}}; + final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 30, LayoutConstants.VGAP_LARGE); + panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panelWrapper.add(panel, BorderLayout.NORTH); + UIExpandablePane folderPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, panelWrapper); + this.add(folderPane, BorderLayout.NORTH); + this.repaint(); + } + + private void bindListeners2Widgets() { + reInitAllListeners(); + AttributeChangeListener changeListener = new AttributeChangeListener() { + @Override + public void attributeChange() { + update(); + } + }; + this.addAttributeChangeListener(changeListener); + } + + /** + * 后台初始化所有事件. + */ + private void reInitAllListeners() { + initListener(this); + } + + @Override + public void populate(FormDesigner designer) { + ButtonGroupMaxRowsMobileAttr maxRowsMobileAttr = ((ButtonGroup)xCreator.toData()).getMobileMaxRowsAttr(); + this.maxShowRowsSpinner.setValue(maxRowsMobileAttr.getMaxShowRows()); + // 数据 populate 完成后,再设置监听 + this.bindListeners2Widgets(); + } + + @Override + public void update() { + ButtonGroupMaxRowsMobileAttr maxRowsMobileAttr = ((ButtonGroup)xCreator.toData()).getMobileMaxRowsAttr(); + maxRowsMobileAttr.setMaxShowRows((int) maxShowRowsSpinner.getValue()); + DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来 + } +}