|
|
@ -1,8 +1,11 @@ |
|
|
|
package com.fr.design.widget.ui.designer; |
|
|
|
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.IntervalConstants; |
|
|
|
import com.fr.design.designer.creator.XCreator; |
|
|
|
import com.fr.design.designer.creator.XCreator; |
|
|
|
import com.fr.design.foldablepane.UIExpandablePane; |
|
|
|
import com.fr.design.foldablepane.UIExpandablePane; |
|
|
|
|
|
|
|
import com.fr.design.fun.WidgetAdvancedPaneProvider; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
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.mainframe.widget.accessibles.AccessibleIconEditor; |
|
|
|
import com.fr.design.widget.btn.ButtonConstants; |
|
|
|
import com.fr.design.widget.btn.ButtonConstants; |
|
|
|
import com.fr.form.ui.Button; |
|
|
|
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 com.fr.stable.StableUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import java.awt.*; |
|
|
|
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<T extends Button> extends AbstractDataModify<T> { |
|
|
|
public abstract class ButtonDefinePane<T extends Button> extends AbstractDataModify<T> { |
|
|
|
private UITextField hotkeysTextField; |
|
|
|
private UITextField hotkeysTextField; |
|
|
|
private UITextField buttonNameTextField; |
|
|
|
private UITextField buttonNameTextField; |
|
|
|
private AccessibleIconEditor iconPane; |
|
|
|
private AccessibleIconEditor iconPane; |
|
|
|
protected UITextField labelNameTextField; |
|
|
|
protected UITextField labelNameTextField; |
|
|
|
|
|
|
|
private final List<BasicBeanPane<T>> extraPaneList = new ArrayList<>(); |
|
|
|
|
|
|
|
private JPanel extraPane; |
|
|
|
|
|
|
|
|
|
|
|
public ButtonDefinePane(XCreator creator){ |
|
|
|
public ButtonDefinePane(XCreator creator){ |
|
|
|
super(creator); |
|
|
|
super(creator); |
|
|
@ -31,20 +42,63 @@ public abstract class ButtonDefinePane<T extends Button> extends AbstractDataMod |
|
|
|
|
|
|
|
|
|
|
|
private void initComponent() { |
|
|
|
private void initComponent() { |
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
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(); |
|
|
|
iconPane = new AccessibleIconEditor(); |
|
|
|
hotkeysTextField = new UITextField(); |
|
|
|
hotkeysTextField = new UITextField(); |
|
|
|
buttonNameTextField = new UITextField(); |
|
|
|
buttonNameTextField = new UITextField(); |
|
|
|
labelNameTextField = 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")); |
|
|
|
UILabel backgroundLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")); |
|
|
|
backgroundLabel.setVerticalAlignment(SwingConstants.TOP); |
|
|
|
backgroundLabel.setVerticalAlignment(SwingConstants.TOP); |
|
|
|
Component[][] n_components = { |
|
|
|
initExtraPane(); |
|
|
|
|
|
|
|
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 initExtraPane() { |
|
|
|
|
|
|
|
initPluginListener(); |
|
|
|
|
|
|
|
refreshExtraAdvancedPane(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void refreshExtraAdvancedPane() { |
|
|
|
|
|
|
|
extraPaneList.clear(); |
|
|
|
|
|
|
|
boolean containsExtraPane = false; |
|
|
|
|
|
|
|
Set<WidgetAdvancedPaneProvider<T>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG); |
|
|
|
|
|
|
|
for (WidgetAdvancedPaneProvider<T> 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<T> 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_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_Label_Name")), labelNameTextField}, |
|
|
|
backgroundCompPane, |
|
|
|
backgroundCompPane, |
|
|
@ -52,13 +106,31 @@ public abstract class ButtonDefinePane<T extends Button> 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_Icon")), iconPane}, |
|
|
|
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Hot_keys")), hotkeysTextField} |
|
|
|
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Hot_keys")), hotkeysTextField} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
hotkeysTextField.setToolTipText(StableUtils.join(ButtonConstants.HOTKEYS, ",")); |
|
|
|
hotkeysTextField.setToolTipText(StableUtils.join(ButtonConstants.HOTKEYS, ",")); |
|
|
|
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(n_components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); |
|
|
|
extraPane = TableLayoutHelper.createGapTableLayoutPane(n_components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); |
|
|
|
JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
extraPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
|
|
|
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); |
|
|
|
protected void initPluginListener() { |
|
|
|
this.add(advancedPane); |
|
|
|
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<T> pane) { |
|
|
|
|
|
|
|
int size = extraPaneList.size(); |
|
|
|
|
|
|
|
index = Math.min(index, size); |
|
|
|
|
|
|
|
extraPaneList.add(index, pane); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -80,6 +152,9 @@ public abstract class ButtonDefinePane<T extends Button> extends AbstractDataMod |
|
|
|
buttonNameTextField.setText(btn.getText()); |
|
|
|
buttonNameTextField.setText(btn.getText()); |
|
|
|
labelNameTextField.setText(btn.getLabelName()); |
|
|
|
labelNameTextField.setText(btn.getLabelName()); |
|
|
|
iconPane.setValue(btn.getIconName()); |
|
|
|
iconPane.setValue(btn.getIconName()); |
|
|
|
|
|
|
|
for (BasicBeanPane<T> pane : extraPaneList) { |
|
|
|
|
|
|
|
pane.populateBean(btn); |
|
|
|
|
|
|
|
} |
|
|
|
populateSubButtonPane(btn); |
|
|
|
populateSubButtonPane(btn); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -94,6 +169,9 @@ public abstract class ButtonDefinePane<T extends Button> extends AbstractDataMod |
|
|
|
btn.setLabelName(labelNameTextField.getText()); |
|
|
|
btn.setLabelName(labelNameTextField.getText()); |
|
|
|
btn.setIconName((String)iconPane.getValue()); |
|
|
|
btn.setIconName((String)iconPane.getValue()); |
|
|
|
btn.setText(buttonNameTextField.getText()); |
|
|
|
btn.setText(buttonNameTextField.getText()); |
|
|
|
|
|
|
|
for (BasicBeanPane<T> pane : extraPaneList) { |
|
|
|
|
|
|
|
pane.updateBean(btn); |
|
|
|
|
|
|
|
} |
|
|
|
return btn; |
|
|
|
return btn; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|