From fba0403899a3404cebd3082084c71fccdf24ed7e Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 25 Dec 2019 17:47:43 +0800 Subject: [PATCH] =?UTF-8?q?MOBILE-24587=20=E7=BB=84=E4=BB=B6=E5=BF=AB?= =?UTF-8?q?=E9=80=9F=E5=AE=9A=E4=BD=8D=20&&=20=20DesignTableManager=20?= =?UTF-8?q?=E5=88=A4=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/DesignTableDataManager.java | 6 +- .../fun/MobileBookMarkStyleProvider.java | 34 ++++ .../AbstractMobileBookMarkStyleProvider.java | 24 +++ ...ltMobileBookMarkStyleCustomDefinePane.java | 31 ++++ .../DefaultMobileBookMarkStyleProvider.java | 28 +++ .../MobileBookMarkStyleCustomDefinePane.java | 20 +++ .../ui/MobileBookMarkStyleDefinePane.java | 57 ++++++ .../mobile/ui/MobileBookMarkStylePane.java | 136 ++++++++++++++ .../wrappers/MobileBookMarkStyleWrapper.java | 30 ++++ .../mobile/MobileBookMarkPropertyUI.java | 36 ++++ .../design/mainframe/WidgetPropertyPane.java | 10 +- .../designer/mobile/BodyMobileDefinePane.java | 18 +- .../mobile/MobileAdvanceDefinePane.java | 167 ++++++++++++++++++ .../mobile/MobileWidgetStyleDefinePane.java | 2 +- .../component/MobileBookMarkSettingPane.java | 117 ++++++++++++ .../component/MobileComponentFrozenPane.java | 10 +- 16 files changed, 716 insertions(+), 10 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/fun/MobileBookMarkStyleProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileBookMarkStyleProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileBookMarkStyleCustomDefinePane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileBookMarkStyleProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleCustomDefinePane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStylePane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileBookMarkStyleWrapper.java create mode 100644 designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBookMarkPropertyUI.java create mode 100644 designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java create mode 100644 designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkSettingPane.java diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index 9af629fa4..25492c55e 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -228,7 +228,11 @@ public abstract class DesignTableDataManager { } public static void removeSelectedColumnNames(String dsName) { - columnCache.get(getEditingTableDataSource()).remove(dsName); + Map map = columnCache.get(getEditingTableDataSource()); + if (map == null) { + return; + } + map.remove(dsName); } public static void addDsColumnNames(String dsName, String[] columnNames) { diff --git a/designer-base/src/main/java/com/fr/design/fun/MobileBookMarkStyleProvider.java b/designer-base/src/main/java/com/fr/design/fun/MobileBookMarkStyleProvider.java new file mode 100644 index 000000000..e8cef684c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/MobileBookMarkStyleProvider.java @@ -0,0 +1,34 @@ +package com.fr.design.fun; + +import com.fr.design.mainframe.mobile.ui.MobileBookMarkStyleCustomDefinePane; +import com.fr.form.ui.mobile.MobileBookMarkStyle; +import com.fr.stable.fun.mark.Mutable; + +/** + * 移动端书签样式扩展接口 + * + * @author hades + * @version 10.0 + * Created by hades on 2019/12/23 + */ +public interface MobileBookMarkStyleProvider extends Mutable { + + String XML_TAG = "MobileBookMarkStyleProvider"; + + int CURRENT_LEVEL = 1; + + /** + * 书签样式 + * @return + */ + Class classForMobileBookMarkStyle(); + + /** + * 书签样式面板 + * @return + */ + Class classForMobileBookMarkStyleAppearance(); + + String displayName(); + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileBookMarkStyleProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileBookMarkStyleProvider.java new file mode 100644 index 000000000..21ed6722b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileBookMarkStyleProvider.java @@ -0,0 +1,24 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.MobileBookMarkStyleProvider; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/24 + */ +@API(level = MobileBookMarkStyleProvider.CURRENT_LEVEL) +public abstract class AbstractMobileBookMarkStyleProvider extends AbstractProvider implements MobileBookMarkStyleProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileBookMarkStyleCustomDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileBookMarkStyleCustomDefinePane.java new file mode 100644 index 000000000..b0ef66ad4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileBookMarkStyleCustomDefinePane.java @@ -0,0 +1,31 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.form.ui.mobile.MobileBookMarkStyle; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/24 + */ +public class DefaultMobileBookMarkStyleCustomDefinePane extends MobileBookMarkStyleCustomDefinePane { + + @Override + protected void initComponent() { + + } + + @Override + public void populateBean(MobileBookMarkStyle ob) { + + } + + @Override + public MobileBookMarkStyle updateBean() { + return null; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileBookMarkStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileBookMarkStyleProvider.java new file mode 100644 index 000000000..d586d8568 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileBookMarkStyleProvider.java @@ -0,0 +1,28 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.fun.impl.AbstractMobileBookMarkStyleProvider; +import com.fr.form.ui.mobile.DefaultMobileBookMarkStyle; +import com.fr.form.ui.mobile.MobileBookMarkStyle; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/24 + */ +public class DefaultMobileBookMarkStyleProvider extends AbstractMobileBookMarkStyleProvider { + + @Override + public Class classForMobileBookMarkStyle() { + return DefaultMobileBookMarkStyle.class; + } + + @Override + public Class classForMobileBookMarkStyleAppearance() { + return DefaultMobileBookMarkStyleCustomDefinePane.class; + } + + @Override + public String displayName() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_None_BookMark_Style"); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleCustomDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleCustomDefinePane.java new file mode 100644 index 000000000..ea2edb78b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleCustomDefinePane.java @@ -0,0 +1,20 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.form.ui.mobile.MobileBookMarkStyle; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/23 + */ +public abstract class MobileBookMarkStyleCustomDefinePane extends BasicBeanPane { + + public MobileBookMarkStyleCustomDefinePane() { + initComponent(); + } + + protected abstract void initComponent(); + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java new file mode 100644 index 000000000..6e0ee06eb --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java @@ -0,0 +1,57 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.MobileBookMarkStyleProvider; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.form.ui.mobile.MobileBookMarkStyle; +import com.fr.general.ComparatorUtils; +import com.fr.invoke.Reflect; + +import javax.swing.*; +import java.awt.*; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/23 + */ +public class MobileBookMarkStyleDefinePane extends BasicBeanPane { + + private MobileBookMarkStyleCustomDefinePane customDefinePane; + private String displayName; + + MobileBookMarkStyleDefinePane(MobileBookMarkStyleProvider bookMarkStyleProvider) { + this.customDefinePane = Reflect.on( + bookMarkStyleProvider.classForMobileBookMarkStyleAppearance()).create().get(); + this.displayName = bookMarkStyleProvider.displayName(); + initComponent(); + } + + private void initComponent() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel settingPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + if (!ComparatorUtils.equals(displayName, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_None_BookMark_Style"))) { + UILabel hintLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Hint")); + hintLabel.setForeground(Color.GRAY); + settingPane.add(hintLabel, BorderLayout.NORTH); + } + settingPane.add(this.customDefinePane, BorderLayout.CENTER); + this.add(settingPane, BorderLayout.CENTER); + } + + @Override + public void populateBean(MobileBookMarkStyle ob) { + this.customDefinePane.populateBean(ob); + } + + @Override + public MobileBookMarkStyle updateBean() { + return this.customDefinePane.updateBean(); + } + + @Override + protected String title4PopupWindow() { + return "MobileBookMarkStyleDefinePane"; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStylePane.java new file mode 100644 index 000000000..4e361d4fa --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStylePane.java @@ -0,0 +1,136 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.MobileBookMarkStyleProvider; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.form.ui.mobile.MobileBookMarkStyle; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/23 + */ +public class MobileBookMarkStylePane extends BasicBeanPane { + + public static ListCellRenderer renderer = new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, + boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof MobileBookMarkStyle) { + this.setText((value.toString())); + } + return this; + } + }; + + private DefaultListModel listModel; + private JList bookMarkList; + private JPanel rightPane; + private CardLayout card; + private Map> map = new HashMap<>(); + + public MobileBookMarkStylePane() { + initComponent(); + } + + private void initComponent() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.listModel = new DefaultListModel<>(); + this.card = new CardLayout(); + this.rightPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + this.rightPane.setLayout(card); + initDefaultAndExtraPanel(); + initLeftListPanel(); + initRightPanel(); + } + + private void initDefaultAndExtraPanel() { + List list = getMobileBookMarkStyleProvider(); + for (MobileBookMarkStyleProvider bookMarkStyleProvider : list) { + String displayName = bookMarkStyleProvider.displayName(); + MobileBookMarkStyleDefinePane mobileBookMarkStyleDefinePane = new MobileBookMarkStyleDefinePane( + bookMarkStyleProvider); + listModel.addElement(displayName); + rightPane.add(displayName, mobileBookMarkStyleDefinePane); + map.put(displayName, mobileBookMarkStyleDefinePane); + } + } + + private void initLeftListPanel() { + bookMarkList = new JList<>(listModel); + bookMarkList.setCellRenderer(renderer); + bookMarkList.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + card.show(rightPane, (String) bookMarkList.getSelectedValue()); + } + }); + JPanel leftPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + leftPanel.add(bookMarkList, BorderLayout.CENTER); + leftPanel.setPreferredSize(new Dimension(100, 500)); + this.add(leftPanel, BorderLayout.WEST); + } + + private void initRightPanel() { + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + centerPane.setPreferredSize(new Dimension(500, 500)); + centerPane.add(rightPane, BorderLayout.CENTER); + this.add(centerPane, BorderLayout.CENTER); + } + + + private List getMobileBookMarkStyleProvider() { + DefaultMobileBookMarkStyleProvider defaultMobileBookMarkStyleProvider = new DefaultMobileBookMarkStyleProvider(); + Set mobileBookMarkStyleProviders = ExtraDesignClassManager.getInstance().getArray( + MobileBookMarkStyleProvider.XML_TAG); + List list = new ArrayList<>(); + list.add(defaultMobileBookMarkStyleProvider); + list.addAll(mobileBookMarkStyleProviders); + return Collections.unmodifiableList(list); + } + + @Override + protected String title4PopupWindow() { + return null; + } + + + @Override + public void populateBean(MobileBookMarkStyle mobileBookMarkStyle) { + if (mobileBookMarkStyle != null) { + List bookMarkStyleProviders = getMobileBookMarkStyleProvider(); + int i = 0; + for (MobileBookMarkStyleProvider bookMarkStyleProvider : bookMarkStyleProviders) { + if (mobileBookMarkStyle.getClass() == bookMarkStyleProvider.classForMobileBookMarkStyle()) { + String displayName = bookMarkStyleProvider.displayName(); + bookMarkList.setSelectedIndex(i); + map.get(displayName).populateBean(mobileBookMarkStyle); + card.show(rightPane, displayName); + return; + } + i++; + } + } + bookMarkList.setSelectedIndex(0); + } + + @Override + public MobileBookMarkStyle updateBean() { + return map.get(bookMarkList.getSelectedValue()).updateBean(); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileBookMarkStyleWrapper.java b/designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileBookMarkStyleWrapper.java new file mode 100644 index 000000000..85c98c103 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileBookMarkStyleWrapper.java @@ -0,0 +1,30 @@ +package com.fr.design.mainframe.widget.wrappers; + +import com.fr.design.Exception.ValidationException; +import com.fr.design.designer.properties.Decoder; +import com.fr.design.designer.properties.Encoder; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/24 + */ +public class MobileBookMarkStyleWrapper implements Encoder, Decoder { + @Override + public Object decode(String txt) { + return null; + } + + @Override + public void validate(String txt) throws ValidationException { + + } + + @Override + public String encode(Object v) { + if (v == null) { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_None_BookMark_Style"); + } + return v.toString(); + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBookMarkPropertyUI.java b/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBookMarkPropertyUI.java new file mode 100644 index 000000000..91451d81f --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBookMarkPropertyUI.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.MobileAdvanceDefinePane; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/24 + */ +public class MobileBookMarkPropertyUI extends AbstractWidgetPropertyUIProvider { + + private XCreator xCreator; + + public MobileBookMarkPropertyUI(XCreator xCreator) { + this.xCreator = xCreator; + } + + @Override + public AbstractPropertyTable createWidgetAttrTable() { + return null; + } + + @Override + public BasicPane createWidgetAttrPane() { + return new MobileAdvanceDefinePane(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/mainframe/WidgetPropertyPane.java b/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java index 8195fbb50..c96683f31 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java @@ -7,6 +7,7 @@ import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.*; import com.fr.design.designer.properties.EventPropertyTable; +import com.fr.design.designer.properties.mobile.MobileBookMarkPropertyUI; import com.fr.design.designer.properties.mobile.MobileStylePropertyUI; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.gui.ibutton.UIHeadGroup; @@ -176,8 +177,13 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper XCreator xCreator = selection.getSelectedCreator(); if (selection != null && xCreator != null) { embeddedPropertyUIProviders = selection.getSelectedCreator().getWidgetPropertyUIProviders(); - if(!designer.getDesignerMode().isFormParameterEditor() && xCreator.supportMobileStyle()) { - embeddedPropertyUIProviders = ArrayUtils.insert(0, embeddedPropertyUIProviders, new MobileStylePropertyUI(xCreator)); + if(!designer.getDesignerMode().isFormParameterEditor()) { + if (!xCreator.acceptType(XWAbsoluteLayout.class, XWFitLayout.class)) { + embeddedPropertyUIProviders = ArrayUtils.insert(0, embeddedPropertyUIProviders, new MobileBookMarkPropertyUI(xCreator)); + } + if (xCreator.supportMobileStyle()) { + embeddedPropertyUIProviders = ArrayUtils.insert(0, embeddedPropertyUIProviders, new MobileStylePropertyUI(xCreator)); + } } } Set set = ExtraDesignClassManager.getInstance().getArray(WidgetPropertyUIProvider.XML_TAG); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java index bfd0ea7ea..3b8367b15 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java @@ -11,6 +11,7 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.MobileWidgetListPane; import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.widget.ui.designer.mobile.component.MobileBookMarkSettingPane; import com.fr.design.widget.ui.designer.mobile.component.MobileComponentFrozenPane; import com.fr.design.widget.ui.designer.mobile.component.MobileComponentMarginPane; import com.fr.design.widget.ui.designer.mobile.component.MobileComponentLayoutIntervalPane; @@ -34,6 +35,7 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { private MobileComponentMarginPane marginPane; private MobileComponentLayoutIntervalPane intervalPane; private MobileComponentFrozenPane frozenPane; + private MobileBookMarkSettingPane bookMarkSettingPane; private UIExpandablePane advancePane; private UIExpandablePane layoutPane; @@ -96,10 +98,14 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { marginPane = new MobileComponentMarginPane(FormBodyPaddingAttrMark.XML_TAG); intervalPane = new MobileComponentLayoutIntervalPane(FormBodyPaddingAttrMark.XML_TAG); frozenPane = new MobileComponentFrozenPane(); + bookMarkSettingPane = new MobileBookMarkSettingPane(); JPanel wrapLayoutPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel wrapAdvancePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); wrapLayoutPane.add(intervalPane, BorderLayout.NORTH); wrapLayoutPane.add(frozenPane, BorderLayout.CENTER); - advancePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, marginPane); + wrapAdvancePane.add(marginPane, BorderLayout.CENTER); + wrapAdvancePane.add(bookMarkSettingPane, BorderLayout.SOUTH); + advancePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, wrapAdvancePane); layoutPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout"), 280, 20, wrapLayoutPane); //高级 holder.add(advancePane, BorderLayout.CENTER); @@ -110,7 +116,7 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { advancePane.setVisible(flag); layoutPane.setVisible(flag); frozenPane.setVisible(appRelayoutCheck.isSelected()); - + bookMarkSettingPane.setVisible(appRelayoutCheck.isSelected()); return holder; } @@ -147,13 +153,15 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { @Override public void populate(FormDesigner designer) { this.designer = designer; + XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); appRelayoutCheck.setSelected(FormDesignerUtils.isAppRelayout(designer)); // 数据 populate 完成后,再设置监听 this.bindListeners2Widgets(); this.addAttributeChangeListener(changeListener); marginPane.populate((RichStyleWidgetProvider) getBodyCreator().toData()); intervalPane.populate((RichStyleWidgetProvider) getBodyCreator().toData()); - frozenPane.populate(designer.getSelectionModel().getSelection().getSelectedCreator()); + frozenPane.populate(xCreator); + bookMarkSettingPane.populate(xCreator); } @Override @@ -174,7 +182,9 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { intervalPane.update((RichStyleWidgetProvider) getBodyCreator().toData()); } if (appRelayout) { - frozenPane.update(designer.getSelectionModel().getSelection().getSelectedCreator()); + XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); + frozenPane.update(xCreator); + bookMarkSettingPane.update(xCreator); } } } 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 new file mode 100644 index 000000000..c74e7c7d0 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java @@ -0,0 +1,167 @@ +package com.fr.design.widget.ui.designer.mobile; + +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.form.main.Form; +import com.fr.form.ui.FormWidgetHelper; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WLayout; +import com.fr.form.ui.container.WSortLayout; +import com.fr.form.ui.mobile.MobileBookMark; +import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.util.Iterator; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/24 + */ +public class MobileAdvanceDefinePane extends MobileWidgetDefinePane { + + private XCreator xCreator; + private UICheckBox useBookMarkCheck; + private UITextField bookMarkNameField; + + public MobileAdvanceDefinePane(XCreator xCreator) { + this.xCreator = xCreator; + } + + @Override + 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.bookMarkNameField = new UITextField() { + @Override + protected void initListener() { + if (shouldResponseChangeListener()) { + addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + attributeChange(); + } + }); + addKeyListener(new KeyAdapter() { + @Override + public void keyTyped(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + attributeChange(); + } + } + }); + } + } + }; + JPanel useBookMarkPane = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{useBookMarkCheck}}, + TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.HGAP_LARGE); + final JPanel bookMarkNamePane = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Name")), bookMarkNameField}}, + TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.HGAP_LARGE); + this.useBookMarkCheck.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + bookMarkNamePane.setVisible(MobileAdvanceDefinePane.this.useBookMarkCheck.isSelected()); + } + }); + 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); + JPanel wrapPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + wrapPane.add(uiExpandablePane, BorderLayout.NORTH); + this.add(wrapPane, 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 Dimension getPreferredSize() { + return new Dimension(super.getPreferredSize().width, 80); + } + + @Override + public Dimension getMaximumSize() { + return new Dimension(400, 200); + } + + @Override + public void populate(FormDesigner designer) { + MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); + this.bookMarkNameField.setText(bookMark.getBookMarkName()); + if (bookMark.isFrozen()) { + this.useBookMarkCheck.setSelected(false); + this.useBookMarkCheck.setEnabled(false); + } else { + this.useBookMarkCheck.setSelected(bookMark.isUseBookMark()); + } + this.bindListeners2Widgets(); + } + + @Override + public void update() { + MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); + bookMark.setUseBookMark(this.useBookMarkCheck.isSelected()); + String newBookMarkName = this.bookMarkNameField.getText(); + if (!isExist(newBookMarkName)) { + bookMark.setBookMarkName(newBookMarkName); + } else { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Rename_Failure"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), + JOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png")); + this.bookMarkNameField.setText(bookMark.getBookMarkName()); + } + } + + private boolean isExist(String name) { + Form form = WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget(); + WLayout container = form.getContainer(); + WSortLayout wSortLayout = (WSortLayout) container.getWidget(container.getWidgetCount() - 1); + Iterator iterator = wSortLayout.getMobileWidgetIterator(); + while (iterator.hasNext()) { + Widget widget = form.getWidgetByName(iterator.next()); + if (widget != null && ComparatorUtils.equals(widget.getMobileBookMark().getBookMarkName(), name)) { + return true; + } + } + return false; + } + +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetStyleDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetStyleDefinePane.java index fb6f81fe5..d96be0083 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetStyleDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetStyleDefinePane.java @@ -66,7 +66,7 @@ public class MobileWidgetStyleDefinePane extends MobileWidgetDefinePane { @Override public Dimension getMaximumSize() { - return new Dimension(400, 200); + return new Dimension(400, 30); } private void bindListeners2Widgets() { 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 new file mode 100644 index 000000000..f6347904d --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkSettingPane.java @@ -0,0 +1,117 @@ +package com.fr.design.widget.ui.designer.mobile.component; + +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.DialogActionAdapter; +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.design.mainframe.WidgetPropertyPane; +import com.fr.design.mainframe.mobile.ui.MobileBookMarkStylePane; +import com.fr.design.mainframe.widget.accessibles.UneditableAccessibleEditor; +import com.fr.design.mainframe.widget.wrappers.MobileBookMarkStyleWrapper; +import com.fr.form.ui.container.WSortLayout; +import com.fr.form.ui.mobile.MobileBookMarkStyle; + +import javax.swing.*; +import java.awt.*; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/18 + */ +public class MobileBookMarkSettingPane extends BasicPane { + + private AccessibleMobileBookMarkStyleEditor mobileBookMarkStyleEditor; + private UICheckBox showHierarchicalBookmarksCheck; + + public MobileBookMarkSettingPane() { + initComponent(); + } + + 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")); + 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} + }; + 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); + } + + @Override + protected String title4PopupWindow() { + return "MobileBookMarkSettingPane"; + } + + public void populate(XCreator xCreator) { + WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); + this.mobileBookMarkStyleEditor.setValue(wSortLayout.getMobileBookMarkStyle()); + this.showHierarchicalBookmarksCheck.setSelected(wSortLayout.isShowBookmarks()); + } + + public void update(XCreator xCreator) { + WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); + wSortLayout.setMobileBookMarkStyle((MobileBookMarkStyle) mobileBookMarkStyleEditor.getValue()); + wSortLayout.setShowBookmarks(showHierarchicalBookmarksCheck.isSelected()); + } + + + class AccessibleMobileBookMarkStyleEditor extends UneditableAccessibleEditor { + + private MobileBookMarkStylePane mobileBookMarkStylePane; + + public AccessibleMobileBookMarkStyleEditor(MobileBookMarkStylePane mobileBookMarkStylePane) { + super(new MobileBookMarkStyleWrapper()); + this.mobileBookMarkStylePane = mobileBookMarkStylePane; + } + + @Override + public void showEditorPane() { + mobileBookMarkStylePane.setPreferredSize(BasicDialog.MEDIUM); + BasicDialog dialog = mobileBookMarkStylePane.showWindow(SwingUtilities.getWindowAncestor(this)); + dialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + MobileBookMarkStyle mobileBookMarkStyle = mobileBookMarkStylePane.updateBean(); + WSortLayout wSortLayout = (WSortLayout) WidgetPropertyPane.getInstance().getEditingFormDesigner().getSelectionModel().getSelection().getSelectedCreator().toData(); + setValue(mobileBookMarkStyle); + wSortLayout.setMobileBookMarkStyle(mobileBookMarkStyle); + fireStateChanged(); + } + }); + mobileBookMarkStylePane.populateBean((MobileBookMarkStyle) getValue()); + dialog.setVisible(true); + } + } + + +} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java index 0d5ce4b71..da6c617c1 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java @@ -11,6 +11,7 @@ import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; +import com.fr.form.ui.FormWidgetHelper; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WSortLayout; import com.fr.stable.ArrayUtils; @@ -64,8 +65,13 @@ public class MobileComponentFrozenPane extends BasicPane { List selected = new ArrayList<>(); WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); Object[] values = uiComboCheckBox.getSelectedValues(); - for (Object widgetName : values) { - selected.add((String) widgetName); + for (Object value : values) { + String widgetName = (String) value; + selected.add(widgetName); + Widget widget = FormWidgetHelper.findWidgetWithBound(wSortLayout, widgetName); + if (widget != null) { + widget.getMobileBookMark().setFrozen(true); + } } wSortLayout.updateFrozenWidgets(selected); }