Browse Source

MOBILE-27220 在表单移动端属性加一个“默认”和“自定义样式”开关

final/10.0
kuangshuai 5 years ago
parent
commit
512cd4b120
  1. 39
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java
  2. 21
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java

39
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java

@ -5,6 +5,7 @@ import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.icombobox.LineComboBox; 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.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -21,14 +22,14 @@ import com.fr.stable.Constants;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Font; import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> { public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
@ -42,6 +43,8 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private Widget widget; private Widget widget;
private MobileStyleCustomDefinePane customBeanPane; private MobileStyleCustomDefinePane customBeanPane;
private Class<? extends MobileStyle> mobileStyleClazz; private Class<? extends MobileStyle> mobileStyleClazz;
private UIComboBox customCombo;
private JPanel settingPane;
private ColorSelectBox colorSelectBox; private ColorSelectBox colorSelectBox;
private Color titleColor = new Color(47, 142, 241); private Color titleColor = new Color(47, 142, 241);
private JPanel commomPane; private JPanel commomPane;
@ -62,6 +65,8 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
@Override @Override
public void populateBean(MobileStyle ob) { public void populateBean(MobileStyle ob) {
this.customBeanPane.populateBean(ob); this.customBeanPane.populateBean(ob);
customCombo.setSelectedIndex(ob.isCommonCustom() ? 1 : 0);
if(ob.getBackground() != null) { if(ob.getBackground() != null) {
colorSelectBox.setSelectObject(((ColorBackground)ob.getBackground()).getColor()); colorSelectBox.setSelectObject(((ColorBackground)ob.getBackground()).getColor());
} }
@ -83,6 +88,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get(); MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get();
this.widget.setMobileStyle(mobileStyle); this.widget.setMobileStyle(mobileStyle);
this.customBeanPane.updateBean(); this.customBeanPane.updateBean();
mobileStyle.setCommonCustom(customCombo.getSelectedIndex() == 1);
mobileStyle.setBackground(ColorBackground.getInstance(colorSelectBox.getSelectObject())); mobileStyle.setBackground(ColorBackground.getInstance(colorSelectBox.getSelectObject()));
mobileStyle.setBorderType(borderType.getSelectedLineStyle()); mobileStyle.setBorderType(borderType.getSelectedLineStyle());
mobileStyle.setBorderColor(borderColor.getSelectObject()); mobileStyle.setBorderColor(borderColor.getSelectObject());
@ -126,6 +132,22 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
commomPane.setBorder(titledBorder); commomPane.setBorder(titledBorder);
this.add(commomPane, BorderLayout.NORTH); this.add(commomPane, BorderLayout.NORTH);
customCombo = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Mobile_Default"), Toolkit.i18nText("FIne-Design_Mobile_Custom")});
customCombo.setSelectedIndex(0);
customCombo.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 15, 20));
customCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean custom = customCombo.getSelectedIndex() == 1;
settingPane.setVisible(custom);
}
});
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Attribute_Settings")), customCombo));
settingPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
settingPane.setVisible(false);
commomPane.add(settingPane);
createBackgroundPane(); createBackgroundPane();
createBorderPane(); createBorderPane();
createIconSettingPane(); createIconSettingPane();
@ -136,7 +158,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
colorSelectBox = new ColorSelectBox(NORMAL_COMBO_WIDTH); colorSelectBox = new ColorSelectBox(NORMAL_COMBO_WIDTH);
JPanel backgroundPane = createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Background")), colorSelectBox); JPanel backgroundPane = createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Background")), colorSelectBox);
commomPane.add(backgroundPane); settingPane.add(backgroundPane);
} }
private void createBorderPane() { private void createBorderPane() {
@ -146,19 +168,20 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
borderColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH); borderColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH);
borderRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2); borderRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2);
borderRadius.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 20, 20)); borderRadius.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 20, 20));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderType")), borderType)); settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderType")), borderType));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderColor")), borderColor)); settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderColor")), borderColor));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderRadius")), borderRadius)); settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderRadius")), borderRadius));
} }
private void createIconSettingPane() { private void createIconSettingPane() {
iconColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH); iconColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH);
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Icon_Color")), iconColor)); iconColor.setSelectObject(new Color(31,173,229));
settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Icon_Color")), iconColor));
} }
private void createFontPane() { private void createFontPane() {
fontConfigPane = new MobileStyleFontConfigPane(); fontConfigPane = new MobileStyleFontConfigPane();
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Font")), fontConfigPane)); settingPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Font")), fontConfigPane));
} }
private void createCustomPane() { private void createCustomPane() {

21
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java

@ -2,6 +2,7 @@ package com.fr.design.mainframe.mobile.ui;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.icombobox.UIComboBoxRenderer;
@ -16,7 +17,6 @@ import javax.swing.JLabel;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
@ -31,7 +31,6 @@ public class MobileStyleFontConfigPane extends JPanel {
public static Vector<Integer> getFontSizes() { public static Vector<Integer> getFontSizes() {
Vector<Integer> FONT_SIZES = new Vector<Integer>(); Vector<Integer> FONT_SIZES = new Vector<Integer>();
FONT_SIZES.add(FONT_NONE);
for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) { for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) {
FONT_SIZES.add(i); FONT_SIZES.add(i);
} }
@ -39,7 +38,7 @@ public class MobileStyleFontConfigPane extends JPanel {
} }
private UIComboBox fontSizeComboBox; private UIComboBox fontSizeComboBox;
private UIToggleButton underline; private UIColorButton color;
private UIToggleButton italic; private UIToggleButton italic;
private UIToggleButton bold; private UIToggleButton bold;
@ -51,10 +50,10 @@ public class MobileStyleFontConfigPane extends JPanel {
fontSizeComboBox = new UIComboBox(); fontSizeComboBox = new UIComboBox();
fontSizeComboBox.setModel(new DefaultComboBoxModel(getFontSizes())); fontSizeComboBox.setModel(new DefaultComboBoxModel(getFontSizes()));
fontSizeComboBox.setSelectedItem(0); fontSizeComboBox.setSelectedItem(16);
fontSizeComboBox.setPreferredSize(new Dimension(60, 20)); fontSizeComboBox.setPreferredSize(new Dimension(60, 20));
fontSizeComboBox.setRenderer(new LineCellRenderer()); fontSizeComboBox.setRenderer(new LineCellRenderer());
underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png")); color = new UIColorButton();
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
@ -62,7 +61,7 @@ public class MobileStyleFontConfigPane extends JPanel {
this.setButtonsSize(BUTTON_SIZE); this.setButtonsSize(BUTTON_SIZE);
Component[] components_font = new Component[]{ Component[] components_font = new Component[]{
fontSizeComboBox, underline, italic, bold fontSizeComboBox, color, italic, bold
}; };
JPanel buttonPane = new JPanel(new BorderLayout()); JPanel buttonPane = new JPanel(new BorderLayout());
@ -73,13 +72,13 @@ public class MobileStyleFontConfigPane extends JPanel {
} }
private void setButtonsTips() { private void setButtonsTips() {
underline.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Underline")); color.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Foreground"));
italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Italic")); italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Italic"));
bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bold")); bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bold"));
} }
private void setButtonsSize(Dimension size) { private void setButtonsSize(Dimension size) {
underline.setPreferredSize(size); color.setPreferredSize(size);
italic.setPreferredSize(size); italic.setPreferredSize(size);
bold.setPreferredSize(size); bold.setPreferredSize(size);
} }
@ -87,9 +86,9 @@ public class MobileStyleFontConfigPane extends JPanel {
public void populateBean(FRFont frFont) { public void populateBean(FRFont frFont) {
fontSizeComboBox.setSelectedItem(frFont.getSize()); fontSizeComboBox.setSelectedItem(frFont.getSize());
color.setColor(frFont.getForeground());
bold.setSelected(frFont.isBold()); bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic()); italic.setSelected(frFont.isItalic());
underline.setSelected(frFont.getUnderline() != Constants.LINE_NONE);
} }
public FRFont updateBean() { public FRFont updateBean() {
@ -100,8 +99,8 @@ public class MobileStyleFontConfigPane extends JPanel {
FRFont.DEFAULT_FONTNAME, FRFont.DEFAULT_FONTNAME,
style, style,
Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()), Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()),
Color.BLACK, color.getColor(),
underline.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE Constants.LINE_NONE
); );
} }

Loading…
Cancel
Save