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..3059ddc37d 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,27 @@ 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 org.jetbrains.annotations.NotNull; -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,20 +43,70 @@ 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 = { + initAdvancedPane(); + JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + 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 initAdvancedPane() { + initPluginListener(); + refreshAdvancedPane(); + } + + private void refreshAdvancedPane() { + 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; + } + refreshAdvancedPane(containsExtraPane); + } + + private void refreshAdvancedPane(boolean containsExtraPane) { + 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 = getExtraAdvancedComponents(panel); + } 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 = getAdvancedComponents(backgroundCompPane, frFont); + } + 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)); + } + + @NotNull + private Component[][] getAdvancedComponents(Component[] backgroundCompPane, Component[] frFont) { + return 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, @@ -52,13 +114,38 @@ public abstract class ButtonDefinePane extends AbstractDataMod {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); - JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); - boundsPane.add(panel); - UIExpandablePane advancedPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, boundsPane); - this.add(advancedPane); + } + + @NotNull + private Component[][] getExtraAdvancedComponents(JPanel panel) { + return 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} + }; + } + + protected void initPluginListener() { + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent event) { + refreshAdvancedPane(); + } + }, 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 @@ -80,6 +167,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 +184,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