|
|
|
@ -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<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 CustomStylePane customStylePane; |
|
|
|
|
private ThemedCellStyleListPane themedCellStyleListPane; |
|
|
|
|
private JPanel createCustomStylePane() { |
|
|
|
|
return customStylePane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void comboBoxItemStateChanged() { |
|
|
|
|
if (jcb.getSelectedIndex() == 0 && themedCellStyleListPane.updateBean() != null) { |
|
|
|
|
customStylePane.populateBean(themedCellStyleListPane.updateBean()); |
|
|
|
|
} else { |
|
|
|
|
themedCellStyleListPane.populateBean(null); |
|
|
|
|
public void setSelectedIndex(int index) { |
|
|
|
|
if (0 <= index && index < FOLLOWING_THEME_STRING_ARRAYS.length) { |
|
|
|
|
followingThemeButtonGroup.setSelectedIndex(index); |
|
|
|
|
cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[index]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int getSelectedIndex() { |
|
|
|
|
return followingThemeButtonGroup.getSelectedIndex(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void addPredefinedChangeListener(ChangeListener changeListener) { |
|
|
|
|
themedCellStyleListPane.addChangeListener(changeListener); |
|
|
|
|
} |
|
|
|
@ -39,31 +147,41 @@ public class StylePane extends UIComboBoxPane<Style> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void updateBorder(Object[] selectionCellBorderObjects) { |
|
|
|
|
if (getSelectedIndex() == 0 && customStylePane.isBorderPaneSelected()) { |
|
|
|
|
if (getSelectedIndex() == 1 && customStylePane.isBorderPaneSelected()) { |
|
|
|
|
customStylePane.updateBorder(selectionCellBorderObjects); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void dealWithBorder(ElementCasePane ePane) { |
|
|
|
|
if (getSelectedIndex() == 0) { |
|
|
|
|
if (getSelectedIndex() == 1) { |
|
|
|
|
customStylePane.dealWithBorder(ePane); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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) { |
|
|
|
|
return customStylePane.updateStyle(style); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected List<FurtherBasicBeanPane<? extends Style>> initPaneList() { |
|
|
|
|
List<FurtherBasicBeanPane<? extends Style>> paneList = new ArrayList<>(); |
|
|
|
|
paneList.add(customStylePane = new CustomStylePane()); |
|
|
|
|
paneList.add(themedCellStyleListPane = new ThemedCellStyleListPane()); |
|
|
|
|
return paneList; |
|
|
|
|
public Style updateBean() { |
|
|
|
|
if (getSelectedIndex() == 0) { |
|
|
|
|
return themedCellStyleListPane.updateBean(); |
|
|
|
|
} else { |
|
|
|
|
return customStylePane.updateBean(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void populateBean(Style style) { |
|
|
|
|
if (style instanceof NameStyle) { |
|
|
|
|
setSelectedIndex(0); |
|
|
|
|
themedCellStyleListPane.populateBean((NameStyle) style); |
|
|
|
|
} else { |
|
|
|
|
setSelectedIndex(1); |
|
|
|
|
customStylePane.populateBean(style); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |