Browse Source

Merge pull request #11647 in DESIGN/design from release/11.0 to bugfix/11.0

* commit '5bb1f8a9ea30e59c511b5c424dedd9053e7fe923':
  REPORT-91591 单元格控件的自定义样式设置
  REPORT-83259 & REPORT-83263 【最强控件】控件样式跟随主题&开放自定义
  REPORT-83259 & REPORT-83263 【最强控件】控件样式跟随主题&开放自定义
  REPORT-83259 & REPORT-83263 【最强控件】控件样式跟随主题&开放自定义
bugfix/11.0
superman 2 years ago
parent
commit
b58ed3a45e
  1. 8
      designer-form/src/main/java/com/fr/design/fun/WidgetAdvancedPaneProvider.java
  2. 131
      designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonDefinePane.java
  3. 99
      designer-form/src/main/java/com/fr/design/widget/ui/designer/LabelDefinePane.java

8
designer-form/src/main/java/com/fr/design/fun/WidgetAdvancedPaneProvider.java

@ -33,6 +33,14 @@ public interface WidgetAdvancedPaneProvider<T> extends Mutable {
*/ */
boolean accept(XCreator creator); boolean accept(XCreator creator);
/**
* 根据Class判断是否需要处理
*
* @param creator
* @return true:需要处理;false:不处理
*/
boolean accept(Class creator);
/** /**
* 创建控件高级设置项的追加面板 * 创建控件高级设置项的追加面板
* *

131
designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonDefinePane.java

@ -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,27 @@ 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 org.jetbrains.annotations.NotNull;
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 +43,70 @@ 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 = { 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<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;
}
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<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 = 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_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 +114,38 @@ 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, ",")); }
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(n_components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); @NotNull
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); private Component[][] getExtraAdvancedComponents(JPanel panel) {
boundsPane.add(panel); return new Component[][]{
UIExpandablePane advancedPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, boundsPane); {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Name")), buttonNameTextField},
this.add(advancedPane); {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<T> pane) {
int size = extraPaneList.size();
index = Math.min(index, size);
extraPaneList.add(index, pane);
} }
@Override @Override
@ -80,6 +167,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 +184,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;
} }

99
designer-form/src/main/java/com/fr/design/widget/ui/designer/LabelDefinePane.java

@ -1,10 +1,13 @@
package com.fr.design.widget.ui.designer; package com.fr.design.widget.ui.designer;
import com.fr.base.BaseUtils; 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.constants.LayoutConstants;
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.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel; 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.FRWidgetFactory;
import com.fr.design.widget.ui.designer.component.FormWidgetValuePane; import com.fr.design.widget.ui.designer.component.FormWidgetValuePane;
import com.fr.form.ui.Label; 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 com.fr.stable.Constants;
import javax.swing.*; import javax.swing.BorderFactory;
import java.awt.*; 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<Label> {
private UIButtonGroup hAlignmentPane; private UIButtonGroup hAlignmentPane;
private FRFontPane frFontPane; private FRFontPane frFontPane;
private final List<BasicBeanPane<Label>> extraPaneList = new ArrayList<>();
private JPanel extraPane;
private static final double F = TableLayout.FILL;
private static final double P = TableLayout.PREFERRED;
public LabelDefinePane(XCreator xCreator) { public LabelDefinePane(XCreator xCreator) {
super(xCreator); super(xCreator);
initComponent(); initComponent();
@ -59,12 +76,9 @@ public class LabelDefinePane extends AbstractDataModify<Label> {
hAlignmentPane = new UIButtonGroup<Integer>(hAlignmentIconArray, hAlignment); hAlignmentPane = new UIButtonGroup<Integer>(hAlignmentIconArray, hAlignment);
hAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Left") hAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Left")
, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right")}); , com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right")});
// 字体大小是浮点数,因为涉及很多字体计算,不太好修改,为了完整显示字体,将FRFontPane中的fontSizeComboBox拉长一点 initExtraPane();
frFontPane = new FRFontPane(LayoutConstants.VGAP_MEDIUM); double[] rowSize = {P, P, P, P, P, P};
double f = TableLayout.FILL; double[] columnSize = {F, WIDGET_VALUE_PANE_WIDTH};
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p, p, p, p};
double[] columnSize = {f, WIDGET_VALUE_PANE_WIDTH};
int[][] rowCount = {{1, 3}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; int[][] rowCount = {{1, 3}, {1, 1}, {1, 1}, {1, 1}, {1, 1}};
UILabel widgetValueLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Estate_Widget_Value")); UILabel widgetValueLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Estate_Widget_Value"));
widgetValueLabel.setVerticalAlignment(SwingConstants.TOP); widgetValueLabel.setVerticalAlignment(SwingConstants.TOP);
@ -75,7 +89,7 @@ public class LabelDefinePane extends AbstractDataModify<Label> {
new Component[]{isStyleAlignmentWrapText, null}, new Component[]{isStyleAlignmentWrapText, null},
new Component[]{isPageSetupVertically, null}, new Component[]{isPageSetupVertically, null},
new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Display_Position_Similar")), hAlignmentPane}, new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Display_Position_Similar")), hAlignmentPane},
new Component[]{fontLabel, frFontPane}, new Component[]{extraPane, null},
}; };
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W4 - 5, IntervalConstants.INTERVAL_L1); JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W4 - 5, IntervalConstants.INTERVAL_L1);
JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -84,6 +98,61 @@ public class LabelDefinePane extends AbstractDataModify<Label> {
return boundsPane; return boundsPane;
} }
private void initExtraPane() {
initPluginListener();
refreshExtraAdvancedPane();
}
protected void refreshExtraAdvancedPane() {
extraPaneList.clear();
boolean containsExtraPane = false;
Set<WidgetAdvancedPaneProvider<Label>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG);
for (WidgetAdvancedPaneProvider<Label> provider : providers) {
if (!provider.accept(creator)) {
continue;
}
insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane());
containsExtraPane = true;
}
if (containsExtraPane) {
extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane();
for (BasicBeanPane<Label> pane : extraPaneList) {
extraPane.add(pane);
}
} else {
// 字体大小是浮点数,因为涉及很多字体计算,不太好修改,为了完整显示字体,将FRFontPane中的fontSizeComboBox拉长一点
frFontPane = new FRFontPane(LayoutConstants.VGAP_MEDIUM);
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font_Size")), frFontPane}
};
double[] rowSize = {P};
double[] columnSize = {P, F};
int[][] rowCount = {{1, 1}};
extraPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
}
}
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<Label> pane) {
int size = extraPaneList.size();
index = Math.min(index, size);
extraPaneList.add(index, pane);
}
@Override @Override
public String title4PopupWindow() { public String title4PopupWindow() {
return "label"; return "label";
@ -95,8 +164,13 @@ public class LabelDefinePane extends AbstractDataModify<Label> {
isStyleAlignmentWrapText.setSelected(ob.isWrap()); isStyleAlignmentWrapText.setSelected(ob.isWrap());
isPageSetupVertically.setSelected(ob.isVerticalCenter()); isPageSetupVertically.setSelected(ob.isVerticalCenter());
hAlignmentPane.setSelectedItem(ob.getTextalign()); hAlignmentPane.setSelectedItem(ob.getTextalign());
if(frFontPane != null) {
frFontPane.populateBean(ob.getFont()); frFontPane.populateBean(ob.getFont());
} }
for (BasicBeanPane<Label> pane : extraPaneList) {
pane.populateBean(ob);
}
}
@Override @Override
@ -106,7 +180,12 @@ public class LabelDefinePane extends AbstractDataModify<Label> {
layout.setWrap(isStyleAlignmentWrapText.isSelected()); layout.setWrap(isStyleAlignmentWrapText.isSelected());
layout.setVerticalCenter(isPageSetupVertically.isSelected()); layout.setVerticalCenter(isPageSetupVertically.isSelected());
layout.setTextalign((int) hAlignmentPane.getSelectedItem()); layout.setTextalign((int) hAlignmentPane.getSelectedItem());
if(frFontPane != null && layout.getFont() != null) {
layout.setFont(frFontPane.update(layout.getFont())); layout.setFont(frFontPane.update(layout.getFont()));
}
for (BasicBeanPane<Label> pane : extraPaneList) {
pane.updateBean(layout);
}
return layout; return layout;
} }
} }

Loading…
Cancel
Save