Browse Source

Merge pull request #11648 in DESIGN/design from bugfix/11.0 to feature/x

* commit 'b58ed3a45e9993889cce05a669e5200783fd5edf':
  REPORT-91591 单元格控件的自定义样式设置
  REPORT-83259 & REPORT-83263 【最强控件】控件样式跟随主题&开放自定义
  REPORT-83259 & REPORT-83263 【最强控件】控件样式跟随主题&开放自定义
  REPORT-83259 & REPORT-83263 【最强控件】控件样式跟随主题&开放自定义
feature/x
superman 2 years ago
parent
commit
00752d0f42
  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);
/**
* 根据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;
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<T extends Button> extends AbstractDataModify<T> {
private UITextField hotkeysTextField;
private UITextField buttonNameTextField;
private AccessibleIconEditor iconPane;
protected UITextField labelNameTextField;
private final List<BasicBeanPane<T>> extraPaneList = new ArrayList<>();
private JPanel extraPane;
public ButtonDefinePane(XCreator creator){
super(creator);
@ -31,20 +43,70 @@ public abstract class ButtonDefinePane<T extends Button> 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<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_Label_Name")), labelNameTextField},
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_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<T> pane) {
int size = extraPaneList.size();
index = Math.min(index, size);
extraPaneList.add(index, pane);
}
@Override
@ -80,6 +167,9 @@ public abstract class ButtonDefinePane<T extends Button> extends AbstractDataMod
buttonNameTextField.setText(btn.getText());
labelNameTextField.setText(btn.getLabelName());
iconPane.setValue(btn.getIconName());
for (BasicBeanPane<T> pane : extraPaneList) {
pane.populateBean(btn);
}
populateSubButtonPane(btn);
}
@ -94,6 +184,9 @@ public abstract class ButtonDefinePane<T extends Button> extends AbstractDataMod
btn.setLabelName(labelNameTextField.getText());
btn.setIconName((String)iconPane.getValue());
btn.setText(buttonNameTextField.getText());
for (BasicBeanPane<T> pane : extraPaneList) {
pane.updateBean(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;
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<Label> {
private UIButtonGroup hAlignmentPane;
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) {
super(xCreator);
initComponent();
@ -59,12 +76,9 @@ public class LabelDefinePane extends AbstractDataModify<Label> {
hAlignmentPane = new UIButtonGroup<Integer>(hAlignmentIconArray, hAlignment);
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")});
// 字体大小是浮点数,因为涉及很多字体计算,不太好修改,为了完整显示字体,将FRFontPane中的fontSizeComboBox拉长一点
frFontPane = new FRFontPane(LayoutConstants.VGAP_MEDIUM);
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p, p, p, p};
double[] columnSize = {f, WIDGET_VALUE_PANE_WIDTH};
initExtraPane();
double[] rowSize = {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}};
UILabel widgetValueLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Estate_Widget_Value"));
widgetValueLabel.setVerticalAlignment(SwingConstants.TOP);
@ -75,7 +89,7 @@ public class LabelDefinePane extends AbstractDataModify<Label> {
new Component[]{isStyleAlignmentWrapText, 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[]{fontLabel, frFontPane},
new Component[]{extraPane, null},
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W4 - 5, IntervalConstants.INTERVAL_L1);
JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -84,6 +98,61 @@ public class LabelDefinePane extends AbstractDataModify<Label> {
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
public String title4PopupWindow() {
return "label";
@ -95,8 +164,13 @@ public class LabelDefinePane extends AbstractDataModify<Label> {
isStyleAlignmentWrapText.setSelected(ob.isWrap());
isPageSetupVertically.setSelected(ob.isVerticalCenter());
hAlignmentPane.setSelectedItem(ob.getTextalign());
if(frFontPane != null) {
frFontPane.populateBean(ob.getFont());
}
for (BasicBeanPane<Label> pane : extraPaneList) {
pane.populateBean(ob);
}
}
@Override
@ -106,7 +180,12 @@ public class LabelDefinePane extends AbstractDataModify<Label> {
layout.setWrap(isStyleAlignmentWrapText.isSelected());
layout.setVerticalCenter(isPageSetupVertically.isSelected());
layout.setTextalign((int) hAlignmentPane.getSelectedItem());
if(frFontPane != null && layout.getFont() != null) {
layout.setFont(frFontPane.update(layout.getFont()));
}
for (BasicBeanPane<Label> pane : extraPaneList) {
pane.updateBean(layout);
}
return layout;
}
}

Loading…
Cancel
Save