Browse Source

Pull request #12125: REPORT-93554 控件主题支持——报表支撑

Merge in DESIGN/design from ~CORAL.CHEN/design:feature/x to feature/x

* commit '930e1df661143636c2bf9dda821b771422c47ba2':
  REPORT-93554 更新Immutable类名
  REPORT-93554 控件主题支持——报表支撑
feature/x
Coral.Chen-张晨 2 years ago
parent
commit
5e503bfbdf
  1. 23
      designer-base/src/main/java/com/fr/design/mainframe/mobile/processor/AbstractMobileStyleDefinePaneCreator.java
  2. 40
      designer-base/src/main/java/com/fr/design/mainframe/mobile/processor/MobileStyleDefinePaneCreator.java
  3. 11
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java
  4. 69
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java

23
designer-base/src/main/java/com/fr/design/mainframe/mobile/processor/AbstractMobileStyleDefinePaneCreator.java

@ -0,0 +1,23 @@
package com.fr.design.mainframe.mobile.processor;
import com.fr.stable.fun.mark.API;
/**
* 移动端Form控件样式模板通用属性替换接口
*
* @author Coral.Chen
* @since 11.0
* Created on 2023/4/11
*/
@API(level = MobileStyleDefinePaneCreator.CURRENT_LEVEL)
public abstract class AbstractMobileStyleDefinePaneCreator implements MobileStyleDefinePaneCreator {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public int layerIndex() {
return DEFAULT_LAYER_INDEX;
}
}

40
designer-base/src/main/java/com/fr/design/mainframe/mobile/processor/MobileStyleDefinePaneCreator.java

@ -0,0 +1,40 @@
package com.fr.design.mainframe.mobile.processor;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.form.ui.Widget;
import com.fr.form.ui.mobile.MobileCommonExtraStyle;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.stable.fun.mark.Immutable;
import org.jetbrains.annotations.Nullable;
/**
* 移动端Form控件样式模板通用属性替换接口
*
* @author Coral.Chen
* @since 11.0
* Created on 2023/4/11
*/
public interface MobileStyleDefinePaneCreator extends Immutable {
String XML_TAG = "MobileStyleDefinePaneCreator";
int CURRENT_LEVEL = 1;
/**
* <p> 创建通用属性样式界面可替换{@link com.fr.design.mainframe.mobile.ui.MobileStyleDefinePane}
* <p> 每种样式的通用属性面板是一样的
*
* @param widget 控件
* @param customDefinePane 自定义面板
* @param mobileStyle 移动端样式
* @return
*/
@Nullable BasicBeanPane<MobileStyle> createBaseBeanPane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customDefinePane, Class<? extends MobileStyle> mobileStyle);
/**
* 替换通用属性面板注册额外属性
*
* @return 属性类
*/
@Nullable Class<? extends MobileCommonExtraStyle> classForCommonExtraStyle(Widget widget);
}

11
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java

