From 93ad4774f6d65411f539109c78a20778f24b3285 Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Mon, 18 May 2020 11:39:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?MOBILE-27000=20=E7=A7=BB=E5=8A=A8=E7=AB=AF?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E8=87=AA=E5=AE=9A=E4=B9=89=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mobile/ui/MobileStyleDefinePane.java | 91 +++++++++++++++--- .../mobile/ui/MobileStyleFontConfigPane.java | 95 +++++++++++++++++++ 2 files changed, 171 insertions(+), 15 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java index 93c24ad69..b700f758c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java @@ -2,15 +2,22 @@ package com.fr.design.mainframe.mobile.ui; import com.fr.base.background.ColorBackground; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.icombobox.LineComboBox; 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.TableLayoutHelper; import com.fr.design.style.color.ColorSelectBox; +import com.fr.design.style.color.NewColorSelectBox; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.form.ui.Widget; import com.fr.form.ui.mobile.MobileStyle; import com.fr.general.FRFont; import com.fr.invoke.Reflect; +import com.fr.stable.Constants; import javax.swing.*; import javax.swing.border.TitledBorder; @@ -19,12 +26,23 @@ import javax.swing.event.ChangeListener; import java.awt.*; public class MobileStyleDefinePane extends BasicBeanPane { - + private final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{ + Constants.LINE_NONE, + Constants.LINE_THIN, //1px + Constants.LINE_MEDIUM, //2px + Constants.LINE_THICK, //3px + }; + private static final int NORMAL_COMBO_WIDTH = 152; private Widget widget; private MobileStyleCustomDefinePane customBeanPane; private Class mobileStyleClazz; private ColorSelectBox colorSelectBox; private Color titleColor = new Color(47, 142, 241); + private JPanel commomPane; + private LineComboBox borderType; + private NewColorSelectBox borderColor; + private UISpinner borderRadius; + private MobileStyleFontConfigPane fontConfigPane; MobileStyleDefinePane(Widget widget, Class customBeanPaneClass, Class mobileStyleClazz) { @@ -40,6 +58,14 @@ public class MobileStyleDefinePane extends BasicBeanPane { if(ob.getBackground() != null) { colorSelectBox.setSelectObject(((ColorBackground)ob.getBackground()).getColor()); } + borderType.setSelectedLineStyle(ob.getBorderType()); + if (ob.getBorderColor() != null) { + borderColor.setSelectObject(ob.getBorderColor()); + } + borderRadius.setValue(ob.getBorderRadius()); + if (ob.getFont() != null) { + fontConfigPane.populateBean(ob.getFont()); + } } @Override @@ -48,6 +74,10 @@ public class MobileStyleDefinePane extends BasicBeanPane { this.widget.setMobileStyle(mobileStyle); this.customBeanPane.updateBean(); mobileStyle.setBackground(ColorBackground.getInstance(colorSelectBox.getSelectObject())); + mobileStyle.setBorderType(borderType.getSelectedLineStyle()); + mobileStyle.setBorderColor(borderColor.getSelectObject()); + mobileStyle.setBorderRadius(borderRadius.getValue()); + mobileStyle.setFont(fontConfigPane.updateBean()); return mobileStyle; } @@ -64,7 +94,7 @@ public class MobileStyleDefinePane extends BasicBeanPane { private void createGeneralPane() { createPreviewPane(); - createBackgroundPane(); + createCommonPane(); } private void createPreviewPane() { @@ -79,29 +109,49 @@ public class MobileStyleDefinePane extends BasicBeanPane { } } - private void createBackgroundPane() { - - JPanel backgroundPane = new JPanel(); - backgroundPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5)); - backgroundPane.setPreferredSize(new Dimension(500, 65)); - + private void createCommonPane() { TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute")); - backgroundPane.setBorder(titledBorder); + commomPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); + commomPane.setBorder(titledBorder); + this.add(commomPane, BorderLayout.NORTH); - UILabel colorSelectLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Widget_Background"), UILabel.RIGHT); - colorSelectLabel.setPreferredSize(new Dimension(65, 20)); + createBackgroundPane(); + createBorderPane(); + createFontPane(); + } - colorSelectBox = new ColorSelectBox(152); + private void createBackgroundPane() { + colorSelectBox = new ColorSelectBox(NORMAL_COMBO_WIDTH); colorSelectBox.addSelectChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { } }); - backgroundPane.add(colorSelectLabel); - backgroundPane.add(colorSelectBox); + JPanel backgroundPane = createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Background")), colorSelectBox); + commomPane.add(backgroundPane); + } - this.add(backgroundPane, BorderLayout.NORTH); + private void createBorderPane() { + borderType = new LineComboBox(BORDER_LINE_STYLE_ARRAY); + borderType.setSelectedLineStyle(Constants.LINE_THIN); + borderType.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 15, 20)); + borderColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH); + borderColor.addSelectChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + borderRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2); + borderRadius.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 20, 20)); + commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderType")), borderType)); + commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderColor")), borderColor)); + commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderRadius")), borderRadius)); + } + + private void createFontPane() { + fontConfigPane = new MobileStyleFontConfigPane(); + commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Font")), fontConfigPane)); } private void createCustomPane() { @@ -109,6 +159,7 @@ public class MobileStyleDefinePane extends BasicBeanPane { TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Set")); configPane.setBorder(titledBorder); + JPanel container = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); configPane.add(this.customBeanPane, BorderLayout.CENTER); this.add(configPane, BorderLayout.CENTER); @@ -119,4 +170,14 @@ public class MobileStyleDefinePane extends BasicBeanPane { titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12)); return titledBorder; } + + private UILabel createConfigLabel(String title) { + UILabel label = new UILabel(title + ":", UILabel.RIGHT); + label.setPreferredSize(new Dimension(75, 20)); + return label; + } + + private JPanel createLeftRightComponentsPane(Component... components) { + return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{components}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java new file mode 100644 index 000000000..dedd06c86 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java @@ -0,0 +1,95 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.base.BaseUtils; +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.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; +import com.fr.stable.Constants; + +import javax.swing.*; +import java.awt.*; +import java.util.Vector; + +public class MobileStyleFontConfigPane extends JPanel { + private static final int MAX_FONT_SIZE = 18; + private static final int MIN_FONT_SIZE = 12; + private static final Dimension BUTTON_SIZE = new Dimension(20, 18); + + public static Vector getFontSizes() { + Vector FONT_SIZES = new Vector(); + for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) { + FONT_SIZES.add(i); + } + return FONT_SIZES; + } + + private UIComboBox fontSizeComboBox; + private UIToggleButton underline; + private UIToggleButton italic; + private UIToggleButton bold; + + public MobileStyleFontConfigPane() { + this.initComponent(); + } + + private void initComponent() { + + fontSizeComboBox = new UIComboBox(getFontSizes()); + fontSizeComboBox.setSelectedItem(16); + fontSizeComboBox.setPreferredSize(new Dimension(60, 20)); + fontSizeComboBox.setEditable(true); + underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.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")); + + this.setButtonsTips(); + this.setButtonsSize(BUTTON_SIZE); + + Component[] components_font = new Component[]{ + fontSizeComboBox, underline, italic, bold + }; + + JPanel buttonPane = new JPanel(new BorderLayout()); + buttonPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE)); + + this.setLayout(new BorderLayout(0,0)); + this.add(buttonPane, BorderLayout.CENTER); + } + + private void setButtonsTips() { + underline.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Underline")); + italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Italic")); + bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bold")); + } + + private void setButtonsSize(Dimension size) { + underline.setPreferredSize(size); + italic.setPreferredSize(size); + bold.setPreferredSize(size); + } + + + public void populateBean(FRFont frFont) { + fontSizeComboBox.setSelectedItem(frFont.getSize()); + bold.setSelected(frFont.isBold()); + italic.setSelected(frFont.isItalic()); + underline.setSelected(frFont.getUnderline() != Constants.LINE_NONE); + } + + public FRFont updateBean() { + int style = Font.PLAIN; + style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN; + style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN; + return FRFont.getInstance( + FRFont.DEFAULT_FONTNAME, + style, + Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()), + Color.BLACK, + underline.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE + ); + } +} From 3f0db7cd7a138fce57817a6b04a8c19199022455 Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Mon, 18 May 2020 14:29:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?import=20=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/mobile/ui/MobileStyleDefinePane.java | 10 ++++++++-- .../mobile/ui/MobileStyleFontConfigPane.java | 12 ++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java index b700f758c..c729b5fc0 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java @@ -19,11 +19,17 @@ import com.fr.general.FRFont; import com.fr.invoke.Reflect; import com.fr.stable.Constants; -import javax.swing.*; +import javax.swing.JPanel; import javax.swing.border.TitledBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; + public class MobileStyleDefinePane extends BasicBeanPane { private final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{ diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java index dedd06c86..7ea91353a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java @@ -2,7 +2,6 @@ package com.fr.design.mainframe.mobile.ui; import com.fr.base.BaseUtils; 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.icombobox.UIComboBox; import com.fr.design.i18n.Toolkit; @@ -10,11 +9,16 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; import com.fr.stable.Constants; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; import java.util.Vector; -public class MobileStyleFontConfigPane extends JPanel { +public class MobileStyleFontConfigPane extends JPanel { private static final int MAX_FONT_SIZE = 18; private static final int MIN_FONT_SIZE = 12; private static final Dimension BUTTON_SIZE = new Dimension(20, 18);