|
|
|
@ -1,9 +1,17 @@
|
|
|
|
|
package com.fr.design.widgettheme; |
|
|
|
|
|
|
|
|
|
import com.fr.base.background.ColorBackground; |
|
|
|
|
import com.fr.base.theme.TemplateTheme; |
|
|
|
|
import com.fr.design.gui.frpane.FontSizeComboPane; |
|
|
|
|
import com.fr.design.gui.frpane.UIPercentDragPane; |
|
|
|
|
import com.fr.design.gui.ibutton.UIColorButton; |
|
|
|
|
import com.fr.design.gui.ibutton.UIToggleButton; |
|
|
|
|
import com.fr.design.gui.icombobox.UIComboBox; |
|
|
|
|
import com.fr.general.IOUtils; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import com.fr.util.ColorUtils; |
|
|
|
|
import com.fr.widgettheme.theme.widget.style.BorderStyle; |
|
|
|
|
import com.fr.widgettheme.theme.widget.style.ButtonBackgroundStyle; |
|
|
|
|
import com.fr.widgettheme.theme.widget.style.ThemeTextStyle; |
|
|
|
|
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle; |
|
|
|
|
import com.fr.widgettheme.theme.bean.ButtonBackground; |
|
|
|
@ -11,7 +19,6 @@ import com.fr.design.beans.BasicBeanPane;
|
|
|
|
|
import com.fr.design.designer.IntervalConstants; |
|
|
|
|
import com.fr.design.file.HistoryTemplateListCache; |
|
|
|
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
|
|
|
|
import com.fr.design.gui.ibutton.UIRadioButton; |
|
|
|
|
import com.fr.design.gui.icombobox.LineComboBox; |
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
import com.fr.design.gui.style.FRFontPane; |
|
|
|
@ -26,11 +33,12 @@ import com.fr.form.ui.Widget;
|
|
|
|
|
import com.fr.general.FRFont; |
|
|
|
|
import com.fr.widgettheme.theme.panel.ButtonStyleDefinedPane; |
|
|
|
|
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; |
|
|
|
|
import com.fr.widgettheme.util.ThemeTextStylePaneCreator; |
|
|
|
|
import com.fr.widgettheme.util.WidgetStyleComponentCombiner; |
|
|
|
|
import com.fr.widgettheme.util.WidgetThemeDesignerUtils; |
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.ButtonGroup; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.SwingConstants; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.Color; |
|
|
|
|
import java.awt.Component; |
|
|
|
@ -38,6 +46,8 @@ import java.util.HashMap;
|
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
import static com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants.THEME_PC_WIDGET_BACKGROUND_WIDTH; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 样式设置pane抽象类 |
|
|
|
|
* |
|
|
|
@ -54,12 +64,12 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
|
|
|
|
|
protected JPanel customPane; |
|
|
|
|
// 主题色
|
|
|
|
|
protected NewColorSelectBox colorSelectBox; |
|
|
|
|
// 风格1
|
|
|
|
|
protected UIRadioButton style1; |
|
|
|
|
// 风格2
|
|
|
|
|
protected UIRadioButton style2; |
|
|
|
|
// 边框线型
|
|
|
|
|
protected LineComboBox lineComboBox; |
|
|
|
|
/** |
|
|
|
|
* 边框颜色 |
|
|
|
|
*/ |
|
|
|
|
protected NewColorSelectBox borderColorSelectBox; |
|
|
|
|
// 圆角边框
|
|
|
|
|
protected UIBoundSpinner borderRadiusSpinner; |
|
|
|
|
// 字体详细设置
|
|
|
|
@ -79,6 +89,33 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
|
|
|
|
|
*/ |
|
|
|
|
protected UIColorButton fontColorButton; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 字体名选择器 |
|
|
|
|
*/ |
|
|
|
|
protected UIComboBox fontNameSelectBox; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 字体粗体配置 |
|
|
|
|
*/ |
|
|
|
|
protected UIToggleButton bold; |
|
|
|
|
/** |
|
|
|
|
* 字体斜体配置 |
|
|
|
|
*/ |
|
|
|
|
protected UIToggleButton italic; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 控件背景颜色配置面板 |
|
|
|
|
*/ |
|
|
|
|
protected NewColorSelectBox widgetBgColorSelectBox; |
|
|
|
|
/** |
|
|
|
|
* 控件背景透明度配置面板 |
|
|
|
|
*/ |
|
|
|
|
protected UIPercentDragPane widgetBgAlphaDragPane; |
|
|
|
|
/** |
|
|
|
|
* 控件图标颜色 |
|
|
|
|
*/ |
|
|
|
|
protected NewColorSelectBox iconColorSelectBox; |
|
|
|
|
|
|
|
|
|
private final Map<StyleSetting, UILabel> labelMap = new HashMap<>(); |
|
|
|
|
private final Map<StyleSetting, Component> paneMap = new HashMap<>(); |
|
|
|
|
public BaseStyleSettingPane(List<StyleSetting> styleSettingList) { |
|
|
|
@ -97,34 +134,30 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void initStyleEditor() { |
|
|
|
|
initStyle(); |
|
|
|
|
colorSelectBox = new NewColorSelectBox(160, true); |
|
|
|
|
colorSelectBox = new NewColorSelectBox(WidgetThemeDisplayConstants.THEME_WIDGET_COMPONENT_WIDTH, false); |
|
|
|
|
lineComboBox = new LineComboBox(WidgetThemeDisplayConstants.BORDER_LINE_STYLE_ARRAY); |
|
|
|
|
borderColorSelectBox = new NewColorSelectBox(WidgetThemeDisplayConstants.THEME_WIDGET_COMPONENT_WIDTH, true); |
|
|
|
|
borderRadiusSpinner = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); |
|
|
|
|
frFontPane = new FRFontPane(); |
|
|
|
|
buttonStyleDefinedPane = new ButtonStyleDefinedPane(); |
|
|
|
|
selectBgColorBox = new NewColorSelectBox(160, true); |
|
|
|
|
selectBgColorBox = new NewColorSelectBox(WidgetThemeDisplayConstants.THEME_WIDGET_COMPONENT_WIDTH, true); |
|
|
|
|
iconColorSelectBox = new NewColorSelectBox(WidgetThemeDisplayConstants.THEME_WIDGET_COMPONENT_WIDTH, true); |
|
|
|
|
fontSizePane = new FontSizeComboPane(); |
|
|
|
|
fontColorButton = new UIColorButton(); |
|
|
|
|
paneMap.put(StyleSetting.STYLE_TYPE, createStyleTypePane()); |
|
|
|
|
bold = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); |
|
|
|
|
italic = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); |
|
|
|
|
widgetBgColorSelectBox = new NewColorSelectBox(WidgetThemeDisplayConstants.THEME_WIDGET_COMPONENT_WIDTH, true); |
|
|
|
|
widgetBgAlphaDragPane = new UIPercentDragPane(); |
|
|
|
|
paneMap.put(StyleSetting.THEME_COLOR, colorSelectBox); |
|
|
|
|
paneMap.put(StyleSetting.LINE_TYPE, lineComboBox); |
|
|
|
|
paneMap.put(StyleSetting.TEXT_STYLE, ThemeTextStylePaneCreator.create(fontSizePane, fontColorButton)); |
|
|
|
|
paneMap.put(StyleSetting.LINE_COLOR, borderColorSelectBox); |
|
|
|
|
paneMap.put(StyleSetting.TEXT_STYLE, WidgetStyleComponentCombiner.combineTextStyleComponent(fontNameSelectBox, fontSizePane, fontColorButton, bold, italic)); |
|
|
|
|
paneMap.put(StyleSetting.BORDER_RADIUS, borderRadiusSpinner); |
|
|
|
|
paneMap.put(StyleSetting.FONT, frFontPane); |
|
|
|
|
paneMap.put(StyleSetting.BTN_BACKGROUND, buttonStyleDefinedPane); |
|
|
|
|
paneMap.put(StyleSetting.SELECT_COLOR, selectBgColorBox); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 初始化style1和style2 |
|
|
|
|
*/ |
|
|
|
|
private void initStyle() { |
|
|
|
|
style1 = new UIRadioButton(Toolkit.i18nText("Fine-Design_Widget_Theme_Style_1")); |
|
|
|
|
style2 = new UIRadioButton(Toolkit.i18nText("Fine-Design_Widget_Theme_Style_2")); |
|
|
|
|
ButtonGroup buttonGroup = new ButtonGroup(); |
|
|
|
|
buttonGroup.add(style1); |
|
|
|
|
buttonGroup.add(style2); |
|
|
|
|
paneMap.put(StyleSetting.WIDGET_BACKGROUND, WidgetStyleComponentCombiner.combineWidgetBackgroundComponent(widgetBgColorSelectBox, widgetBgAlphaDragPane, THEME_PC_WIDGET_BACKGROUND_WIDTH)); |
|
|
|
|
paneMap.put(StyleSetting.ICON_COLOR, iconColorSelectBox); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected JPanel createHeadPane() { |
|
|
|
@ -143,14 +176,6 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
|
|
|
|
|
return headPane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected JPanel createStyleTypePane() { |
|
|
|
|
// 容纳风格1和风格2的panel
|
|
|
|
|
JPanel stylePane = new JPanel(FRGUIPaneFactory.createBoxFlowLayout()); |
|
|
|
|
stylePane.add(style1); |
|
|
|
|
stylePane.add(style2); |
|
|
|
|
return stylePane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected JPanel createCustomPane() { |
|
|
|
|
int size = styleSettingList.size(); |
|
|
|
|
|
|
|
|
@ -212,92 +237,95 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setThemedStyle(ThemedWidgetStyle widgetStyle) { |
|
|
|
|
setColorSelectBox(widgetStyle); |
|
|
|
|
setStyle(widgetStyle); |
|
|
|
|
setLineComboBox(widgetStyle); |
|
|
|
|
setBorderRadiusSpinner(widgetStyle); |
|
|
|
|
setTextStylePane(widgetStyle); |
|
|
|
|
setFrFontPane(widgetStyle); |
|
|
|
|
setButtonStyleDefinedPane(widgetStyle); |
|
|
|
|
setSelectBgColor(widgetStyle); |
|
|
|
|
setColorSelectBox(widgetStyle.getThemeColor()); |
|
|
|
|
setLineComboBox(widgetStyle.getBorderStyle().getLineType()); |
|
|
|
|
setBorderRadiusSpinner(widgetStyle.getBorderStyle().getRadius()); |
|
|
|
|
setTextStylePane(widgetStyle.getTextStyle()); |
|
|
|
|
setFrFontPane(widgetStyle.getFontStyle().getFont()); |
|
|
|
|
setButtonStyleDefinedPane(widgetStyle.getButtonBackgroundStyle()); |
|
|
|
|
setSelectBgColor(widgetStyle.getSelectBackgroundColor()); |
|
|
|
|
setWidgetBackground(widgetStyle.getWidgetBackground()); |
|
|
|
|
setBorderColor(widgetStyle.getBorderStyle().getBorderColor()); |
|
|
|
|
setIconColor(widgetStyle.getIconColor()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setColorSelectBox(ThemedWidgetStyle widgetStyle) { |
|
|
|
|
private void setColorSelectBox(Color themeColor) { |
|
|
|
|
if (colorSelectBox != null) { |
|
|
|
|
colorSelectBox.setSelectObject(widgetStyle.getThemeColor()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
private void setStyle(ThemedWidgetStyle widgetStyle) { |
|
|
|
|
if (widgetStyle.getStyleType() == ThemedWidgetStyle.DEFAULT_STYLE) { |
|
|
|
|
if (style1 != null) { |
|
|
|
|
style1.setSelected(true); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (style2 != null) { |
|
|
|
|
style2.setSelected(true); |
|
|
|
|
} |
|
|
|
|
colorSelectBox.setSelectObject(themeColor); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setLineComboBox(ThemedWidgetStyle widgetStyle) { |
|
|
|
|
private void setLineComboBox(int lineType) { |
|
|
|
|
if (lineComboBox != null) { |
|
|
|
|
lineComboBox.setSelectedLineStyle(widgetStyle.getBorderStyle().getLineType()); |
|
|
|
|
lineComboBox.setSelectedLineStyle(lineType); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setBorderRadiusSpinner(ThemedWidgetStyle widgetStyle) { |
|
|
|
|
private void setBorderRadiusSpinner(double radius) { |
|
|
|
|
if (borderRadiusSpinner != null) { |
|
|
|
|
borderRadiusSpinner.setValue(widgetStyle.getBorderStyle().getRadius()); |
|
|
|
|
borderRadiusSpinner.setValue(radius); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setTextStylePane(ThemedWidgetStyle widgetStyle) { |
|
|
|
|
ThemeTextStyle textStyle = widgetStyle.getTextStyle(); |
|
|
|
|
this.fontSizePane.setValue(textStyle.getFontSize()); |
|
|
|
|
this.fontColorButton.setColor(textStyle.getFontColor()); |
|
|
|
|
private void setTextStylePane(ThemeTextStyle textStyle) { |
|
|
|
|
if (fontSizePane != null) { |
|
|
|
|
this.fontSizePane.setValue(textStyle.getFontSize()); |
|
|
|
|
} |
|
|
|
|
if (fontColorButton != null) { |
|
|
|
|
this.fontColorButton.setColor(textStyle.getFontColor()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setFrFontPane(ThemedWidgetStyle widgetStyle) { |
|
|
|
|
private void setFrFontPane(FRFont font) { |
|
|
|
|
if (frFontPane != null) { |
|
|
|
|
frFontPane.populateBean(widgetStyle.getFontStyle().getFont()); |
|
|
|
|
frFontPane.populateBean(font); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setButtonStyleDefinedPane(ThemedWidgetStyle widgetStyle) { |
|
|
|
|
private void setButtonStyleDefinedPane(ButtonBackgroundStyle backgroundStyle) { |
|
|
|
|
if (buttonStyleDefinedPane != null) { |
|
|
|
|
buttonStyleDefinedPane.populate(ButtonBackground.create(widgetStyle.getButtonBackgroundStyle())); |
|
|
|
|
buttonStyleDefinedPane.populate(ButtonBackground.create(backgroundStyle)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setDefaultStyle() { |
|
|
|
|
if (colorSelectBox != null) { |
|
|
|
|
colorSelectBox.setSelectObject(ThemedWidgetStyle.DEFAULT_COLOR); |
|
|
|
|
} |
|
|
|
|
if (style1 != null) { |
|
|
|
|
style1.setSelected(true); |
|
|
|
|
} |
|
|
|
|
if (lineComboBox != null) { |
|
|
|
|
lineComboBox.setSelectedLineStyle(BorderStyle.DEFAULT_LINE_TYPE); |
|
|
|
|
} |
|
|
|
|
if (borderRadiusSpinner != null) { |
|
|
|
|
borderRadiusSpinner.setValue(BorderStyle.DEFAULT_BORDER_RADIUS); |
|
|
|
|
} |
|
|
|
|
if (fontSizePane != null) { |
|
|
|
|
fontSizePane.setValue(ThemeTextStyle.DEFAULT_FONT_SIZE); |
|
|
|
|
setColorSelectBox(ThemedWidgetStyle.DEFAULT_COLOR); |
|
|
|
|
setLineComboBox(BorderStyle.DEFAULT_LINE_TYPE); |
|
|
|
|
setBorderRadiusSpinner(BorderStyle.DEFAULT_BORDER_RADIUS); |
|
|
|
|
setTextStylePane(ThemeTextStyle.DEFAULT_WIDGET_STYLE); |
|
|
|
|
setFrFontPane(FRFont.getInstance()); |
|
|
|
|
setSelectBgColor(WidgetThemeDisplayConstants.DEFAULT_TRANSPARENT_COLOR); |
|
|
|
|
setWidgetBackground(WidgetThemeDisplayConstants.DEFAULT_COLOR_BACKGROUND); |
|
|
|
|
setBorderColor(BorderStyle.DEFAULT_WIDGET_BORDER_COLOR); |
|
|
|
|
setIconColor(Color.BLACK); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setSelectBgColor(Color selectBgColor) { |
|
|
|
|
if (selectBgColorBox != null) { |
|
|
|
|
selectBgColorBox.setSelectObject(selectBgColor); |
|
|
|
|
} |
|
|
|
|
if (fontColorButton != null) { |
|
|
|
|
fontColorButton.setColor(Color.BLACK); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setWidgetBackground(ColorBackground background) { |
|
|
|
|
if (widgetBgColorSelectBox != null) { |
|
|
|
|
widgetBgColorSelectBox.setSelectObject(background.getColor()); |
|
|
|
|
} |
|
|
|
|
if (frFontPane != null) { |
|
|
|
|
frFontPane.populateBean(FRFont.getInstance()); |
|
|
|
|
if (widgetBgAlphaDragPane != null) { |
|
|
|
|
//0-255,需要转化为
|
|
|
|
|
double alpha = ColorUtils.roundColorAlphaDouble(background.getColor()); |
|
|
|
|
widgetBgAlphaDragPane.populateBean(alpha); |
|
|
|
|
} |
|
|
|
|
if (selectBgColorBox != null) { |
|
|
|
|
selectBgColorBox.setSelectObject(null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setBorderColor(Color borderColor) { |
|
|
|
|
if(borderColorSelectBox != null) { |
|
|
|
|
borderColorSelectBox.setSelectObject(borderColor); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setSelectBgColor(ThemedWidgetStyle widgetStyle) { |
|
|
|
|
if(selectBgColorBox != null) { |
|
|
|
|
selectBgColorBox.setSelectObject(widgetStyle.getSelectBackgroundColor()); |
|
|
|
|
private void setIconColor(Color iconColor) { |
|
|
|
|
if(iconColorSelectBox != null) { |
|
|
|
|
iconColorSelectBox.setSelectObject(iconColor); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -305,13 +333,8 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
|
|
|
|
|
* 初始化枚举和UILabel对应的map |
|
|
|
|
*/ |
|
|
|
|
private void initLabelMap() { |
|
|
|
|
labelMap.put(StyleSetting.THEME_COLOR, new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Color"))); |
|
|
|
|
labelMap.put(StyleSetting.TEXT_STYLE, new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Text_Style"))); |
|
|
|
|
labelMap.put(StyleSetting.FONT, new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Font"))); |
|
|
|
|
labelMap.put(StyleSetting.STYLE_TYPE, new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Style"))); |
|
|
|
|
labelMap.put(StyleSetting.LINE_TYPE, new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Border_Line"))); |
|
|
|
|
labelMap.put(StyleSetting.BORDER_RADIUS, new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Border_Radius"))); |
|
|
|
|
labelMap.put(StyleSetting.BTN_BACKGROUND, new UILabel(Toolkit.i18nText("Fine-Design_Theme_Widget_Background"))); |
|
|
|
|
labelMap.put(StyleSetting.SELECT_COLOR, new UILabel(Toolkit.i18nText("Fine-Design_Widget_Background_Select_Box"))); |
|
|
|
|
for (StyleSetting setting : StyleSetting.values()) { |
|
|
|
|
labelMap.put(setting, WidgetThemeDesignerUtils.createTopAlignmentLabel(Toolkit.i18nText(setting.getLabelI18nKey()))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|