Browse Source

REPORT-93554 控件主题支持——报表支撑

feature/x
parent
commit
654b9a1b17
  1. 23
      designer-base/src/main/java/com/fr/design/mainframe/mobile/processor/AbstractMobileStyleDefinePaneProcessor.java
  2. 40
      designer-base/src/main/java/com/fr/design/mainframe/mobile/processor/MobileStyleDefinePaneProcessor.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/AbstractMobileStyleDefinePaneProcessor.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 = MobileStyleDefinePaneProcessor.CURRENT_LEVEL)
public abstract class AbstractMobileStyleDefinePaneProcessor implements MobileStyleDefinePaneProcessor {
@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/MobileStyleDefinePaneProcessor.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 MobileStyleDefinePaneProcessor extends Immutable {
String XML_TAG = "MobileStyleDefinePaneProcessor";
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 NewColorSelectBox iconColor;
private MobileStyleFontConfigPane fontConfigPane;
private MobileStyle mobileStyle;
MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass,
Class<? extends MobileStyle> mobileStyleClazz) {
this.widget = widget;
this.customBeanPane = Reflect.on(customBeanPaneClass).create(widget).get();
this.mobileStyleClazz = mobileStyleClazz;
initMobileStyle(widget);
init();
}
private void initMobileStyle(Widget widget) {
mobileStyle = widget.getMobileStyle() != null ? widget.getMobileStyle() : Reflect.on(mobileStyleClazz).create().get();
}
@Override
public void populateBean(MobileStyle ob) {
this.customBeanPane.populateBean(ob);
customCombo.setSelectedIndex(ob.isCommonCustom() ? 1 : 0);
if(ob.getCommonBackground() != null) {
colorSelectBox.setSelectObject(((ColorBackground)ob.getCommonBackground()).getColor());
if (ob.getCommonBackground() != null) {
colorSelectBox.setSelectObject(((ColorBackground) ob.getCommonBackground()).getColor());
}
borderType.setSelectedLineStyle(ob.getCommonBorderType());
if (ob.getCommonBorderColor() != null) {
@ -85,7 +91,6 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
@Override
public MobileStyle updateBean() {
MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get();
this.widget.setMobileStyle(mobileStyle);
this.customBeanPane.updateBean();
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.fun.MobileWidgetStyleProvider;
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.container.WScaleLayout;
import com.fr.form.ui.mobile.MobileCommonExtraStyle;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.StyleClassMap;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.observer.PluginEventType;
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.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.Map;
@ -28,9 +43,11 @@ public class MobileStylePane extends BasicPane {
private JList styleList;
private Map<String, BasicBeanPane<MobileStyle>> map = new HashMap<>();
private boolean checkFlag = true;
public MobileStylePane(Widget widget) {
if(widget instanceof WScaleLayout) {
this.widget = ((CRBoundsWidget)((WScaleLayout) widget).getBoundsWidget()).getWidget();
if (widget instanceof WScaleLayout) {
this.widget = ((CRBoundsWidget) ((WScaleLayout) widget).getBoundsWidget()).getWidget();
} else {
this.widget = widget;
}
@ -63,13 +80,18 @@ public class MobileStylePane extends BasicPane {
}
private void init() {
initComponent();
initPluginListener();
}
private void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
listModel = new DefaultListModel<>();
card = new CardLayout();
right = FRGUIPaneFactory.createCardLayout_S_Pane();
right.setLayout(card);
MobileWidgetStyleProvider[] styleProviders = getMobileWidgetStyleProviders();
for(MobileWidgetStyleProvider styleProvider: styleProviders) {
for (MobileWidgetStyleProvider styleProvider : styleProviders) {
this.addProvider2View(styleProvider);
}
this.addWestList();
@ -107,7 +129,15 @@ public class MobileStylePane extends BasicPane {
listModel.addElement(displayName);
try {
MobileStyleDefinePaneProcessor processor = ExtraDesignClassManager.getInstance().getSingle(MobileStyleDefinePaneProcessor.XML_TAG);
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);
map.put(displayName, mobileStyleBasicBeanPane);
} catch (Exception e) {
@ -133,4 +163,33 @@ public class MobileStylePane extends BasicPane {
styleProviders = ArrayUtils.insert(0, styleProviders, defaultMobileWidgetStyleProvider);
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