From e362e333feeef23fcb87f97e92a730e0a16fef49 Mon Sep 17 00:00:00 2001 From: Hades Date: Wed, 12 Feb 2020 16:18:27 +0800 Subject: [PATCH 1/3] =?UTF-8?q?MOBILE-25111=20=E9=BB=98=E8=AE=A4UI?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/icheckbox/UICheckBox.java | 20 +++-- .../designer/creator/XWAbsoluteLayout.java | 12 +++ .../cardlayout/XWCardMainBorderLayout.java | 11 +++ .../mobile/MobileBooKMarkUsePropertyUI.java | 36 ++++++++ .../mobile/MobileAdvanceDefinePane.java | 14 ++- .../mobile/MobileBookMarkDefinePane.java | 62 +++++++++++++ .../component/MobileBookMarkSettingPane.java | 25 +----- .../component/MobileBookMarkUsePane.java | 86 +++++++++++++++++++ 8 files changed, 235 insertions(+), 31 deletions(-) create mode 100644 designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBooKMarkUsePropertyUI.java create mode 100644 designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileBookMarkDefinePane.java create mode 100644 designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkUsePane.java diff --git a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java index 10ea06a8c..379274b90 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java @@ -59,24 +59,28 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser initListener(); } - private void initListener() { + protected void initListener() { if (shouldResponseChangeListener()) { this.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - if (uiObserverListener == null) { - return; - } - if (globalNameListener != null && shouldResponseNameListener()) { - globalNameListener.setGlobalName(checkboxName); - } - uiObserverListener.doChange(); + attributeChange(); } }); } } + protected void attributeChange() { + if (uiObserverListener == null) { + return; + } + if (globalNameListener != null && shouldResponseNameListener()) { + globalNameListener.setGlobalName(checkboxName); + } + uiObserverListener.doChange(); + } + /** * 给组件登记一个观察者监听事件 * diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java index 56fcf6486..22d702dfd 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -13,8 +13,11 @@ import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter; import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; +import com.fr.design.designer.properties.mobile.MobileBooKMarkUsePropertyUI; import com.fr.design.form.layout.FRAbsoluteLayout; +import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.form.util.XCreatorConstants; +import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.icon.IconPathConstants; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.EditingMouseListener; @@ -590,4 +593,13 @@ public class XWAbsoluteLayout extends XLayoutContainer { public boolean isSupportShared() { return true; } + + @Override + public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { + if (FormDesignerUtils.isAppRelayout(WidgetPropertyPane.getInstance().getEditingFormDesigner())) { + return new WidgetPropertyUIProvider[] {new MobileBooKMarkUsePropertyUI(this)}; + } else { + return super.getWidgetPropertyUIProviders(); + } + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index edbabeadf..c51fe491e 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -16,7 +16,10 @@ import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWidgetCreator; +import com.fr.design.designer.properties.mobile.MobileBooKMarkUsePropertyUI; +import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.form.util.XCreatorConstants; +import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.icon.IconPathConstants; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.EditingMouseListener; @@ -512,4 +515,12 @@ public class XWCardMainBorderLayout extends XWBorderLayout { return true; } + @Override + public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { + if (FormDesignerUtils.isAppRelayout(WidgetPropertyPane.getInstance().getEditingFormDesigner())) { + return new WidgetPropertyUIProvider[] {new MobileBooKMarkUsePropertyUI(this)}; + } else { + return super.getWidgetPropertyUIProviders(); + } + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBooKMarkUsePropertyUI.java b/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBooKMarkUsePropertyUI.java new file mode 100644 index 000000000..6b6a773e9 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBooKMarkUsePropertyUI.java @@ -0,0 +1,36 @@ +package com.fr.design.designer.properties.mobile; + +import com.fr.design.designer.creator.XCreator; +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.MobileBookMarkDefinePane; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/2/12 + */ +public class MobileBooKMarkUsePropertyUI extends AbstractWidgetPropertyUIProvider { + + private XCreator xCreator; + + public MobileBooKMarkUsePropertyUI(XCreator xCreator) { + this.xCreator = xCreator; + } + + @Override + public AbstractPropertyTable createWidgetAttrTable() { + return null; + } + + @Override + public BasicPane createWidgetAttrPane() { + return new MobileBookMarkDefinePane(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/MobileAdvanceDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java index 9533e552c..2bed8c117 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java @@ -53,7 +53,7 @@ public class MobileAdvanceDefinePane extends MobileWidgetDefinePane { public void initPropertyGroups(Object source) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - this.useBookMarkCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Use_BookMark")); + this.useBookMarkCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Use_BookMark"), false); this.bookMarkNameField = new UITextField() { @Override protected void initListener() { @@ -85,9 +85,18 @@ public class MobileAdvanceDefinePane extends MobileWidgetDefinePane { this.useBookMarkCheck.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - bookMarkNamePane.setVisible(MobileAdvanceDefinePane.this.useBookMarkCheck.isSelected()); + boolean selected = MobileAdvanceDefinePane.this.useBookMarkCheck.isSelected(); + Widget widget = MobileAdvanceDefinePane.this.xCreator.toData(); + MobileBookMark bookMark = widget.getMobileBookMark(); + bookMarkNamePane.setVisible(selected); + if (selected && StringUtils.isEmpty(bookMark.getBookMarkName())) { + String name = widget.getWidgetName(); + MobileAdvanceDefinePane.this.bookMarkNameField.setText(name); + bookMark.setBookMarkName(name); + } } }); + bookMarkNamePane.setVisible(xCreator.toData().getMobileBookMark().isUseBookMark()); contentPane.add(useBookMarkPane, BorderLayout.NORTH); contentPane.add(bookMarkNamePane, BorderLayout.CENTER); UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark"), 280, 20, contentPane); @@ -144,6 +153,7 @@ public class MobileAdvanceDefinePane extends MobileWidgetDefinePane { } if (!isExist(newBookMarkName)) { bookMark.setBookMarkName(newBookMarkName); + DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); } else { FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Rename_Failure"), diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileBookMarkDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileBookMarkDefinePane.java new file mode 100644 index 000000000..4a53d2971 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileBookMarkDefinePane.java @@ -0,0 +1,62 @@ +package com.fr.design.widget.ui.designer.mobile; + +import com.fr.design.designer.creator.XCreator; +import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.widget.ui.designer.mobile.component.MobileBookMarkUsePane; + +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/2/12 + */ +public class MobileBookMarkDefinePane extends MobileWidgetDefinePane { + + private XCreator xCreator; + private MobileBookMarkUsePane mobileBookMarkUsePane; + + public MobileBookMarkDefinePane(XCreator xCreator) { + this.xCreator = xCreator; + } + + @Override + public void initPropertyGroups(Object source) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.mobileBookMarkUsePane = new MobileBookMarkUsePane(); + UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, mobileBookMarkUsePane); + panel.add(uiExpandablePane); + this.add(panel, BorderLayout.NORTH); + } + + 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) { + this.mobileBookMarkUsePane.populate(xCreator); + this.bindListeners2Widgets(); + } + + @Override + public void update() { + this.mobileBookMarkUsePane.update(xCreator); + } +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkSettingPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkSettingPane.java index 6acd9638d..5f3f3663e 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkSettingPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkSettingPane.java @@ -29,7 +29,7 @@ import java.awt.*; public class MobileBookMarkSettingPane extends BasicPane { private AccessibleMobileBookMarkStyleEditor mobileBookMarkStyleEditor; - private UICheckBox showHierarchicalBookmarksCheck; + private MobileBookMarkUsePane showBookMarkPane; public MobileBookMarkSettingPane() { initComponent(); @@ -38,30 +38,13 @@ public class MobileBookMarkSettingPane extends BasicPane { private void initComponent() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.mobileBookMarkStyleEditor = new AccessibleMobileBookMarkStyleEditor(new MobileBookMarkStylePane()); - this.showHierarchicalBookmarksCheck = new UICheckBox( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Show_BookMark"), true); JPanel booKMarkPane = TableLayoutHelper.createGapTableLayoutPane( new Component[][]{new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText( "Fine-Design_Mobile_BookMark_Style")), this.mobileBookMarkStyleEditor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.HGAP_LARGE ); - UILabel hintLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Show_BookMark_Hint")); - hintLabel.setForeground(Color.GRAY); - double f = TableLayout.FILL; - double p = TableLayout.PREFERRED; - double[] rowSize = {p, p}; - double[] columnSize = {f}; - int[][] rowCount = {{1}, {1}}; - Component[][] components = new Component[][]{ - new Component[]{this.showHierarchicalBookmarksCheck}, - new Component[]{hintLabel} - }; + this.showBookMarkPane = new MobileBookMarkUsePane(); JPanel wrapPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - JPanel showBookMarkPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, - IntervalConstants.INTERVAL_L1, - IntervalConstants.INTERVAL_L1); - showBookMarkPane.setBorder( - BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); wrapPane.add(booKMarkPane, BorderLayout.NORTH); wrapPane.add(showBookMarkPane, BorderLayout.CENTER); this.add(wrapPane, BorderLayout.CENTER); @@ -75,13 +58,13 @@ public class MobileBookMarkSettingPane extends BasicPane { public void populate(XCreator xCreator) { WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); this.mobileBookMarkStyleEditor.setValue(wSortLayout.getMobileBookMarkStyle()); - this.showHierarchicalBookmarksCheck.setSelected(wSortLayout.isShowBookmarks()); + this.showBookMarkPane.populate(xCreator); } public void update(XCreator xCreator) { WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); wSortLayout.setMobileBookMarkStyle((MobileBookMarkStyle) mobileBookMarkStyleEditor.getValue()); - wSortLayout.setShowBookmarks(showHierarchicalBookmarksCheck.isSelected()); + this.showBookMarkPane.update(xCreator); } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkUsePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkUsePane.java new file mode 100644 index 000000000..fb4148629 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkUsePane.java @@ -0,0 +1,86 @@ +package com.fr.design.widget.ui.designer.mobile.component; + +import com.fr.design.designer.IntervalConstants; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.form.ui.container.WLayout; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/2/12 + */ +public class MobileBookMarkUsePane extends BasicPane { + + private UICheckBox showHierarchicalBookmarksCheck; + + public MobileBookMarkUsePane() { + initComponent(); + } + + + private void initComponent() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.showHierarchicalBookmarksCheck = new UICheckBox( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Show_BookMark"), true) { + @Override + protected void initListener() { + this.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + attributeChange(); + } + }); + } + }; + UILabel hintLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Show_BookMark_Hint")); + hintLabel.setForeground(Color.GRAY); + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p}; + double[] columnSize = {f}; + int[][] rowCount = {{1}, {1}}; + Component[][] components = new Component[][]{ + new Component[]{this.showHierarchicalBookmarksCheck}, + new Component[]{hintLabel} + }; + JPanel wrapPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel showBookMarkPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, + IntervalConstants.INTERVAL_L1, + IntervalConstants.INTERVAL_L1); + showBookMarkPane.setBorder( + BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); + wrapPane.add(showBookMarkPane, BorderLayout.CENTER); + this.add(showBookMarkPane, BorderLayout.CENTER); + } + + public void populate(XCreator xCreator) { + WLayout wLayout = ((WLayout) xCreator.toData()); + this.showHierarchicalBookmarksCheck.setSelected(wLayout.isShowBookmarks()); + } + + public void update(XCreator xCreator) { + WLayout wLayout = ((WLayout) xCreator.toData()); + wLayout.setShowBookmarks(showHierarchicalBookmarksCheck.isSelected()); + } + + @Override + protected String title4PopupWindow() { + return "MobileBookMarkUsePane"; + } +} From 415097149f45d8d01a5de0bc56b95d2e28eb73d2 Mon Sep 17 00:00:00 2001 From: Hades Date: Wed, 12 Feb 2020 18:24:29 +0800 Subject: [PATCH 2/3] fix --- .../widget/ui/designer/mobile/MobileAdvanceDefinePane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java index 2bed8c117..045c2702f 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java @@ -148,12 +148,12 @@ public class MobileAdvanceDefinePane extends MobileWidgetDefinePane { MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); bookMark.setUseBookMark(this.useBookMarkCheck.isSelected()); String newBookMarkName = this.bookMarkNameField.getText(); + DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); if (ComparatorUtils.equals(newBookMarkName, bookMark.getBookMarkName())) { return; } if (!isExist(newBookMarkName)) { bookMark.setBookMarkName(newBookMarkName); - DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); } else { FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Rename_Failure"), From 790e2b4dbb42d00b7a194c10f3e319d85fa3b177 Mon Sep 17 00:00:00 2001 From: Hades Date: Wed, 12 Feb 2020 19:04:38 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix=20=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/designer/mobile/MobileAdvanceDefinePane.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java index 045c2702f..587ea5395 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java @@ -103,6 +103,19 @@ public class MobileAdvanceDefinePane extends MobileWidgetDefinePane { JPanel wrapPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); wrapPane.add(uiExpandablePane, BorderLayout.NORTH); this.add(wrapPane, BorderLayout.NORTH); + initData(); + } + + private void initData() { + MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); + String bookMarkName = bookMark.getBookMarkName(); + if (StringUtils.isEmpty(bookMarkName)) { + String widgetName = xCreator.toData().getWidgetName(); + this.bookMarkNameField.setText(widgetName); + bookMark.setBookMarkName(widgetName); + } else { + this.bookMarkNameField.setText(bookMarkName); + } } private void bindListeners2Widgets() {