obo
1 year ago
65 changed files with 4391 additions and 73 deletions
@ -0,0 +1,102 @@ |
|||||||
|
package com.fr.controldisplayenhance; |
||||||
|
|
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.constants.LayoutConstants; |
||||||
|
import com.fr.design.file.HistoryTemplateListCache; |
||||||
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.design.mainframe.widget.accessibles.AccessibleBackgroundEditor; |
||||||
|
import com.fr.form.ui.container.WParameterLayout; |
||||||
|
import com.fr.general.Background; |
||||||
|
import org.jetbrains.annotations.Nullable; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设计器参数面板的“高级”设置增加背景的主题样式设置 |
||||||
|
* |
||||||
|
* @author Bruce.Deng |
||||||
|
* @version 11.0 |
||||||
|
* Created by Bruce.Deng on 2023/2/20 |
||||||
|
*/ |
||||||
|
public class ParameterBackgroundStyleSettingPane extends BasicBeanPane<WParameterLayout> { |
||||||
|
|
||||||
|
public static final String[] FOLLOWING_THEME_STRING_ARRAYS = new String[]{ |
||||||
|
Toolkit.i18nText("Fine-Design_Widget_Follow_Theme"), |
||||||
|
Toolkit.i18nText("Fine-Design_Widget_Theme_Custom") |
||||||
|
}; |
||||||
|
|
||||||
|
private UIButtonGroup head; |
||||||
|
private JPanel customPane; |
||||||
|
private AccessibleBackgroundEditor background; |
||||||
|
|
||||||
|
public ParameterBackgroundStyleSettingPane() { |
||||||
|
this.setLayout(new BorderLayout(0, LayoutConstants.VGAP_SMALL)); |
||||||
|
head = new UIButtonGroup(FOLLOWING_THEME_STRING_ARRAYS) { |
||||||
|
@Override |
||||||
|
public void setSelectedIndex(int newSelectedIndex, boolean fireChanged) { |
||||||
|
//表示从跟随主题切换到自定义
|
||||||
|
if (selectedIndex != newSelectedIndex && newSelectedIndex == 1) { |
||||||
|
background.setValue(getThemeBackground()); |
||||||
|
} |
||||||
|
super.setSelectedIndex(newSelectedIndex, fireChanged); |
||||||
|
} |
||||||
|
}; |
||||||
|
customPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
background = new AccessibleBackgroundEditor(); |
||||||
|
customPane.add(background); |
||||||
|
this.add(head, BorderLayout.NORTH); |
||||||
|
this.add(customPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
private void attributeChange() { |
||||||
|
customPane.setVisible(head.getSelectedIndex() == 1); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(WParameterLayout wParameterLayout) { |
||||||
|
if (wParameterLayout.isBackgroundFollowTheme()) { |
||||||
|
head.setSelectedIndex(0); |
||||||
|
} else { |
||||||
|
head.setSelectedIndex(1); |
||||||
|
background.setValue(wParameterLayout.getBackground()); |
||||||
|
} |
||||||
|
attributeChange(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
@Nullable |
||||||
|
public WParameterLayout updateBean() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(WParameterLayout wParameterLayout) { |
||||||
|
attributeChange(); |
||||||
|
if (head.getSelectedIndex() != 1) { |
||||||
|
wParameterLayout.setBackgroundFollowTheme(true); |
||||||
|
wParameterLayout.setBackground(getThemeBackground()); |
||||||
|
} else { |
||||||
|
wParameterLayout.setBackgroundFollowTheme(false); |
||||||
|
wParameterLayout.setBackground((Background) background.getValue()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private Background getThemeBackground() { |
||||||
|
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||||
|
if (JTemplate.isValid(template)) { |
||||||
|
TemplateTheme theme = template.getTemplateTheme(); |
||||||
|
return theme.getParamContainerStyle().getBackground(); |
||||||
|
} |
||||||
|
return (Background) background.getValue(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return Toolkit.i18nText("Fine-Design_Widget_Theme_ParamContainer_Background"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
package com.fr.controldisplayenhance.designer; |
||||||
|
|
||||||
|
import com.fr.base.io.BaseBook; |
||||||
|
import com.fr.base.svg.IconUtils; |
||||||
|
import com.fr.design.actions.JTemplateAction; |
||||||
|
import com.fr.controldisplayenhance.util.WidgetThemeDesignerUtils; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
|
import com.fr.design.file.HistoryTemplateListCache; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.widgettheme.control.attr.WidgetDisplayEnhanceMarkAttr; |
||||||
|
|
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bruce.Deng |
||||||
|
* @version 11.0 |
||||||
|
* Created by Bruce.Deng on 2022/11/28 |
||||||
|
*/ |
||||||
|
public class WidgetThemeDisplayAction<T extends JTemplate<?, ?>> extends JTemplateAction<T> { |
||||||
|
|
||||||
|
public WidgetThemeDisplayAction(T jwb) { |
||||||
|
super(jwb); |
||||||
|
setName(Toolkit.i18nText("Fine-Design_Widget_Display_Enhance")); |
||||||
|
this.setSmallIcon(IconUtils.readIcon("/com/fr/widgettheme/menu.svg")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
final T jwb = getEditingComponent(); |
||||||
|
if (jwb == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
BaseBook wbTpl = jwb.getTarget(); |
||||||
|
WidgetDisplayEnhanceMarkAttr attr = WidgetThemeDesignerUtils.getStrongestControlAttrFromTemplate(wbTpl); |
||||||
|
final WidgetThemeDisplayConfigPane configPane = new WidgetThemeDisplayConfigPane(); |
||||||
|
configPane.populate(attr); |
||||||
|
configPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||||
|
@Override |
||||||
|
public void doOk() { |
||||||
|
wbTpl.addAttrMark(configPane.update()); |
||||||
|
jwb.fireTargetModified(); |
||||||
|
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().activeOldJTemplate(); |
||||||
|
} |
||||||
|
}).setVisible(true); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,66 @@ |
|||||||
|
package com.fr.controldisplayenhance.designer; |
||||||
|
|
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.gui.icheckbox.UICheckBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.VerticalFlowLayout; |
||||||
|
import com.fr.widgettheme.control.attr.WidgetDisplayEnhanceMarkAttr; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bruce.Deng |
||||||
|
* @version 11.0 |
||||||
|
* Created by Bruce.Deng on 2022/11/28 |
||||||
|
*/ |
||||||
|
public class WidgetThemeDisplayConfigPane extends BasicPane { |
||||||
|
|
||||||
|
private UICheckBox widgetEnhance; |
||||||
|
|
||||||
|
public WidgetThemeDisplayConfigPane() { |
||||||
|
initComponents(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComponents() { |
||||||
|
VerticalFlowLayout layout = new VerticalFlowLayout(); |
||||||
|
layout.setAlignLeft(true); |
||||||
|
this.setLayout(layout); |
||||||
|
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
this.add(northPane); |
||||||
|
widgetEnhance = new UICheckBox(Toolkit.i18nText("Fine-Design_Widget_Enable_Display_Enhance")); |
||||||
|
widgetEnhance.setSelected(true); |
||||||
|
northPane.add(widgetEnhance); |
||||||
|
|
||||||
|
JPanel southPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
this.add(southPane); |
||||||
|
UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Widget_Display_Enhance_Tip")); |
||||||
|
label.setForeground(Color.GRAY); |
||||||
|
southPane.add(label); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return Toolkit.i18nText("Fine-Design_Widget_Display_Enhance"); |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(WidgetDisplayEnhanceMarkAttr widgetDisplayEnhanceMarkAttr) { |
||||||
|
if (widgetDisplayEnhanceMarkAttr == null) { |
||||||
|
widgetDisplayEnhanceMarkAttr = new WidgetDisplayEnhanceMarkAttr(); |
||||||
|
} |
||||||
|
widgetEnhance.setSelected(widgetDisplayEnhanceMarkAttr.isWidgetEnhance()); |
||||||
|
} |
||||||
|
|
||||||
|
public WidgetDisplayEnhanceMarkAttr update() { |
||||||
|
WidgetDisplayEnhanceMarkAttr attr = new WidgetDisplayEnhanceMarkAttr(); |
||||||
|
attr.setWidgetEnhance(widgetEnhance.isSelected()); |
||||||
|
if (widgetEnhance.isSelected()) { |
||||||
|
// SCDesignRecord record = new SCDesignRecord(DesignKit.getCurrentEditingTemplateId());
|
||||||
|
// DesignRecorderProvider.getRecorder().record(record);
|
||||||
|
} |
||||||
|
return attr; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,104 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.edit; |
||||||
|
|
||||||
|
import com.fr.design.ExtraDesignClassManager; |
||||||
|
import com.fr.design.event.UIObserverListener; |
||||||
|
import com.fr.design.fun.BackgroundQuickUIProvider; |
||||||
|
import com.fr.design.gui.style.BackgroundPane; |
||||||
|
import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; |
||||||
|
import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; |
||||||
|
import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane; |
||||||
|
import com.fr.design.mainframe.backgroundpane.ImageBackgroundQuickPane; |
||||||
|
import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; |
||||||
|
import com.fr.design.mainframe.backgroundpane.PatternBackgroundQuickPane; |
||||||
|
import com.fr.design.mainframe.backgroundpane.TextureBackgroundQuickPane; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bruce.Deng |
||||||
|
* @version 11.0 |
||||||
|
* Created by Bruce.Deng on 2023/1/5 |
||||||
|
*/ |
||||||
|
public class ParamContainerBackgroundPane extends BackgroundPane { |
||||||
|
public ParamContainerBackgroundPane(){ |
||||||
|
super(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
protected BackgroundQuickPane[] supportKindsOfBackgroundUI() { |
||||||
|
NullBackgroundQuickPane nullBackgroundPane = new NullBackgroundQuickPane(); |
||||||
|
|
||||||
|
ColorBackgroundQuickPane colorBackgroundPane = new ColorBackgroundQuickPane(true); |
||||||
|
colorBackgroundPane.registerChangeListener(new UIObserverListener() { |
||||||
|
@Override |
||||||
|
public void doChange() { |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
ImageBackgroundQuickPane imageBackgroundPane = new ImageBackgroundQuickPane(); |
||||||
|
imageBackgroundPane.registerChangeListener(new UIObserverListener() { |
||||||
|
@Override |
||||||
|
public void doChange() { |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
GradientBackgroundQuickPane gradientBackgroundPane = createGradientBackgroundQuickPane(); |
||||||
|
gradientBackgroundPane.registerChangeListener(new UIObserverListener() { |
||||||
|
@Override |
||||||
|
public void doChange() { |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
TextureBackgroundQuickPane textureBackgroundPane = new TextureBackgroundQuickPane(); |
||||||
|
textureBackgroundPane.registerChangeListener(new UIObserverListener() { |
||||||
|
@Override |
||||||
|
public void doChange() { |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
PatternBackgroundQuickPane patternBackgroundPane = new PatternBackgroundQuickPane(); |
||||||
|
patternBackgroundPane.registerChangeListener(new UIObserverListener() { |
||||||
|
@Override |
||||||
|
public void doChange() { |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
List<BackgroundQuickPane> kinds = new ArrayList<BackgroundQuickPane>(); |
||||||
|
|
||||||
|
kinds.add(nullBackgroundPane); |
||||||
|
kinds.add(colorBackgroundPane); |
||||||
|
kinds.add(imageBackgroundPane); |
||||||
|
kinds.add(gradientBackgroundPane); |
||||||
|
kinds.add(textureBackgroundPane); |
||||||
|
kinds.add(patternBackgroundPane); |
||||||
|
|
||||||
|
Set<BackgroundQuickUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(BackgroundQuickUIProvider.MARK_STRING); |
||||||
|
for (BackgroundQuickUIProvider provider : providers) { |
||||||
|
BackgroundQuickPane newTypePane = provider.appearanceForBackground(); |
||||||
|
newTypePane.registerChangeListener(new UIObserverListener() { |
||||||
|
@Override |
||||||
|
public void doChange() { |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
kinds.add(newTypePane); |
||||||
|
} |
||||||
|
|
||||||
|
return kinds.toArray(new BackgroundQuickPane[kinds.size()]); |
||||||
|
} |
||||||
|
|
||||||
|
protected GradientBackgroundQuickPane createGradientBackgroundQuickPane() { |
||||||
|
// 使用默认的150宽度构建渐变条
|
||||||
|
return new GradientBackgroundQuickPane(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,78 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.edit; |
||||||
|
|
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.widgettheme.theme.widget.style.ThemedParamContainerStyle; |
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bruce.Deng |
||||||
|
* @version 11.0 |
||||||
|
* Created by Bruce.Deng on 2022/12/16 |
||||||
|
*/ |
||||||
|
public class ParamContainerStyleEditPane<T extends TemplateTheme> extends BasicBeanPane<T> { |
||||||
|
public static final int LABEL_WIDTH = 60; |
||||||
|
public static final int SETTING_WIDTH = 193; |
||||||
|
|
||||||
|
private final ParamContainerBackgroundPane backgroundPane; |
||||||
|
|
||||||
|
public ParamContainerStyleEditPane() { |
||||||
|
backgroundPane = new ParamContainerBackgroundPane(); |
||||||
|
|
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
|
||||||
|
JPanel uiLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
uiLabelPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Background")), BorderLayout.NORTH); |
||||||
|
uiLabelPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
||||||
|
JPanel backgroundLabeledPane = TableLayoutHelper.createCommonTableLayoutPane( |
||||||
|
new Component[][]{ new Component[] { uiLabelPane, backgroundPane } }, |
||||||
|
new double[] { p }, new double[] { LABEL_WIDTH, SETTING_WIDTH}, IntervalConstants.INTERVAL_L1 |
||||||
|
); |
||||||
|
backgroundLabeledPane.setBorder(BorderFactory.createEmptyBorder( |
||||||
|
IntervalConstants.INTERVAL_L1, |
||||||
|
IntervalConstants.INTERVAL_L1, |
||||||
|
IntervalConstants.INTERVAL_L1, |
||||||
|
IntervalConstants.INTERVAL_L1 |
||||||
|
)); |
||||||
|
this.add(backgroundLabeledPane); |
||||||
|
setBorder(BorderFactory.createEmptyBorder()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(T t) { |
||||||
|
ThemedParamContainerStyle paramContainerStyle = (ThemedParamContainerStyle) t.getParamContainerStyle(); |
||||||
|
if (paramContainerStyle == null) { |
||||||
|
paramContainerStyle = new ThemedParamContainerStyle(); |
||||||
|
t.setParamContainerStyle(paramContainerStyle); |
||||||
|
} |
||||||
|
backgroundPane.populateBean(paramContainerStyle.getBackground()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public T updateBean() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(T t) { |
||||||
|
ThemedParamContainerStyle style = (ThemedParamContainerStyle) t.getParamContainerStyle(); |
||||||
|
if (style == null) { |
||||||
|
style = new ThemedParamContainerStyle(); |
||||||
|
t.setParamContainerStyle(style); |
||||||
|
} |
||||||
|
style.setBackground(backgroundPane.update()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return Toolkit.i18nText("Fine-Design_Widget_Theme_ParamContainer"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,135 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.edit.widget; |
||||||
|
|
||||||
|
import com.fr.base.background.ColorBackground; |
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.widgettheme.theme.widget.style.BorderStyle; |
||||||
|
import com.fr.widgettheme.theme.widget.style.ButtonBackgroundStyle; |
||||||
|
import com.fr.widgettheme.theme.widget.style.FontSizeStyle; |
||||||
|
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle; |
||||||
|
import com.fr.design.gui.ibutton.UIRadioButton; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* 桌面端主题面板 |
||||||
|
* |
||||||
|
* @author Coral.Chen |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/3/28 |
||||||
|
*/ |
||||||
|
public class DesktopWidgetStyleEditPane<T extends TemplateTheme> extends WidgetStyleEditPane<T> { |
||||||
|
// 风格1
|
||||||
|
protected UIRadioButton style1; |
||||||
|
// 风格2
|
||||||
|
protected UIRadioButton style2; |
||||||
|
// 控件深浅主题 自动
|
||||||
|
protected UIRadioButton widgetThemeAuto; |
||||||
|
// 控件深浅主题 深色
|
||||||
|
protected UIRadioButton widgetThemeDark; |
||||||
|
// 控件深浅主题 浅色
|
||||||
|
protected UIRadioButton widgetThemeLight; |
||||||
|
|
||||||
|
public DesktopWidgetStyleEditPane() { |
||||||
|
super(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Component[][] generateComponent() { |
||||||
|
initStyleEditor(); |
||||||
|
// 容纳风格1和风格2的panel
|
||||||
|
JPanel stylePane = new JPanel(FRGUIPaneFactory.createBoxFlowLayout()); |
||||||
|
stylePane.add(style1); |
||||||
|
stylePane.add(style2); |
||||||
|
|
||||||
|
JPanel widgetThemePane = new JPanel(FRGUIPaneFactory.createBoxFlowLayout()); |
||||||
|
widgetThemePane.add(widgetThemeAuto); |
||||||
|
widgetThemePane.add(widgetThemeDark); |
||||||
|
widgetThemePane.add(widgetThemeLight); |
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Color")), colorSelectBox}, |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Style")), stylePane}, |
||||||
|
// todo 预览
|
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Border_Line")), lineComboBox}, |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Border_Radius")), borderRadiusSpinner}, |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Font_Size")), fontSizeComoBox}, |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Theme_Widget_Theme")), widgetThemePane}, |
||||||
|
}; |
||||||
|
return components; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void initStyleEditor() { |
||||||
|
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); |
||||||
|
|
||||||
|
widgetThemeAuto = new UIRadioButton(Toolkit.i18nText("Fine-Design_Theme_Widget_Theme_Auto")); |
||||||
|
widgetThemeDark = new UIRadioButton(Toolkit.i18nText("Fine-Design_Widget_Theme_Dark")); |
||||||
|
widgetThemeLight = new UIRadioButton(Toolkit.i18nText("Fine-Design_Theme_Widget_Theme_Light")); |
||||||
|
ButtonGroup widgetThemeGroup = new ButtonGroup(); |
||||||
|
widgetThemeGroup.add(widgetThemeAuto); |
||||||
|
widgetThemeGroup.add(widgetThemeDark); |
||||||
|
widgetThemeGroup.add(widgetThemeLight); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(T t) { |
||||||
|
ThemedWidgetStyle style = (ThemedWidgetStyle) t.getWidgetStyle(); |
||||||
|
if (style == null) { |
||||||
|
style = new ThemedWidgetStyle(); |
||||||
|
t.setWidgetStyle(style); |
||||||
|
} |
||||||
|
if (style.getStyleType() == 1) { |
||||||
|
style1.setSelected(true); |
||||||
|
} else { |
||||||
|
style2.setSelected(true); |
||||||
|
} |
||||||
|
switch (style.getWidgetThemeType()) { |
||||||
|
case 1: |
||||||
|
widgetThemeDark.setSelected(true); |
||||||
|
break; |
||||||
|
case 2: |
||||||
|
widgetThemeLight.setSelected(true); |
||||||
|
break; |
||||||
|
default: |
||||||
|
widgetThemeAuto.setSelected(true); |
||||||
|
break; |
||||||
|
} |
||||||
|
colorSelectBox.setSelectObject(style.getThemeColor()); |
||||||
|
lineComboBox.setSelectedLineStyle(style.getBorderStyle().getLineType()); |
||||||
|
borderRadiusSpinner.setValue(style.getBorderStyle().getRadius()); |
||||||
|
fontSizeComoBox.setSelectedItem(style.getFontSizeStyle().getFontSize()); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(T t) { |
||||||
|
ThemedWidgetStyle style = (ThemedWidgetStyle) t.getWidgetStyle(); |
||||||
|
if (style == null) { |
||||||
|
style = new ThemedWidgetStyle(); |
||||||
|
t.setWidgetStyle(style); |
||||||
|
} |
||||||
|
style.setThemeColor(colorSelectBox.getSelectObject()); |
||||||
|
BorderStyle borderStyle = new BorderStyle(); |
||||||
|
borderStyle.setLineType(lineComboBox.getSelectedLineStyle()); |
||||||
|
borderStyle.setRadius((int) borderRadiusSpinner.getValue()); |
||||||
|
style.setBorderStyle(borderStyle); |
||||||
|
FontSizeStyle fontSizeStyle = new FontSizeStyle(); |
||||||
|
fontSizeStyle.setFontSize((Integer) fontSizeComoBox.getSelectedItem()); |
||||||
|
style.setFontSizeStyle(fontSizeStyle); |
||||||
|
ButtonBackgroundStyle buttonBackgroundStyle = new ButtonBackgroundStyle(); |
||||||
|
ColorBackground buttonBackground = ColorBackground.getInstance(style.getThemeColor()); |
||||||
|
buttonBackgroundStyle.setInitialBackground(buttonBackground); |
||||||
|
buttonBackgroundStyle.setOverBackground(buttonBackground); |
||||||
|
buttonBackgroundStyle.setClickBackground(buttonBackground); |
||||||
|
style.setButtonBackgroundStyle(buttonBackgroundStyle); |
||||||
|
style.setStyleType(style1.isSelected() ? 1 : 2); |
||||||
|
style.setWidgetThemeType(widgetThemeAuto.isSelected() ? 0 : widgetThemeDark.isSelected() ? 1 : 2); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,76 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.edit.widget; |
||||||
|
|
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.widgettheme.theme.widget.style.BorderStyle; |
||||||
|
import com.fr.widgettheme.theme.widget.style.FontSizeStyle; |
||||||
|
import com.fr.widgettheme.theme.widget.style.MobileThemedWidgetStyle; |
||||||
|
import com.fr.design.gui.icombobox.LineComboBox; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; |
||||||
|
|
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.Vector; |
||||||
|
|
||||||
|
/** |
||||||
|
* 移动端控件样式编辑面板 |
||||||
|
* |
||||||
|
* @author Coral.Chen |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/3/28 |
||||||
|
*/ |
||||||
|
public class MobileWidgetStyleEditPane<T extends TemplateTheme> extends WidgetStyleEditPane<T> { |
||||||
|
/** |
||||||
|
* 移动端字体列表 12-18 |
||||||
|
*/ |
||||||
|
private static Vector<Integer> FONT_SIZES = new Vector<Integer>() { |
||||||
|
{ |
||||||
|
addAll(Arrays.asList(12, 13, 14, 15, 16, 17, 18)); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
public MobileWidgetStyleEditPane() { |
||||||
|
super(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void initLineBox() { |
||||||
|
lineComboBox = new LineComboBox(WidgetThemeDisplayConstants.MOBILE_BORDER_LINE_STYLE_ARRAY); |
||||||
|
lineComboBox.setSelectedLineStyle(com.fr.stable.Constants.LINE_THIN); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initFontSizeComoBox() { |
||||||
|
fontSizeComoBox = new UIComboBox(FONT_SIZES); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(T t) { |
||||||
|
MobileThemedWidgetStyle style = (MobileThemedWidgetStyle) t.getMobileWidgetStyle(); |
||||||
|
if (style == null) { |
||||||
|
style = new MobileThemedWidgetStyle(); |
||||||
|
t.setMobileWidgetStyle(style); |
||||||
|
} |
||||||
|
colorSelectBox.setSelectObject(style.getThemeColor()); |
||||||
|
lineComboBox.setSelectedLineStyle(style.getBorderStyle().getLineType()); |
||||||
|
borderRadiusSpinner.setValue(style.getBorderStyle().getRadius()); |
||||||
|
fontSizeComoBox.setSelectedItem(style.getFontSizeStyle().getFontSize()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(T t) { |
||||||
|
MobileThemedWidgetStyle style = (MobileThemedWidgetStyle) t.getMobileWidgetStyle(); |
||||||
|
if (style == null) { |
||||||
|
style = new MobileThemedWidgetStyle(); |
||||||
|
t.setMobileWidgetStyle(style); |
||||||
|
} |
||||||
|
style.setThemeColor(colorSelectBox.getSelectObject()); |
||||||
|
BorderStyle borderStyle = new BorderStyle(); |
||||||
|
borderStyle.setLineType(lineComboBox.getSelectedLineStyle()); |
||||||
|
borderStyle.setRadius((int) borderRadiusSpinner.getValue()); |
||||||
|
style.setBorderStyle(borderStyle); |
||||||
|
FontSizeStyle fontSizeStyle = new FontSizeStyle(); |
||||||
|
fontSizeStyle.setFontSize((Integer) fontSizeComoBox.getSelectedItem()); |
||||||
|
style.setFontSizeStyle(fontSizeStyle); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,135 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.edit.widget; |
||||||
|
|
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import org.jetbrains.annotations.Nullable; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* 组件主题编辑容器,包含移动端控制面板和桌面端控制面板 |
||||||
|
* 默认展开桌面端 |
||||||
|
* |
||||||
|
* @author Coral.Chen |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/3/28 |
||||||
|
*/ |
||||||
|
public class WidgetStyleEditContainerPane<T extends TemplateTheme> extends BasicBeanPane<T> { |
||||||
|
private UIButtonGroup<Integer> terminalStyleGroup; |
||||||
|
private WidgetStyleEditPane<T> desktop; |
||||||
|
private WidgetStyleEditPane<T> mobile; |
||||||
|
|
||||||
|
public WidgetStyleEditContainerPane() { |
||||||
|
initComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComponent() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
// 初始化按钮组,桌面端&移动端
|
||||||
|
initButtonGroup(); |
||||||
|
// 创建按钮组面板
|
||||||
|
createButtonGroupPane(); |
||||||
|
// 默认选中桌面端
|
||||||
|
terminalStyleGroup.setSelectedIndex(0); |
||||||
|
// cardLayout用来切换面板
|
||||||
|
// 桌面端
|
||||||
|
initDesktopPanel(); |
||||||
|
// 移动端
|
||||||
|
initMobilePanel(); |
||||||
|
createCardContainer(); |
||||||
|
initListener(); |
||||||
|
} |
||||||
|
|
||||||
|
private void createCardContainer() { |
||||||
|
JPanel cardPanel = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||||
|
cardPanel.add(desktop, BorderLayout.CENTER); |
||||||
|
cardPanel.add(mobile, BorderLayout.CENTER); |
||||||
|
this.add(cardPanel, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
private void initMobilePanel() { |
||||||
|
mobile = new MobileWidgetStyleEditPane<>(); |
||||||
|
mobile.setVisible(false); |
||||||
|
} |
||||||
|
|
||||||
|
private void initDesktopPanel() { |
||||||
|
desktop = new DesktopWidgetStyleEditPane<>(); |
||||||
|
// 默认可见性
|
||||||
|
desktop.setVisible(true); |
||||||
|
} |
||||||
|
|
||||||
|
private void createButtonGroupPane() { |
||||||
|
Component[][] components = { |
||||||
|
new Component[]{terminalStyleGroup}, |
||||||
|
}; |
||||||
|
final double p = TableLayout.PREFERRED; |
||||||
|
double[] rowSize = {p}; |
||||||
|
double[] columnSize = {p, p}; |
||||||
|
int[][] rowCount = {{1, 1}}; |
||||||
|
JPanel groupPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); |
||||||
|
this.add(groupPane, BorderLayout.NORTH); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 初始化按钮组 |
||||||
|
*/ |
||||||
|
private void initButtonGroup() { |
||||||
|
terminalStyleGroup = new UIButtonGroup<>(new String[]{ |
||||||
|
Toolkit.i18nText("Fine-Design_Widget_Terminal_Desktop"), |
||||||
|
Toolkit.i18nText("Fine-Design_Widget_Terminal_Mobile")}); |
||||||
|
this.add(terminalStyleGroup, BorderLayout.NORTH); |
||||||
|
terminalStyleGroup.setSelectedIndex(0); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 初始化按钮组的listener |
||||||
|
*/ |
||||||
|
private void initListener() { |
||||||
|
terminalStyleGroup.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
showTerminalPane(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 展示具体面板 |
||||||
|
*/ |
||||||
|
private void showTerminalPane() { |
||||||
|
desktop.setVisible(terminalStyleGroup.getSelectedIndex() == 0); |
||||||
|
mobile.setVisible(terminalStyleGroup.getSelectedIndex() == 1); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(T ob) { |
||||||
|
desktop.populateBean(ob); |
||||||
|
mobile.populateBean(ob); |
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
@Override |
||||||
|
public T updateBean() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(T ob) { |
||||||
|
desktop.updateBean(ob); |
||||||
|
mobile.updateBean(ob); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return Toolkit.i18nText("Fine-Design_Theme_Widget_Style"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,112 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.edit.widget; |
||||||
|
|
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
|
import com.fr.design.gui.icombobox.LineComboBox; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.ispinner.UISpinner; |
||||||
|
import com.fr.design.gui.style.FRFontPane; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.design.style.color.NewColorSelectBox; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; |
||||||
|
import org.jetbrains.annotations.Nullable; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* 组件样式编辑基础类 |
||||||
|
* |
||||||
|
* @author Coral.Chen |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/5/22 |
||||||
|
*/ |
||||||
|
public class WidgetStyleEditPane<T extends TemplateTheme> extends BasicBeanPane<T> { |
||||||
|
|
||||||
|
// 主题色
|
||||||
|
protected NewColorSelectBox colorSelectBox; |
||||||
|
|
||||||
|
// 边框线型
|
||||||
|
protected LineComboBox lineComboBox; |
||||||
|
// 圆角边框
|
||||||
|
protected UISpinner borderRadiusSpinner; |
||||||
|
// 字体大小
|
||||||
|
protected UIComboBox fontSizeComoBox; |
||||||
|
|
||||||
|
|
||||||
|
public WidgetStyleEditPane() { |
||||||
|
initComponents(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComponents() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
initCommonStyleEditor(); |
||||||
|
double f = TableLayout.PREFERRED; |
||||||
|
final double p = TableLayout.PREFERRED; |
||||||
|
double[] rowSize = {p, p, p, p, p, p}; |
||||||
|
double[] columnSize = {p, p}; |
||||||
|
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; |
||||||
|
Component[][] components = generateComponent(); |
||||||
|
JPanel customPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); |
||||||
|
customPane.setBorder(BorderFactory.createEmptyBorder(20, 10, 0, 10)); |
||||||
|
this.add(customPane, BorderLayout.NORTH); |
||||||
|
} |
||||||
|
|
||||||
|
public Component[][] generateComponent() { |
||||||
|
Component[][] components = new Component[][]{new Component[]{ |
||||||
|
new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Color")), colorSelectBox}, |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Border_Line")), lineComboBox}, |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Border_Radius")), borderRadiusSpinner}, |
||||||
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Font_Size")), fontSizeComoBox}}; |
||||||
|
return components; |
||||||
|
} |
||||||
|
|
||||||
|
private void initCommonStyleEditor() { |
||||||
|
colorSelectBox = new NewColorSelectBox(140, true); |
||||||
|
colorSelectBox.setSelectObject(WidgetThemeDisplayConstants.DEFAULT_THEME_COLOR); |
||||||
|
initLineBox(); |
||||||
|
borderRadiusSpinner = new UISpinner(0, Integer.MAX_VALUE, 1); |
||||||
|
initFontSizeComoBox(); |
||||||
|
fontSizeComoBox.setSelectedItem(16); |
||||||
|
} |
||||||
|
|
||||||
|
protected void initFontSizeComoBox() { |
||||||
|
fontSizeComoBox = new UIComboBox(FRFontPane.getFontSizes()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 初始化边框线型 |
||||||
|
*/ |
||||||
|
public void initLineBox() { |
||||||
|
lineComboBox = new LineComboBox(WidgetThemeDisplayConstants.BORDER_LINE_STYLE_ARRAY); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(T t) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Nullable |
||||||
|
@Override |
||||||
|
public T updateBean() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(T t) { |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return StringUtils.EMPTY; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,65 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.panel; |
||||||
|
|
||||||
|
import com.fr.widgettheme.theme.widget.style.ButtonBackgroundStyle; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.widgettheme.theme.bean.ButtonBackground; |
||||||
|
import com.fr.design.mainframe.widget.accessibles.AccessibleImgBackgroundEditor; |
||||||
|
import com.fr.general.Background; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by johntsai(mailto://johntsai@fanruan.com) on 10/3/23.
|
||||||
|
**/ |
||||||
|
public class ButtonStyleDefinedPane extends BasicPane { |
||||||
|
|
||||||
|
protected AccessibleImgBackgroundEditor initBackgroundPane; |
||||||
|
protected AccessibleImgBackgroundEditor overBackgroundPane; |
||||||
|
protected AccessibleImgBackgroundEditor clickBackgroundPane; |
||||||
|
|
||||||
|
public ButtonStyleDefinedPane() { |
||||||
|
this.initComponents(); |
||||||
|
} |
||||||
|
|
||||||
|
protected void initComponents() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
initBackgroundPane = new AccessibleImgBackgroundEditor(); |
||||||
|
overBackgroundPane = new AccessibleImgBackgroundEditor(); |
||||||
|
clickBackgroundPane = new AccessibleImgBackgroundEditor(); |
||||||
|
double f = TableLayout.FILL; |
||||||
|
final double p = TableLayout.PREFERRED; |
||||||
|
double[] rowSize = {p, p, p}; |
||||||
|
double[] columnSize = {p, f}; |
||||||
|
int[][] rowCount = {{1, 1},{1, 1},{1, 1}}; |
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Background_Initial")), initBackgroundPane}, |
||||||
|
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Background_Over")), overBackgroundPane}, |
||||||
|
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Background_Click")), clickBackgroundPane}, |
||||||
|
}; |
||||||
|
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 7, 7); |
||||||
|
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
||||||
|
this.add(panel, BorderLayout.CENTER); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public void populate(ButtonBackground buttonBackground) { |
||||||
|
initBackgroundPane.setValue(buttonBackground.getInitialBackground()); |
||||||
|
overBackgroundPane.setValue(buttonBackground.getOverBackground()); |
||||||
|
clickBackgroundPane.setValue(buttonBackground.getClickBackground()); |
||||||
|
} |
||||||
|
|
||||||
|
public ButtonBackgroundStyle update() { |
||||||
|
return new ButtonBackgroundStyle((Background) initBackgroundPane.getValue(), (Background) overBackgroundPane.getValue(), (Background) clickBackgroundPane.getValue()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,135 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.panel; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.base.Style; |
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.image.BufferedImage; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主题界面预览单元格子 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @version 11.0 |
||||||
|
* Created by John.Ying on 2023/3/18 |
||||||
|
*/ |
||||||
|
public class ControlPreviewCell extends JPanel { |
||||||
|
protected static final LayoutManager DEFAULT = FRGUIPaneFactory.createRightFlowLayout(); |
||||||
|
protected static final Color DEFAULT_COLOR = new Color(210, 210, 210); |
||||||
|
protected static final Color DEFAULT_THEME_COLOR = new Color(54, 133, 242); |
||||||
|
protected static final String DEFAULT_MESSAGE = ""; |
||||||
|
protected static final int NO_SCALE_RESOLUTION = 100; |
||||||
|
protected static final int DEFAULT_ALPHA = 255; |
||||||
|
/** |
||||||
|
* 格子文本数据 |
||||||
|
*/ |
||||||
|
protected String value; |
||||||
|
protected TemplateTheme reportTheme; |
||||||
|
/** |
||||||
|
* 字体的颜色 |
||||||
|
*/ |
||||||
|
protected Color textColor = DEFAULT_COLOR; |
||||||
|
|
||||||
|
public Color getTextColor() { |
||||||
|
return textColor; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTextColor(Color textColor) { |
||||||
|
this.textColor = textColor; |
||||||
|
} |
||||||
|
|
||||||
|
public ControlPreviewCell() { |
||||||
|
this(DEFAULT, DEFAULT_MESSAGE); |
||||||
|
} |
||||||
|
|
||||||
|
public ControlPreviewCell(String value) { |
||||||
|
this(DEFAULT, value); |
||||||
|
} |
||||||
|
|
||||||
|
public ControlPreviewCell(LayoutManager layoutManager, String value) { |
||||||
|
this.setLayout(layoutManager); |
||||||
|
this.setOpaque(false); |
||||||
|
this.value = value; |
||||||
|
this.setPreferredSize(new Dimension(80, 30)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 主题样式变化后监听改变 |
||||||
|
*/ |
||||||
|
public void refresh(TemplateTheme reportTheme) { |
||||||
|
this.reportTheme = reportTheme; |
||||||
|
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) this.reportTheme.getWidgetStyle(); |
||||||
|
//主题色设置为透明或者插件启动前已有的主题启动插件后主题色为null
|
||||||
|
if (widgetStyle.getThemeColor() == null) { |
||||||
|
widgetStyle.setThemeColor(DEFAULT_THEME_COLOR); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 填充圆角矩形背景色 |
||||||
|
*/ |
||||||
|
public void paintBgColor(Graphics g, ThemedWidgetStyle widgetStyle) { |
||||||
|
this.paintBgColor(g, widgetStyle, DEFAULT_ALPHA); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isDefaultStyle() { |
||||||
|
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) reportTheme.getWidgetStyle(); |
||||||
|
return widgetStyle.getStyleType() == WidgetThemeDisplayConstants.DEFAULT_STYLE; |
||||||
|
} |
||||||
|
|
||||||
|
public Color getThemeColor() { |
||||||
|
|
||||||
|
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) reportTheme.getWidgetStyle(); |
||||||
|
return widgetStyle.getThemeColor(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
protected Icon setStyleTwoIcon(Icon icon, Icon defaultIcon) { |
||||||
|
if (this.reportTheme != null && !isDefaultStyle()) { |
||||||
|
|
||||||
|
if (icon instanceof ImageIcon) { |
||||||
|
ImageIcon imageIcon = (ImageIcon) icon; |
||||||
|
BufferedImage bufferedImage = ImageUtils.colorImage(ImageUtils.imageIconToBufferedImage(imageIcon), getThemeColor()); |
||||||
|
return new ImageIcon(bufferedImage); |
||||||
|
} |
||||||
|
} |
||||||
|
return defaultIcon; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 填充圆角矩形背景色 |
||||||
|
*/ |
||||||
|
public void paintBgColor(Graphics g, ThemedWidgetStyle widgetStyle, int alpha) { |
||||||
|
Color themeColor = widgetStyle.getThemeColor(); |
||||||
|
g.setColor(new Color(themeColor.getRed(), themeColor.getGreen(), themeColor.getBlue(), alpha)); |
||||||
|
g.fillRoundRect(0, 0, getSize().width - 1, getSize().height - 1, widgetStyle.getBorderStyle().getRadius(), widgetStyle.getBorderStyle().getRadius()); |
||||||
|
//需要重新绘制一遍字体,否则会被颜色填充给遮住
|
||||||
|
Graphics2D g2d = (Graphics2D) g.create(); |
||||||
|
FRFont font = FRFont.getInstance(FRFont.DEFAULT_FONTNAME, Font.PLAIN, widgetStyle.getFontSizeStyle().getFontSize(), textColor); |
||||||
|
BaseUtils.drawStringStyleInRotation(g2d, getWidth(), getHeight(), this.value, |
||||||
|
Style.getInstance(font).deriveHorizontalAlignment(Constants.LEFT) |
||||||
|
.deriveTextStyle(Style.TEXTSTYLE_SINGLELINE), NO_SCALE_RESOLUTION); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paintComponent(Graphics g) { |
||||||
|
super.paintComponent(g); |
||||||
|
if (this.reportTheme == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
Graphics2D g2d = (Graphics2D) g.create(); |
||||||
|
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) reportTheme.getWidgetStyle(); |
||||||
|
FRFont font = FRFont.getInstance(FRFont.DEFAULT_FONTNAME, Font.PLAIN, widgetStyle.getFontSizeStyle().getFontSize(), textColor); |
||||||
|
//每个预览格子通用的字体绘制
|
||||||
|
BaseUtils.drawStringStyleInRotation(g2d, getWidth(), getHeight(), this.value, |
||||||
|
Style.getInstance(font).deriveHorizontalAlignment(Constants.LEFT) |
||||||
|
.deriveTextStyle(Style.TEXTSTYLE_SINGLELINE), NO_SCALE_RESOLUTION); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,72 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.panel; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.base.svg.IconUtils; |
||||||
|
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle; |
||||||
|
import com.fr.design.border.UIRoundedBorder; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主题界面预览控件单元格子,控件图表直接用icon |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @version 11.0 |
||||||
|
* Created by John.Ying on 2023/3/18 |
||||||
|
*/ |
||||||
|
public class ControlPreviewCellWithIcon extends ControlPreviewCell { |
||||||
|
private static final int CONTROL_ALPHA = 16; |
||||||
|
|
||||||
|
JLabel jLabel; |
||||||
|
Icon icon; |
||||||
|
Icon defaultIcon; |
||||||
|
|
||||||
|
public ControlPreviewCellWithIcon() { |
||||||
|
this(DEFAULT, DEFAULT_MESSAGE); |
||||||
|
} |
||||||
|
|
||||||
|
public ControlPreviewCellWithIcon(String value) { |
||||||
|
this(DEFAULT, value); |
||||||
|
} |
||||||
|
|
||||||
|
public ControlPreviewCellWithIcon(LayoutManager layoutManager, String value) { |
||||||
|
this.setLayout(layoutManager); |
||||||
|
this.value = value; |
||||||
|
this.setPreferredSize(new Dimension(100, 27)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据icon地址绘制一个图标,用jlabel进行展示 |
||||||
|
* |
||||||
|
* @param url icon地址 |
||||||
|
*/ |
||||||
|
public void drawIcon(String url) { |
||||||
|
if (StringUtils.isEmpty(url)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
defaultIcon = IconUtils.readIcon(url); |
||||||
|
icon = setStyleTwoIcon(icon, defaultIcon); |
||||||
|
this.jLabel = new JLabel(icon); |
||||||
|
jLabel.setPreferredSize(new Dimension(21, 17)); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paintComponent(Graphics g) { |
||||||
|
super.paintComponent(g); |
||||||
|
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) reportTheme.getWidgetStyle(); |
||||||
|
//风格一边框不显示主题色
|
||||||
|
Color borderColor = isDefaultStyle() ? DEFAULT_COLOR : widgetStyle.getThemeColor(); |
||||||
|
this.setBorder(new UIRoundedBorder(widgetStyle.getBorderStyle().getLineType() |
||||||
|
, borderColor, widgetStyle.getBorderStyle().getRadius())); |
||||||
|
icon = setStyleTwoIcon(icon, defaultIcon); |
||||||
|
this.jLabel.setIcon(icon); |
||||||
|
this.add(jLabel, BorderLayout.EAST); |
||||||
|
if (widgetStyle.getStyleType() != WidgetThemeDisplayConstants.DEFAULT_STYLE) { |
||||||
|
paintBgColor(g, widgetStyle, CONTROL_ALPHA); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,130 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.panel; |
||||||
|
|
||||||
|
import com.fr.base.background.ColorBackground; |
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.theme.preview.ThemePreviewed; |
||||||
|
import com.fr.general.Background; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.geom.Rectangle2D; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主题界面页面中的参数界面 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @version 11.0 |
||||||
|
* Created by John.Ying on 2023/3/18 |
||||||
|
*/ |
||||||
|
public class ControlPreviewPane extends JPanel implements ThemePreviewed<TemplateTheme> { |
||||||
|
|
||||||
|
public static final int PREVIEW_WIDTH = 615; |
||||||
|
|
||||||
|
public static final int PREVIEW_HEIGHT = 62; |
||||||
|
|
||||||
|
/** |
||||||
|
* 参数界面中放置的所有cell,用于监听主题样式变更 |
||||||
|
*/ |
||||||
|
public final List<ControlPreviewCell> list = new ArrayList<>(); |
||||||
|
|
||||||
|
private Background background; |
||||||
|
|
||||||
|
private static final String DATE_ICON_URL = "/com/fr/web/images/form/resources/date_16.png"; |
||||||
|
|
||||||
|
private static final String COMBOBOX_ICON_URL = "/com/fr/widgettheme/combobox.png"; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void refresh(TemplateTheme style) { |
||||||
|
this.background = style.getParamContainerStyle().getBackground(); |
||||||
|
for (ControlPreviewCell controlPreviewCell : list) { |
||||||
|
controlPreviewCell.refresh(style); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paintComponent(Graphics g) { |
||||||
|
super.paintComponent(g); |
||||||
|
paintBackground((Graphics2D) g); |
||||||
|
} |
||||||
|
|
||||||
|
protected void paintBackground(Graphics2D g2d) { |
||||||
|
if (background == null) { |
||||||
|
background = ColorBackground.getInstance(Color.WHITE); |
||||||
|
} |
||||||
|
background.paint(g2d, new Rectangle2D.Double(0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 初始化参数界面,往里面添加各种cell |
||||||
|
*/ |
||||||
|
public void initControlPreviewPane() { |
||||||
|
initDateControlPane(); |
||||||
|
initComboboxControlPane(); |
||||||
|
initRadioButtonControlPane(); |
||||||
|
initNormalButtonControlPane(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 初始化日期控件包括文字跟控件 |
||||||
|
*/ |
||||||
|
private void initDateControlPane() { |
||||||
|
TextPreviewCell dateTextCell = new TextPreviewCell(Toolkit.i18nText("Fine-Design_Theme_Control_Date_Text")); |
||||||
|
dateTextCell.setPreferredSize(new Dimension(80, 30)); |
||||||
|
ControlPreviewCellWithIcon dateEditorCell = new ControlPreviewCellWithIcon(Toolkit.i18nText("Fine-Design_Theme_Control_Date_Editor_Text")); |
||||||
|
dateEditorCell.drawIcon(DATE_ICON_URL); |
||||||
|
dateEditorCell.setTextColor(ControlPreviewCell.DEFAULT_COLOR); |
||||||
|
this.add(dateTextCell); |
||||||
|
this.add(dateEditorCell); |
||||||
|
this.list.add(dateTextCell); |
||||||
|
this.list.add(dateEditorCell); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 初始化下拉框控件包括文件跟控件 |
||||||
|
*/ |
||||||
|
private void initComboboxControlPane() { |
||||||
|
TextPreviewCell comboBoxTextCell = new TextPreviewCell(Toolkit.i18nText("Fine-Design_Theme_Control_ComboBox_Text")); |
||||||
|
comboBoxTextCell.setPreferredSize(new Dimension(60, 30)); |
||||||
|
ControlPreviewCellWithIcon comboBoxControlPreviewCell = new ControlPreviewCellWithIcon(Toolkit.i18nText("Fine-Design_Theme_Control_ComboBox_Editor_Text")); |
||||||
|
comboBoxControlPreviewCell.drawIcon(COMBOBOX_ICON_URL); |
||||||
|
comboBoxControlPreviewCell.setTextColor(ControlPreviewCell.DEFAULT_COLOR); |
||||||
|
this.add(comboBoxTextCell); |
||||||
|
this.add(comboBoxControlPreviewCell); |
||||||
|
this.list.add(comboBoxControlPreviewCell); |
||||||
|
this.list.add(comboBoxTextCell); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 初始化单选按钮组控件 |
||||||
|
*/ |
||||||
|
private void initRadioButtonControlPane() { |
||||||
|
RingControlPreviewCell ringControlPreviewCell = new RingControlPreviewCell(); |
||||||
|
RoundControlPreviewCell roundControlPreviewCell = new RoundControlPreviewCell(); |
||||||
|
|
||||||
|
TextPreviewCell yearTextFieldCell = new TextPreviewCell(Toolkit.i18nText("Fine-Design_Theme_Control_Radio_Year")); |
||||||
|
yearTextFieldCell.setPreferredSize(new Dimension(38, 30)); |
||||||
|
TextPreviewCell monthTextFieldCell = new TextPreviewCell(Toolkit.i18nText("Fine-Design_Theme_Control_Radio_Month")); |
||||||
|
monthTextFieldCell.setPreferredSize(new Dimension(38, 30)); |
||||||
|
this.add(ringControlPreviewCell); |
||||||
|
this.add(yearTextFieldCell); |
||||||
|
this.add(roundControlPreviewCell); |
||||||
|
this.add(monthTextFieldCell); |
||||||
|
this.list.add(ringControlPreviewCell); |
||||||
|
this.list.add(roundControlPreviewCell); |
||||||
|
this.list.add(yearTextFieldCell); |
||||||
|
this.list.add(monthTextFieldCell); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 初始化按钮预览格子 |
||||||
|
*/ |
||||||
|
private void initNormalButtonControlPane() { |
||||||
|
NormalButtonPreviewCell normalButton = new NormalButtonPreviewCell(FRGUIPaneFactory.createCenterFlowLayout(), ControlPreviewCell.DEFAULT_MESSAGE); |
||||||
|
this.add(normalButton); |
||||||
|
this.list.add(normalButton); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,56 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.panel; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.image.BufferedImage; |
||||||
|
import java.awt.image.WritableRaster; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by johntsai(mailto://johntsai@fanruan.com) on 15/6/23.
|
||||||
|
**/ |
||||||
|
public class ImageUtils { |
||||||
|
|
||||||
|
public static BufferedImage colorImage(BufferedImage image, Color color) { |
||||||
|
int width = image.getWidth(); |
||||||
|
int height = image.getHeight(); |
||||||
|
WritableRaster raster = image.getRaster(); |
||||||
|
|
||||||
|
for (int xx = 0; xx < width; xx++) { |
||||||
|
for (int yy = 0; yy < height; yy++) { |
||||||
|
int[] pixels = raster.getPixel(xx, yy, (int[]) null); |
||||||
|
|
||||||
|
if (pixels[0] > 0 && pixels[0] < 255) { |
||||||
|
pixels[0] = color.getRed(); |
||||||
|
} else { |
||||||
|
pixels[0] = 255; |
||||||
|
} |
||||||
|
if (pixels[1] > 0 && pixels[1] < 255) { |
||||||
|
pixels[1] = color.getGreen(); |
||||||
|
} else { |
||||||
|
pixels[1] = 255; |
||||||
|
} |
||||||
|
if (pixels[2] > 0 && pixels[2] < 255) { |
||||||
|
|
||||||
|
pixels[2] = color.getBlue(); |
||||||
|
} else { |
||||||
|
pixels[2] = 255; |
||||||
|
} |
||||||
|
|
||||||
|
raster.setPixel(xx, yy, pixels); |
||||||
|
} |
||||||
|
} |
||||||
|
return image; |
||||||
|
} |
||||||
|
|
||||||
|
public static BufferedImage imageIconToBufferedImage(ImageIcon icon) { |
||||||
|
BufferedImage bi = new BufferedImage( |
||||||
|
icon.getIconWidth(), |
||||||
|
icon.getIconHeight(), |
||||||
|
BufferedImage.TYPE_INT_ARGB); |
||||||
|
Graphics g = bi.createGraphics(); |
||||||
|
icon.paintIcon(null, g, 0, 0); |
||||||
|
g.dispose(); |
||||||
|
return bi; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.panel; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主题参数面板按钮预览格子 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/3/27 |
||||||
|
*/ |
||||||
|
public class NormalButtonPreviewCell extends ControlPreviewCell { |
||||||
|
|
||||||
|
/** |
||||||
|
* 按钮上的label |
||||||
|
*/ |
||||||
|
private UILabel uiLabel; |
||||||
|
|
||||||
|
public NormalButtonPreviewCell() { |
||||||
|
this(DEFAULT, DEFAULT_MESSAGE); |
||||||
|
} |
||||||
|
|
||||||
|
public NormalButtonPreviewCell(String value) { |
||||||
|
this(DEFAULT, value); |
||||||
|
} |
||||||
|
|
||||||
|
public NormalButtonPreviewCell(LayoutManager layoutManager, String value) { |
||||||
|
this.setLayout(layoutManager); |
||||||
|
this.value = value; |
||||||
|
this.uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Theme_Control_Normal_Button")); |
||||||
|
this.setPreferredSize(new Dimension(80, 27)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paintComponent(Graphics g) { |
||||||
|
super.paintComponent(g); |
||||||
|
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) reportTheme.getWidgetStyle(); |
||||||
|
paintBgColor(g, widgetStyle); |
||||||
|
uiLabel.setForeground(Color.WHITE); |
||||||
|
FRFont font = FRFont.getInstance(FRFont.DEFAULT_FONTNAME, Font.PLAIN, widgetStyle.getFontSizeStyle().getFontSize(), Color.WHITE); |
||||||
|
uiLabel.setFont(font); |
||||||
|
this.add(uiLabel, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.panel; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主题界面预览控件单元格子,单选按钮组被选中的样子 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @version 11.0 |
||||||
|
* Created by John.Ying on 2023/3/18 |
||||||
|
*/ |
||||||
|
public class RingControlPreviewCell extends ControlPreviewCell { |
||||||
|
/** |
||||||
|
* 圆环厚度 |
||||||
|
*/ |
||||||
|
private static final int THICK_NESS = 4; |
||||||
|
|
||||||
|
public RingControlPreviewCell() { |
||||||
|
this(DEFAULT, DEFAULT_MESSAGE); |
||||||
|
} |
||||||
|
|
||||||
|
public RingControlPreviewCell(String value) { |
||||||
|
this(DEFAULT, value); |
||||||
|
} |
||||||
|
|
||||||
|
public RingControlPreviewCell(LayoutManager layoutManager, String value) { |
||||||
|
this.setLayout(layoutManager); |
||||||
|
this.setOpaque(false); |
||||||
|
this.value = value; |
||||||
|
this.setPreferredSize(new Dimension(20, 30)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paintComponent(Graphics g) { |
||||||
|
super.paintComponent(g); |
||||||
|
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) reportTheme.getWidgetStyle(); |
||||||
|
Graphics2D g2d = (Graphics2D) g.create(); |
||||||
|
g2d.setColor(widgetStyle.getThemeColor()); |
||||||
|
g2d.fillOval(5, 9, 15, 15); |
||||||
|
g2d.setColor(Color.WHITE); |
||||||
|
g2d.fillOval(5 + THICK_NESS, 9 + THICK_NESS, 15 - 2 * THICK_NESS, 15 - 2 * THICK_NESS); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,41 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.panel; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主题界面预览控件单元格子,单选按钮组未被选中的样子 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @version 11.0 |
||||||
|
* Created by John.Ying on 2023/3/18 |
||||||
|
*/ |
||||||
|
public class RoundControlPreviewCell extends ControlPreviewCell { |
||||||
|
public RoundControlPreviewCell() { |
||||||
|
this(DEFAULT, DEFAULT_MESSAGE); |
||||||
|
} |
||||||
|
|
||||||
|
public RoundControlPreviewCell(String value) { |
||||||
|
this(DEFAULT, value); |
||||||
|
} |
||||||
|
|
||||||
|
public RoundControlPreviewCell(LayoutManager layoutManager, String value) { |
||||||
|
this.setLayout(layoutManager); |
||||||
|
this.setOpaque(false); |
||||||
|
this.value = value; |
||||||
|
this.setPreferredSize(new Dimension(23, 30)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paintComponent(Graphics g) { |
||||||
|
super.paintComponent(g); |
||||||
|
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) reportTheme.getWidgetStyle(); |
||||||
|
//风格一边框不显示主题色
|
||||||
|
Color borderColor = isDefaultStyle() ? DEFAULT_COLOR : widgetStyle.getThemeColor(); |
||||||
|
Graphics2D g2d = (Graphics2D) g.create(); |
||||||
|
g2d.setColor(borderColor); |
||||||
|
g2d.drawOval(5, 9, 15, 15); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.panel; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* 文字预览格子 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/3/27 |
||||||
|
*/ |
||||||
|
public class TextPreviewCell extends ControlPreviewCell { |
||||||
|
|
||||||
|
public TextPreviewCell(String value) { |
||||||
|
this(DEFAULT, value); |
||||||
|
} |
||||||
|
|
||||||
|
public TextPreviewCell(LayoutManager layoutManager, String value) { |
||||||
|
this.setLayout(layoutManager); |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void refresh(TemplateTheme reportTheme) { |
||||||
|
super.refresh(reportTheme); |
||||||
|
// 文字根据是否深色主题自适应改变
|
||||||
|
if (reportTheme.isDark()) { |
||||||
|
textColor = Color.WHITE; |
||||||
|
} else { |
||||||
|
textColor = Color.BLACK; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,211 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.panel; |
||||||
|
|
||||||
|
import com.fr.base.BaseFormula; |
||||||
|
import com.fr.base.background.ColorBackground; |
||||||
|
import com.fr.base.theme.FormTheme; |
||||||
|
import com.fr.chart.chartattr.ChartCollection; |
||||||
|
import com.fr.chart.chartattr.Title; |
||||||
|
import com.fr.chart.chartdata.NormalChartData; |
||||||
|
import com.fr.chart.charttypes.ChartTypeManager; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.theme.TemplateThemePreviewPane; |
||||||
|
import com.fr.design.mainframe.theme.preview.ChartComponentPreviewPane; |
||||||
|
import com.fr.design.mainframe.theme.preview.UINoOpaquePanel; |
||||||
|
import com.fr.general.Background; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.plugin.chart.PiePlot4VanChart; |
||||||
|
import com.fr.plugin.chart.attr.VanChartLegend; |
||||||
|
import com.fr.plugin.chart.attr.axis.VanChartAxis; |
||||||
|
import com.fr.plugin.chart.base.AttrLabel; |
||||||
|
import com.fr.plugin.chart.base.VanChartTools; |
||||||
|
import com.fr.plugin.chart.column.VanChartColumnPlot; |
||||||
|
import com.fr.plugin.chart.type.GradientType; |
||||||
|
import com.fr.plugin.chart.type.RadiusType; |
||||||
|
import com.fr.plugin.chart.vanchart.VanChart; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.geom.Rectangle2D; |
||||||
|
|
||||||
|
import static com.fr.design.i18n.Toolkit.i18nText; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主题界面预览控frm界面,就是主jar里的那个界面,做了简单的修改 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @version 11.0 |
||||||
|
* Created by John.Ying on 2023/3/18 |
||||||
|
*/ |
||||||
|
public class WidgetDisplayFormThemePreviewPane extends TemplateThemePreviewPane<FormTheme> { |
||||||
|
private WidgetThemeECComponentPreviewPane elementCasePane; |
||||||
|
private Background background; |
||||||
|
private ChartComponentPreviewPane columnChartPreviewPane; |
||||||
|
private ChartComponentPreviewPane pieChartPreviewPane; |
||||||
|
private ControlPreviewPane controlPreviewPane; |
||||||
|
private float alpha = 1.0F; |
||||||
|
|
||||||
|
public WidgetDisplayFormThemePreviewPane() { |
||||||
|
setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
controlPreviewPane = new ControlPreviewPane(); |
||||||
|
controlPreviewPane.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); |
||||||
|
controlPreviewPane.setPreferredSize(new Dimension(615, 40)); |
||||||
|
controlPreviewPane.initControlPreviewPane(); |
||||||
|
JPanel content = new UINoOpaquePanel(); |
||||||
|
content.setLayout(new BorderLayout()); |
||||||
|
add(controlPreviewPane, BorderLayout.NORTH); |
||||||
|
JPanel chartContent = createChartContent(); |
||||||
|
content.add(chartContent, BorderLayout.CENTER); |
||||||
|
content.add(elementCasePane = new WidgetThemeECComponentPreviewPane(), BorderLayout.SOUTH); |
||||||
|
add(content, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createChartContent() { |
||||||
|
JPanel chartContent = new UINoOpaquePanel(); |
||||||
|
chartContent.setLayout(new BorderLayout()); |
||||||
|
JPanel columnChartPanel = new UINoOpaquePanel() { |
||||||
|
public Dimension getPreferredSize() { |
||||||
|
return new Dimension(379, 314); |
||||||
|
} |
||||||
|
}; |
||||||
|
columnChartPanel.setLayout(new BorderLayout()); |
||||||
|
columnChartPreviewPane = createChartPreviewPane(initColumnChart(), i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Comp_Title1")); |
||||||
|
columnChartPanel.add(columnChartPreviewPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
JPanel pieChartPanel = new UINoOpaquePanel() { |
||||||
|
public Dimension getPreferredSize() { |
||||||
|
return new Dimension(236, 314); |
||||||
|
} |
||||||
|
}; |
||||||
|
pieChartPanel.setLayout(new BorderLayout()); |
||||||
|
pieChartPreviewPane = createChartPreviewPane(initPieChart(), i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Comp_Title2")); |
||||||
|
pieChartPanel.add(pieChartPreviewPane, BorderLayout.CENTER); |
||||||
|
chartContent.add(columnChartPanel, BorderLayout.CENTER); |
||||||
|
chartContent.add(pieChartPanel, BorderLayout.EAST); |
||||||
|
return chartContent; |
||||||
|
} |
||||||
|
|
||||||
|
private ChartComponentPreviewPane createChartPreviewPane(ChartCollection chartCollection, String title) { |
||||||
|
ChartComponentPreviewPane chartComponentPreviewPane = new ChartComponentPreviewPane(title); |
||||||
|
chartComponentPreviewPane.getContentPane().populate(chartCollection); |
||||||
|
chartComponentPreviewPane.getContentPane().setCallbackEvent(this); |
||||||
|
return chartComponentPreviewPane; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void refresh(FormTheme theme) { |
||||||
|
background = theme.getBodyStyle().getStyle().getBackground(); |
||||||
|
alpha = theme.getBodyStyle().getStyle().getAlpha(); |
||||||
|
elementCasePane.refresh(theme); |
||||||
|
columnChartPreviewPane.refresh(theme); |
||||||
|
pieChartPreviewPane.refresh(theme); |
||||||
|
controlPreviewPane.refresh(theme); |
||||||
|
repaint(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
protected void paintBackground(Graphics2D g2d) { |
||||||
|
if (background == null) { |
||||||
|
background = ColorBackground.getInstance(Color.WHITE); |
||||||
|
} |
||||||
|
Composite oldComposite = g2d.getComposite(); |
||||||
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha)); |
||||||
|
background.paint(g2d, new Rectangle2D.Double(0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT)); |
||||||
|
g2d.setComposite(oldComposite); |
||||||
|
} |
||||||
|
|
||||||
|
//柱形图
|
||||||
|
private ChartCollection initColumnChart() { |
||||||
|
try { |
||||||
|
VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID)[0].clone(); |
||||||
|
chart.getTitle().setTitleVisible(false); |
||||||
|
VanChartTools vanChartTools = chart.getVanChartTools(); |
||||||
|
vanChartTools.setSort(false); |
||||||
|
vanChartTools.setExport(false); |
||||||
|
vanChartTools.setFullScreen(false); |
||||||
|
|
||||||
|
VanChartColumnPlot plot = chart.getPlot(); |
||||||
|
AttrLabel defaultAttrLabel = plot.getDefaultAttrLabel(); |
||||||
|
defaultAttrLabel.setEnable(true); |
||||||
|
defaultAttrLabel.getAttrLabelDetail().getBorder().setBorderStyle(0); |
||||||
|
defaultAttrLabel.getAttrLabelDetail().getBackground().setBackground(null); |
||||||
|
plot.getConditionCollection().getDefaultAttr().addDataSeriesCondition(defaultAttrLabel); |
||||||
|
|
||||||
|
plot.getLegend().setPosition(Constants.TOP); |
||||||
|
plot.getGradientStyle().setGradientType(GradientType.NONE); |
||||||
|
plot.setSeriesOverlapPercent(30); |
||||||
|
plot.setCategoryIntervalPercent(30); |
||||||
|
|
||||||
|
VanChartAxis defaultYAxis = plot.getDefaultYAxis(); |
||||||
|
Title title = new Title(); |
||||||
|
title.setTextObject(Toolkit.i18nText("Fine-Design_Chart_Axis_Title")); |
||||||
|
title.getTextAttr().setRotation(-90); |
||||||
|
title.getTextAttr().setThemed(true); |
||||||
|
defaultYAxis.setTitle(title); |
||||||
|
defaultYAxis.setShowAxisTitle(true); |
||||||
|
defaultYAxis.setCustomMaxValue(true); |
||||||
|
defaultYAxis.setCustomMinValue(true); |
||||||
|
defaultYAxis.setCustomMainUnit(true); |
||||||
|
defaultYAxis.setMaxValue(BaseFormula.createFormulaBuilder().build("=600")); |
||||||
|
defaultYAxis.setMinValue(BaseFormula.createFormulaBuilder().build("=0")); |
||||||
|
defaultYAxis.setMainUnit(BaseFormula.createFormulaBuilder().build("=200")); |
||||||
|
|
||||||
|
Object[] category = { |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Category") + "1", |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Category") + "2", |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Category") + "3", |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Category") + "4" |
||||||
|
}; |
||||||
|
Object[] series = { |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Series") + "1", |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Series") + "2" |
||||||
|
}; |
||||||
|
Object[][] value = { |
||||||
|
{"250", "540", "300", "410"}, |
||||||
|
{"180", "190", "170", "100"}, |
||||||
|
}; |
||||||
|
NormalChartData normalChartData = new NormalChartData(category, series, value); |
||||||
|
chart.setPreViewChartData(normalChartData); |
||||||
|
ChartCollection chartCollection = new ChartCollection(chart); |
||||||
|
return chartCollection; |
||||||
|
} catch (Exception ex) { |
||||||
|
FineLoggerFactory.getLogger().error(ex.getMessage(), ex); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
//饼图
|
||||||
|
private ChartCollection initPieChart() { |
||||||
|
try { |
||||||
|
VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(PiePlot4VanChart.VAN_CHART_PIE_PLOT)[0].clone(); |
||||||
|
chart.getTitle().setTitleVisible(false); |
||||||
|
VanChartTools vanChartTools = chart.getVanChartTools(); |
||||||
|
vanChartTools.setSort(false); |
||||||
|
vanChartTools.setExport(false); |
||||||
|
vanChartTools.setFullScreen(false); |
||||||
|
|
||||||
|
PiePlot4VanChart plot = chart.getPlot(); |
||||||
|
VanChartLegend legend = (VanChartLegend) plot.getLegend(); |
||||||
|
legend.setPosition(Constants.BOTTOM); |
||||||
|
legend.setCustomSize(true); |
||||||
|
legend.setMaxHeight(28); |
||||||
|
plot.getGradientStyle().setGradientType(GradientType.NONE); |
||||||
|
plot.setInnerRadiusPercent(75); |
||||||
|
plot.getRadius().setRadiusType(RadiusType.FIXED); |
||||||
|
plot.getRadius().setRadius(70); |
||||||
|
|
||||||
|
Object[] category = {StringUtils.EMPTY}; |
||||||
|
Object[] series = {"A1", "B1", "C1", "D1", "E1", "F1", "G1", "H1"}; |
||||||
|
Object[][] value = {{45}, {24}, {12}, {8}, {5}, {3}, {2}, {1},}; |
||||||
|
NormalChartData normalChartData = new NormalChartData(category, series, value); |
||||||
|
chart.setPreViewChartData(normalChartData); |
||||||
|
ChartCollection chartCollection = new ChartCollection(chart); |
||||||
|
return chartCollection; |
||||||
|
} catch (Exception ex) { |
||||||
|
FineLoggerFactory.getLogger().error(ex.getMessage(), ex); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,136 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.panel; |
||||||
|
|
||||||
|
import com.fr.base.BaseFormula; |
||||||
|
import com.fr.base.background.ColorBackground; |
||||||
|
import com.fr.base.theme.ReportTheme; |
||||||
|
import com.fr.chart.chartattr.ChartCollection; |
||||||
|
import com.fr.chart.chartattr.Title; |
||||||
|
import com.fr.chart.chartdata.NormalChartData; |
||||||
|
import com.fr.chart.charttypes.ChartTypeManager; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.theme.TemplateThemePreviewPane; |
||||||
|
import com.fr.design.mainframe.theme.preview.ChartPreviewPane; |
||||||
|
import com.fr.general.Background; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.plugin.chart.attr.axis.VanChartAxis; |
||||||
|
import com.fr.plugin.chart.base.AttrLabel; |
||||||
|
import com.fr.plugin.chart.base.VanChartTools; |
||||||
|
import com.fr.plugin.chart.column.VanChartColumnPlot; |
||||||
|
import com.fr.plugin.chart.type.GradientType; |
||||||
|
import com.fr.plugin.chart.vanchart.VanChart; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
import java.awt.geom.Rectangle2D; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主题界面预览控cpt界面,就是主jar里的那个界面,做了简单的修改 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @version 11.0 |
||||||
|
* Created by John.Ying on 2023/3/18 |
||||||
|
*/ |
||||||
|
public class WidgetDisplayReportThemePreviewPane extends TemplateThemePreviewPane<ReportTheme> { |
||||||
|
private Background background; |
||||||
|
|
||||||
|
private final WidgetThemeECReportPreviewPane reportPreviewPane; |
||||||
|
|
||||||
|
private final ChartPreviewPane chartPreviewPane; |
||||||
|
|
||||||
|
private final ControlPreviewPane controlPreviewPane; |
||||||
|
|
||||||
|
public WidgetDisplayReportThemePreviewPane() { |
||||||
|
setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
chartPreviewPane = new ChartPreviewPane(); |
||||||
|
chartPreviewPane.setPreferredSize(new Dimension(615, 207)); |
||||||
|
chartPreviewPane.populate(initColumnChart()); |
||||||
|
chartPreviewPane.setCallbackEvent(this); |
||||||
|
reportPreviewPane = new WidgetThemeECReportPreviewPane(); |
||||||
|
reportPreviewPane.setPreferredSize(new Dimension(615, 257)); |
||||||
|
controlPreviewPane = new ControlPreviewPane(); |
||||||
|
controlPreviewPane.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); |
||||||
|
controlPreviewPane.setPreferredSize(new Dimension(615, 40)); |
||||||
|
controlPreviewPane.initControlPreviewPane(); |
||||||
|
this.add(reportPreviewPane, BorderLayout.CENTER); |
||||||
|
this.add(chartPreviewPane, BorderLayout.SOUTH); |
||||||
|
this.add(controlPreviewPane, BorderLayout.NORTH); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void refresh(ReportTheme theme) { |
||||||
|
background = theme.getBodyStyle().getBackground(); |
||||||
|
reportPreviewPane.refresh(theme); |
||||||
|
chartPreviewPane.refresh(theme); |
||||||
|
controlPreviewPane.refresh(theme); |
||||||
|
repaint(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
protected void paintBackground(Graphics2D g2d) { |
||||||
|
if (background == null) { |
||||||
|
background = ColorBackground.getInstance(Color.WHITE); |
||||||
|
} |
||||||
|
background.paint(g2d, new Rectangle2D.Double(0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//柱形图
|
||||||
|
private ChartCollection initColumnChart() { |
||||||
|
try { |
||||||
|
VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID)[0].clone(); |
||||||
|
VanChartTools vanChartTools = chart.getVanChartTools(); |
||||||
|
vanChartTools.setSort(false); |
||||||
|
vanChartTools.setExport(false); |
||||||
|
vanChartTools.setFullScreen(false); |
||||||
|
|
||||||
|
VanChartColumnPlot plot = chart.getPlot(); |
||||||
|
AttrLabel defaultAttrLabel = plot.getDefaultAttrLabel(); |
||||||
|
defaultAttrLabel.setEnable(true); |
||||||
|
defaultAttrLabel.getAttrLabelDetail().getBorder().setBorderStyle(0); |
||||||
|
defaultAttrLabel.getAttrLabelDetail().getBackground().setBackground(null); |
||||||
|
plot.getConditionCollection().getDefaultAttr().addDataSeriesCondition(defaultAttrLabel); |
||||||
|
|
||||||
|
plot.getGradientStyle().setGradientType(GradientType.NONE); |
||||||
|
plot.setSeriesOverlapPercent(30); |
||||||
|
plot.setCategoryIntervalPercent(30); |
||||||
|
|
||||||
|
VanChartAxis defaultYAxis = plot.getDefaultYAxis(); |
||||||
|
Title title = new Title(); |
||||||
|
title.setTextObject(Toolkit.i18nText("Fine-Design_Chart_Axis_Title")); |
||||||
|
title.getTextAttr().setRotation(-90); |
||||||
|
title.getTextAttr().setThemed(true); |
||||||
|
defaultYAxis.setTitle(title); |
||||||
|
defaultYAxis.setShowAxisTitle(true); |
||||||
|
defaultYAxis.setCustomMaxValue(true); |
||||||
|
defaultYAxis.setCustomMinValue(true); |
||||||
|
defaultYAxis.setCustomMainUnit(true); |
||||||
|
defaultYAxis.setMaxValue(BaseFormula.createFormulaBuilder().build("=600")); |
||||||
|
defaultYAxis.setMinValue(BaseFormula.createFormulaBuilder().build("=0")); |
||||||
|
defaultYAxis.setMainUnit(BaseFormula.createFormulaBuilder().build("=200")); |
||||||
|
|
||||||
|
Object[] category = { |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Category") + "1", |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Category") + "2", |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Category") + "3", |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Category") + "4" |
||||||
|
}; |
||||||
|
Object[] series = { |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Series") + "1", |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Series") + "2", |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Series") + "3" |
||||||
|
}; |
||||||
|
Object[][] value = { |
||||||
|
{"340", "510", "300", "250"}, |
||||||
|
{"180", "360", "170", "100"}, |
||||||
|
{"210", "205", "405", "190"} |
||||||
|
}; |
||||||
|
NormalChartData normalChartData = new NormalChartData(category, series, value); |
||||||
|
chart.setPreViewChartData(normalChartData); |
||||||
|
ChartCollection chartCollection = new ChartCollection(chart); |
||||||
|
return chartCollection; |
||||||
|
} catch (Exception ex) { |
||||||
|
FineLoggerFactory.getLogger().error(ex.getMessage(), ex); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.panel; |
||||||
|
|
||||||
|
import com.fr.base.theme.FormTheme; |
||||||
|
import com.fr.design.mainframe.theme.preview.ComponentPreviewPane; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
import static com.fr.design.i18n.Toolkit.i18nText; |
||||||
|
|
||||||
|
/** |
||||||
|
* 决策报表主题界面的那个表格+标题部分 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @version 1.0 |
||||||
|
* Created by John.Ying on 2021/3/18 |
||||||
|
*/ |
||||||
|
public class WidgetThemeECComponentPreviewPane extends ComponentPreviewPane { |
||||||
|
private WidgetThemeECPreviewPane contentPane; |
||||||
|
|
||||||
|
public WidgetThemeECComponentPreviewPane() { |
||||||
|
super(i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_EC_Title")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected Component createContentPane() { |
||||||
|
contentPane = new WidgetThemeECPreviewPane(); |
||||||
|
return contentPane; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void refresh(FormTheme theme) { |
||||||
|
super.refresh(theme); |
||||||
|
contentPane.refresh(theme); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,109 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.panel; |
||||||
|
|
||||||
|
import com.fr.base.CellBorderSourceFlag; |
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.base.theme.settings.ThemedCellStyleList; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.theme.preview.UINoOpaquePanel; |
||||||
|
import com.fr.design.mainframe.theme.preview.ecpreview.AbstractECPreviewPane; |
||||||
|
import com.fr.design.mainframe.theme.preview.ecpreview.cell.AbstractPreviewCell; |
||||||
|
import com.fr.design.mainframe.theme.preview.ecpreview.cell.PreviewCell; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主题界面frm里的那个表格,做了简单修改,削减了几行重复内容,腾出控件参数面板的空间 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @version 1.0 |
||||||
|
* Created by John.Ying on 2021/3/18 |
||||||
|
*/ |
||||||
|
public class WidgetThemeECPreviewPane extends AbstractECPreviewPane { |
||||||
|
private final List<AbstractPreviewCell> headerCellList = new ArrayList<>(); |
||||||
|
private final List<AbstractPreviewCell> contentCellList = new ArrayList<>(); |
||||||
|
private final List<AbstractPreviewCell> highLightCellList = new ArrayList<>(); |
||||||
|
private final List<AbstractPreviewCell> assistCellList = new ArrayList<>(); |
||||||
|
private static final int COL_COUNT = 5; |
||||||
|
private static final int CONTENT_ROW_COUNT = 1; |
||||||
|
|
||||||
|
public WidgetThemeECPreviewPane() { |
||||||
|
this.setPreferredSize(new Dimension(517, 158 - 36)); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(0, 1, 2, 1)); |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
JPanel titlePane = new UINoOpaquePanel(new GridLayout()); |
||||||
|
JPanel extCenterPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); |
||||||
|
this.add(extCenterPane, BorderLayout.CENTER); |
||||||
|
extCenterPane.add(titlePane, BorderLayout.NORTH); |
||||||
|
for (int c = 0; c < COL_COUNT; c++) { |
||||||
|
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header")); |
||||||
|
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER; |
||||||
|
if (c > 0) { |
||||||
|
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
if (c < COL_COUNT - 1) { |
||||||
|
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
cell.setBorderSourceFlag(flag); |
||||||
|
cell.setPreferredSize(new Dimension(103, 36)); |
||||||
|
titlePane.add(cell); |
||||||
|
headerCellList.add(cell); |
||||||
|
} |
||||||
|
JPanel contentPane = new UINoOpaquePanel(new GridLayout(1, 5, 0, 0)); |
||||||
|
extCenterPane.add(contentPane, BorderLayout.CENTER); |
||||||
|
for (int i = 0; i < COL_COUNT * CONTENT_ROW_COUNT; i++) { |
||||||
|
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Main_Text")); |
||||||
|
int c = i % COL_COUNT; |
||||||
|
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER; |
||||||
|
if (c > 0) { |
||||||
|
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
if (c < COL_COUNT - 1) { |
||||||
|
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
cell.setBorderSourceFlag(flag); |
||||||
|
cell.setPreferredSize(new Dimension(103, 30)); |
||||||
|
contentPane.add(cell); |
||||||
|
contentCellList.add(cell); |
||||||
|
} |
||||||
|
|
||||||
|
JPanel endPane = new UINoOpaquePanel(new GridLayout()); |
||||||
|
extCenterPane.add(endPane, BorderLayout.SOUTH); |
||||||
|
for (int c = 0; c < COL_COUNT; c++) { |
||||||
|
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text")); |
||||||
|
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER; |
||||||
|
if (c > 0) { |
||||||
|
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
if (c < COL_COUNT - 1) { |
||||||
|
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
cell.setBorderSourceFlag(flag); |
||||||
|
cell.setPreferredSize(new Dimension(103, 30)); |
||||||
|
endPane.add(cell); |
||||||
|
highLightCellList.add(cell); |
||||||
|
} |
||||||
|
|
||||||
|
JPanel extSouthPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); |
||||||
|
PreviewCell assistCell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Assist_Text")); |
||||||
|
assistCell.setBorderSourceFlag(CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER); |
||||||
|
assistCell.setPreferredSize(new Dimension(123, 30)); |
||||||
|
assistCellList.add(assistCell); |
||||||
|
extSouthPane.add(assistCell); |
||||||
|
this.add(extSouthPane, BorderLayout.SOUTH); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void refresh(TemplateTheme theme) { |
||||||
|
ThemedCellStyleList cellStyleConfig = theme.getCellStyleList(); |
||||||
|
refresh(headerCellList, cellStyleConfig.getUse4Header()); |
||||||
|
refresh(contentCellList, cellStyleConfig.getUse4MainText()); |
||||||
|
refresh(highLightCellList, cellStyleConfig.getUse4HighlightText()); |
||||||
|
refresh(assistCellList, cellStyleConfig.getUse4SupportInfo()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,197 @@ |
|||||||
|
package com.fr.controldisplayenhance.theme.panel; |
||||||
|
|
||||||
|
import com.fr.base.CellBorderSourceFlag; |
||||||
|
import com.fr.base.theme.ReportTheme; |
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.base.theme.settings.ThemedCellStyleList; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.theme.preview.ThemePreviewed; |
||||||
|
import com.fr.design.mainframe.theme.preview.UINoOpaquePanel; |
||||||
|
import com.fr.design.mainframe.theme.preview.ecpreview.AbstractECPreviewPane; |
||||||
|
import com.fr.design.mainframe.theme.preview.ecpreview.cell.AbstractPreviewCell; |
||||||
|
import com.fr.design.mainframe.theme.preview.ecpreview.cell.CornerPreviewCell; |
||||||
|
import com.fr.design.mainframe.theme.preview.ecpreview.cell.PreviewCell; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.geom.Point2D; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主题界面report里的那个表格,做了简单修改,削减了几行重复内容,腾出控件参数面板的空间 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @version 1.0 |
||||||
|
* Created by John.Ying on 2021/3/18 |
||||||
|
*/ |
||||||
|
public class WidgetThemeECReportPreviewPane extends UINoOpaquePanel implements ThemePreviewed<ReportTheme> { |
||||||
|
private final List<AbstractPreviewCell> headerTitleCellList = new ArrayList<>(); // 大标题样式单元格
|
||||||
|
private final List<AbstractPreviewCell> headerCellList = new ArrayList<>(); // 表头样式单元格
|
||||||
|
private final List<AbstractPreviewCell> titleCellList = new ArrayList<>(); // 小标题样式单元格
|
||||||
|
private final List<AbstractPreviewCell> contentCellList = new ArrayList<>(); // 正文样式单元格
|
||||||
|
private final List<AbstractPreviewCell> highLightCellList = new ArrayList<>(); // 高亮文本样式单元格
|
||||||
|
private final List<AbstractPreviewCell> assistCellList = new ArrayList<>(); // 辅助信息样式单元格
|
||||||
|
private static final int CONTENT_ROW_COUNT = 3; |
||||||
|
private static final int COL_COUNT = 3; |
||||||
|
|
||||||
|
private final PreviewPane previewPane; |
||||||
|
|
||||||
|
public WidgetThemeECReportPreviewPane() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
previewPane = new PreviewPane(); |
||||||
|
this.add(previewPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void refresh(ReportTheme theme) { |
||||||
|
previewPane.refresh(theme); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
class PreviewPane extends AbstractECPreviewPane { |
||||||
|
|
||||||
|
|
||||||
|
public PreviewPane() { |
||||||
|
this.setPreferredSize(new Dimension(517, 208)); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); |
||||||
|
|
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
JPanel northPane = createNorthPane(); |
||||||
|
JPanel centerPane = createCenterPane(); |
||||||
|
JPanel southPane = createSouthPane(); |
||||||
|
this.add(northPane, BorderLayout.NORTH); |
||||||
|
this.add(centerPane, BorderLayout.CENTER); |
||||||
|
this.add(southPane, BorderLayout.SOUTH); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createNorthPane() { |
||||||
|
JPanel northPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); |
||||||
|
AbstractPreviewCell bigTitleCell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Cell_Style_Big_Title")); |
||||||
|
bigTitleCell.setBorderSourceFlag(CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER); |
||||||
|
bigTitleCell.setPreferredSize(new Dimension(615, 46)); |
||||||
|
headerTitleCellList.add(bigTitleCell); |
||||||
|
northPane.add(bigTitleCell, BorderLayout.NORTH); |
||||||
|
CornerPreviewCell cornerCell = new CornerPreviewCell(new String[]{Toolkit.i18nText("Fine-Design_Basic_Column_Name"), |
||||||
|
Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_EC_Data"), Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Row_Name")}, |
||||||
|
new Point2D[]{new Point(159, 71), new Point(225, 49)}); |
||||||
|
cornerCell.setBorderSourceFlag(CellBorderSourceFlag.INVALID_BORDER_SOURCE); |
||||||
|
cornerCell.setPreferredSize(new Dimension(225, 71)); |
||||||
|
titleCellList.add(cornerCell); |
||||||
|
northPane.add(cornerCell, BorderLayout.WEST); |
||||||
|
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); |
||||||
|
northPane.add(centerPane, BorderLayout.CENTER); |
||||||
|
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Small_Title")); |
||||||
|
cell.setBorderSourceFlag(CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER); |
||||||
|
titleCellList.add(cell); |
||||||
|
cell.setPreferredSize(new Dimension(308, 38)); |
||||||
|
centerPane.add(cell, BorderLayout.NORTH); |
||||||
|
JPanel eastSouthPane = new UINoOpaquePanel(new GridLayout()); |
||||||
|
for (int c = 0; c < CONTENT_ROW_COUNT; c++) { |
||||||
|
PreviewCell headerCell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header")); |
||||||
|
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER; |
||||||
|
if (c > 0) { |
||||||
|
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
if (c < CONTENT_ROW_COUNT - 1) { |
||||||
|
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
headerCell.setBorderSourceFlag(flag); |
||||||
|
headerCellList.add(headerCell); |
||||||
|
eastSouthPane.add(headerCell); |
||||||
|
} |
||||||
|
centerPane.add(eastSouthPane, BorderLayout.CENTER); |
||||||
|
return northPane; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createCenterPane() { |
||||||
|
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); |
||||||
|
JPanel westPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); |
||||||
|
centerPane.add(westPane, BorderLayout.WEST); |
||||||
|
PreviewCell cell1 = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Small_Title")); |
||||||
|
titleCellList.add(cell1); |
||||||
|
cell1.setPreferredSize(new Dimension(112, 93)); |
||||||
|
westPane.add(cell1, BorderLayout.WEST); |
||||||
|
JPanel gridPane = new UINoOpaquePanel(new GridLayout(3, 1)); |
||||||
|
for (int r = 0; r < 3; r++) { |
||||||
|
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header")); |
||||||
|
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER; |
||||||
|
if (r > 0) { |
||||||
|
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
if (r < COL_COUNT - 1) { |
||||||
|
flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
cell.setBorderSourceFlag(flag); |
||||||
|
cell.setPreferredSize(new Dimension(113, 31)); |
||||||
|
headerCellList.add(cell); |
||||||
|
gridPane.add(cell); |
||||||
|
} |
||||||
|
westPane.add(gridPane, BorderLayout.CENTER); |
||||||
|
JPanel innerCenterPane = new UINoOpaquePanel(new GridLayout(3, 3)); |
||||||
|
centerPane.add(innerCenterPane, BorderLayout.CENTER); |
||||||
|
for (int i = 0; i < COL_COUNT*CONTENT_ROW_COUNT; i++) { |
||||||
|
PreviewCell cell ; |
||||||
|
int r = i / CONTENT_ROW_COUNT; |
||||||
|
int c = i % CONTENT_ROW_COUNT; |
||||||
|
if (c == CONTENT_ROW_COUNT - 1) { |
||||||
|
cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text")); |
||||||
|
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER; |
||||||
|
if (r != 0) { |
||||||
|
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
if (r != COL_COUNT - 1) { |
||||||
|
flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
cell.setBorderSourceFlag(flag); |
||||||
|
highLightCellList.add(cell); |
||||||
|
} else { |
||||||
|
cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Main_Text")); |
||||||
|
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER; |
||||||
|
if (r > 0) { |
||||||
|
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
if (r < COL_COUNT - 1) { |
||||||
|
flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
if (c > 0) { |
||||||
|
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
if (c < CONTENT_ROW_COUNT - 2) { |
||||||
|
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER; |
||||||
|
} |
||||||
|
cell.setBorderSourceFlag(flag); |
||||||
|
|
||||||
|
contentCellList.add(cell); |
||||||
|
} |
||||||
|
cell.setPreferredSize(new Dimension(123, 31)); |
||||||
|
innerCenterPane.add(cell); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
return centerPane; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createSouthPane(){ |
||||||
|
JPanel southPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); |
||||||
|
PreviewCell assistCell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Assist_Text")); |
||||||
|
assistCell.setBorderSourceFlag(CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER); |
||||||
|
assistCell.setPreferredSize(new Dimension(123, 30)); |
||||||
|
assistCellList.add(assistCell); |
||||||
|
southPane.add(assistCell, BorderLayout.CENTER); |
||||||
|
return southPane; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void refresh(TemplateTheme theme) { |
||||||
|
ThemedCellStyleList cellStyleConfig = theme.getCellStyleList(); |
||||||
|
refresh(headerTitleCellList, cellStyleConfig.getUse4BigTitle()); |
||||||
|
refresh(headerCellList, cellStyleConfig.getUse4Header()); |
||||||
|
refresh(contentCellList, cellStyleConfig.getUse4MainText()); |
||||||
|
refresh(titleCellList, cellStyleConfig.getUse4SmallTitle()); |
||||||
|
refresh(highLightCellList, cellStyleConfig.getUse4HighlightText()); |
||||||
|
refresh(assistCellList, cellStyleConfig.getUse4SupportInfo()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,56 @@ |
|||||||
|
package com.fr.controldisplayenhance.util; |
||||||
|
|
||||||
|
import com.fr.base.io.AttrMark; |
||||||
|
import com.fr.base.io.IOFile; |
||||||
|
import com.fr.design.file.HistoryTemplateListCache; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.widgettheme.control.attr.WidgetDisplayEnhanceMarkAttr; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Bruce.Deng |
||||||
|
* @version 11.0 |
||||||
|
* Created by Bruce.Deng on 2022/12/1 |
||||||
|
*/ |
||||||
|
public class WidgetThemeDesignerUtils { |
||||||
|
|
||||||
|
private WidgetThemeDesignerUtils() { |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 从 WorkBook 中加载 WatermarkAttr 属性对象 |
||||||
|
* |
||||||
|
* @param template AttrMark 对象,包括 WorkBook |
||||||
|
* @return StrongestControlMarkAttr 对象 |
||||||
|
*/ |
||||||
|
public static WidgetDisplayEnhanceMarkAttr getStrongestControlAttrFromTemplate(AttrMark template) { |
||||||
|
return template.getAttrMark(WidgetDisplayEnhanceMarkAttr.XML_TAG); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 判断是否启用了控件显示增强 |
||||||
|
* |
||||||
|
* @return 开启与否 |
||||||
|
*/ |
||||||
|
public static boolean enableWidgetEnhance() { |
||||||
|
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||||
|
if (JTemplate.isValid(jTemplate)) { |
||||||
|
IOFile ioFile = (IOFile) jTemplate.getTarget(); |
||||||
|
WidgetDisplayEnhanceMarkAttr mark = ioFile.getAttrMark(WidgetDisplayEnhanceMarkAttr.XML_TAG); |
||||||
|
return mark != null && mark.isWidgetEnhance(); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 判断当前widget是否为新多选下拉树控件 |
||||||
|
*/ |
||||||
|
public static boolean isNewComboBoxTreeEditor(Object widget) { |
||||||
|
String className = widget.getClass().getName(); |
||||||
|
if (widget instanceof Class) { |
||||||
|
className = ((Class) widget).getName(); |
||||||
|
} |
||||||
|
return StringUtils.equals(className, "com.fr.plugin.widget.newcomboboxtree.NewComboBoxTreeEditor") |
||||||
|
|| StringUtils.equals(className, "com.fr.plugin.widget.newcomboboxtree.XNewComboBoxTreeEditor"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,268 @@ |
|||||||
|
package com.fr.controldisplayenhance.widget.mobile.pane; |
||||||
|
|
||||||
|
import com.fr.base.background.ColorBackground; |
||||||
|
import com.fr.widgettheme.theme.widget.style.MobileThemedWidgetStyle; |
||||||
|
import com.fr.widgettheme.theme.widget.mobile.style.WidgetThemeMobileCommonExtraStyle; |
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.constants.LayoutConstants; |
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
|
import com.fr.design.file.HistoryTemplateListCache; |
||||||
|
import com.fr.design.gui.icombobox.LineComboBox; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.ispinner.UISpinner; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; |
||||||
|
import com.fr.design.style.color.ColorSelectBox; |
||||||
|
import com.fr.design.style.color.NewColorSelectBox; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.mobile.MobileCommonExtraStyle; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.invoke.Reflect; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.border.EmptyBorder; |
||||||
|
import javax.swing.border.TitledBorder; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ItemEvent; |
||||||
|
import java.awt.event.ItemListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> 开启控件显示增强后替换原通用属性面板 |
||||||
|
* <p> 参考{@link com.fr.design.mainframe.mobile.ui.MobileStyleDefinePane} |
||||||
|
* |
||||||
|
* @author Coral.Chen |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/4/11 |
||||||
|
*/ |
||||||
|
public class DisplayEnhanceMobileStyleDefinePane extends BasicBeanPane<MobileStyle> { |
||||||
|
public static final int NORMAL_COMBO_WIDTH = 152; |
||||||
|
protected Widget widget; |
||||||
|
protected MobileStyleCustomDefinePane customBeanPane; |
||||||
|
protected Class<? extends MobileStyle> mobileStyleClazz; |
||||||
|
protected UIComboBox customCombo; |
||||||
|
protected JPanel settingPane; |
||||||
|
protected NewColorSelectBox themeColorSelectBox; |
||||||
|
protected Color titleColor = new Color(47, 142, 241); |
||||||
|
protected JPanel commonPane; |
||||||
|
protected LineComboBox borderType; |
||||||
|
protected UISpinner borderRadius; |
||||||
|
protected MobileStyleFontConfigPane fontConfigPane; |
||||||
|
protected ColorSelectBox widgetBackgroundSelectBox; |
||||||
|
|
||||||
|
protected MobileStyle mobileStyle; |
||||||
|
|
||||||
|
public DisplayEnhanceMobileStyleDefinePane(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) { |
||||||
|
MobileCommonExtraStyle extraStyle = ob.getMobileCommonExtraStyle(); |
||||||
|
if (extraStyle instanceof WidgetThemeMobileCommonExtraStyle) { |
||||||
|
WidgetThemeMobileCommonExtraStyle style = (WidgetThemeMobileCommonExtraStyle) extraStyle; |
||||||
|
customCombo.setSelectedIndex(style.isCustom() ? 1 : 0); |
||||||
|
borderType.setSelectedLineStyle(style.getBorderType()); |
||||||
|
borderRadius.setValue(style.getBorderRadius()); |
||||||
|
if (style.getThemeColor() != null) { |
||||||
|
themeColorSelectBox.setSelectObject(style.getThemeColor()); |
||||||
|
} |
||||||
|
if (style.getNewFont() != null) { |
||||||
|
fontConfigPane.populateBean(style.getNewFont()); |
||||||
|
} |
||||||
|
if (style.getWidgetBackground() != null) { |
||||||
|
widgetBackgroundSelectBox.setSelectObject(((ColorBackground) style.getWidgetBackground()).getColor()); |
||||||
|
} |
||||||
|
} |
||||||
|
this.customBeanPane.populateBean(ob); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public MobileStyle updateBean() { |
||||||
|
mobileStyle = Reflect.on(mobileStyleClazz).create().get(); |
||||||
|
WidgetThemeMobileCommonExtraStyle extraStyle = new WidgetThemeMobileCommonExtraStyle(); |
||||||
|
extraStyle.setCustom(customCombo.getSelectedIndex() == 1); |
||||||
|
extraStyle.setThemeColor(themeColorSelectBox.getSelectObject()); |
||||||
|
extraStyle.setBorderType(borderType.getSelectedLineStyle()); |
||||||
|
extraStyle.setBorderRadius(borderRadius.getValue()); |
||||||
|
extraStyle.setNewFont(fontConfigPane.updateBean()); |
||||||
|
extraStyle.setWidgetBackground(ColorBackground.getInstance(widgetBackgroundSelectBox.getSelectObject())); |
||||||
|
mobileStyle.setMobileCommonExtraStyle(extraStyle); |
||||||
|
this.widget.setMobileStyle(mobileStyle); |
||||||
|
this.customBeanPane.updateBean(); |
||||||
|
return mobileStyle; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return StringUtils.EMPTY; |
||||||
|
} |
||||||
|
|
||||||
|
private void init() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
createGeneralPane(); |
||||||
|
createCustomPane(); |
||||||
|
} |
||||||
|
|
||||||
|
protected void createFontPane(Color defaultFontColor) { |
||||||
|
fontConfigPane = new MobileStyleFontConfigPane(defaultFontColor); |
||||||
|
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Font")), fontConfigPane)); |
||||||
|
} |
||||||
|
|
||||||
|
private void createGeneralPane() { |
||||||
|
createPreviewPane(); |
||||||
|
createCommonPane(); |
||||||
|
} |
||||||
|
|
||||||
|
private void createPreviewPane() { |
||||||
|
JPanel mobileStylePreviewPane = Reflect.on(customBeanPane).call("createPreviewPane").get(); |
||||||
|
if (mobileStylePreviewPane != null) { |
||||||
|
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Widget_Style_Preview")); |
||||||
|
previewPane.setBorder(titledBorder); |
||||||
|
previewPane.setPreferredSize(new Dimension(500, 83)); |
||||||
|
previewPane.add(mobileStylePreviewPane, BorderLayout.CENTER); |
||||||
|
this.add(previewPane, BorderLayout.NORTH); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void createCommonPane() { |
||||||
|
TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute")); |
||||||
|
commonPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); |
||||||
|
commonPane.setBorder(titledBorder); |
||||||
|
this.add(commonPane, BorderLayout.NORTH); |
||||||
|
|
||||||
|
|
||||||
|
customCombo = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Mobile_Default"), Toolkit.i18nText("Fine-Design_Mobile_Custom")}); |
||||||
|
customCombo.setSelectedIndex(0); |
||||||
|
customCombo.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 15, 20)); |
||||||
|
customCombo.addItemListener(new ItemListener() { |
||||||
|
@Override |
||||||
|
public void itemStateChanged(ItemEvent e) { |
||||||
|
boolean custom = customCombo.getSelectedIndex() == 1; |
||||||
|
settingPane.setVisible(custom); |
||||||
|
} |
||||||
|
}); |
||||||
|
commonPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Attribute_Settings")), customCombo)); |
||||||
|
|
||||||
|
settingPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); |
||||||
|
settingPane.setBorder(new EmptyBorder(-10, 0, 0, 0)); |
||||||
|
settingPane.setVisible(false); |
||||||
|
commonPane.add(settingPane); |
||||||
|
createUniversalPane(); |
||||||
|
} |
||||||
|
|
||||||
|
protected void createUniversalPane() { |
||||||
|
// 主题色
|
||||||
|
createThemePane(); |
||||||
|
// 组件背景
|
||||||
|
createBackgroundPane(); |
||||||
|
// 边框线型
|
||||||
|
createBorderLinePane(); |
||||||
|
// 圆角边框
|
||||||
|
createBorderRadiusPane(); |
||||||
|
// 字体
|
||||||
|
createFontPane(WidgetThemeDisplayConstants.DEFAULT_FONT_COLOR_BLACK); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
protected void createBackgroundPane() { |
||||||
|
widgetBackgroundSelectBox = new ColorSelectBox(NORMAL_COMBO_WIDTH); |
||||||
|
initBackgroundColor(); |
||||||
|
JPanel backgroundPane = createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Background")), widgetBackgroundSelectBox); |
||||||
|
settingPane.add(backgroundPane); |
||||||
|
} |
||||||
|
|
||||||
|
protected void initBackgroundColor() { |
||||||
|
widgetBackgroundSelectBox.setSelectObject(WidgetThemeDisplayConstants.DEFAULT_TRANSPARENT_COLOR); |
||||||
|
} |
||||||
|
|
||||||
|
protected void createThemePane() { |
||||||
|
themeColorSelectBox = new NewColorSelectBox(NORMAL_COMBO_WIDTH); |
||||||
|
// 默认为当前模板选中的主题色
|
||||||
|
themeColorSelectBox.setSelectObject(getCurrentTemplateThemeColor()); |
||||||
|
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Basic_Theme_Color")), themeColorSelectBox)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
protected void createBorderLinePane() { |
||||||
|
borderType = new LineComboBox(WidgetThemeDisplayConstants.MOBILE_BORDER_LINE_STYLE_ARRAY); |
||||||
|
initDefaultLineType(); |
||||||
|
borderType.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 15, 20)); |
||||||
|
// 边框线型
|
||||||
|
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderType")), borderType)); |
||||||
|
} |
||||||
|
|
||||||
|
protected void initDefaultLineType() { |
||||||
|
borderType.setSelectedLineStyle(Constants.LINE_THIN); |
||||||
|
} |
||||||
|
|
||||||
|
protected void createBorderRadiusPane() { |
||||||
|
borderRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2); |
||||||
|
borderRadius.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 20, 20)); |
||||||
|
// 圆角边框
|
||||||
|
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderRadius")), borderRadius)); |
||||||
|
} |
||||||
|
|
||||||
|
protected void createCustomPane() { |
||||||
|
JPanel configPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Set")); |
||||||
|
configPane.setBorder(titledBorder); |
||||||
|
|
||||||
|
configPane.add(this.customBeanPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
this.add(configPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
protected TitledBorder createTitledBorder(String title) { |
||||||
|
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(title, titleColor); |
||||||
|
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12)); |
||||||
|
return titledBorder; |
||||||
|
} |
||||||
|
|
||||||
|
protected UILabel createConfigLabel(String title) { |
||||||
|
UILabel label = new UILabel(title, UILabel.LEFT); |
||||||
|
label.setPreferredSize(new Dimension(75, 20)); |
||||||
|
label.setBorder(new EmptyBorder(0, 15, 0, 0)); |
||||||
|
return label; |
||||||
|
} |
||||||
|
|
||||||
|
protected JPanel createLeftRightComponentsPane(Component... components) { |
||||||
|
JPanel tableLayoutPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{components}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||||
|
return tableLayoutPane; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取当前编辑移动端控件样式主题色 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
protected Color getCurrentTemplateThemeColor() { |
||||||
|
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||||
|
Color themeColor = WidgetThemeDisplayConstants.DEFAULT_THEME_COLOR; |
||||||
|
if (JTemplate.isValid(jTemplate)) { |
||||||
|
MobileThemedWidgetStyle mobileWidgetStyle = (MobileThemedWidgetStyle) jTemplate.getTemplateTheme().getMobileWidgetStyle(); |
||||||
|
mobileWidgetStyle = mobileWidgetStyle == null ? new MobileThemedWidgetStyle() : mobileWidgetStyle; |
||||||
|
themeColor = mobileWidgetStyle.getThemeColor(); |
||||||
|
} |
||||||
|
return themeColor; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,59 @@ |
|||||||
|
package com.fr.controldisplayenhance.widget.mobile.pane; |
||||||
|
|
||||||
|
import com.fr.base.background.ColorBackground; |
||||||
|
import com.fr.widgettheme.theme.widget.mobile.style.FileEditorStyle; |
||||||
|
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.invoke.Reflect; |
||||||
|
|
||||||
|
/** |
||||||
|
* 文件属性定义面板 |
||||||
|
* |
||||||
|
* @author Coral.Chen |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/5/19 |
||||||
|
*/ |
||||||
|
public class FileEditorMobileStyleDefinePane extends DisplayEnhanceMobileStyleDefinePane { |
||||||
|
|
||||||
|
public FileEditorMobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass, Class<? extends MobileStyle> mobileStyleClazz) { |
||||||
|
super(widget, customBeanPaneClass, mobileStyleClazz); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(MobileStyle ob) { |
||||||
|
MobileCommonExtraStyle extraStyle = ob.getMobileCommonExtraStyle(); |
||||||
|
if (extraStyle instanceof FileEditorStyle) { |
||||||
|
FileEditorStyle style = (FileEditorStyle) extraStyle; |
||||||
|
customCombo.setSelectedIndex(style.isCustom() ? 1 : 0); |
||||||
|
if (style.getWidgetBackground() != null) { |
||||||
|
widgetBackgroundSelectBox.setSelectObject(((ColorBackground) style.getWidgetBackground()).getColor()); |
||||||
|
} |
||||||
|
borderType.setSelectedLineStyle(style.getBorderType()); |
||||||
|
borderRadius.setValue(style.getBorderRadius()); |
||||||
|
} |
||||||
|
this.customBeanPane.populateBean(ob); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public MobileStyle updateBean() { |
||||||
|
mobileStyle = Reflect.on(mobileStyleClazz).create().get(); |
||||||
|
FileEditorStyle extraStyle = new FileEditorStyle(); |
||||||
|
extraStyle.setCustom(customCombo.getSelectedIndex() == 1); |
||||||
|
extraStyle.setWidgetBackground(ColorBackground.getInstance(widgetBackgroundSelectBox.getSelectObject())); |
||||||
|
extraStyle.setBorderType(borderType.getSelectedLineStyle()); |
||||||
|
extraStyle.setBorderRadius(borderRadius.getValue()); |
||||||
|
mobileStyle.setMobileCommonExtraStyle(extraStyle); |
||||||
|
this.widget.setMobileStyle(mobileStyle); |
||||||
|
this.customBeanPane.updateBean(); |
||||||
|
return mobileStyle; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void createUniversalPane() { |
||||||
|
createBackgroundPane(); |
||||||
|
createBorderLinePane(); |
||||||
|
createBorderRadiusPane(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,93 @@ |
|||||||
|
package com.fr.controldisplayenhance.widget.mobile.pane; |
||||||
|
|
||||||
|
import com.fr.base.background.ColorBackground; |
||||||
|
import com.fr.widgettheme.theme.widget.mobile.style.FreeButtonStyle; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; |
||||||
|
import com.fr.design.style.color.NewColorSelectBox; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.mobile.MobileCommonExtraStyle; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.invoke.Reflect; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; |
||||||
|
|
||||||
|
/** |
||||||
|
* 按钮控件通用属性面板 |
||||||
|
* |
||||||
|
* @author Coral.Chen |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/5/25 |
||||||
|
*/ |
||||||
|
public class FreeButtonMobileStyleDefinePane extends DisplayEnhanceMobileStyleDefinePane { |
||||||
|
private NewColorSelectBox borderColorSelectBox; |
||||||
|
private NewColorSelectBox iconColorSelectBox; |
||||||
|
|
||||||
|
|
||||||
|
public FreeButtonMobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass, Class<? extends MobileStyle> mobileStyleClazz) { |
||||||
|
super(widget, customBeanPaneClass, mobileStyleClazz); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(MobileStyle ob) { |
||||||
|
super.populateBean(ob); |
||||||
|
MobileCommonExtraStyle extraStyle = ob.getMobileCommonExtraStyle(); |
||||||
|
if (extraStyle instanceof FreeButtonStyle) { |
||||||
|
FreeButtonStyle style = (FreeButtonStyle) extraStyle; |
||||||
|
if (style.getBorderColor() != null) { |
||||||
|
borderColorSelectBox.setSelectObject(style.getBorderColor()); |
||||||
|
} |
||||||
|
if (style.getIconColor() != null) { |
||||||
|
iconColorSelectBox.setSelectObject(style.getIconColor()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public MobileStyle updateBean() { |
||||||
|
mobileStyle = Reflect.on(mobileStyleClazz).create().get(); |
||||||
|
FreeButtonStyle extraStyle = new FreeButtonStyle(); |
||||||
|
extraStyle.setCustom(customCombo.getSelectedIndex() == 1); |
||||||
|
extraStyle.setWidgetBackground(ColorBackground.getInstance(widgetBackgroundSelectBox.getSelectObject())); |
||||||
|
extraStyle.setBorderType(borderType.getSelectedLineStyle()); |
||||||
|
extraStyle.setBorderColor(borderColorSelectBox.getSelectObject()); |
||||||
|
extraStyle.setBorderRadius(borderRadius.getValue()); |
||||||
|
extraStyle.setNewFont(fontConfigPane.updateBean()); |
||||||
|
extraStyle.setIconColor(iconColorSelectBox.getSelectObject()); |
||||||
|
mobileStyle.setMobileCommonExtraStyle(extraStyle); |
||||||
|
this.widget.setMobileStyle(mobileStyle); |
||||||
|
this.customBeanPane.updateBean(); |
||||||
|
return mobileStyle; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void createUniversalPane() { |
||||||
|
createBackgroundPane(); |
||||||
|
createBorderLinePane(); |
||||||
|
initBorderColor(); |
||||||
|
createBorderRadiusPane(); |
||||||
|
initIconColor(); |
||||||
|
createFontPane(WidgetThemeDisplayConstants.DEFAULT_WHITE_COLOR); |
||||||
|
} |
||||||
|
|
||||||
|
private void initIconColor() { |
||||||
|
iconColorSelectBox = new NewColorSelectBox(NORMAL_COMBO_WIDTH); |
||||||
|
iconColorSelectBox.setSelectObject(WidgetThemeDisplayConstants.DEFAULT_WHITE_COLOR); |
||||||
|
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Icon_Color")), iconColorSelectBox)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initDefaultLineType() { |
||||||
|
borderType.setSelectedLineStyle(com.fr.stable.Constants.LINE_NONE); |
||||||
|
} |
||||||
|
|
||||||
|
private void initBorderColor() { |
||||||
|
borderColorSelectBox = new NewColorSelectBox(NORMAL_COMBO_WIDTH); |
||||||
|
borderColorSelectBox.setSelectObject(WidgetThemeDisplayConstants.DEFAULT_THEME_COLOR); |
||||||
|
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderColor")), borderColorSelectBox)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initBackgroundColor() { |
||||||
|
widgetBackgroundSelectBox.setSelectObject(getCurrentTemplateThemeColor()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,77 @@ |
|||||||
|
package com.fr.controldisplayenhance.widget.mobile.pane; |
||||||
|
|
||||||
|
import com.fr.base.background.ColorBackground; |
||||||
|
import com.fr.widgettheme.theme.widget.mobile.style.LabelIconSettingStyle; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; |
||||||
|
import com.fr.design.style.color.NewColorSelectBox; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.mobile.MobileCommonExtraStyle; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.invoke.Reflect; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; |
||||||
|
|
||||||
|
/** |
||||||
|
* 标签控件属性定义面板 |
||||||
|
* |
||||||
|
* @author Coral.Chen |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/5/15 |
||||||
|
*/ |
||||||
|
public class LabelMobileStyleDefinePane extends DisplayEnhanceMobileStyleDefinePane { |
||||||
|
private NewColorSelectBox borderColorSelectBox; |
||||||
|
|
||||||
|
public LabelMobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass, |
||||||
|
Class<? extends MobileStyle> mobileStyleClazz) { |
||||||
|
super(widget, customBeanPaneClass, mobileStyleClazz); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(MobileStyle ob) { |
||||||
|
super.populateBean(ob); |
||||||
|
MobileCommonExtraStyle extraStyle = ob.getMobileCommonExtraStyle(); |
||||||
|
if (extraStyle instanceof LabelIconSettingStyle) { |
||||||
|
LabelIconSettingStyle style = (LabelIconSettingStyle) extraStyle; |
||||||
|
if (style.getBorderColor() != null) { |
||||||
|
borderColorSelectBox.setSelectObject(style.getBorderColor()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public MobileStyle updateBean() { |
||||||
|
mobileStyle = Reflect.on(mobileStyleClazz).create().get(); |
||||||
|
LabelIconSettingStyle extraStyle = new LabelIconSettingStyle(); |
||||||
|
extraStyle.setCustom(customCombo.getSelectedIndex() == 1); |
||||||
|
extraStyle.setWidgetBackground(ColorBackground.getInstance(widgetBackgroundSelectBox.getSelectObject())); |
||||||
|
extraStyle.setBorderType(borderType.getSelectedLineStyle()); |
||||||
|
extraStyle.setBorderColor(borderColorSelectBox.getSelectObject()); |
||||||
|
extraStyle.setBorderRadius(borderRadius.getValue()); |
||||||
|
extraStyle.setNewFont(fontConfigPane.updateBean()); |
||||||
|
mobileStyle.setMobileCommonExtraStyle(extraStyle); |
||||||
|
this.widget.setMobileStyle(mobileStyle); |
||||||
|
this.customBeanPane.updateBean(); |
||||||
|
return mobileStyle; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void createUniversalPane() { |
||||||
|
createBackgroundPane(); |
||||||
|
createBorderLinePane(); |
||||||
|
initBorderColor(); |
||||||
|
createBorderRadiusPane(); |
||||||
|
createFontPane(WidgetThemeDisplayConstants.DEFAULT_FONT_COLOR_BLACK); |
||||||
|
} |
||||||
|
|
||||||
|
private void initBorderColor() { |
||||||
|
borderColorSelectBox = new NewColorSelectBox(NORMAL_COMBO_WIDTH); |
||||||
|
borderColorSelectBox.setSelectObject(WidgetThemeDisplayConstants.DEFAULT_TRANSPARENT_COLOR); |
||||||
|
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderColor")), borderColorSelectBox)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initDefaultLineType() { |
||||||
|
borderType.setSelectedLineStyle(com.fr.stable.Constants.LINE_NONE); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,132 @@ |
|||||||
|
package com.fr.controldisplayenhance.widget.mobile.pane; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.design.constants.LayoutConstants; |
||||||
|
import com.fr.design.gui.ibutton.UIColorButton; |
||||||
|
import com.fr.design.gui.ibutton.UIToggleButton; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBoxRenderer; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.border.EmptyBorder; |
||||||
|
import java.awt.*; |
||||||
|
import java.util.Vector; |
||||||
|
|
||||||
|
/** |
||||||
|
* 移动端字体面板 |
||||||
|
* |
||||||
|
* @author Coral.Chen |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/5/22 |
||||||
|
*/ |
||||||
|
|
||||||
|
public class MobileStyleFontConfigPane extends JPanel { |
||||||
|
public static final int FONT_NONE = 0; |
||||||
|
private static final int MAX_FONT_SIZE = 18; |
||||||
|
private static final int MIN_FONT_SIZE = 12; |
||||||
|
private static final Dimension BUTTON_SIZE = new Dimension(20, 18); |
||||||
|
|
||||||
|
public static Vector<Integer> getFontSizes() { |
||||||
|
Vector<Integer> FONT_SIZES = new Vector<Integer>(); |
||||||
|
for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) { |
||||||
|
FONT_SIZES.add(i); |
||||||
|
} |
||||||
|
return FONT_SIZES; |
||||||
|
} |
||||||
|
|
||||||
|
private UIComboBox fontSizeComboBox; |
||||||
|
private UIColorButton color; |
||||||
|
private UIToggleButton italic; |
||||||
|
private UIToggleButton bold; |
||||||
|
|
||||||
|
public MobileStyleFontConfigPane() { |
||||||
|
this.initComponent(new Color(0, 0, 0)); |
||||||
|
} |
||||||
|
|
||||||
|
public MobileStyleFontConfigPane(Color defaultFontColor) { |
||||||
|
this.initComponent(defaultFontColor); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComponent(Color defaultFontColor) { |
||||||
|
fontSizeComboBox = new UIComboBox(); |
||||||
|
fontSizeComboBox.setModel(new DefaultComboBoxModel(getFontSizes())); |
||||||
|
fontSizeComboBox.setSelectedItem(16); |
||||||
|
fontSizeComboBox.setPreferredSize(new Dimension(60, 20)); |
||||||
|
fontSizeComboBox.setRenderer(new LineCellRenderer()); |
||||||
|
color = new UIColorButton(); |
||||||
|
color.setColor(defaultFontColor); |
||||||
|
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); |
||||||
|
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); |
||||||
|
|
||||||
|
this.setButtonsTips(); |
||||||
|
this.setButtonsSize(BUTTON_SIZE); |
||||||
|
|
||||||
|
Component[] components_font = new Component[]{ |
||||||
|
fontSizeComboBox, color, italic, bold |
||||||
|
}; |
||||||
|
|
||||||
|
JPanel buttonPane = new JPanel(new BorderLayout()); |
||||||
|
JPanel flowPane = GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE); |
||||||
|
// 4是flowPane的默认横向gap,但会导致最左边的控件和边上也有4的间隙,调整一下
|
||||||
|
flowPane.setBorder(new EmptyBorder(0, -LayoutConstants.HGAP_LARGE, 0, 0)); |
||||||
|
buttonPane.add(flowPane); |
||||||
|
|
||||||
|
this.setLayout(new BorderLayout(0, 0)); |
||||||
|
this.add(buttonPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
private void setButtonsTips() { |
||||||
|
color.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Foreground")); |
||||||
|
italic.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Italic")); |
||||||
|
bold.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Bold")); |
||||||
|
} |
||||||
|
|
||||||
|
private void setButtonsSize(Dimension size) { |
||||||
|
color.setPreferredSize(size); |
||||||
|
italic.setPreferredSize(size); |
||||||
|
bold.setPreferredSize(size); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void populateBean(FRFont frFont) { |
||||||
|
fontSizeComboBox.setSelectedItem(frFont.getSize()); |
||||||
|
color.setColor(frFont.getForeground()); |
||||||
|
bold.setSelected(frFont.isBold()); |
||||||
|
italic.setSelected(frFont.isItalic()); |
||||||
|
} |
||||||
|
|
||||||
|
public FRFont updateBean() { |
||||||
|
int style = Font.PLAIN; |
||||||
|
style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN; |
||||||
|
style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN; |
||||||
|
return FRFont.getInstance( |
||||||
|
FRFont.DEFAULT_FONTNAME, |
||||||
|
style, |
||||||
|
Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()), |
||||||
|
color.getColor(), |
||||||
|
Constants.LINE_NONE |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
private class LineCellRenderer extends UIComboBoxRenderer { |
||||||
|
public LineCellRenderer() { |
||||||
|
super(); |
||||||
|
} |
||||||
|
|
||||||
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||||
|
JLabel renderer = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||||
|
int currentValue = ((Integer) value).intValue(); |
||||||
|
if (currentValue == com.fr.design.mainframe.mobile.ui.MobileStyleFontConfigPane.FONT_NONE) { |
||||||
|
renderer.setText(StringUtils.BLANK + Toolkit.i18nText("Fine-Design_Report_None")); |
||||||
|
} |
||||||
|
return renderer; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,65 @@ |
|||||||
|
package com.fr.controldisplayenhance.widget.mobile.provider; |
||||||
|
|
||||||
|
import com.fr.controldisplayenhance.widget.mobile.pane.FileEditorMobileStyleDefinePane; |
||||||
|
import com.fr.controldisplayenhance.widget.mobile.pane.FreeButtonMobileStyleDefinePane; |
||||||
|
import com.fr.controldisplayenhance.widget.mobile.pane.LabelMobileStyleDefinePane; |
||||||
|
import com.fr.widgettheme.theme.widget.mobile.style.FileEditorStyle; |
||||||
|
import com.fr.widgettheme.theme.widget.mobile.style.FreeButtonStyle; |
||||||
|
import com.fr.widgettheme.theme.widget.mobile.style.LabelIconSettingStyle; |
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; |
||||||
|
import com.fr.form.ui.FreeButton; |
||||||
|
import com.fr.form.ui.Label; |
||||||
|
import com.fr.form.ui.MultiFileEditor; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.mobile.MobileCommonExtraStyle; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
|
||||||
|
/** |
||||||
|
* 样式创建工厂 |
||||||
|
* |
||||||
|
* @author Coral.Chen |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/5/15 |
||||||
|
*/ |
||||||
|
public class DisplayEnhanceMobileStyleFactory { |
||||||
|
|
||||||
|
/** |
||||||
|
* 先写个简单工厂处理一下特殊的控件 |
||||||
|
* |
||||||
|
* @param widget |
||||||
|
* @return 特殊控件的通用属性面板 |
||||||
|
*/ |
||||||
|
public static BasicBeanPane<MobileStyle> createWidgetMobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customDefinePane, Class<? extends MobileStyle> mobileStyle) { |
||||||
|
if (widget instanceof Label) { |
||||||
|
return new LabelMobileStyleDefinePane(widget, customDefinePane, mobileStyle); |
||||||
|
} |
||||||
|
if (widget instanceof MultiFileEditor) { |
||||||
|
return new FileEditorMobileStyleDefinePane(widget, customDefinePane, mobileStyle); |
||||||
|
} |
||||||
|
if (widget instanceof FreeButton) { |
||||||
|
return new FreeButtonMobileStyleDefinePane(widget, customDefinePane, mobileStyle); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 生成控件移动端通用属性 |
||||||
|
* |
||||||
|
* @param widget |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static Class<? extends MobileCommonExtraStyle> classForWidgetCommonExtraStyle(Widget widget) { |
||||||
|
if (widget instanceof Label) { |
||||||
|
return LabelIconSettingStyle.class; |
||||||
|
} |
||||||
|
if (widget instanceof MultiFileEditor) { |
||||||
|
return FileEditorStyle.class; |
||||||
|
} |
||||||
|
if (widget instanceof FreeButton) { |
||||||
|
return FreeButtonStyle.class; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,70 @@ |
|||||||
|
package com.fr.controldisplayenhance.widget.mobile.provider; |
||||||
|
|
||||||
|
import com.fr.base.io.IOFile; |
||||||
|
import com.fr.controldisplayenhance.widget.mobile.pane.DisplayEnhanceMobileStyleDefinePane; |
||||||
|
import com.fr.widgettheme.theme.widget.mobile.style.WidgetThemeMobileCommonExtraStyle; |
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.file.HistoryTemplateListCache; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; |
||||||
|
import com.fr.form.ui.FreeButton; |
||||||
|
import com.fr.form.ui.Label; |
||||||
|
import com.fr.form.ui.MultiFileEditor; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.mobile.MobileCommonExtraStyle; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.widgettheme.control.attr.WidgetDisplayEnhanceMarkAttr; |
||||||
|
import org.jetbrains.annotations.NotNull; |
||||||
|
|
||||||
|
/** |
||||||
|
* 控件主题移动端样式窗口创建类 |
||||||
|
* |
||||||
|
* @author obo |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/11/13 |
||||||
|
*/ |
||||||
|
public class WidgetThemeMobileStyleDefinePaneCreator { |
||||||
|
|
||||||
|
private WidgetThemeMobileStyleDefinePaneCreator() { |
||||||
|
} |
||||||
|
|
||||||
|
public static BasicBeanPane<MobileStyle> createBaseBeanPane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customDefinePane, Class<? extends MobileStyle> mobileStyle) { |
||||||
|
try { |
||||||
|
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||||
|
if (JTemplate.isValid(jTemplate)) { |
||||||
|
IOFile ioFile = (IOFile) jTemplate.getTarget(); |
||||||
|
WidgetDisplayEnhanceMarkAttr mark = ioFile.getAttrMark(WidgetDisplayEnhanceMarkAttr.XML_TAG); |
||||||
|
if (mark != null && mark.isWidgetEnhance()) { |
||||||
|
if (commonWidget(widget)) { |
||||||
|
return new DisplayEnhanceMobileStyleDefinePane(widget, customDefinePane, mobileStyle); |
||||||
|
} else { |
||||||
|
return DisplayEnhanceMobileStyleFactory.createWidgetMobileStyleDefinePane(widget, customDefinePane, mobileStyle); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error("[Strongest-Control]: create base bean pane failed.", e); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public static @NotNull Class<? extends MobileCommonExtraStyle> classForCommonExtraStyle(Widget widget) { |
||||||
|
if (commonWidget(widget)) { |
||||||
|
return WidgetThemeMobileCommonExtraStyle.class; |
||||||
|
} else { |
||||||
|
return DisplayEnhanceMobileStyleFactory.classForWidgetCommonExtraStyle(widget); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否为普通控件 |
||||||
|
* 按钮控件、标签控件、文件控件需要特殊处理 |
||||||
|
* |
||||||
|
* @param widget 控件 |
||||||
|
* @return 是/否 |
||||||
|
*/ |
||||||
|
private static boolean commonWidget(Widget widget) { |
||||||
|
return !((widget instanceof FreeButton) || (widget instanceof Label) || (widget instanceof MultiFileEditor)); |
||||||
|
} |
||||||
|
} |
After Width: | Height: | Size: 285 B |
After Width: | Height: | Size: 595 B |
@ -0,0 +1,76 @@ |
|||||||
|
package com.fr.design.widgettheme; |
||||||
|
|
||||||
|
import com.fr.widgettheme.theme.widget.style.FontStyle; |
||||||
|
import com.fr.form.ui.Label; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.LabelTheme; |
||||||
|
|
||||||
|
import java.util.Collections; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by johntsai(mailto://johntsai@fanruan.com) on 2/3/23.
|
||||||
|
* 设计器控件属性的“高级”设置增加主题样式设置项,用于标签控件 |
||||||
|
**/ |
||||||
|
public class LabelSettingPane<T extends Widget> extends StyleSettingPane<T> { |
||||||
|
|
||||||
|
public LabelSettingPane() { |
||||||
|
super(Collections.singletonList(StyleSetting.FONT)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(T t) { |
||||||
|
LabelTheme widgetTheme = initLabelTheme(t); |
||||||
|
if (widgetTheme.isFollowTheme()) { |
||||||
|
styleSettingHead.setSelectedIndex(0); |
||||||
|
// todo 参数面板里的控件样式跟随改变
|
||||||
|
} else { |
||||||
|
styleSettingHead.setSelectedIndex(1); |
||||||
|
FRFont font = ((Label) t).getFont(); |
||||||
|
frFontPane.populateBean(font); |
||||||
|
} |
||||||
|
switchCard(); |
||||||
|
} |
||||||
|
|
||||||
|
private LabelTheme initLabelTheme(T t) { |
||||||
|
LabelTheme widgetTheme = (LabelTheme) t.getWidgetTheme(); |
||||||
|
if (widgetTheme == null) { |
||||||
|
widgetTheme = new LabelTheme(); |
||||||
|
t.setWidgetTheme(widgetTheme); |
||||||
|
} |
||||||
|
return widgetTheme; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(T t) { |
||||||
|
LabelTheme widgetTheme = initLabelTheme(t); |
||||||
|
updateLabelBean(widgetTheme); |
||||||
|
((Label) t).setFont(widgetTheme.getFontStyle().getFont()); |
||||||
|
} |
||||||
|
|
||||||
|
private void updateLabelBean(LabelTheme widgetTheme) { |
||||||
|
int selectIndex = styleSettingHead.getSelectedIndex(); |
||||||
|
widgetTheme.setFollowTheme(selectIndex == 0); |
||||||
|
updateLabelStyleBean(widgetTheme); |
||||||
|
} |
||||||
|
|
||||||
|
private void updateLabelStyleBean(LabelTheme widgetTheme) { |
||||||
|
if (widgetTheme.isFollowTheme()) { |
||||||
|
widgetTheme.setFontStyle(new FontStyle()); |
||||||
|
frFontPane.populateBean(widgetTheme.getFontStyle().getFont()); |
||||||
|
} else { |
||||||
|
widgetTheme.setFontStyle(new FontStyle(frFontPane.update(widgetTheme.getFontStyle().getFont()))); |
||||||
|
} |
||||||
|
switchCard(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public T updateBean() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "labelSetting"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
package com.fr.design.widgettheme; |
||||||
|
|
||||||
|
import com.fr.widgettheme.theme.widget.style.FontSizeStyle; |
||||||
|
import com.fr.design.widgettheme.common.ButtonSettingPane; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.ParaButtonTheme; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.cell.ButtonTheme; |
||||||
|
|
||||||
|
import java.util.Arrays; |
||||||
|
|
||||||
|
/** |
||||||
|
* 参数面板:设计器控件属性的“高级”设置增加主题样式设置项,包括: |
||||||
|
* 单选按钮组控件/复选按钮组控件/复选按钮控件 |
||||||
|
* |
||||||
|
* @author Bruce.Deng |
||||||
|
* @version 11.0 |
||||||
|
* Created by Bruce.Deng on 2023/2/27 |
||||||
|
*/ |
||||||
|
public class ParaButtonSettingPane<T extends Widget> extends ButtonSettingPane<T> { |
||||||
|
|
||||||
|
public ParaButtonSettingPane() { |
||||||
|
super(Arrays.asList( |
||||||
|
StyleSetting.THEME_COLOR, |
||||||
|
StyleSetting.STYLE_TYPE, |
||||||
|
StyleSetting.FONT_SIZE |
||||||
|
)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected ButtonTheme getButtonTheme() { |
||||||
|
return new ParaButtonTheme(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void assignFontSizePane(ButtonTheme buttonTheme) { |
||||||
|
ParaButtonTheme paraButtonTheme = (ParaButtonTheme) buttonTheme; |
||||||
|
fontSizePane.setValue(paraButtonTheme.getFontSizeStyle().getFontSize()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void assignFontSizeStyle(ButtonTheme buttonTheme) { |
||||||
|
ParaButtonTheme paraButtonTheme = (ParaButtonTheme) buttonTheme; |
||||||
|
paraButtonTheme.setFontSizeStyle(new FontSizeStyle(fontSizePane.getValue())); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
package com.fr.design.widgettheme; |
||||||
|
|
||||||
|
import com.fr.widgettheme.theme.widget.style.FontSizeStyle; |
||||||
|
import com.fr.design.widgettheme.common.EditorSettingPane; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.ParaEditorTheme; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.cell.EditorTheme; |
||||||
|
|
||||||
|
import java.util.Arrays; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 设计器控件属性的“高级”设置增加主题样式设置项,包括: |
||||||
|
* 文本控件/数字控件/密码控件/文本域控件/下拉框控件/下拉复选框控件/下拉树控件/日期控件 |
||||||
|
* |
||||||
|
* @author Bruce.Deng |
||||||
|
* @version 11.0 |
||||||
|
* Created by Bruce.Deng on 2023/2/2 |
||||||
|
*/ |
||||||
|
public class ParaEditorSettingPane<T extends Widget> extends EditorSettingPane<T> { |
||||||
|
|
||||||
|
public ParaEditorSettingPane() { |
||||||
|
super(Arrays.asList( |
||||||
|
StyleSetting.THEME_COLOR, |
||||||
|
StyleSetting.STYLE_TYPE, |
||||||
|
StyleSetting.LINE_TYPE, |
||||||
|
StyleSetting.BORDER_RADIUS, |
||||||
|
StyleSetting.FONT_SIZE |
||||||
|
)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void assignFontSizePane(EditorTheme widgetTheme) { |
||||||
|
ParaEditorTheme paraEditorTheme= (ParaEditorTheme) widgetTheme; |
||||||
|
fontSizePane.setValue(paraEditorTheme.getFontSizeStyle().getFontSize()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void assignFontSizeStyle(EditorTheme widgetTheme) { |
||||||
|
ParaEditorTheme paraEditorTheme= (ParaEditorTheme) widgetTheme; |
||||||
|
paraEditorTheme.setFontSizeStyle(new FontSizeStyle(fontSizePane.getValue())); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected EditorTheme getEditorTheme() { |
||||||
|
return new ParaEditorTheme(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,64 @@ |
|||||||
|
package com.fr.design.widgettheme; |
||||||
|
|
||||||
|
import com.fr.widgettheme.theme.widget.style.FontStyle; |
||||||
|
import com.fr.design.widgettheme.common.NormalButtonSettingPane; |
||||||
|
import com.fr.form.ui.FreeButton; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.ParaNormalButtonTheme; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.cell.NormalButtonTheme; |
||||||
|
|
||||||
|
import java.util.Arrays; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by johntsai(mailto://johntsai@fanruan.com) on 2/3/23.
|
||||||
|
**/ |
||||||
|
public class ParaNormalButtonSettingPane<T extends Widget> extends NormalButtonSettingPane<T> { |
||||||
|
|
||||||
|
public ParaNormalButtonSettingPane() { |
||||||
|
super(Arrays.asList( |
||||||
|
StyleSetting.BTN_BACKGROUND, |
||||||
|
StyleSetting.LINE_TYPE, |
||||||
|
StyleSetting.BORDER_RADIUS, |
||||||
|
StyleSetting.FONT |
||||||
|
)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void assignFontPane(NormalButtonTheme normalButtonTheme) { |
||||||
|
ParaNormalButtonTheme paraNormalButtonTheme = (ParaNormalButtonTheme) normalButtonTheme; |
||||||
|
frFontPane.populateBean(paraNormalButtonTheme.getFontStyle().getFont()); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initCustomStyle(FreeButton freeButton, NormalButtonTheme widgetTheme) { |
||||||
|
super.initCustomStyle(freeButton, widgetTheme); |
||||||
|
FRFont font = freeButton.getFont(); |
||||||
|
((ParaNormalButtonTheme) widgetTheme).setFontStyle(new FontStyle(font)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void updateCustomStyle(FreeButton freeButton, NormalButtonTheme widgetTheme) { |
||||||
|
super.updateCustomStyle(freeButton, widgetTheme); |
||||||
|
FontStyle fontStyle = ((ParaNormalButtonTheme) widgetTheme).getFontStyle(); |
||||||
|
freeButton.setFont(fontStyle.getFont()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void assignFontStyle(NormalButtonTheme normalButtonTheme) { |
||||||
|
ParaNormalButtonTheme paraNormalButtonTheme = (ParaNormalButtonTheme) normalButtonTheme; |
||||||
|
if (paraNormalButtonTheme.isFollowTheme()) { |
||||||
|
paraNormalButtonTheme.setFontStyle(new FontStyle()); |
||||||
|
assignFontPane(normalButtonTheme); |
||||||
|
} else { |
||||||
|
paraNormalButtonTheme.setFontStyle(new FontStyle(frFontPane.update(paraNormalButtonTheme.getFontStyle().getFont()))); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected NormalButtonTheme getDefaultNormalButtonTheme() { |
||||||
|
return new ParaNormalButtonTheme(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,45 @@ |
|||||||
|
package com.fr.design.widgettheme; |
||||||
|
|
||||||
|
import com.fr.widgettheme.theme.widget.style.FontSizeStyle; |
||||||
|
import com.fr.design.widgettheme.common.TreeEditorSettingPane; |
||||||
|
import com.fr.form.ui.TreeEditor; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.ParaTreeTheme; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.cell.TreeTheme; |
||||||
|
|
||||||
|
import java.util.Arrays; |
||||||
|
|
||||||
|
/** |
||||||
|
* 参数面板:设计器控件属性的“高级”设置增加主题样式设置项,包括: |
||||||
|
* 视图树 |
||||||
|
* |
||||||
|
* @author Bruce.Deng |
||||||
|
* @version 11.0 |
||||||
|
* Created by Bruce.Deng on 2023/2/28 |
||||||
|
*/ |
||||||
|
public class ParaTreeEditorSettingPane<T extends TreeEditor> extends TreeEditorSettingPane<T> { |
||||||
|
|
||||||
|
public ParaTreeEditorSettingPane() { |
||||||
|
super(Arrays.asList( |
||||||
|
StyleSetting.THEME_COLOR, |
||||||
|
StyleSetting.STYLE_TYPE, |
||||||
|
StyleSetting.FONT_SIZE |
||||||
|
)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected TreeTheme getTreeTheme() { |
||||||
|
return new ParaTreeTheme(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void assignFontSizePane(TreeTheme widgetTheme) { |
||||||
|
ParaTreeTheme paraTreeTheme= (ParaTreeTheme) widgetTheme; |
||||||
|
fontSizePane.setValue(paraTreeTheme.getFontSizeStyle().getFontSize()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void assignFontSizeStyle(TreeTheme widgetTheme) { |
||||||
|
ParaTreeTheme paraTreeTheme= (ParaTreeTheme) widgetTheme; |
||||||
|
paraTreeTheme.setFontSizeStyle(new FontSizeStyle(fontSizePane.getValue())); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
package com.fr.design.widgettheme; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by johntsai(mailto://johntsai@fanruan.com) on 2/3/23.
|
||||||
|
**/ |
||||||
|
public enum StyleSetting { |
||||||
|
|
||||||
|
THEME_COLOR, |
||||||
|
STYLE_TYPE, |
||||||
|
LINE_TYPE, |
||||||
|
BORDER_RADIUS, |
||||||
|
FONT_SIZE, |
||||||
|
FONT, |
||||||
|
BTN_BACKGROUND |
||||||
|
|
||||||
|
} |
@ -0,0 +1,263 @@ |
|||||||
|
package com.fr.design.widgettheme; |
||||||
|
|
||||||
|
import com.fr.base.theme.TemplateTheme; |
||||||
|
import com.fr.widgettheme.theme.widget.style.BorderStyle; |
||||||
|
import com.fr.widgettheme.theme.widget.style.FontSizeStyle; |
||||||
|
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle; |
||||||
|
import com.fr.widgettheme.theme.bean.ButtonBackground; |
||||||
|
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; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.design.style.color.NewColorSelectBox; |
||||||
|
import com.fr.design.widget.ui.designer.component.FontSizeComboPane; |
||||||
|
import com.fr.design.widget.ui.designer.component.UIBoundSpinner; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.controldisplayenhance.theme.panel.ButtonStyleDefinedPane; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by johntsai(mailto://johntsai@fanruan.com) on 2/3/23.
|
||||||
|
**/ |
||||||
|
public abstract class StyleSettingPane<T extends Widget> extends BasicBeanPane<T> { |
||||||
|
|
||||||
|
protected List<StyleSetting> styleSettingList; |
||||||
|
//样式切换标题头部
|
||||||
|
protected UIButtonGroup<String> styleSettingHead; |
||||||
|
// 自定义样式
|
||||||
|
protected JPanel customPane; |
||||||
|
// 主题色
|
||||||
|
protected NewColorSelectBox colorSelectBox; |
||||||
|
// 风格1
|
||||||
|
protected UIRadioButton style1; |
||||||
|
// 风格2
|
||||||
|
protected UIRadioButton style2; |
||||||
|
// 边框线型
|
||||||
|
protected LineComboBox lineComboBox; |
||||||
|
// 圆角边框
|
||||||
|
protected UIBoundSpinner borderRadiusSpinner; |
||||||
|
// 字体大小
|
||||||
|
protected FontSizeComboPane fontSizePane; |
||||||
|
// 字体详细设置
|
||||||
|
protected FRFontPane frFontPane; |
||||||
|
// 按钮背景设置
|
||||||
|
protected ButtonStyleDefinedPane buttonStyleDefinedPane; |
||||||
|
|
||||||
|
|
||||||
|
public StyleSettingPane(List<StyleSetting> styleSettingList) { |
||||||
|
this.styleSettingList = styleSettingList; |
||||||
|
|
||||||
|
initStyleEditor(); |
||||||
|
initPane(); |
||||||
|
initDefaultValue(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
protected void initPane() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
this.add(createHeadPane(), BorderLayout.NORTH); |
||||||
|
this.add(createCustomPane(), BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
protected void initStyleEditor() { |
||||||
|
styleSettingList.forEach(it -> { |
||||||
|
switch (it) { |
||||||
|
case STYLE_TYPE: |
||||||
|
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); |
||||||
|
break; |
||||||
|
case THEME_COLOR: |
||||||
|
colorSelectBox = new NewColorSelectBox(160, true); |
||||||
|
break; |
||||||
|
case LINE_TYPE: |
||||||
|
lineComboBox = new LineComboBox(WidgetThemeDisplayConstants.BORDER_LINE_STYLE_ARRAY); |
||||||
|
break; |
||||||
|
case FONT_SIZE: |
||||||
|
fontSizePane = new FontSizeComboPane(); |
||||||
|
break; |
||||||
|
case BORDER_RADIUS: |
||||||
|
borderRadiusSpinner = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); |
||||||
|
break; |
||||||
|
case FONT: |
||||||
|
frFontPane = new FRFontPane(); |
||||||
|
break; |
||||||
|
case BTN_BACKGROUND: |
||||||
|
buttonStyleDefinedPane = new ButtonStyleDefinedPane(); |
||||||
|
break; |
||||||
|
default: |
||||||
|
break; |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
protected JPanel createHeadPane() { |
||||||
|
UILabel headLabel = new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Style_Setting")); |
||||||
|
String[] titles = new String[]{Toolkit.i18nText("Fine-Design_Widget_Follow_Theme"), Toolkit.i18nText("Fine-Design_Widget_Theme_Custom")}; |
||||||
|
styleSettingHead = new UIButtonGroup(titles) { |
||||||
|
@Override |
||||||
|
public void setSelectedIndex(int newSelectedIndex, boolean fireChanged) { |
||||||
|
super.setSelectedIndex(newSelectedIndex, fireChanged); |
||||||
|
switchCard(); |
||||||
|
} |
||||||
|
}; |
||||||
|
JPanel headPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ |
||||||
|
new Component[]{headLabel, styleSettingHead}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); |
||||||
|
headPane.setBorder(BorderFactory.createEmptyBorder(0, 0, IntervalConstants.INTERVAL_L1, 0)); |
||||||
|
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(); |
||||||
|
|
||||||
|
double f = TableLayout.FILL; |
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
|
||||||
|
double[] rowSize = new double[size]; |
||||||
|
for (int i = 0; i < size; i++) { |
||||||
|
rowSize[i] = p; |
||||||
|
} |
||||||
|
|
||||||
|
double[] columnSize = {p, f}; |
||||||
|
|
||||||
|
int[][] rowCount = new int[size][2]; |
||||||
|
for (int i = 0; i < size; i++) { |
||||||
|
for (int j = 0; j < 2; j++) { |
||||||
|
rowCount[i][j] = 1; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
customPane = TableLayoutHelper.createGapTableLayoutPane(createComponents(size), rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); |
||||||
|
customPane.setBorder(BorderFactory.createEmptyBorder(0, 0, IntervalConstants.INTERVAL_L1, 0)); |
||||||
|
return customPane; |
||||||
|
} |
||||||
|
|
||||||
|
protected Component[][] createComponents(int size) { |
||||||
|
Component[][] result = new Component[size][2]; |
||||||
|
for (int i = 0; i < size; i++) { |
||||||
|
result[i] = createComponentByStyleSetting(styleSettingList.get(i)); |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
protected Component[] createComponentByStyleSetting(StyleSetting styleSetting) { |
||||||
|
switch (styleSetting) { |
||||||
|
case THEME_COLOR: |
||||||
|
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Color")), colorSelectBox}; |
||||||
|
case FONT_SIZE: |
||||||
|
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Font_Size")), fontSizePane}; |
||||||
|
case FONT: |
||||||
|
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Font")), frFontPane}; |
||||||
|
case STYLE_TYPE: |
||||||
|
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Style")), createStyleTypePane()}; |
||||||
|
case LINE_TYPE: |
||||||
|
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Border_Line")), lineComboBox}; |
||||||
|
case BORDER_RADIUS: |
||||||
|
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Border_Radius")), borderRadiusSpinner}; |
||||||
|
case BTN_BACKGROUND: |
||||||
|
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Theme_Widget_Background")), buttonStyleDefinedPane}; |
||||||
|
default: |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected void switchCard() { |
||||||
|
customPane.setVisible(styleSettingHead.getSelectedIndex() == 1); |
||||||
|
} |
||||||
|
|
||||||
|
protected void initDefaultValue() { |
||||||
|
// 读取当前模板的主题
|
||||||
|
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||||
|
if (JTemplate.isValid(template)) { |
||||||
|
TemplateTheme theme = template.getTemplateTheme(); |
||||||
|
|
||||||
|
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) theme.getWidgetStyle(); |
||||||
|
|
||||||
|
if (widgetStyle != null) { |
||||||
|
setThemedStyle(widgetStyle); |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
setDefaultStyle(); |
||||||
|
} |
||||||
|
|
||||||
|
private void setThemedStyle(ThemedWidgetStyle widgetStyle) { |
||||||
|
if (colorSelectBox != null) { |
||||||
|
colorSelectBox.setSelectObject(widgetStyle.getThemeColor()); |
||||||
|
} |
||||||
|
if (widgetStyle.getStyleType() == WidgetThemeDisplayConstants.DEFAULT_STYLE) { |
||||||
|
if (style1 != null) { |
||||||
|
style1.setSelected(true); |
||||||
|
} |
||||||
|
} else { |
||||||
|
if (style2 != null) { |
||||||
|
style2.setSelected(true); |
||||||
|
} |
||||||
|
} |
||||||
|
if (lineComboBox != null) { |
||||||
|
|
||||||
|
lineComboBox.setSelectedLineStyle(widgetStyle.getBorderStyle().getLineType()); |
||||||
|
} |
||||||
|
if (borderRadiusSpinner != null) { |
||||||
|
borderRadiusSpinner.setValue(widgetStyle.getBorderStyle().getRadius()); |
||||||
|
} |
||||||
|
if (fontSizePane != null) { |
||||||
|
fontSizePane.setValue(widgetStyle.getFontSizeStyle().getFontSize()); |
||||||
|
} |
||||||
|
if (frFontPane != null) { |
||||||
|
frFontPane.populateBean(widgetStyle.getFontStyle().getFont()); |
||||||
|
} |
||||||
|
if (buttonStyleDefinedPane != null) { |
||||||
|
buttonStyleDefinedPane.populate(ButtonBackground.create(widgetStyle.getButtonBackgroundStyle())); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void setDefaultStyle() { |
||||||
|
if (colorSelectBox != null) { |
||||||
|
colorSelectBox.setSelectObject(WidgetThemeDisplayConstants.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(FontSizeStyle.DEFAULT_FONT_SIZE); |
||||||
|
} |
||||||
|
if (frFontPane != null) { |
||||||
|
frFontPane.populateBean(FRFont.getInstance()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,109 @@ |
|||||||
|
package com.fr.design.widgettheme.common; |
||||||
|
|
||||||
|
import com.fr.design.widgettheme.StyleSetting; |
||||||
|
import com.fr.design.widgettheme.StyleSettingPane; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.cell.ButtonTheme; |
||||||
|
import org.jetbrains.annotations.Nullable; |
||||||
|
|
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设计器控件属性的“高级”设置增加主题样式设置项,包括: |
||||||
|
* 单选按钮组控件/复选按钮组控件/复选按钮控件 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @version 11.0 |
||||||
|
* Created by John.Ying on 2023/4/18 |
||||||
|
*/ |
||||||
|
public class ButtonSettingPane<T extends Widget> extends StyleSettingPane<T> { |
||||||
|
|
||||||
|
public ButtonSettingPane() { |
||||||
|
super(Arrays.asList( |
||||||
|
StyleSetting.THEME_COLOR, |
||||||
|
StyleSetting.STYLE_TYPE |
||||||
|
)); |
||||||
|
} |
||||||
|
|
||||||
|
public ButtonSettingPane(List<StyleSetting> styleSettingList) { |
||||||
|
super(styleSettingList); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(T t) { |
||||||
|
ButtonTheme widgetTheme = initButtonTheme(t); |
||||||
|
populateButtonBean(widgetTheme); |
||||||
|
} |
||||||
|
|
||||||
|
protected ButtonTheme initButtonTheme(T t) { |
||||||
|
ButtonTheme widgetTheme = (ButtonTheme) t.getWidgetTheme(); |
||||||
|
if (widgetTheme == null) { |
||||||
|
widgetTheme = getButtonTheme(); |
||||||
|
updateButtonStyleBean(widgetTheme); |
||||||
|
t.setWidgetTheme(widgetTheme); |
||||||
|
} |
||||||
|
return widgetTheme; |
||||||
|
} |
||||||
|
|
||||||
|
protected ButtonTheme getButtonTheme() { |
||||||
|
return new ButtonTheme(); |
||||||
|
} |
||||||
|
|
||||||
|
protected void assignFontSizePane(ButtonTheme buttonTheme) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
protected void assignFontSizeStyle(ButtonTheme buttonTheme) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
protected void populateButtonBean(ButtonTheme buttonTheme) { |
||||||
|
if (buttonTheme.isFollowTheme()) { |
||||||
|
styleSettingHead.setSelectedIndex(0); |
||||||
|
// todo 参数面板里的控件样式跟随改变
|
||||||
|
} else { |
||||||
|
styleSettingHead.setSelectedIndex(1); |
||||||
|
colorSelectBox.setSelectObject(buttonTheme.getThemeColor()); |
||||||
|
if (buttonTheme.getStyleType() == WidgetThemeDisplayConstants.STYLE_1) { |
||||||
|
style1.setSelected(true); |
||||||
|
} else { |
||||||
|
style2.setSelected(true); |
||||||
|
} |
||||||
|
assignFontSizePane(buttonTheme); |
||||||
|
} |
||||||
|
switchCard(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(T t) { |
||||||
|
ButtonTheme widgetTheme = initButtonTheme(t); |
||||||
|
updateCellButtonBean(widgetTheme); |
||||||
|
} |
||||||
|
|
||||||
|
protected void updateCellButtonBean(ButtonTheme buttonTheme) { |
||||||
|
int selectIndex = styleSettingHead.getSelectedIndex(); |
||||||
|
buttonTheme.setFollowTheme(selectIndex == 0); |
||||||
|
updateButtonStyleBean(buttonTheme); |
||||||
|
} |
||||||
|
|
||||||
|
protected void updateButtonStyleBean(ButtonTheme buttonTheme) { |
||||||
|
buttonTheme.setThemeColor(colorSelectBox.getSelectObject()); |
||||||
|
buttonTheme.setStyleType(style1.isSelected() ? WidgetThemeDisplayConstants.STYLE_1 : WidgetThemeDisplayConstants.STYLE_2); |
||||||
|
assignFontSizeStyle(buttonTheme); |
||||||
|
switchCard(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
@Nullable |
||||||
|
public T updateBean() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "buttonSetting"; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,116 @@ |
|||||||
|
package com.fr.design.widgettheme.common; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.widgettheme.theme.widget.style.BorderStyle; |
||||||
|
import com.fr.design.widgettheme.StyleSettingPane; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.design.widgettheme.StyleSetting; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.cell.EditorTheme; |
||||||
|
import org.jetbrains.annotations.Nullable; |
||||||
|
|
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设计器控件属性的“高级”设置增加主题样式设置项,包括: |
||||||
|
* 文本控件/数字控件/密码控件/文本域控件/下拉框控件/下拉复选框控件/下拉树控件/日期控件 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @version 11.0 |
||||||
|
* Created by John.Ying on 2023/4/18 |
||||||
|
*/ |
||||||
|
public class EditorSettingPane<T extends Widget> extends StyleSettingPane<T> { |
||||||
|
|
||||||
|
public EditorSettingPane() { |
||||||
|
super(Arrays.asList( |
||||||
|
StyleSetting.THEME_COLOR, |
||||||
|
StyleSetting.STYLE_TYPE, |
||||||
|
StyleSetting.LINE_TYPE, |
||||||
|
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); |
||||||
|
// todo 参数面板里的控件样式跟随改变
|
||||||
|
} else { |
||||||
|
styleSettingHead.setSelectedIndex(1); |
||||||
|
colorSelectBox.setSelectObject(editorTheme.getThemeColor()); |
||||||
|
if (editorTheme.getStyleType() == WidgetThemeDisplayConstants.STYLE_1) { |
||||||
|
style1.setSelected(true); |
||||||
|
} else { |
||||||
|
style2.setSelected(true); |
||||||
|
} |
||||||
|
lineComboBox.setSelectedLineStyle(editorTheme.getBorderStyle().getLineType()); |
||||||
|
borderRadiusSpinner.setValue(editorTheme.getBorderStyle().getRadius()); |
||||||
|
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.setStyleType(style1.isSelected() ? WidgetThemeDisplayConstants.STYLE_1 : WidgetThemeDisplayConstants.STYLE_2); |
||||||
|
editorTheme.setBorderStyle(new BorderStyle((int) borderRadiusSpinner.getValue(), lineComboBox.getSelectedLineStyle())); |
||||||
|
assignFontSizeStyle(editorTheme); |
||||||
|
switchCard(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,144 @@ |
|||||||
|
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.StyleSettingPane; |
||||||
|
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 javax.swing.*; |
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设计器控件属性的“高级”设置增加主题样式设置项,包括: |
||||||
|
* 按钮组件 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @version 11.0 |
||||||
|
* Created by John.Ying on 2023/4/27 |
||||||
|
*/ |
||||||
|
public class NormalButtonSettingPane<T extends Widget> extends StyleSettingPane<T> { |
||||||
|
|
||||||
|
public NormalButtonSettingPane() { |
||||||
|
super(Arrays.asList( |
||||||
|
StyleSetting.BTN_BACKGROUND, |
||||||
|
StyleSetting.LINE_TYPE, |
||||||
|
StyleSetting.BORDER_RADIUS |
||||||
|
)); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
||||||
|
} |
||||||
|
|
||||||
|
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); |
||||||
|
// todo 参数面板里的控件样式跟随改变
|
||||||
|
} else { |
||||||
|
styleSettingHead.setSelectedIndex(1); |
||||||
|
lineComboBox.setSelectedLineStyle(widgetTheme.getBorderStyle().getLineType()); |
||||||
|
borderRadiusSpinner.setValue(widgetTheme.getBorderStyle().getRadius()); |
||||||
|
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); |
||||||
|
|
||||||
|
// 切换到跟随主题时,修改主题样式为默认样式,防止将自定义样式写入到模版,被主jar读取解析
|
||||||
|
if (widgetTheme.isFollowTheme()) { |
||||||
|
t.setWidgetTheme(getDefaultNormalButtonTheme()); |
||||||
|
} |
||||||
|
|
||||||
|
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())); |
||||||
|
|
||||||
|
switchCard(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
@Nullable |
||||||
|
public T updateBean() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "normalButtonSetting"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,108 @@ |
|||||||
|
package com.fr.design.widgettheme.common; |
||||||
|
|
||||||
|
import com.fr.design.widgettheme.StyleSetting; |
||||||
|
import com.fr.design.widgettheme.StyleSettingPane; |
||||||
|
import com.fr.form.ui.TreeEditor; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; |
||||||
|
import com.fr.widgettheme.theme.widget.theme.cell.TreeTheme; |
||||||
|
import org.jetbrains.annotations.Nullable; |
||||||
|
|
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设计器控件属性的“高级”设置增加主题样式设置项,包括: |
||||||
|
* 视图树 |
||||||
|
* |
||||||
|
* @author John.Ying |
||||||
|
* @version 11.0 |
||||||
|
* Created by John.Ying on 2023/4/18 |
||||||
|
*/ |
||||||
|
public class TreeEditorSettingPane<T extends TreeEditor> extends StyleSettingPane<T> { |
||||||
|
|
||||||
|
public TreeEditorSettingPane() { |
||||||
|
super(Arrays.asList( |
||||||
|
StyleSetting.THEME_COLOR, |
||||||
|
StyleSetting.STYLE_TYPE |
||||||
|
)); |
||||||
|
} |
||||||
|
|
||||||
|
public TreeEditorSettingPane(List<StyleSetting> styleSettingList) { |
||||||
|
super(styleSettingList); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(T t) { |
||||||
|
TreeTheme treeTheme = initEditorTheme(t); |
||||||
|
populateTreeBean(treeTheme); |
||||||
|
} |
||||||
|
|
||||||
|
protected TreeTheme initEditorTheme(T t) { |
||||||
|
TreeTheme widgetTheme = (TreeTheme) t.getWidgetTheme(); |
||||||
|
if (widgetTheme == null) { |
||||||
|
widgetTheme = getTreeTheme(); |
||||||
|
updateTreeStyleBean(widgetTheme); |
||||||
|
t.setWidgetTheme(widgetTheme); |
||||||
|
} |
||||||
|
return widgetTheme; |
||||||
|
} |
||||||
|
|
||||||
|
protected TreeTheme getTreeTheme() { |
||||||
|
return new TreeTheme(); |
||||||
|
} |
||||||
|
|
||||||
|
protected void populateTreeBean(TreeTheme treeTheme) { |
||||||
|
if (treeTheme.isFollowTheme()) { |
||||||
|
styleSettingHead.setSelectedIndex(0); |
||||||
|
// todo 参数面板里的控件样式跟随改变
|
||||||
|
} else { |
||||||
|
styleSettingHead.setSelectedIndex(1); |
||||||
|
colorSelectBox.setSelectObject(treeTheme.getThemeColor()); |
||||||
|
if (treeTheme.getStyleType() == WidgetThemeDisplayConstants.STYLE_1) { |
||||||
|
style1.setSelected(true); |
||||||
|
} else { |
||||||
|
style2.setSelected(true); |
||||||
|
} |
||||||
|
assignFontSizePane(treeTheme); |
||||||
|
} |
||||||
|
switchCard(); |
||||||
|
} |
||||||
|
|
||||||
|
protected void assignFontSizePane(TreeTheme widgetTheme) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
protected void assignFontSizeStyle(TreeTheme widgetTheme) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(T t) { |
||||||
|
TreeTheme treeTheme = initEditorTheme(t); |
||||||
|
updateTreeBean(treeTheme); |
||||||
|
} |
||||||
|
|
||||||
|
protected void updateTreeBean(TreeTheme treeTheme) { |
||||||
|
int selectIndex = styleSettingHead.getSelectedIndex(); |
||||||
|
treeTheme.setFollowTheme(selectIndex == 0); |
||||||
|
updateTreeStyleBean(treeTheme); |
||||||
|
} |
||||||
|
|
||||||
|
protected void updateTreeStyleBean(TreeTheme treeTheme) { |
||||||
|
treeTheme.setThemeColor(colorSelectBox.getSelectObject()); |
||||||
|
treeTheme.setStyleType(style1.isSelected() ? WidgetThemeDisplayConstants.STYLE_1 : WidgetThemeDisplayConstants.STYLE_2); |
||||||
|
assignFontSizeStyle(treeTheme); |
||||||
|
switchCard(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
@Nullable |
||||||
|
public T updateBean() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "treeEditorSetting"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,115 @@ |
|||||||
|
package com.fr.design.widgettheme.processor; |
||||||
|
|
||||||
|
import com.fr.controldisplayenhance.util.WidgetThemeDesignerUtils; |
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.form.parameter.FormSubmitButton; |
||||||
|
import com.fr.form.ui.Button; |
||||||
|
import com.fr.form.ui.CheckBox; |
||||||
|
import com.fr.form.ui.CheckBoxGroup; |
||||||
|
import com.fr.form.ui.ComboBox; |
||||||
|
import com.fr.form.ui.ComboCheckBox; |
||||||
|
import com.fr.form.ui.DateEditor; |
||||||
|
import com.fr.form.ui.FreeButton; |
||||||
|
import com.fr.form.ui.NumberEditor; |
||||||
|
import com.fr.form.ui.Password; |
||||||
|
import com.fr.form.ui.RadioGroup; |
||||||
|
import com.fr.form.ui.TextArea; |
||||||
|
import com.fr.form.ui.TextEditor; |
||||||
|
import com.fr.form.ui.TreeComboBoxEditor; |
||||||
|
import com.fr.form.ui.TreeEditor; |
||||||
|
import com.fr.report.web.button.form.TreeNodeToggleButton; |
||||||
|
import com.fr.report.web.button.write.AppendRowButton; |
||||||
|
import com.fr.report.web.button.write.DeleteRowButton; |
||||||
|
import com.fr.design.widgettheme.common.ButtonSettingPane; |
||||||
|
import com.fr.design.widgettheme.common.EditorSettingPane; |
||||||
|
import com.fr.design.widgettheme.common.NormalButtonSettingPane; |
||||||
|
import com.fr.design.widgettheme.common.TreeEditorSettingPane; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 控件主题窗口创建接受类 |
||||||
|
* 当前类型被接受时,添加对应pane到extraPaneList |
||||||
|
* |
||||||
|
* @author Coral.Chen |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/4/28 |
||||||
|
*/ |
||||||
|
public class WidgetThemeCreatorPaneAcceptor<T> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 构造器,考虑泛型 |
||||||
|
*/ |
||||||
|
public WidgetThemeCreatorPaneAcceptor() { |
||||||
|
//
|
||||||
|
} |
||||||
|
|
||||||
|
public void accept(Class creator, List<BasicBeanPane<T>> extraPaneList) { |
||||||
|
acceptEditor(creator, extraPaneList); |
||||||
|
acceptRoot(creator, extraPaneList); |
||||||
|
acceptTree(creator, extraPaneList); |
||||||
|
acceptLabel(creator, extraPaneList); |
||||||
|
acceptNormal(creator, extraPaneList); |
||||||
|
acceptButton(creator, extraPaneList); |
||||||
|
} |
||||||
|
|
||||||
|
private void insertShortCut(List<BasicBeanPane<T>> extraPaneList, BasicBeanPane pane) { |
||||||
|
extraPaneList.add(0, pane); |
||||||
|
} |
||||||
|
|
||||||
|
private void acceptEditor(Class creator, List<BasicBeanPane<T>> extraPaneList) { |
||||||
|
boolean accept = WidgetThemeDesignerUtils.enableWidgetEnhance() |
||||||
|
&& (creator == TextArea.class |
||||||
|
|| creator == TextEditor.class |
||||||
|
|| creator == NumberEditor.class |
||||||
|
|| creator == Password.class |
||||||
|
|| creator == ComboBox.class |
||||||
|
|| creator == ComboCheckBox.class |
||||||
|
|| creator == DateEditor.class |
||||||
|
|| creator == TreeComboBoxEditor.class) |
||||||
|
|| WidgetThemeDesignerUtils.isNewComboBoxTreeEditor(creator); |
||||||
|
if (accept) { |
||||||
|
insertShortCut(extraPaneList, new EditorSettingPane<>()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void acceptRoot(Class creator, List<BasicBeanPane<T>> extraPaneList) { |
||||||
|
//return false
|
||||||
|
} |
||||||
|
|
||||||
|
private void acceptTree(Class creator, List<BasicBeanPane<T>> extraPaneList) { |
||||||
|
boolean accept = WidgetThemeDesignerUtils.enableWidgetEnhance() && creator == TreeEditor.class; |
||||||
|
|
||||||
|
if (accept) { |
||||||
|
insertShortCut(extraPaneList, new TreeEditorSettingPane<>()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void acceptLabel(Class creator, List<BasicBeanPane<T>> extraPaneList) { |
||||||
|
//return false
|
||||||
|
} |
||||||
|
|
||||||
|
private void acceptNormal(Class creator, List<BasicBeanPane<T>> extraPaneList) { |
||||||
|
boolean accept = WidgetThemeDesignerUtils.enableWidgetEnhance() |
||||||
|
&& (creator == AppendRowButton.class |
||||||
|
|| creator == FreeButton.class |
||||||
|
|| creator == DeleteRowButton.class |
||||||
|
|| creator == FormSubmitButton.class |
||||||
|
|| creator == TreeNodeToggleButton.class |
||||||
|
|| creator == Button.class); |
||||||
|
if (accept) { |
||||||
|
insertShortCut(extraPaneList, new NormalButtonSettingPane<>()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void acceptButton(Class creator, List<BasicBeanPane<T>> extraPaneList) { |
||||||
|
boolean accept = WidgetThemeDesignerUtils.enableWidgetEnhance() |
||||||
|
&& (creator == CheckBox.class |
||||||
|
|| creator == RadioGroup.class |
||||||
|
|| creator == CheckBoxGroup.class); |
||||||
|
if (accept) { |
||||||
|
insertShortCut(extraPaneList, new ButtonSettingPane<>()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,91 @@ |
|||||||
|
package com.fr.design.widgettheme.processor; |
||||||
|
|
||||||
|
import com.fr.controldisplayenhance.util.WidgetThemeDesignerUtils; |
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.designer.creator.XButton; |
||||||
|
import com.fr.design.designer.creator.XCheckBox; |
||||||
|
import com.fr.design.designer.creator.XCheckBoxGroup; |
||||||
|
import com.fr.design.designer.creator.XComboBox; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.designer.creator.XDateEditor; |
||||||
|
import com.fr.design.designer.creator.XLabel; |
||||||
|
import com.fr.design.designer.creator.XRadioGroup; |
||||||
|
import com.fr.design.designer.creator.XTextArea; |
||||||
|
import com.fr.design.designer.creator.XTreeComboBoxEditor; |
||||||
|
import com.fr.design.designer.creator.XTreeEditor; |
||||||
|
import com.fr.design.designer.creator.XWParameterLayout; |
||||||
|
import com.fr.design.designer.creator.XWrapperedFieldEditor; |
||||||
|
import com.fr.design.widgettheme.LabelSettingPane; |
||||||
|
import com.fr.design.widgettheme.ParaButtonSettingPane; |
||||||
|
import com.fr.design.widgettheme.ParaEditorSettingPane; |
||||||
|
import com.fr.design.widgettheme.ParaTreeEditorSettingPane; |
||||||
|
import com.fr.controldisplayenhance.ParameterBackgroundStyleSettingPane; |
||||||
|
import com.fr.design.widgettheme.common.NormalButtonSettingPane; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public class WidgetThemeXCreaterPaneAcceptor<T> { |
||||||
|
|
||||||
|
public WidgetThemeXCreaterPaneAcceptor(){} |
||||||
|
|
||||||
|
public void accept(XCreator creator, List<BasicBeanPane<T>> extraPaneList) { |
||||||
|
acceptEditor(creator, extraPaneList); |
||||||
|
acceptRoot(creator, extraPaneList); |
||||||
|
acceptTree(creator, extraPaneList); |
||||||
|
acceptLabel(creator, extraPaneList); |
||||||
|
acceptNormal(creator, extraPaneList); |
||||||
|
acceptButton(creator, extraPaneList); |
||||||
|
} |
||||||
|
|
||||||
|
private void insertShortCut(List<BasicBeanPane<T>> extraPaneList, BasicBeanPane pane) { |
||||||
|
extraPaneList.add(0, pane); |
||||||
|
} |
||||||
|
|
||||||
|
private void acceptEditor(XCreator creator, List<BasicBeanPane<T>> extraPaneList){ |
||||||
|
boolean accept = WidgetThemeDesignerUtils.enableWidgetEnhance() |
||||||
|
&& (creator instanceof XWrapperedFieldEditor |
||||||
|
|| creator instanceof XTextArea |
||||||
|
|| creator instanceof XComboBox |
||||||
|
|| creator instanceof XDateEditor |
||||||
|
|| creator instanceof XTreeComboBoxEditor) |
||||||
|
|| WidgetThemeDesignerUtils.isNewComboBoxTreeEditor(creator); |
||||||
|
if (accept) { |
||||||
|
insertShortCut(extraPaneList, new ParaEditorSettingPane<>()); |
||||||
|
} |
||||||
|
} |
||||||
|
private void acceptRoot(XCreator creator, List<BasicBeanPane<T>> extraPaneList){ |
||||||
|
boolean accept = WidgetThemeDesignerUtils.enableWidgetEnhance() && creator instanceof XWParameterLayout; |
||||||
|
if(accept) { |
||||||
|
insertShortCut(extraPaneList, new ParameterBackgroundStyleSettingPane()); |
||||||
|
} |
||||||
|
} |
||||||
|
private void acceptTree(XCreator creator, List<BasicBeanPane<T>> extraPaneList){ |
||||||
|
boolean accept = WidgetThemeDesignerUtils.enableWidgetEnhance() |
||||||
|
&& (creator instanceof XTreeEditor |
||||||
|
&& !(creator instanceof XTreeComboBoxEditor)); |
||||||
|
if (accept) { |
||||||
|
insertShortCut(extraPaneList, new ParaTreeEditorSettingPane<>()); |
||||||
|
} |
||||||
|
} |
||||||
|
private void acceptLabel(XCreator creator, List<BasicBeanPane<T>> extraPaneList){ |
||||||
|
boolean accept = WidgetThemeDesignerUtils.enableWidgetEnhance() && creator instanceof XLabel; |
||||||
|
if(accept) { |
||||||
|
insertShortCut(extraPaneList, new LabelSettingPane<>()); |
||||||
|
} |
||||||
|
} |
||||||
|
private void acceptNormal(XCreator creator, List<BasicBeanPane<T>> extraPaneList){ |
||||||
|
boolean accept = WidgetThemeDesignerUtils.enableWidgetEnhance() && creator instanceof XButton; |
||||||
|
if (accept) { |
||||||
|
insertShortCut(extraPaneList, new NormalButtonSettingPane<>()); |
||||||
|
} |
||||||
|
} |
||||||
|
private void acceptButton(XCreator creator, List<BasicBeanPane<T>> extraPaneList){ |
||||||
|
boolean accept = WidgetThemeDesignerUtils.enableWidgetEnhance() |
||||||
|
&& (creator instanceof XRadioGroup |
||||||
|
|| creator instanceof XCheckBoxGroup |
||||||
|
|| creator instanceof XCheckBox); |
||||||
|
if (accept) { |
||||||
|
insertShortCut(extraPaneList, new ParaButtonSettingPane<>()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
package com.fr.strongest; |
||||||
|
|
||||||
|
import com.finebi.cbb.utils.StringUtils; |
||||||
|
import com.fr.base.io.BaseBook; |
||||||
|
import com.fr.design.constants.DesignerLaunchStatus; |
||||||
|
import com.fr.design.mainframe.JForm; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.design.mainframe.JTemplateEvent; |
||||||
|
import com.fr.design.mainframe.JWorkBook; |
||||||
|
import com.fr.event.Event; |
||||||
|
import com.fr.event.EventDispatcher; |
||||||
|
import com.fr.event.Listener; |
||||||
|
import com.fr.event.Null; |
||||||
|
import com.fr.module.ModuleContext; |
||||||
|
import com.fr.widgettheme.control.attr.WidgetDisplayEnhanceMarkAttr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 控件属性增强启动类 |
||||||
|
* |
||||||
|
* @author Leo.Qin |
||||||
|
* @since 11.0 |
||||||
|
* Created on 2023/11/7 |
||||||
|
*/ |
||||||
|
public class WidgetThemeListenerStarter { |
||||||
|
private WidgetThemeListenerStarter(){} |
||||||
|
public static void start() { |
||||||
|
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() { |
||||||
|
@Override |
||||||
|
public void on(Event event, Null param) { |
||||||
|
init(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private static void init() { |
||||||
|
Listener<JTemplate> attrListener = new Listener<JTemplate>() { |
||||||
|
@Override |
||||||
|
public void on(Event event, JTemplate temp) { |
||||||
|
dealWithJTemplate4Attr(temp); |
||||||
|
} |
||||||
|
}; |
||||||
|
if (ModuleContext.isDesignerStartup()) { |
||||||
|
EventDispatcher.listen(JTemplateEvent.BEFORE_TEMPLATE_INIT, attrListener); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static void dealWithJTemplate4Attr(JTemplate temp) { |
||||||
|
if (temp instanceof JWorkBook || temp instanceof JForm) { |
||||||
|
BaseBook workBook = (BaseBook) temp.getTarget(); |
||||||
|
if (isNeedAddAttr(temp, workBook)) { |
||||||
|
WidgetDisplayEnhanceMarkAttr attr = new WidgetDisplayEnhanceMarkAttr(); |
||||||
|
attr.setWidgetEnhance(true); |
||||||
|
workBook.addAttrMark(attr); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static boolean isNeedAddAttr(JTemplate temp, BaseBook workBook) { |
||||||
|
// 模板为新建模板(temp.isNewCreateTpl没法用,此时还没赋值)
|
||||||
|
return (StringUtils.isEmpty(workBook.getTemplateID()) || temp.isNewCreateTpl()) && |
||||||
|
workBook.getAttrMark(WidgetDisplayEnhanceMarkAttr.XML_TAG) == null; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue