Browse Source

REPORT-83259 & REPORT-83263 【最强控件】控件样式跟随主题&开放自定义

feature/x
Bruce.Deng 2 years ago
parent
commit
b53002904f
  1. 15
      designer-base/src/main/java/com/fr/design/fun/TemplateThemePaneProvider.java
  2. 3
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateThemePaneProvider.java
  3. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java
  4. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java
  5. 30
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeEditorPane.java
  6. 18
      designer-form/src/main/java/com/fr/design/fun/WidgetAdvancedPaneProvider.java
  7. 76
      designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java
  8. 50
      designer-form/src/main/java/com/fr/design/widget/ui/designer/FieldEditorDefinePane.java

15
designer-base/src/main/java/com/fr/design/fun/TemplateThemePaneProvider.java

@ -4,6 +4,8 @@ import com.fr.design.beans.BasicBeanPane;
import com.fr.stable.fun.mark.Mutable;
/**
* 设计器模板主题管理-细节定制部分,支持添加tab
*
* @author Bruce.Deng
* @version 11.0
* Created by Bruce.Deng on 2023/2/7
@ -14,9 +16,20 @@ public interface TemplateThemePaneProvider<T> extends Mutable {
int CURRENT_LEVEL = 1;
String getTabName();
/**
* 插入tab的位置
*
* @param total 已插入的tab数
* @return 插入位置如果想放到最后则返回-1
*/
int getInsertPosition(int total);
/**
* 获取tab对象
*
* @return tab对象
*/
BasicBeanPane<T> getTab();
}

3
designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateThemePaneProvider.java

