From ef34c9236732a63be0efc63be51505189d07001c Mon Sep 17 00:00:00 2001 From: fanglei <294531121> Date: Thu, 29 Dec 2016 11:18:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E8=A1=A8=E5=8D=95->=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E8=8F=9C=E5=8D=95->=E7=A7=BB=E5=8A=A8=E7=AB=AF=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E4=B8=AD=E5=8A=A0=E5=85=A5=E6=8A=A5=E8=A1=A8=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E6=96=B9=E5=BC=8F=E7=9A=84=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/mobile/MobileUseHtmlGroupPane.java | 106 +---------------- .../mobile/MobileUseHtmlGroupBeanPane.java | 112 ++++++++++++++++++ .../form/mobile/FormMobileAttrPane.java | 33 ++++-- .../form/mobile/MobileUseHtmlGroupPane.java | 29 +++++ 4 files changed, 167 insertions(+), 113 deletions(-) create mode 100644 designer_base/src/com/fr/design/dialog/mobile/MobileUseHtmlGroupBeanPane.java create mode 100644 designer_form/src/com/fr/design/form/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 index 50c5e3238..0e0ec087d 100644 --- a/designer/src/com/fr/design/report/mobile/MobileUseHtmlGroupPane.java +++ b/designer/src/com/fr/design/report/mobile/MobileUseHtmlGroupPane.java @@ -1,109 +1,12 @@ 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.design.dialog.mobile.MobileUseHtmlGroupBeanPane; 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); - } - } - +public class MobileUseHtmlGroupPane extends MobileUseHtmlGroupBeanPane { @Override public void populateBean(ElementCaseMobileAttr mobileAttr) { if(mobileAttr != null) { @@ -122,9 +25,4 @@ public class MobileUseHtmlGroupPane extends BasicBeanPane mobileAttr.setUseHTML(getSelectRadioIndex() == 1); } } - - @Override - protected String title4PopupWindow() { - return Inter.getLocText("FR-mobile_report_analysis"); - } } diff --git a/designer_base/src/com/fr/design/dialog/mobile/MobileUseHtmlGroupBeanPane.java b/designer_base/src/com/fr/design/dialog/mobile/MobileUseHtmlGroupBeanPane.java new file mode 100644 index 000000000..5ddf61e56 --- /dev/null +++ b/designer_base/src/com/fr/design/dialog/mobile/MobileUseHtmlGroupBeanPane.java @@ -0,0 +1,112 @@ +package com.fr.design.dialog.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 javax.swing.*; +import java.awt.*; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + +/** + * 由于MobileUserHtmlGroupPane 现在在report和form中均会用到,会出现重复代码,故放入base中 + * Created by fanglei on 2016/12/28. + */ +public abstract class MobileUseHtmlGroupBeanPane extends BasicBeanPane { + + private List radioButtons = new ArrayList(); + + public MobileUseHtmlGroupBeanPane() { + 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 + protected String title4PopupWindow() { + return Inter.getLocText("FR-mobile_report_analysis"); + } +} + diff --git a/designer_form/src/com/fr/design/form/mobile/FormMobileAttrPane.java b/designer_form/src/com/fr/design/form/mobile/FormMobileAttrPane.java index 0aafd8258..2431ebc8d 100644 --- a/designer_form/src/com/fr/design/form/mobile/FormMobileAttrPane.java +++ b/designer_form/src/com/fr/design/form/mobile/FormMobileAttrPane.java @@ -1,6 +1,7 @@ package com.fr.design.form.mobile; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.form.main.mobile.FormMobileAttr; import com.fr.general.Inter; @@ -15,22 +16,34 @@ public class FormMobileAttrPane extends BasicBeanPane{ //工具栏容器 private MobileToolBarPane mobileToolBarPane; + //h5解析容器 + private MobileUseHtmlGroupPane mobileUseHtmlGroupPane; + static final int paddingHeight = 10; public FormMobileAttrPane() { this.initComponents(); } + //现在只有两个panel,填不满自适应对话框,只能为工具栏Panel和h5解析方式panel分别包裹上一层Panel再计算高度,不然会自动 + //拉长两个Panel的高度去填满整个对话框。 private void initComponents() { - JPanel jPanel = new JPanel(); + JPanel jPanel1 = new JPanel(); + JPanel jPanel2 = new JPanel(); this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - jPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); + jPanel1.setLayout(FRGUIPaneFactory.createBorderLayout()); + jPanel1.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + jPanel2.setLayout(FRGUIPaneFactory.createBorderLayout()); + jPanel2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.mobileToolBarPane = new MobileToolBarPane(); + this.mobileUseHtmlGroupPane = new MobileUseHtmlGroupPane(); //设置一个JPanel包裹mobileToolBarPane这个Panel,让jPanel的高度等于mobileToolBarPane高度加10,再放入this中 - jPanel.setPreferredSize(new Dimension(0, (int)this.mobileToolBarPane.getPreferredSize().getHeight() + paddingHeight)); - jPanel.add("North", mobileToolBarPane); - this.add(jPanel); + jPanel1.setPreferredSize(new Dimension(0, (int)this.mobileToolBarPane.getPreferredSize().getHeight() + paddingHeight)); + jPanel2.setPreferredSize(new Dimension(0, (int)this.mobileUseHtmlGroupPane.getPreferredSize().getHeight() + paddingHeight)); + jPanel1.add("North", this.mobileUseHtmlGroupPane); + jPanel2.add("North", this.mobileToolBarPane); + this.add("North", jPanel1); + this.add("Center", jPanel2); } @Override @@ -39,13 +52,15 @@ public class FormMobileAttrPane extends BasicBeanPane{ ob = new FormMobileAttr(); } this.mobileToolBarPane.populateBean(ob); + this.mobileUseHtmlGroupPane.populateBean(ob); } @Override public FormMobileAttr updateBean() { - FormMobileAttr caseMobileAttr = new FormMobileAttr(); - this.mobileToolBarPane.updateBean(caseMobileAttr); - return caseMobileAttr; + FormMobileAttr formMobileAttr = new FormMobileAttr(); + this.mobileToolBarPane.updateBean(formMobileAttr); + this.mobileUseHtmlGroupPane.updateBean(formMobileAttr); + return formMobileAttr; } @Override diff --git a/designer_form/src/com/fr/design/form/mobile/MobileUseHtmlGroupPane.java b/designer_form/src/com/fr/design/form/mobile/MobileUseHtmlGroupPane.java new file mode 100644 index 000000000..45550a842 --- /dev/null +++ b/designer_form/src/com/fr/design/form/mobile/MobileUseHtmlGroupPane.java @@ -0,0 +1,29 @@ +package com.fr.design.form.mobile; + +import com.fr.design.dialog.mobile.MobileUseHtmlGroupBeanPane; +import com.fr.form.main.mobile.FormMobileAttr; + +/** + * 直接copyreport中的MobileUseHtmlGroupPane + * Created by fanglei on 2016/12/28. + */ +public class MobileUseHtmlGroupPane extends MobileUseHtmlGroupBeanPane { + @Override + public void populateBean(FormMobileAttr mobileAttr) { + if(mobileAttr != null) { + selectIndexButton(mobileAttr.isUseHTML() ? 1 : 0); + } + } + + @Override + public FormMobileAttr updateBean() { + return null; + } + + @Override + public void updateBean(FormMobileAttr mobileAttr) { + if(mobileAttr != null) { + mobileAttr.setUseHTML(getSelectRadioIndex() == 1); + } + } +}