From cab83ef74b6bc2cb1255fdafb5a84215789dd00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Sat, 22 Apr 2023 22:08:09 +0800 Subject: [PATCH 1/7] =?UTF-8?q?REPORT-92628=20=E6=8E=A7=E4=BB=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=B8=BB=E9=A2=98=E5=88=87=E6=8D=A2-=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=8E=A7=E4=BB=B6=E6=9C=AA=E5=AE=9E=E7=8E=B0=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E6=A0=B7=E5=BC=8F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/widget/btn/ButtonConstants.java | 16 ++ .../design/widget/btn/ButtonDetailPane.java | 62 ------- .../design/widget/btn/ButtonDetailPane.java | 151 ++++++++++++++++++ .../btn/ButtonWithHotkeysDetailPane.java | 11 +- .../ui/btn/FormSubmitButtonDetailPane.java | 15 +- .../ui/btn/AppendRowButtonDefinePane.java | 20 ++- .../ui/btn/DefaultButtonDetailPane.java | 17 ++ .../ui/btn/DeleteRowButtonDefinePane.java | 17 +- .../widget/ui/btn/FreeButtonDetailPane.java | 19 ++- 9 files changed, 259 insertions(+), 69 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java create mode 100644 designer-form/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java rename {designer-base => designer-form}/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java (90%) diff --git a/designer-base/src/main/java/com/fr/design/widget/btn/ButtonConstants.java b/designer-base/src/main/java/com/fr/design/widget/btn/ButtonConstants.java index 9be9a8fba4..85b2cbc08e 100644 --- a/designer-base/src/main/java/com/fr/design/widget/btn/ButtonConstants.java +++ b/designer-base/src/main/java/com/fr/design/widget/btn/ButtonConstants.java @@ -44,4 +44,20 @@ public class ButtonConstants { StableFactory.getMarkedClass(BridgeMark.SUBMIT_BUTTON, Widget.class), StableFactory.getMarkedClass(BridgeMark.TREE_NODE_TOGGLE_BUTTON, Widget.class) }; + + public static final String[] TYPES4BUTTON4STRONGEST_CONTROL = { + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Common"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Insert_Row"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Delete_Row"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_Type_Parameter_Submit"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_TreeNode") + }; + + public static final Class[] CLASSES4BUTTON4STRONGEST_CONTROL = { + Button.class, + StableFactory.getMarkedClass(BridgeMark.APPEND_ROW_BUTTON, Widget.class), + StableFactory.getMarkedClass(BridgeMark.DELETE_ROW_BUTTON, Widget.class), + StableFactory.getMarkedClass(BridgeMark.SUBMIT_BUTTON, Widget.class), + StableFactory.getMarkedClass(BridgeMark.TREE_NODE_TOGGLE_BUTTON, Widget.class) + }; } diff --git a/designer-base/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java b/designer-base/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java deleted file mode 100644 index 63d678577a..0000000000 --- a/designer-base/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.fr.design.widget.btn; - -import com.fr.design.gui.icombobox.DictionaryComboBox; -import com.fr.design.dialog.BasicPane; -import com.fr.design.widget.btn.ButtonConstants; -import com.fr.form.ui.Button; - - -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by IntelliJ IDEA. - * Author : Richer - * Version: 6.5.6 - * Date : 11-11-15 - * Time : 下午6:21 - */ -public abstract class ButtonDetailPane extends BasicPane { - private List ls = new ArrayList(); - - @Override - public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Button"); - } - - public void populate(T button) { - - } - - public abstract T createButton(); - - public abstract T update(); - - protected void typeChange(Object obj) { - for (int i = 0, len = ls.size(); i < len; i++) { - ls.get(i).stateChanged(new ChangeEvent(obj)); - } - } - - public void addTypeChangeListener(ChangeListener l) { - ls.add(l); - } - - public abstract Class classType(); - - protected DictionaryComboBox createButtonTypeComboBox() { - final DictionaryComboBox dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES4BUTTON, ButtonConstants.TYPES4BUTTON, false); - dictionaryComboBox.setSelectedItem(classType()); - dictionaryComboBox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - typeChange(dictionaryComboBox.getSelectedItem()); - } - }); - return dictionaryComboBox; - } -} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java b/designer-form/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java new file mode 100644 index 0000000000..81e28bf296 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java @@ -0,0 +1,151 @@ +package com.fr.design.widget.btn; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.WidgetAdvancedPaneProvider; +import com.fr.design.gui.icombobox.DictionaryComboBox; +import com.fr.design.dialog.BasicPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.form.ui.Button; +import com.fr.general.GeneralContext; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; + + +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * Created by IntelliJ IDEA. + * Author : Richer + * Version: 6.5.6 + * Date : 11-11-15 + * Time : 下午6:21 + */ +public abstract class ButtonDetailPane extends BasicPane { + private List ls = new ArrayList(); + protected final List> extraPaneList = new ArrayList<>(); + protected JPanel extraPane; + protected boolean containsExtraPane; + protected static double F = TableLayout.FILL; + protected static double P = TableLayout.PREFERRED; + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Button"); + } + + public void populate(T button) { + + } + + public abstract T createButton(); + + public abstract T update(); + + protected void typeChange(Object obj) { + for (int i = 0, len = ls.size(); i < len; i++) { + ls.get(i).stateChanged(new ChangeEvent(obj)); + } + } + + public void addTypeChangeListener(ChangeListener l) { + ls.add(l); + } + + public abstract Class classType(); + + protected DictionaryComboBox createButtonTypeComboBox() { +// final DictionaryComboBox dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES4BUTTON, ButtonConstants.TYPES4BUTTON, false); +// dictionaryComboBox.setSelectedItem(classType()); +// dictionaryComboBox.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// typeChange(dictionaryComboBox.getSelectedItem()); +// } +// }); +// return dictionaryComboBox; + return createButtonTypeComboBox(false); + } + + private DictionaryComboBox initDictionaryComboBox(DictionaryComboBox dictionaryComboBox) { + dictionaryComboBox.setSelectedItem(classType()); + dictionaryComboBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + typeChange(dictionaryComboBox.getSelectedItem()); + } + }); + return dictionaryComboBox; +// return createButtonTypeComboBox(); + } + + protected DictionaryComboBox createButtonTypeComboBox(Boolean containsExtraPane) { + final DictionaryComboBox dictionaryComboBox; + if (!containsExtraPane) { + dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES4BUTTON, ButtonConstants.TYPES4BUTTON, false); + } else { + dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES4BUTTON4STRONGEST_CONTROL, ButtonConstants.TYPES4BUTTON4STRONGEST_CONTROL, false); + } + return initDictionaryComboBox(dictionaryComboBox); + } + + + + protected void initExtraPane() { + initPluginListener(); + refreshExtraAdvancedPane(); + } + + protected void refreshExtraAdvancedPane() { + // do nothing + } + + protected void refreshExtraAdvancedPane(Class cls) { + extraPaneList.clear(); + boolean containsExtraPane = false; + Set> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG); + for (WidgetAdvancedPaneProvider provider : providers) { + if (!provider.accept(cls)) { + continue; + } + insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane()); + containsExtraPane = true; + } + if (containsExtraPane) { + extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); + for (BasicBeanPane pane : extraPaneList) { + extraPane.add(pane); + } + } + this.containsExtraPane = containsExtraPane; + + } + + protected void initPluginListener() { + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent event) { + refreshExtraAdvancedPane(); + } + }, pluginContext -> pluginContext.getRuntime().contain(WidgetAdvancedPaneProvider.XML_TAG)); + } + + /** + * 插入配置项面板 + * + * @param index 插入的位置 + * @param pane 配置项面板 + */ + protected void insertShortCut(int index, BasicBeanPane pane) { + int size = extraPaneList.size(); + index = Math.min(index, size); + extraPaneList.add(index, pane); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java b/designer-form/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java similarity index 90% rename from designer-base/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java rename to designer-form/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java index b75aeaa81f..904126e9d0 100644 --- a/designer-base/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java @@ -4,6 +4,7 @@ import java.awt.*; import javax.swing.*; +import com.fr.design.beans.BasicBeanPane; import com.fr.design.designer.IntervalConstants; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ilable.UILabel; @@ -42,8 +43,9 @@ public abstract class ButtonWithHotkeysDetailPane extends Butt JPanel labelPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); iconPane = new AccessibleIconEditor(); labelPane.add(iconPane); + Component comp = createCenterPane(); Component[][] n_components = { - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Button_Type")), createButtonTypeComboBox()}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Button_Type")), createButtonTypeComboBox(containsExtraPane)}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Name")), buttonNameTextField = new UITextField()}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_Icon")), iconPane}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Hot_keys")), hotkeysTextField = new UITextField()}, @@ -52,7 +54,6 @@ public abstract class ButtonWithHotkeysDetailPane extends Butt JPanel panel = TableLayoutHelper.createGapTableLayoutPane(n_components, rowSize, columnSize, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); advancePane.add(panel, BorderLayout.NORTH); - Component comp = createCenterPane(); if(comp != null ) { advancePane.add(comp,BorderLayout.CENTER); } @@ -71,6 +72,9 @@ public abstract class ButtonWithHotkeysDetailPane extends Butt iconPane.setValue(button.getIconName()); buttonNameTextField.setText(button.getText()); hotkeysTextField.setText(button.getHotkeys()); + for (BasicBeanPane pane : extraPaneList) { + pane.populateBean(button); + } } @Override @@ -79,6 +83,9 @@ public abstract class ButtonWithHotkeysDetailPane extends Butt button.setIconName((String)iconPane.getValue()); button.setText(buttonNameTextField.getText()); button.setHotkeys(hotkeysTextField.getText()); + for (BasicBeanPane pane : extraPaneList) { + pane.updateBean(button); + } return button; } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/btn/FormSubmitButtonDetailPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/btn/FormSubmitButtonDetailPane.java index acc2e76c4e..83d24e8e87 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/btn/FormSubmitButtonDetailPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/btn/FormSubmitButtonDetailPane.java @@ -1,5 +1,6 @@ package com.fr.design.widget.ui.btn; +import com.fr.design.layout.TableLayoutHelper; import com.fr.form.parameter.FormSubmitButton; import com.fr.design.widget.btn.ButtonWithHotkeysDetailPane; @@ -16,7 +17,14 @@ public class FormSubmitButtonDetailPane extends ButtonWithHotkeysDetailPane
extends Button @Override protected Component createCenterPane() { - return defineColumnRowPane = new DefineAppendColumnRowPane(); + initExtraPane(); + defineColumnRowPane = new DefineAppendColumnRowPane(); + Component[][] components = new Component[][]{ + new Component[]{defineColumnRowPane, null}, + new Component[]{extraPane, null} + }; + double[] rowSize = {P, P}; + double[] columnSize = {P, F}; + int[][] rowCount = {{1, 1},{1, 1}}; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 10, 7); } @Override @@ -55,4 +68,9 @@ public class AppendRowButtonDefinePane extends Button public Class classType() { return AppendRowButton.class; } + + @Override + protected void refreshExtraAdvancedPane() { + super.refreshExtraAdvancedPane(AppendRowButton.class); + } } diff --git a/designer-realize/src/main/java/com/fr/design/widget/ui/btn/DefaultButtonDetailPane.java b/designer-realize/src/main/java/com/fr/design/widget/ui/btn/DefaultButtonDetailPane.java index e7f621ccb4..326bcbbfcc 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/ui/btn/DefaultButtonDetailPane.java +++ b/designer-realize/src/main/java/com/fr/design/widget/ui/btn/DefaultButtonDetailPane.java @@ -1,5 +1,6 @@ package com.fr.design.widget.ui.btn; +import com.fr.design.layout.TableLayoutHelper; import com.fr.form.ui.Button; import com.fr.form.ui.FreeButton; import com.fr.design.widget.btn.ButtonWithHotkeysDetailPane; @@ -14,6 +15,16 @@ public class DefaultButtonDetailPane extends ButtonWithHotkeysDetailPane