You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
3.5 KiB
103 lines
3.5 KiB
1 year ago
|
package com.fr.widgettheme;
|
||
1 year ago
|
|
||
|
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;
|
||
|
|
||
1 year ago
|
import javax.swing.JPanel;
|
||
|
import java.awt.BorderLayout;
|
||
1 year ago
|
|
||
|
/**
|
||
|
* 设计器参数面板的“高级”设置增加背景的主题样式设置
|
||
|
*
|
||
|
* @author Bruce.Deng
|
||
1 year ago
|
* @since 11.0
|
||
|
* Created on 2023/2/20
|
||
1 year ago
|
*/
|
||
|
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");
|
||
|
}
|
||
|
}
|