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.
119 lines
4.2 KiB
119 lines
4.2 KiB
package com.fr.design.widgettheme.common; |
|
|
|
|
|
import com.fr.util.ColorUtils; |
|
import com.fr.widgettheme.theme.widget.style.BorderStyle; |
|
import com.fr.design.widgettheme.BaseStyleSettingPane; |
|
import com.fr.form.ui.Widget; |
|
import com.fr.design.widgettheme.StyleSetting; |
|
import com.fr.widgettheme.theme.widget.theme.cell.EditorTheme; |
|
import com.fr.widgettheme.util.WidgetThemeDesignerUtils; |
|
import org.jetbrains.annotations.Nullable; |
|
|
|
import java.util.Arrays; |
|
import java.util.List; |
|
|
|
/** |
|
* 设计器控件属性的“高级”设置增加主题样式设置项,包括: |
|
* 文本控件/数字控件/密码控件/文本域控件/下拉框控件/下拉复选框控件/下拉树控件/日期控件 |
|
* |
|
* @author John.Ying |
|
* @since 11.0 |
|
* Created on 2023/4/18 |
|
*/ |
|
public class EditorSettingPane<T extends Widget> extends BaseStyleSettingPane<T> { |
|
|
|
public EditorSettingPane() { |
|
super(Arrays.asList( |
|
StyleSetting.THEME_COLOR, |
|
StyleSetting.WIDGET_BACKGROUND, |
|
StyleSetting.LINE_TYPE, |
|
StyleSetting.LINE_COLOR, |
|
StyleSetting.BORDER_RADIUS |
|
)); |
|
} |
|
|
|
public EditorSettingPane(List<StyleSetting> styleSettingList) { |
|
super(styleSettingList); |
|
} |
|
|
|
@Override |
|
protected String title4PopupWindow() { |
|
return "fieldEditorSetting"; |
|
} |
|
|
|
protected void assignFontSizePane(EditorTheme widgetTheme) { |
|
|
|
} |
|
|
|
protected void assignFontSizeStyle(EditorTheme widgetTheme) { |
|
|
|
} |
|
|
|
@Override |
|
public void populateBean(T t) { |
|
EditorTheme widgetTheme = initEditorTheme(t); |
|
populateEditorBean(widgetTheme); |
|
} |
|
|
|
protected EditorTheme initEditorTheme(T t) { |
|
EditorTheme widgetTheme = (EditorTheme) t.getWidgetTheme(); |
|
if (widgetTheme == null) { |
|
widgetTheme = getEditorTheme(); |
|
updateEditorStyleBean(widgetTheme); |
|
t.setWidgetTheme(widgetTheme); |
|
} |
|
return widgetTheme; |
|
} |
|
|
|
protected EditorTheme getEditorTheme() { |
|
return new EditorTheme(); |
|
} |
|
|
|
protected void populateEditorBean(EditorTheme editorTheme) { |
|
if (editorTheme.isFollowTheme()) { |
|
styleSettingHead.setSelectedIndex(0); |
|
} else { |
|
styleSettingHead.setSelectedIndex(1); |
|
colorSelectBox.setSelectObject(editorTheme.getThemeColor()); |
|
lineComboBox.setSelectedLineStyle(editorTheme.getBorderStyle().getLineType()); |
|
borderRadiusSpinner.setValue(editorTheme.getBorderStyle().getRadius()); |
|
borderColorSelectBox.setSelectObject(editorTheme.getBorderStyle().getBorderColor()); |
|
widgetBgColorSelectBox.setSelectObject(ColorUtils.ignoreColorAlpha(editorTheme.getWidgetBackground().getColor())); |
|
widgetBgAlphaDragPane.populateBean(ColorUtils.roundColorAlphaDouble(editorTheme.getWidgetBackground().getColor())); |
|
iconColorSelectBox.setSelectObject(editorTheme.getIconColor()); |
|
selectBgColorBox.setSelectObject(editorTheme.getSelectBoxBgColor()); |
|
assignFontSizePane(editorTheme); |
|
} |
|
switchCard(); |
|
} |
|
|
|
@Override |
|
@Nullable |
|
public T updateBean() { |
|
return null; |
|
} |
|
|
|
@Override |
|
public void updateBean(T t) { |
|
EditorTheme widgetTheme = initEditorTheme(t); |
|
updateEditorBean(widgetTheme); |
|
} |
|
|
|
protected void updateEditorBean(EditorTheme editorTheme) { |
|
int selectIndex = styleSettingHead.getSelectedIndex(); |
|
editorTheme.setFollowTheme(selectIndex == 0); |
|
updateEditorStyleBean(editorTheme); |
|
} |
|
|
|
protected void updateEditorStyleBean(EditorTheme editorTheme) { |
|
editorTheme.setThemeColor(colorSelectBox.getSelectObject()); |
|
editorTheme.setSelectBoxBgColor(selectBgColorBox.getSelectObject()); |
|
editorTheme.setBorderStyle(new BorderStyle((int) borderRadiusSpinner.getValue(), lineComboBox.getSelectedLineStyle(), borderColorSelectBox.getSelectObject())); |
|
editorTheme.setWidgetBackground(ColorUtils.createColorBackgroundWithAlpha(widgetBgColorSelectBox.getSelectObject(), widgetBgAlphaDragPane.updateBean())); |
|
editorTheme.setIconColor(iconColorSelectBox.getSelectObject()); |
|
assignFontSizeStyle(editorTheme); |
|
switchCard(); |
|
} |
|
|
|
}
|
|
|