diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java index 72ee9b2217..b95d2fc9ca 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java @@ -1,35 +1,143 @@ package com.fr.design.mainframe.cell.settingpane.style; -import java.util.ArrayList; -import java.util.List; +import com.fr.base.NameStyle; +import com.fr.base.Style; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icontainer.UIScrollPane; +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 com.fr.design.mainframe.ElementCasePane; +import com.fr.general.ComparatorUtils; +import com.teamdev.jxbrowser.deps.org.checkerframework.checker.guieffect.qual.UI; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JScrollPane; import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; -import com.fr.base.Style; -import com.fr.design.beans.FurtherBasicBeanPane; -import com.fr.design.gui.frpane.UIComboBoxPane; -import com.fr.general.ComparatorUtils; +public class StylePane extends BasicPane { + public static final String[] FOLLOWING_THEME_STRING_ARRAYS = new String[]{ + Toolkit.i18nText("Fine-Design_Style_Follow_Theme"), + Toolkit.i18nText("Fine-Design_Style_Not_Follow_Theme"), + }; + public static final int DEFAULT_SELECTED_INDEX = 0; -import com.fr.design.mainframe.ElementCasePane; + private final UIButtonGroup followingThemeButtonGroup; + private final CustomStylePane customStylePane; + private final ThemedCellStyleListPane themedCellStyleListPane; + private final CardLayout cardLayout; + private final JComponent[] panes = new JComponent[2]; + + private JPanel contentPane; + + public StylePane() { + followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); + customStylePane = new CustomStylePane(); + themedCellStyleListPane = new ThemedCellStyleListPane(); + panes[0] = createThemedStylePane(); + panes[1] = createCustomStylePane(); + cardLayout = new CardLayout(); + + initializePane(); + } + + private void initializePane() { + setLayout(new BorderLayout(0, IntervalConstants.INTERVAL_L1)); + + add(createFollowingThemePane(), BorderLayout.NORTH); + contentPane = createTabbedContentPane(); + add(contentPane, BorderLayout.CENTER); + } + + private JPanel createFollowingThemePane() { + followingThemeButtonGroup.setSelectedIndex(DEFAULT_SELECTED_INDEX); + followingThemeButtonGroup.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int selectedIndex = followingThemeButtonGroup.getSelectedIndex(); + cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]); + if (selectedIndex == 1) { + customStylePane.populateBean(themedCellStyleListPane.updateBean()); + } else { + themedCellStyleListPane.populateBean(null); + } + } + }); + + UILabel uiLabel = new UILabel("样式设置"); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + return TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{ new Component[] { uiLabel, followingThemeButtonGroup} }, + new double[] { p }, new double[] { p, f}, + IntervalConstants.INTERVAL_L1, 0); + } + + protected JPanel createTabbedContentPane() { + JPanel contentPane = new JPanel(cardLayout) { + @Override + public Dimension getPreferredSize() { + int selectedIndex = followingThemeButtonGroup.getSelectedIndex(); + if (selectedIndex < 0) { + return super.getPreferredSize(); + } else { + return panes[selectedIndex].getPreferredSize(); + } + } + }; + for (int i = 0; i < FOLLOWING_THEME_STRING_ARRAYS.length; i++) { + contentPane.add(panes[i], FOLLOWING_THEME_STRING_ARRAYS[i]); + } + cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[DEFAULT_SELECTED_INDEX]); + + return contentPane; + } + + private JPanel createThemedStylePane() { + JPanel container = new JPanel(new BorderLayout(0, IntervalConstants.INTERVAL_L1)); + UILabel uiLabel = new UILabel("样式选择"); + uiLabel.setPreferredSize(new Dimension(uiLabel.getPreferredSize().width, 20)); + container.add(uiLabel, BorderLayout.NORTH); + themedCellStyleListPane.setBorder(BorderFactory.createEmptyBorder()); + UIScrollPane scrollPane = new UIScrollPane(themedCellStyleListPane); + container.add(scrollPane, BorderLayout.CENTER); + return container; + } -public class StylePane extends UIComboBoxPane