From 18ba11eff8df43a2242b43e3e836cc44aab7f4ef Mon Sep 17 00:00:00 2001 From: kunsnat Date: Wed, 3 Aug 2016 17:22:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/mobile/MobileUseHtmlGroupPane.java | 130 ++++++++++++++++++ .../report/mobile/ReportMobileAttrPane.java | 12 +- 2 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 designer/src/com/fr/design/report/mobile/MobileUseHtmlGroupPane.java diff --git a/designer/src/com/fr/design/report/mobile/MobileUseHtmlGroupPane.java b/designer/src/com/fr/design/report/mobile/MobileUseHtmlGroupPane.java new file mode 100644 index 0000000000..cab8f0f635 --- /dev/null +++ b/designer/src/com/fr/design/report/mobile/MobileUseHtmlGroupPane.java @@ -0,0 +1,130 @@ +package com.fr.design.report.mobile; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.border.UITitledBorder; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.general.Inter; +import com.fr.report.mobile.ElementCaseMobileAttr; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by kunsnat on 2016/8/3. + */ +public class MobileUseHtmlGroupPane extends BasicBeanPane { + + private List radioButtons = new ArrayList(); + + public MobileUseHtmlGroupPane() { + initComponents(); + } + + private void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(UITitledBorder.createBorderWithTitle(this.title4PopupWindow())); + + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p}; + double[] columnSize = {p, p, p}; + + UIRadioButton useApp = new UIRadioButton(Inter.getLocText("FR-mobile_native_analysis")); + useApp.setSelected(true); + UIRadioButton useHTML5 = new UIRadioButton(Inter.getLocText("FR-mobile_html_analysis")); + + addToButtonGroup(useApp, useHTML5); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Inter.getLocText("FR-mobile_analysis_style")), useApp, useHTML5}, + new Component[]{new UILabel(Inter.getLocText("FR-mobile_analysis_annotation")), null, null} + }; + JPanel usePane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + usePane.setBorder(BorderFactory.createEmptyBorder(10, 13, 10, 10)); + + this.add(usePane); + } + + private void addToButtonGroup(UIRadioButton... radios) { + ButtonGroup buttonGroup = new ButtonGroup(); + for (UIRadioButton radio : radios) { + radioButtons.add(radio); + buttonGroup.add(radio); + } + } + + /** + * 设置按钮状态 + */ + public void setEnabled(boolean enabled) { + for (UIRadioButton radioButton : radioButtons) { + radioButton.setEnabled(enabled); + } + } + + /** + * 获取当前选中的按钮index + * + * @return 按钮index + */ + public int getSelectRadioIndex() { + for (int i = 0, len = radioButtons.size(); i < len; i++) { + if (radioButtons.get(i).isSelected()) { + return i; + } + } + + return 0; + } + + /** + * 选中指定index的按钮 + */ + public void selectIndexButton(int index) { + if (index < 0 || index > radioButtons.size() - 1) { + return; + } + + UIRadioButton button = radioButtons.get(index); + button.setSelected(true); + } + + /** + * 给所有的按钮加上监听 + */ + public void addActionListener(ActionListener actionListener) { + for (UIRadioButton radioButton : radioButtons) { + radioButton.addActionListener(actionListener); + } + } + + @Override + public void populateBean(ElementCaseMobileAttr mobileAttr) { + if(mobileAttr != null) { + selectIndexButton(mobileAttr.isUseHTML() ? 1 : 0); + } + } + + @Override + public ElementCaseMobileAttr updateBean() { + return null; + } + + @Override + public void updateBean(ElementCaseMobileAttr mobileAttr) { + if(mobileAttr != null) { + mobileAttr.setUseHTML(getSelectRadioIndex() == 1); + } + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("FR-mobile_report_analysis"); + } +} diff --git a/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java b/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java index 1d2d399319..3c00232194 100644 --- a/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java +++ b/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java @@ -14,6 +14,8 @@ public class ReportMobileAttrPane extends BasicBeanPane{ private AppFitBrowserPane appFitBrowserPane; + private MobileUseHtmlGroupPane htmlGroupPane; + public ReportMobileAttrPane() { initComponents(); } @@ -27,6 +29,8 @@ public class ReportMobileAttrPane extends BasicBeanPane{ appFitBrowserPane.setAppFitPreviewPane(appFitPreviewPane); this.add(appFitBrowserPane); + this.add(htmlGroupPane = new MobileUseHtmlGroupPane()); + this.add(appFitPreviewPane); } @@ -37,11 +41,17 @@ public class ReportMobileAttrPane extends BasicBeanPane{ } appFitBrowserPane.populateBean(ob); + htmlGroupPane.populateBean(ob); + } @Override public ElementCaseMobileAttr updateBean() { - return appFitBrowserPane.updateBean(); + ElementCaseMobileAttr caseMobileAttr = appFitBrowserPane.updateBean(); + + htmlGroupPane.updateBean(caseMobileAttr); + + return caseMobileAttr; } @Override From c1740ebe1c4758334c3331bd145d91c1e03fa8de Mon Sep 17 00:00:00 2001 From: kunsnat Date: Wed, 3 Aug 2016 17:29:07 +0800 Subject: [PATCH 2/2] T --- .../src/com/fr/design/report/mobile/MobileUseHtmlGroupPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer/src/com/fr/design/report/mobile/MobileUseHtmlGroupPane.java b/designer/src/com/fr/design/report/mobile/MobileUseHtmlGroupPane.java index cab8f0f635..50c5e32381 100644 --- a/designer/src/com/fr/design/report/mobile/MobileUseHtmlGroupPane.java +++ b/designer/src/com/fr/design/report/mobile/MobileUseHtmlGroupPane.java @@ -37,7 +37,7 @@ public class MobileUseHtmlGroupPane extends BasicBeanPane UIRadioButton useApp = new UIRadioButton(Inter.getLocText("FR-mobile_native_analysis")); useApp.setSelected(true); - UIRadioButton useHTML5 = new UIRadioButton(Inter.getLocText("FR-mobile_html_analysis")); + UIRadioButton useHTML5 = new UIRadioButton(Inter.getLocText("FR-mobile_html_analysis")); addToButtonGroup(useApp, useHTML5);