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.
141 lines
4.2 KiB
141 lines
4.2 KiB
package com.fr.widgettheme.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 com.fr.widgettheme.ThemePreviewTerminal; |
|
import org.jetbrains.annotations.Nullable; |
|
|
|
import javax.swing.JPanel; |
|
import java.awt.BorderLayout; |
|
import java.awt.Component; |
|
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"); |
|
} |
|
|
|
public ThemePreviewTerminal getTerminalStyle() { |
|
return ThemePreviewTerminal.getTypeByCode(terminalStyleGroup.getSelectedIndex()); |
|
} |
|
} |