Browse Source

REPORT-57935 【主题切换】单元格右侧设计面板显示不符合交互图

【问题原因】
 重写单元格右侧栏样式面板

【改动思路】
同上
research/11.0
Starryi 3 years ago
parent
commit
2cf2c81cde
  1. 168
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java

168
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; package com.fr.design.mainframe.cell.settingpane.style;
import java.util.ArrayList; import com.fr.base.NameStyle;
import java.util.List; 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 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; public class StylePane extends BasicPane {
import com.fr.design.beans.FurtherBasicBeanPane; public static final String[] FOLLOWING_THEME_STRING_ARRAYS = new String[]{
import com.fr.design.gui.frpane.UIComboBoxPane; Toolkit.i18nText("Fine-Design_Style_Follow_Theme"),
import com.fr.general.ComparatorUtils; 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<String> 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<Style> { private JPanel createCustomStylePane() {
private CustomStylePane customStylePane; return customStylePane;
private ThemedCellStyleListPane themedCellStyleListPane; }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style");
} }
@Override public void setSelectedIndex(int index) {
protected void comboBoxItemStateChanged() { if (0 <= index && index < FOLLOWING_THEME_STRING_ARRAYS.length) {
if (jcb.getSelectedIndex() == 0 && themedCellStyleListPane.updateBean() != null) { followingThemeButtonGroup.setSelectedIndex(index);
customStylePane.populateBean(themedCellStyleListPane.updateBean()); cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[index]);
} else {
themedCellStyleListPane.populateBean(null);
} }
} }
public int getSelectedIndex() {
return followingThemeButtonGroup.getSelectedIndex();
}
public void addPredefinedChangeListener(ChangeListener changeListener) { public void addPredefinedChangeListener(ChangeListener changeListener) {
themedCellStyleListPane.addChangeListener(changeListener); themedCellStyleListPane.addChangeListener(changeListener);
} }
@ -39,31 +147,41 @@ public class StylePane extends UIComboBoxPane<Style> {
} }
public void updateBorder(Object[] selectionCellBorderObjects) { public void updateBorder(Object[] selectionCellBorderObjects) {
if (getSelectedIndex() == 0 && customStylePane.isBorderPaneSelected()) { if (getSelectedIndex() == 1 && customStylePane.isBorderPaneSelected()) {
customStylePane.updateBorder(selectionCellBorderObjects); customStylePane.updateBorder(selectionCellBorderObjects);
} }
} }
public void dealWithBorder(ElementCasePane ePane) { public void dealWithBorder(ElementCasePane ePane) {
if (getSelectedIndex() == 0) { if (getSelectedIndex() == 1) {
customStylePane.dealWithBorder(ePane); customStylePane.dealWithBorder(ePane);
} }
} }
public void setSelctedByName(String id) { public void setSelctedByName(String id) {
jcb.setSelectedIndex(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"),id)? 0 : 1); setSelectedIndex(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"), id)? 1 : 0);
} }
public Style updateStyle(Style style) { public Style updateStyle(Style style) {
return customStylePane.updateStyle(style); return customStylePane.updateStyle(style);
} }
@Override public Style updateBean() {
protected List<FurtherBasicBeanPane<? extends Style>> initPaneList() { if (getSelectedIndex() == 0) {
List<FurtherBasicBeanPane<? extends Style>> paneList = new ArrayList<>(); return themedCellStyleListPane.updateBean();
paneList.add(customStylePane = new CustomStylePane()); } else {
paneList.add(themedCellStyleListPane = new ThemedCellStyleListPane()); return customStylePane.updateBean();
return paneList; }
}
public void populateBean(Style style) {
if (style instanceof NameStyle) {
setSelectedIndex(0);
themedCellStyleListPane.populateBean((NameStyle) style);
} else {
setSelectedIndex(1);
customStylePane.populateBean(style);
}
} }
} }
Loading…
Cancel
Save