帆软报表设计器源代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

138 lines
4.8 KiB

package com.fr.design.widgettheme.common;
import com.fr.widgettheme.theme.widget.style.BorderStyle;
import com.fr.widgettheme.theme.widget.style.ButtonBackgroundStyle;
import com.fr.widgettheme.theme.bean.ButtonBackground;
import com.fr.design.widgettheme.BaseStyleSettingPane;
import com.fr.form.ui.FreeButton;
import com.fr.form.ui.Widget;
import com.fr.design.widgettheme.StyleSetting;
import com.fr.widgettheme.theme.widget.theme.cell.NormalButtonTheme;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.List;
/**
* 设计器控件属性的“高级”设置增加主题样式设置项,包括:
* 按钮组件
*
* @author John.Ying
* @since 11.0
* Created on 2023/4/27
*/
public class NormalButtonSettingPane<T extends Widget> extends BaseStyleSettingPane<T> {
public NormalButtonSettingPane() {
super(Arrays.asList(
StyleSetting.BTN_BACKGROUND,
StyleSetting.LINE_TYPE,
StyleSetting.LINE_COLOR,
StyleSetting.BORDER_RADIUS
));
}
public NormalButtonSettingPane(List<StyleSetting> styleSettingList) {
super(styleSettingList);
}
@Override
public void populateBean(T t) {
NormalButtonTheme widgetTheme = initNormalButtonTheme(t);
if (t instanceof FreeButton && ((FreeButton) t).isCustomStyle()) {
initCustomStyle((FreeButton) t, widgetTheme);
}
populateNormalButtonBean(widgetTheme);
}
/**
* 根据freeButton自定义样式,初始化widgetTheme
*/
protected void initCustomStyle(FreeButton freeButton, NormalButtonTheme widgetTheme) {
ButtonBackgroundStyle buttonBackgroundStyle = new ButtonBackgroundStyle(freeButton.getInitialBackground(), freeButton.getOverBackground(), freeButton.getClickBackground());
widgetTheme.setButtonBackgroundStyle(buttonBackgroundStyle);
widgetTheme.setFollowTheme(false);
}
protected void populateNormalButtonBean(NormalButtonTheme widgetTheme) {
if (widgetTheme.isFollowTheme()) {
styleSettingHead.setSelectedIndex(0);
} else {
styleSettingHead.setSelectedIndex(1);
BorderStyle borderStyle = widgetTheme.getBorderStyle();
lineComboBox.setSelectedLineStyle(borderStyle.getLineType());
borderRadiusSpinner.setValue(borderStyle.getRadius());
borderColorSelectBox.setSelectObject(borderStyle.getBorderColor());
assignFontPane(widgetTheme);
buttonStyleDefinedPane.populate(ButtonBackground.create(widgetTheme.getButtonBackgroundStyle()));
}
switchCard();
}
protected void assignFontPane(NormalButtonTheme normalButtonTheme) {
}
protected void assignFontStyle(NormalButtonTheme normalButtonTheme) {
}
protected NormalButtonTheme initNormalButtonTheme(T t) {
NormalButtonTheme widgetTheme = (NormalButtonTheme) t.getWidgetTheme();
if (widgetTheme == null) {
widgetTheme = getDefaultNormalButtonTheme();
t.setWidgetTheme(widgetTheme);
}
return widgetTheme;
}
protected NormalButtonTheme getDefaultNormalButtonTheme() {
return new NormalButtonTheme();
}
@Override
public void updateBean(T t) {
NormalButtonTheme widgetTheme = initNormalButtonTheme(t);
int selectIndex = styleSettingHead.getSelectedIndex();
widgetTheme.setFollowTheme(selectIndex == 0);
updateNormalButtonStyleBean(widgetTheme);
if (t instanceof FreeButton) {
FreeButton freeButton = (FreeButton) t;
freeButton.setCustomStyle(!widgetTheme.isFollowTheme());
updateCustomStyle(freeButton, widgetTheme);
}
}
/**
* 更新freeButton的自定义样式
*/
protected void updateCustomStyle(FreeButton freeButton, NormalButtonTheme widgetTheme) {
ButtonBackgroundStyle backgroundStyle = widgetTheme.getButtonBackgroundStyle();
freeButton.setInitialBackground(backgroundStyle.getInitialBackground());
freeButton.setOverBackground(backgroundStyle.getOverBackground());
freeButton.setClickBackground(backgroundStyle.getClickBackground());
}
protected void updateNormalButtonStyleBean(NormalButtonTheme normalButtonTheme) {
assignFontStyle(normalButtonTheme);
normalButtonTheme.setButtonBackgroundStyle(buttonStyleDefinedPane.update());
normalButtonTheme.setBorderStyle(new BorderStyle((int) borderRadiusSpinner.getValue(), lineComboBox.getSelectedLineStyle(), borderColorSelectBox.getSelectObject()));
switchCard();
}
@Override
@Nullable
public T updateBean() {
return null;
}
@Override
protected String title4PopupWindow() {
return "normalButtonSetting";
}
}