From 3934830c1b8e90fa86cb7dbb0ae145bafbad0663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Sun, 23 Apr 2023 11:46:43 +0800 Subject: [PATCH] =?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--=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/widget/btn/ButtonConstants.java | 4 +- .../design/widget/btn/ButtonDetailPane.java | 74 +++++++++ .../btn/ButtonWithHotkeysDetailPane.java | 14 +- .../design/widget/btn/ButtonDetailPane.java | 151 ------------------ .../design/widget/ui/btn/ExtraButtonPane.java | 111 +++++++++++++ .../ui/btn/FormSubmitButtonDetailPane.java | 17 +- .../ui/btn/AppendRowButtonDefinePane.java | 16 +- .../ui/btn/DefaultButtonDetailPane.java | 24 +-- .../ui/btn/DeleteRowButtonDefinePane.java | 18 +-- .../widget/ui/btn/FreeButtonDetailPane.java | 18 +-- .../btn/TreeNodeToogleButtonDefinePane.java | 11 +- 11 files changed, 214 insertions(+), 244 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java rename {designer-form => designer-base}/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java (90%) delete mode 100644 designer-form/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java create mode 100644 designer-form/src/main/java/com/fr/design/widget/ui/btn/ExtraButtonPane.java 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 85b2cbc08e..3efc320d84 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 @@ -45,7 +45,7 @@ public class ButtonConstants { StableFactory.getMarkedClass(BridgeMark.TREE_NODE_TOGGLE_BUTTON, Widget.class) }; - public static final String[] TYPES4BUTTON4STRONGEST_CONTROL = { + public static final String[] TYPES_BUTTON_NO_FREE = { 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"), @@ -53,7 +53,7 @@ public class ButtonConstants { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_TreeNode") }; - public static final Class[] CLASSES4BUTTON4STRONGEST_CONTROL = { + public static final Class[] CLASSES_BUTTON_NO_FREE = { Button.class, StableFactory.getMarkedClass(BridgeMark.APPEND_ROW_BUTTON, Widget.class), StableFactory.getMarkedClass(BridgeMark.DELETE_ROW_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 new file mode 100644 index 0000000000..2b73a3fe7f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java @@ -0,0 +1,74 @@ +package com.fr.design.widget.btn; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.icombobox.DictionaryComboBox; +import com.fr.design.dialog.BasicPane; +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(); + protected final List> extraPaneList = 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() { + 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; + } + + protected DictionaryComboBox createButtonTypeComboBox(Boolean containsExtraPane) { + final DictionaryComboBox dictionaryComboBox; + if (!containsExtraPane) { + dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES4BUTTON, ButtonConstants.TYPES4BUTTON, false); + } else { + dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES_BUTTON_NO_FREE, ButtonConstants.TYPES_BUTTON_NO_FREE, false); + } + return initDictionaryComboBox(dictionaryComboBox); + } +} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java b/designer-base/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java similarity index 90% rename from designer-form/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java rename to designer-base/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java index 904126e9d0..65eb04841f 100644 --- a/designer-form/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java +++ b/designer-base/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java @@ -4,9 +4,9 @@ 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.icombobox.DictionaryComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; @@ -45,7 +45,7 @@ public abstract class ButtonWithHotkeysDetailPane extends Butt labelPane.add(iconPane); Component comp = createCenterPane(); Component[][] n_components = { - {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_Report_Button_Type")), createCustomButtonTypeComboBox()}, {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()}, @@ -64,6 +64,10 @@ public abstract class ButtonWithHotkeysDetailPane extends Butt protected abstract Component createCenterPane(); + protected DictionaryComboBox createCustomButtonTypeComboBox() { + return createButtonTypeComboBox(); + } + @Override public void populate(T button) { if (button == null) { @@ -72,9 +76,6 @@ 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 @@ -83,9 +84,6 @@ 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/btn/ButtonDetailPane.java b/designer-form/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java deleted file mode 100644 index 81e28bf296..0000000000 --- a/designer-form/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java +++ /dev/null @@ -1,151 +0,0 @@ -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-form/src/main/java/com/fr/design/widget/ui/btn/ExtraButtonPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/btn/ExtraButtonPane.java new file mode 100644 index 0000000000..46f9a5eb79 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/ui/btn/ExtraButtonPane.java @@ -0,0 +1,111 @@ +package com.fr.design.widget.ui.btn; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.BasicPane; +import com.fr.design.fun.WidgetAdvancedPaneProvider; +import com.fr.design.gui.icombobox.DictionaryComboBox; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.widget.btn.ButtonWithHotkeysDetailPane; +import com.fr.form.ui.Button; +import com.fr.general.GeneralContext; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; +import org.jetbrains.annotations.Nullable; + +import javax.swing.JPanel; +import java.awt.Component; +import java.util.Set; + + +public abstract class ExtraButtonPane extends ButtonWithHotkeysDetailPane { + protected JPanel extraPane; + protected boolean containsExtraPane; + protected static double F = TableLayout.FILL; + protected static double P = TableLayout.PREFERRED; + + protected void initExtraPane() { + initPluginListener(); + refreshExtraAdvancedPane(classType()); + } + + + 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(classType()); + } + }, 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); + } + + @Override + public void populate(T button) { + super.populate(button); + for (BasicBeanPane pane : extraPaneList) { + pane.populateBean(button); + } + } + + @Override + public T update() { + T button = super.update(); + for (BasicBeanPane pane : extraPaneList) { + pane.updateBean(button); + } + return button; + } + + @Override + protected DictionaryComboBox createCustomButtonTypeComboBox() { + return createButtonTypeComboBox(containsExtraPane); + } + + protected Component createExtraPane(@Nullable BasicPane pane) { + initExtraPane(); + Component[][] components = new Component[][]{ + new Component[]{pane, 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); + } + +} 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 83d24e8e87..e7ddb10ce9 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,8 +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; import java.awt.*; @@ -13,18 +11,11 @@ import java.awt.*; * Date : 11-11-15 * Time : 下午6:25 */ -public class FormSubmitButtonDetailPane extends ButtonWithHotkeysDetailPane { +public class FormSubmitButtonDetailPane extends ExtraButtonPane { @Override protected Component createCenterPane() { - initExtraPane(); - Component[][] components = new Component[][]{ - new Component[]{extraPane, null} - }; - double[] rowSize = {P}; - double[] columnSize = {P, F}; - int[][] rowCount = {{1, 1}}; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 10, 7); + return createExtraPane(null); } @Override @@ -46,8 +37,4 @@ public class FormSubmitButtonDetailPane extends ButtonWithHotkeysDetailPane
extends ButtonWithHotkeysDetailPane { +public class AppendRowButtonDefinePane extends ExtraButtonPane { private DefineAppendColumnRowPane defineColumnRowPane; // @Override @@ -30,16 +30,8 @@ public class AppendRowButtonDefinePane extends Button @Override protected Component createCenterPane() { - 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); + return createExtraPane(defineColumnRowPane); } @Override @@ -69,8 +61,4 @@ public class AppendRowButtonDefinePane extends Button 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 326bcbbfcc..2c1ae8108a 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,31 +1,22 @@ 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; + import java.awt.*; + /** * Created by IntelliJ IDEA. Author : Richer Version: 6.5.6 Date : 11-11-15 Time * : 下午6:24 */ -public class DefaultButtonDetailPane extends ButtonWithHotkeysDetailPane