@ -53,22 +53,28 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private UISpinner borderRadius; private UISpinner borderRadius;
private NewColorSelectBox iconColor; private NewColorSelectBox iconColor;
private MobileStyleFontConfigPane fontConfigPane; private MobileStyleFontConfigPane fontConfigPane;
private MobileStyle mobileStyle;
MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass, MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass,
Class<? extends MobileStyle> mobileStyleClazz) { Class<? extends MobileStyle> mobileStyleClazz) {
this.widget = widget; this.widget = widget;
this.customBeanPane = Reflect.on(customBeanPaneClass).create(widget).get(); this.customBeanPane = Reflect.on(customBeanPaneClass).create(widget).get();
this.mobileStyleClazz = mobileStyleClazz; this.mobileStyleClazz = mobileStyleClazz;
initMobileStyle(widget);
init(); init();
} }
private void initMobileStyle(Widget widget) {
mobileStyle = widget.getMobileStyle() != null ? widget.getMobileStyle() : Reflect.on(mobileStyleClazz).create().get();
}
@Override @Override
public void populateBean(MobileStyle ob) { public void populateBean(MobileStyle ob) {
this.customBeanPane.populateBean(ob); this.customBeanPane.populateBean(ob);
customCombo.setSelectedIndex(ob.isCommonCustom() ? 1 : 0); customCombo.setSelectedIndex(ob.isCommonCustom() ? 1 : 0);
if(ob.getCommonBackground() != null) { if (ob.getCommonBackground() != null) {
colorSelectBox.setSelectObject(((ColorBackground)ob.getCommonBackground()).getColor()); colorSelectBox.setSelectObject(((ColorBackground) ob.getCommonBackground()).getColor());
} }
borderType.setSelectedLineStyle(ob.getCommonBorderType()); borderType.setSelectedLineStyle(ob.getCommonBorderType());
if (ob.getCommonBorderColor() != null) { if (ob.getCommonBorderColor() != null) {
@ -85,7 +91,6 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
@Override @Override
public MobileStyle updateBean() { public MobileStyle updateBean() {
MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get();
this.widget.setMobileStyle(mobileStyle); this.widget.setMobileStyle(mobileStyle);
this.customBeanPane.updateBean(); this.customBeanPane.updateBean();
mobileStyle.setCommonCustom(customCombo.getSelectedIndex() == 1); mobileStyle.setCommonCustom(customCombo.getSelectedIndex() == 1);

69
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java

@ -5,17 +5,32 @@ import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.fun.MobileWidgetStyleProvider; import com.fr.design.fun.MobileWidgetStyleProvider;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.mobile.processor.MobileStyleDefinePaneProcessor;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WScaleLayout; import com.fr.form.ui.container.WScaleLayout;
import com.fr.form.ui.mobile.MobileCommonExtraStyle;
import com.fr.form.ui.mobile.MobileStyle; import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.StyleClassMap;
import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.observer.PluginEventType;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import javax.swing.*; import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -28,9 +43,11 @@ public class MobileStylePane extends BasicPane {
private JList styleList; private JList styleList;
private Map<String, BasicBeanPane<MobileStyle>> map = new HashMap<>(); private Map<String, BasicBeanPane<MobileStyle>> map = new HashMap<>();
private boolean checkFlag = true;
public MobileStylePane(Widget widget) { public MobileStylePane(Widget widget) {
if(widget instanceof WScaleLayout) { if (widget instanceof WScaleLayout) {
this.widget = ((CRBoundsWidget)((WScaleLayout) widget).getBoundsWidget()).getWidget(); this.widget = ((CRBoundsWidget) ((WScaleLayout) widget).getBoundsWidget()).getWidget();
} else { } else {
this.widget = widget; this.widget = widget;
} }
@ -63,13 +80,18 @@ public class MobileStylePane extends BasicPane {
} }
private void init() { private void init() {
initComponent();
initPluginListener();
}
private void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
listModel = new DefaultListModel<>(); listModel = new DefaultListModel<>();
card = new CardLayout(); card = new CardLayout();
right = FRGUIPaneFactory.createCardLayout_S_Pane(); right = FRGUIPaneFactory.createCardLayout_S_Pane();
right.setLayout(card); right.setLayout(card);
MobileWidgetStyleProvider[] styleProviders = getMobileWidgetStyleProviders(); MobileWidgetStyleProvider[] styleProviders = getMobileWidgetStyleProviders();
for(MobileWidgetStyleProvider styleProvider: styleProviders) { for (MobileWidgetStyleProvider styleProvider : styleProviders) {
this.addProvider2View(styleProvider); this.addProvider2View(styleProvider);
} }
this.addWestList(); this.addWestList();
@ -107,7 +129,15 @@ public class MobileStylePane extends BasicPane {
listModel.addElement(displayName); listModel.addElement(displayName);
try { try {
MobileStyleDefinePaneProcessor processor = ExtraDesignClassManager.getInstance().getSingle(MobileStyleDefinePaneProcessor.XML_TAG);
BasicBeanPane<MobileStyle> mobileStyleBasicBeanPane = new MobileStyleDefinePane(widget, appearanceClazz, mobileStyleClazz); BasicBeanPane<MobileStyle> mobileStyleBasicBeanPane = new MobileStyleDefinePane(widget, appearanceClazz, mobileStyleClazz);
if (checkFlag && processor != null && processor.createBaseBeanPane(widget, appearanceClazz, mobileStyleClazz) != null) {
mobileStyleBasicBeanPane = processor.createBaseBeanPane(widget, appearanceClazz, mobileStyleClazz);
Class<? extends MobileCommonExtraStyle> extraStyle = processor.classForCommonExtraStyle(widget);
if (extraStyle != null) {
StyleClassMap.getCommonStyleMap().put(extraStyle.getName(), extraStyle.getName());
}
}
right.add(displayName, mobileStyleBasicBeanPane); right.add(displayName, mobileStyleBasicBeanPane);
map.put(displayName, mobileStyleBasicBeanPane); map.put(displayName, mobileStyleBasicBeanPane);
} catch (Exception e) { } catch (Exception e) {
@ -133,4 +163,33 @@ public class MobileStylePane extends BasicPane {
styleProviders = ArrayUtils.insert(0, styleProviders, defaultMobileWidgetStyleProvider); styleProviders = ArrayUtils.insert(0, styleProviders, defaultMobileWidgetStyleProvider);
return styleProviders; return styleProviders;
} }
private void initPluginListener() {
EventDispatcher.listen(PluginEventType.AfterRun, new Listener<PluginContext>() {
@Override
public void on(Event event, PluginContext pluginContext) {
if (pluginContext.getRuntime().contain(MobileStyleDefinePaneProcessor.XML_TAG)) {
checkFlag = true;
refreshDockingView();
}
}
});
EventDispatcher.listen(PluginEventType.BeforeStop, new Listener<PluginContext>() {
@Override
public void on(Event event, PluginContext pluginContext) {
if (pluginContext.getRuntime().contain(MobileStyleDefinePaneProcessor.XML_TAG)) {
checkFlag = false;
refreshDockingView();
}
}
});
}
private void refreshDockingView() {
removeAll();
initComponent();
populate(widget.getMobileStyle());
this.updateUI();
this.repaint();
}
} }
Loading…
Cancel
Save