From 2cf2c81cde7634e151cecfa967737ecfeaad3397 Mon Sep 17 00:00:00 2001 From: Starryi Date: Wed, 25 Aug 2021 15:00:57 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-57935=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E5=8D=95=E5=85=83=E6=A0=BC=E5=8F=B3?= =?UTF-8?q?=E4=BE=A7=E8=AE=BE=E8=AE=A1=E9=9D=A2=E6=9D=BF=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=8D=E7=AC=A6=E5=90=88=E4=BA=A4=E4=BA=92=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 重写单元格右侧栏样式面板 【改动思路】 同上 --- .../cell/settingpane/style/StylePane.java | 168 +++++++++++++++--- 1 file changed, 143 insertions(+), 25 deletions(-) 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 72ee9b221..b95d2fc9c 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