@ -7,10 +7,11 @@ import com.fr.stable.fun.mark.API;
/**
* @author Bruce.Deng
* @version 11.0
* @see TemplateThemePaneProvider
* Created by Bruce.Deng on 2023/2/7
*/
@API(level = TemplateThemePaneProvider.CURRENT_LEVEL)
public abstract class AbstractTemplateThemePaneProvider extends AbstractProvider implements TemplateThemePaneProvider {
public abstract class AbstractTemplateThemePaneProvider<T> extends AbstractProvider implements TemplateThemePaneProvider<T> {
@Override
public int currentAPILevel() {

2
designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java

@ -67,7 +67,7 @@ public class FormThemeProfilePane extends TemplateThemeProfilePane<FormTheme> {
componentStyleSettingPane = new ComponentStyleEditPane();
addCustomEditorPane(i18nText("Fine-Design_Predefined_Component_Style"), componentStyleSettingPane);
addExtraEditPane();
refreshExtraAdvancedPane();
}
@Override

2
designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java

@ -49,7 +49,7 @@ public class ReportThemeProfilePane extends TemplateThemeProfilePane<ReportTheme
addCustomEditorPane(Toolkit.i18nText("Fine-Design_Predefined_Template_Background"), reportBodyStyleSettingPane);
addCustomEditorPane(Toolkit.i18nText("Fine-Design_Predefined_Cell_Style"), createCellStyleSettingPane());
addCustomEditorPane(Toolkit.i18nText("Fine-Design_Predefined_Chart_Style"), createChartStyleSettingPane());
addExtraEditPane();
refreshExtraAdvancedPane();
}
@Override

30
designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeEditorPane.java

@ -24,6 +24,9 @@ import com.fr.design.mainframe.theme.edit.ui.LabelUtils;
import com.fr.design.mainframe.theme.ui.AutoCheckTextField;
import com.fr.design.mainframe.theme.ui.AutoCheckThemeNameTextField;
import com.fr.design.mainframe.theme.ui.BorderUtils;
import com.fr.general.GeneralContext;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
@ -175,7 +178,7 @@ public abstract class TemplateThemeEditorPane<T extends TemplateTheme> extends J
uiTabbedPane = new UITabbedPane();
uiTabbedPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 1));
container.add(uiTabbedPane, BorderLayout.CENTER);
initPluginListener();
return container;
}
@ -197,15 +200,30 @@ public abstract class TemplateThemeEditorPane<T extends TemplateTheme> extends J
uiTabbedPane.addTab(title, settingPane);
}
protected void addExtraEditPane() {
protected void refreshExtraAdvancedPane() {
extraPaneList.clear();
Set<TemplateThemePaneProvider<T>> providers = ExtraDesignClassManager.getInstance().getArray(TemplateThemePaneProvider.XML_TAG);
if (providers != null) {
for (TemplateThemePaneProvider<T> provider : providers) {
BasicBeanPane<T> tab = provider.getTab();
extraPaneList.add(tab);
addCustomEditorPane(provider.getTabName(), tab);
insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.getTab());
}
for (BasicBeanPane<T> pane : extraPaneList) {
addCustomEditorPane(pane.getTitle(), pane);
}
}
private void insertShortCut(int index, BasicBeanPane<T> pane) {
int size = extraPaneList.size();
index = Math.min(index, size);
extraPaneList.add(index, pane);
}
private void initPluginListener() {
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent event) {
refreshExtraAdvancedPane();
}
}, pluginContext -> pluginContext.getRuntime().contain(TemplateThemePaneProvider.XML_TAG));
}
protected JPanel createCellStyleSettingPane() {

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

@ -1,11 +1,11 @@
package com.fr.design.fun;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.beans.AbstractBasicBeanPane;
import com.fr.design.designer.creator.XCreator;
import com.fr.stable.fun.mark.Mutable;
/**
* 控件属性面板的高级设置项扩展
* 设计器控件的属性设置下高级设置项扩展支持追加设置项
*
* @author Bruce.Deng
* @version 11.0
@ -18,10 +18,18 @@ public interface WidgetAdvancedPaneProvider<T> extends Mutable {
int CURRENT_LEVEL = 1;
/**
* 是否需要处理
* 获取插入的位置
*
* @param total 已插入的面板数
* @return 插入位置如果想放到最后则返回-1
*/
int getInsertPosition(int total);
/**
* 根据XCreator判断是否需要处理
*
* @param creator
* @return true:需要处理/false:不处理
* @return true:需要处理;false:不处理
*/
boolean accept(XCreator creator);
@ -30,5 +38,5 @@ public interface WidgetAdvancedPaneProvider<T> extends Mutable {
*
* @return 高级设置项追加面板
*/
BasicBeanPane<T> createExtraAdvancedPane();
AbstractBasicBeanPane<T> createExtraAdvancedPane();
}

76
designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java

@ -34,6 +34,9 @@ import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.design.widget.ui.designer.component.UIBoundSpinner;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.general.Background;
import com.fr.general.GeneralContext;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.report.stable.FormConstants;
import javax.swing.BorderFactory;
@ -64,6 +67,7 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
private boolean newForm;
private PropertyGroupPane extraPropertyGroupPane;
protected final List<BasicBeanPane<WParameterLayout>> extraPaneList = new ArrayList<>();
private JPanel backgroundPane;
public RootDesignDefinePane(XCreator xCreator) {
super(xCreator);
@ -156,6 +160,8 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
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")});
backgroundPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.initExtraPane();
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p, p, p};
@ -163,7 +169,7 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}};
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), getBackgroundPane()},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), backgroundPane},
new Component[]{displayReport, null},
new Component[]{useParamsTemplate, null},
new Component[]{fireAfterEditor, null},
@ -180,6 +186,54 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
return jPanel;
}
private void initExtraPane() {
initPluginListener();
refreshExtraAdvancedPane();
}
private void initPluginListener() {
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent event) {
refreshExtraAdvancedPane();
}
}, pluginContext -> pluginContext.getRuntime().contain(WidgetAdvancedPaneProvider.XML_TAG));
}
private void refreshExtraAdvancedPane() {
extraPaneList.clear();
backgroundPane.removeAll();
Set<WidgetAdvancedPaneProvider<WParameterLayout>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG);
for (WidgetAdvancedPaneProvider<WParameterLayout> provider : providers) {
if (!provider.accept(creator)) {
continue;
}
insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane());
}
if (extraPaneList.isEmpty()) {
if (background == null) {
background = new AccessibleBackgroundEditor();
}
backgroundPane.add(background);
} else {
for (BasicBeanPane<WParameterLayout> pane : extraPaneList) {
backgroundPane.add(pane);
}
}
}
/**
* 插入配置项面板
*
* @param index 插入的位置
* @param pane 配置项面板
*/
public void insertShortCut(int index, BasicBeanPane<WParameterLayout> pane) {
int size = extraPaneList.size();
index = Math.min(index, size);
extraPaneList.add(index, pane);
}
/**
* @param
* @Description: 获取新决策报表的AdvancePane
@ -203,7 +257,8 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
fireAfterEditor.setSelected(false);
}
});
backgroundPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.initExtraPane();
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p, p};
@ -211,7 +266,7 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}};
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), getBackgroundPane()},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), backgroundPane},
new Component[]{displayReport, null},
new Component[]{useParamsTemplate, null},
new Component[]{fireAfterEditor, null},
@ -353,19 +408,4 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
public DataCreatorUI dataUI() {
return null;
}
private Component getBackgroundPane() {
Set<WidgetAdvancedPaneProvider<WParameterLayout>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG);
if (providers != null) {
for (WidgetAdvancedPaneProvider<WParameterLayout> provider : providers) {
if (provider.accept(creator)) {
BasicBeanPane<WParameterLayout> extraAdvancedPane = provider.createExtraAdvancedPane();
extraPaneList.add(extraAdvancedPane);
return extraAdvancedPane;
}
}
}
background = new AccessibleBackgroundEditor();
return background;
}
}

50
designer-form/src/main/java/com/fr/design/widget/ui/designer/FieldEditorDefinePane.java

@ -21,7 +21,10 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.ui.designer.component.FontSizeComboPane;
import com.fr.form.ui.FieldEditor;
import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
@ -40,7 +43,8 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
protected JPanel validatePane;
protected FontSizeComboPane fontSizePane;
protected UITextField labelNameTextField;
protected final List<BasicBeanPane<T>> extraPaneList = new ArrayList<>();
private final List<BasicBeanPane<T>> extraPaneList = new ArrayList<>();
private JPanel extraPane;
public FieldEditorDefinePane(XCreator xCreator) {
super(xCreator);
@ -56,7 +60,9 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
JPanel contentPane = this.setFirstContentPane();
JPanel jPanel = FRGUIPaneFactory.createYBoxEmptyBorderPane();
jPanel.add(contentPane);
this.addExtraAdvancedPane(jPanel, creator);
extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane();
jPanel.add(extraPane);
this.initExtraPane();
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
if (contentPane != null) {
UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, jPanel);
@ -65,16 +71,23 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
this.addValidatePane();
}
protected void addExtraAdvancedPane(JPanel jPanel, XCreator xCreator) {
private void initExtraPane() {
initPluginListener();
refreshExtraAdvancedPane();
}
private void refreshExtraAdvancedPane() {
extraPaneList.clear();
extraPane.removeAll();
Set<WidgetAdvancedPaneProvider<T>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG);
if (providers != null) {
for (WidgetAdvancedPaneProvider<T> provider : providers) {
if (provider.accept(xCreator)) {
BasicBeanPane<T> extraAdvancedPane = provider.createExtraAdvancedPane();
extraPaneList.add(extraAdvancedPane);
jPanel.add(extraAdvancedPane);
if (!provider.accept(creator)) {
continue;
}
insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane());
}
for (BasicBeanPane<T> pane : extraPaneList) {
extraPane.add(pane);
}
}
@ -177,4 +190,25 @@ public abstract class FieldEditorDefinePane<T extends FieldEditor> extends Abstr
return null;
}
/**
* 插入配置项面板
*
* @param index 插入的位置
* @param pane 配置项面板
*/
private void insertShortCut(int index, BasicBeanPane<T> pane) {
int size = extraPaneList.size();
index = Math.min(index, size);
extraPaneList.add(index, pane);
}
private void initPluginListener() {
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent event) {
refreshExtraAdvancedPane();
}
}, pluginContext -> pluginContext.getRuntime().contain(WidgetAdvancedPaneProvider.XML_TAG));
}
}

Loading…
Cancel
Save