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.
288 lines
14 KiB
288 lines
14 KiB
package com.fr.design.mainframe.mobile.ui.radiogroup; |
|
|
|
import com.fr.design.constants.LayoutConstants; |
|
import com.fr.design.designer.IntervalConstants; |
|
import com.fr.design.dialog.AttrScrollPane; |
|
import com.fr.design.dialog.BasicScrollPane; |
|
import com.fr.design.gui.ibutton.UIColorButton; |
|
import com.fr.design.gui.icombobox.LineComboBox; |
|
import com.fr.design.gui.icombobox.UIComboBox; |
|
import com.fr.design.gui.ilable.UILabel; |
|
import com.fr.design.gui.ispinner.UISpinner; |
|
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.mobile.ui.MobileStyleCustomDefinePane; |
|
import com.fr.design.mainframe.mobile.utils.DesignerUtils; |
|
import com.fr.design.mainframe.mobile.utils.FontConfigPane; |
|
import com.fr.design.style.color.NewColorSelectBox; |
|
import com.fr.form.ui.Widget; |
|
import com.fr.form.ui.mobile.MobileStyle; |
|
import com.fr.form.ui.mobile.radiogroup.UnitedMobileStyle; |
|
import com.fr.general.FRFont; |
|
import com.fr.stable.Constants; |
|
|
|
import javax.swing.*; |
|
import javax.swing.event.ChangeEvent; |
|
import javax.swing.event.ChangeListener; |
|
import java.awt.*; |
|
import java.awt.event.ItemEvent; |
|
import java.awt.event.ItemListener; |
|
|
|
public class UnitedCustomDefinePane extends MobileStyleCustomDefinePane { |
|
|
|
private JPanel scrollPanel; |
|
private UIComboBox custom; |
|
private JPanel centerPane; |
|
|
|
private UISpinner leftSpinner; |
|
private UISpinner rightSpinner; |
|
private UISpinner topSpinner; |
|
private UISpinner bottomSpinner; |
|
|
|
private UIComboBox buttonAlignCombo; |
|
private NewColorSelectBox initialColorSelectBox; |
|
private NewColorSelectBox selectedColorSelectBox; |
|
|
|
private LineComboBox borderLineCombo; |
|
private NewColorSelectBox borderColor; |
|
private UISpinner borderRadiusSpinner; |
|
|
|
private FontConfigPane initialFontConfPane; |
|
private UIColorButton selectedFontColor; |
|
|
|
public UnitedCustomDefinePane(Widget widget) { |
|
super(widget); |
|
} |
|
|
|
@Override |
|
protected JPanel createPreviewPane() { |
|
return null; |
|
} |
|
|
|
@Override |
|
protected void init() { |
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
this.addScrollPane(); |
|
this.addStyleSelectPane(); |
|
this.addConfigPane(); |
|
} |
|
|
|
private void addScrollPane() { |
|
scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
BasicScrollPane basicScrollPane = new AttrScrollPane() { |
|
@Override |
|
protected JPanel createContentPane() { |
|
return scrollPanel; |
|
} |
|
}; |
|
this.add(basicScrollPane); |
|
} |
|
|
|
private void addStyleSelectPane() { |
|
JPanel stylePanel = new JPanel(); |
|
stylePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); |
|
UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Style")); |
|
custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-RadioGroup_Style_Default"), |
|
Toolkit.i18nText("Fine-Plugin-RadioGroup_Style_Custom")}); |
|
custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); |
|
custom.addItemListener(new ItemListener() { |
|
@Override |
|
public void itemStateChanged(ItemEvent e) { |
|
boolean isCustom = custom.getSelectedIndex() == 1; |
|
centerPane.setVisible(isCustom); |
|
} |
|
}); |
|
stylePanel.add(buttonStyleLabel); |
|
stylePanel.add(custom); |
|
scrollPanel.add(stylePanel, BorderLayout.NORTH); |
|
} |
|
|
|
private void addConfigPane() { |
|
centerPane = createCenterPane(); |
|
centerPane.setVisible(false); |
|
|
|
addPaddingPane(); |
|
addBackgroundPane(); |
|
addBorderPane(); |
|
addFontPane(); |
|
|
|
scrollPanel.add(centerPane, BorderLayout.CENTER); |
|
custom.setSelectedIndex(1); |
|
} |
|
|
|
private JPanel createCenterPane() { |
|
return FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); |
|
} |
|
|
|
private void addPaddingPane() { |
|
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Layout"))); |
|
UILabel buttonAlignLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Alignment")); |
|
UILabel paddingHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Button_Padding")); |
|
UILabel emptyHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("")); |
|
|
|
UILabel leftLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Left")); |
|
leftSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultHorizontalPadding); |
|
|
|
UILabel rightLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Right")); |
|
rightSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultHorizontalPadding); |
|
|
|
UILabel topLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Top")); |
|
topSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultVerticalPadding); |
|
|
|
UILabel bottomLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Bottom")); |
|
bottomSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultVerticalPadding); |
|
|
|
JPanel leftSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftLabel, leftSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); |
|
JPanel rightSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{rightLabel, rightSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); |
|
JPanel topSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{topLabel, topSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); |
|
JPanel bottomSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{bottomLabel, bottomSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); |
|
|
|
JPanel vPaddingSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{topSpinnerPanel, bottomSpinnerPanel}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL); |
|
JPanel hPaddingSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftSpinnerPanel, rightSpinnerPanel}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL); |
|
// 按钮排布下拉框 |
|
buttonAlignCombo = new UIComboBox(new String[]{ |
|
Toolkit.i18nText("Fine-Plugin-RadioGroup_Alignment_Split"), |
|
Toolkit.i18nText("Fine-Plugin-RadioGroup_Alignment_Nature"), |
|
}); |
|
buttonAlignCombo.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); |
|
double p = TableLayout.PREFERRED; |
|
double[] rowSize = {p, p, p}; |
|
double[] columnSize = {p, p}; |
|
JPanel paddingPanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{ |
|
{paddingHintLabel, vPaddingSpinnerPanel}, |
|
{emptyHintLabel, hPaddingSpinnerPanel}, |
|
{buttonAlignLabel, buttonAlignCombo} |
|
}, rowSize, columnSize, 10); |
|
|
|
centerPane.add(paddingPanel); |
|
} |
|
|
|
private void addBackgroundPane() { |
|
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background"))); |
|
|
|
UILabel initialColorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background_Init")); |
|
initialColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { |
|
@Override |
|
public void stateChanged(ChangeEvent e) { |
|
} |
|
}); |
|
initialColorSelectBox.setSelectObject(Color.WHITE); |
|
JPanel initialColorSelectPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initialColorLabel, initialColorSelectBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
|
centerPane.add(initialColorSelectPane); |
|
|
|
UILabel selectedColorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background_Select")); |
|
selectedColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { |
|
@Override |
|
public void stateChanged(ChangeEvent e) { |
|
|
|
} |
|
}); |
|
selectedColorSelectBox.setSelectObject(new Color(31, 173, 229)); |
|
JPanel selectedColorSelectPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectedColorLabel, selectedColorSelectBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
|
centerPane.add(selectedColorSelectPane); |
|
} |
|
|
|
private void addBorderPane() { |
|
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border"))); |
|
|
|
UILabel borderTypeLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Line")); |
|
borderLineCombo = new LineComboBox(DesignerUtils.BORDER_LINE_STYLE_ARRAY); |
|
borderLineCombo.setSelectedLineStyle(Constants.LINE_THIN); |
|
|
|
UILabel colorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Color")); |
|
borderColor = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { |
|
@Override |
|
public void stateChanged(ChangeEvent e) { |
|
} |
|
}); |
|
borderColor.setSelectObject(new Color(31, 173, 229) ); |
|
|
|
UILabel radiusLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Radius")); |
|
borderRadiusSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 2); |
|
borderRadiusSpinner.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); |
|
|
|
double p = TableLayout.PREFERRED; |
|
double[] rowSize = {p, p, p}; |
|
double[] columnSize = {p, p}; |
|
JPanel borderPanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][] { |
|
{borderTypeLabel, borderLineCombo}, |
|
{colorLabel, borderColor}, |
|
{radiusLabel, borderRadiusSpinner} |
|
}, rowSize, columnSize, 10); |
|
|
|
centerPane.add(borderPanel); |
|
|
|
} |
|
|
|
private void addFontPane() { |
|
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font"))); |
|
|
|
UILabel initialFontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font_init")); |
|
initialFontConfPane = new FontConfigPane(); |
|
initialFontConfPane.setFontColor(new Color(31, 173, 229)); |
|
JPanel fontPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initialFontLabel, initialFontConfPane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
|
centerPane.add(fontPanel); |
|
UILabel selectedFontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font_Select")); |
|
selectedFontColor = new UIColorButton(); |
|
selectedFontColor.setPreferredSize(new Dimension(20, 20)); |
|
selectedFontColor.setColor(Color.WHITE); |
|
JPanel selectFontColorPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectedFontLabel, selectedFontColor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
|
centerPane.add(selectFontColorPanel); |
|
|
|
} |
|
|
|
@Override |
|
public void populateBean(MobileStyle ob) { |
|
UnitedMobileStyle mobileStyle = (UnitedMobileStyle) ob; |
|
custom.setSelectedIndex(mobileStyle.isCustom() ? 1 : 0); |
|
leftSpinner.setValue(mobileStyle.getLeftPadding()); |
|
rightSpinner.setValue(mobileStyle.getRightPadding()); |
|
topSpinner.setValue(mobileStyle.getTopPadding()); |
|
bottomSpinner.setValue(mobileStyle.getBottomPadding()); |
|
buttonAlignCombo.setSelectedIndex(mobileStyle.getButtonAlign()); |
|
initialColorSelectBox.setSelectObject(mobileStyle.getInitialBackgroundColor()); |
|
selectedColorSelectBox.setSelectObject(mobileStyle.getSelectedBackgroundColor()); |
|
borderLineCombo.setSelectedLineStyle(mobileStyle.getBorderType()); |
|
borderColor.setSelectObject(mobileStyle.getBorderColor()); |
|
borderRadiusSpinner.setValue(mobileStyle.getBorderRadius()); |
|
if(mobileStyle.getInitialFont() != null) { |
|
initialFontConfPane.populate(mobileStyle.getInitialFont()); |
|
} |
|
if(mobileStyle.getSelectedFont() != null) { |
|
selectedFontColor.setColor(mobileStyle.getSelectedFont().getForeground()); |
|
} |
|
} |
|
|
|
@Override |
|
public MobileStyle updateBean() { |
|
UnitedMobileStyle mobileStyle = (UnitedMobileStyle)this.widget.getMobileStyle(); |
|
|
|
mobileStyle.setCustom(custom.getSelectedIndex() == 1); |
|
mobileStyle.setLeftPadding(leftSpinner.getValue()); |
|
mobileStyle.setRightPadding(rightSpinner.getValue()); |
|
mobileStyle.setTopPadding(topSpinner.getValue()); |
|
mobileStyle.setBottomPadding(bottomSpinner.getValue()); |
|
mobileStyle.setButtonAlign(buttonAlignCombo.getSelectedIndex()); |
|
mobileStyle.setInitialBackgroundColor(initialColorSelectBox.getSelectObject()); |
|
mobileStyle.setSelectedBackgroundColor(selectedColorSelectBox.getSelectObject()); |
|
mobileStyle.setBorderType(borderLineCombo.getSelectedLineStyle()); |
|
mobileStyle.setBorderColor(borderColor.getSelectObject()); |
|
mobileStyle.setBorderRadius(borderRadiusSpinner.getValue()); |
|
|
|
FRFont initialFont = initialFontConfPane.updateFont(null, null, null); |
|
FRFont selectedFont = initialFontConfPane.updateFont(selectedFontColor.getColor(), null, null); |
|
selectedFont.setForeground(selectedFontColor.getColor()); |
|
|
|
mobileStyle.setInitialFont(initialFont); |
|
mobileStyle.setSelectedFont(selectedFont); |
|
|
|
return mobileStyle; |
|
} |
|
|
|
@Override |
|
protected String title4PopupWindow() { |
|
return null; |
|
} |
|
}
|
|
|