From 895035b289540eac098946fd766744804790f545 Mon Sep 17 00:00:00 2001 From: "Bruce.Deng" Date: Thu, 9 Mar 2023 19:58:39 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-83259=20&=20REPORT-83263=20=E3=80=90?= =?UTF-8?q?=E6=9C=80=E5=BC=BA=E6=8E=A7=E4=BB=B6=E3=80=91=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B7=9F=E9=9A=8F=E4=B8=BB=E9=A2=98&?= =?UTF-8?q?=E5=BC=80=E6=94=BE=E8=87=AA=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widget/ui/designer/ButtonDefinePane.java | 124 ++++++++++++++---- .../widget/ui/designer/LabelDefinePane.java | 103 +++++++++++++-- 2 files changed, 192 insertions(+), 35 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonDefinePane.java index 6d8191c2f9..0b0f734751 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonDefinePane.java @@ -1,8 +1,11 @@ package com.fr.design.widget.ui.designer; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.beans.BasicBeanPane; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.XCreator; import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.fun.WidgetAdvancedPaneProvider; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; @@ -11,18 +14,26 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.widget.accessibles.AccessibleIconEditor; import com.fr.design.widget.btn.ButtonConstants; import com.fr.form.ui.Button; - +import com.fr.general.GeneralContext; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import com.fr.stable.StableUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.Component; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; public abstract class ButtonDefinePane extends AbstractDataModify { private UITextField hotkeysTextField; private UITextField buttonNameTextField; private AccessibleIconEditor iconPane; protected UITextField labelNameTextField; - + private final List> extraPaneList = new ArrayList<>(); + private JPanel extraPane; public ButtonDefinePane(XCreator creator){ super(creator); @@ -31,36 +42,97 @@ public abstract class ButtonDefinePane extends AbstractDataMod private void initComponent() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double rowSize[] = {p, p, p, p, p, p, p, p}; - double columnSize[] = {p, f}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; iconPane = new AccessibleIconEditor(); hotkeysTextField = new UITextField(); buttonNameTextField = new UITextField(); labelNameTextField = new UITextField(); - Component[] backgroundCompPane = createBackgroundComp(); - Component[] frFont = createFontPane(); UILabel backgroundLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")); backgroundLabel.setVerticalAlignment(SwingConstants.TOP); - Component[][] n_components = { - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Name")), buttonNameTextField}, - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField}, - backgroundCompPane, - frFont, - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon")), iconPane}, - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Hot_keys")), hotkeysTextField} - }; - hotkeysTextField.setToolTipText(StableUtils.join(ButtonConstants.HOTKEYS, ",")); - JPanel panel = TableLayoutHelper.createGapTableLayoutPane(n_components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); + initExtraPane(); JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); - boundsPane.add(panel); + boundsPane.add(extraPane); UIExpandablePane advancedPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, boundsPane); this.add(advancedPane); } + private void initExtraPane() { + initPluginListener(); + refreshExtraAdvancedPane(); + } + + private void refreshExtraAdvancedPane() { + extraPaneList.clear(); + boolean containsExtraPane = false; + Set> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG); + for (WidgetAdvancedPaneProvider provider : providers) { + if (!provider.accept(creator)) { + continue; + } + insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane()); + containsExtraPane = true; + } + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + Component[] backgroundCompPane = createBackgroundComp(); + Component[] frFont = createFontPane(); + double rowSize[]; + double columnSize[]; + int[][] rowCount; + Component[][] n_components; + if (containsExtraPane) { + JPanel panel = FRGUIPaneFactory.createYBoxEmptyBorderPane(); + for (BasicBeanPane pane : extraPaneList) { + panel.add(pane); + } + rowSize = new double[]{p, p, p, p, p}; + columnSize = new double[]{p, f}; + rowCount = new int[][]{{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; + n_components = new Component[][]{ + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Name")), buttonNameTextField}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon")), iconPane}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Hot_keys")), hotkeysTextField}, + {panel, null} + }; + } else { + rowSize = new double[]{p, p, p, p, p, p, p, p}; + columnSize = new double[]{p, f}; + rowCount = new int[][]{{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; + n_components = new Component[][]{ + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Name")), buttonNameTextField}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField}, + backgroundCompPane, + frFont, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon")), iconPane}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Hot_keys")), hotkeysTextField} + }; + } + hotkeysTextField.setToolTipText(StableUtils.join(ButtonConstants.HOTKEYS, ",")); + extraPane = TableLayoutHelper.createGapTableLayoutPane(n_components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); + extraPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + } + + 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); + } + @Override public String title4PopupWindow() { return "Button"; @@ -80,6 +152,9 @@ public abstract class ButtonDefinePane extends AbstractDataMod buttonNameTextField.setText(btn.getText()); labelNameTextField.setText(btn.getLabelName()); iconPane.setValue(btn.getIconName()); + for (BasicBeanPane pane : extraPaneList) { + pane.populateBean(btn); + } populateSubButtonPane(btn); } @@ -94,6 +169,9 @@ public abstract class ButtonDefinePane extends AbstractDataMod btn.setLabelName(labelNameTextField.getText()); btn.setIconName((String)iconPane.getValue()); btn.setText(buttonNameTextField.getText()); + for (BasicBeanPane pane : extraPaneList) { + pane.updateBean(btn); + } return btn; } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/LabelDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/LabelDefinePane.java index 992ea9cfb5..040137141c 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/LabelDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/LabelDefinePane.java @@ -1,10 +1,13 @@ package com.fr.design.widget.ui.designer; import com.fr.base.BaseUtils; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.beans.BasicBeanPane; import com.fr.design.constants.LayoutConstants; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.XCreator; import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.fun.WidgetAdvancedPaneProvider; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; @@ -15,11 +18,20 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.ui.designer.component.FormWidgetValuePane; import com.fr.form.ui.Label; - +import com.fr.general.GeneralContext; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import com.fr.stable.Constants; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; /** @@ -33,6 +45,11 @@ public class LabelDefinePane extends AbstractDataModify