Browse Source

Merge pull request #618 in BA/design from ~FANGLEI/design:dev to dev

* commit '0be0c5ee7558fa7342a02b926f706a2439f269a8':
  常量改成大写
  在表单->模板菜单->移动端属性中加入报表解析方式的选项
master
wei 8 years ago
parent
commit
99705e7675
  1. 106
      designer/src/com/fr/design/report/mobile/MobileUseHtmlGroupPane.java
  2. 112
      designer_base/src/com/fr/design/dialog/mobile/MobileUseHtmlGroupBeanPane.java
  3. 35
      designer_form/src/com/fr/design/form/mobile/FormMobileAttrPane.java
  4. 29
      designer_form/src/com/fr/design/form/mobile/MobileUseHtmlGroupPane.java

106
designer/src/com/fr/design/report/mobile/MobileUseHtmlGroupPane.java

@ -1,109 +1,12 @@
package com.fr.design.report.mobile; package com.fr.design.report.mobile;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.mobile.MobileUseHtmlGroupBeanPane;
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 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. * Created by kunsnat on 2016/8/3.
*/ */
public class MobileUseHtmlGroupPane extends BasicBeanPane<ElementCaseMobileAttr> { public class MobileUseHtmlGroupPane extends MobileUseHtmlGroupBeanPane<ElementCaseMobileAttr> {
private List<UIRadioButton> radioButtons = new ArrayList<UIRadioButton>();
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 @Override
public void populateBean(ElementCaseMobileAttr mobileAttr) { public void populateBean(ElementCaseMobileAttr mobileAttr) {
if(mobileAttr != null) { if(mobileAttr != null) {
@ -122,9 +25,4 @@ public class MobileUseHtmlGroupPane extends BasicBeanPane<ElementCaseMobileAttr>
mobileAttr.setUseHTML(getSelectRadioIndex() == 1); mobileAttr.setUseHTML(getSelectRadioIndex() == 1);
} }
} }
@Override
protected String title4PopupWindow() {
return Inter.getLocText("FR-mobile_report_analysis");
}
} }

112
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<T> extends BasicBeanPane<T> {
private List<UIRadioButton> radioButtons = new ArrayList<UIRadioButton>();
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");
}
}

35
designer_form/src/com/fr/design/form/mobile/FormMobileAttrPane.java

@ -1,6 +1,7 @@
package com.fr.design.form.mobile; package com.fr.design.form.mobile;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.form.main.mobile.FormMobileAttr; import com.fr.form.main.mobile.FormMobileAttr;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -15,22 +16,34 @@ public class FormMobileAttrPane extends BasicBeanPane<FormMobileAttr>{
//工具栏容器 //工具栏容器
private MobileToolBarPane mobileToolBarPane; private MobileToolBarPane mobileToolBarPane;
static final int paddingHeight = 10; //h5解析容器
private MobileUseHtmlGroupPane mobileUseHtmlGroupPane;
static final int PADDINGHEIGHT = 10;
public FormMobileAttrPane() { public FormMobileAttrPane() {
this.initComponents(); this.initComponents();
} }
//现在只有两个panel,填不满自适应对话框,只能为工具栏Panel和h5解析方式panel分别包裹上一层Panel再计算高度,不然会自动
//拉长两个Panel的高度去填满整个对话框。
private void initComponents() { private void initComponents() {
JPanel jPanel = new JPanel(); JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); jPanel1.setLayout(FRGUIPaneFactory.createBorderLayout());
jPanel.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.mobileToolBarPane = new MobileToolBarPane();
this.mobileUseHtmlGroupPane = new MobileUseHtmlGroupPane();
//设置一个JPanel包裹mobileToolBarPane这个Panel,让jPanel的高度等于mobileToolBarPane高度加10,再放入this中 //设置一个JPanel包裹mobileToolBarPane这个Panel,让jPanel的高度等于mobileToolBarPane高度加10,再放入this中
jPanel.setPreferredSize(new Dimension(0, (int)this.mobileToolBarPane.getPreferredSize().getHeight() + paddingHeight)); jPanel1.setPreferredSize(new Dimension(0, (int)this.mobileToolBarPane.getPreferredSize().getHeight() + PADDINGHEIGHT));
jPanel.add("North", mobileToolBarPane); jPanel2.setPreferredSize(new Dimension(0, (int)this.mobileUseHtmlGroupPane.getPreferredSize().getHeight() + PADDINGHEIGHT));
this.add(jPanel); jPanel1.add("North", this.mobileUseHtmlGroupPane);
jPanel2.add("North", this.mobileToolBarPane);
this.add("North", jPanel1);
this.add("Center", jPanel2);
} }
@Override @Override
@ -39,13 +52,15 @@ public class FormMobileAttrPane extends BasicBeanPane<FormMobileAttr>{
ob = new FormMobileAttr(); ob = new FormMobileAttr();
} }
this.mobileToolBarPane.populateBean(ob); this.mobileToolBarPane.populateBean(ob);
this.mobileUseHtmlGroupPane.populateBean(ob);
} }
@Override @Override
public FormMobileAttr updateBean() { public FormMobileAttr updateBean() {
FormMobileAttr caseMobileAttr = new FormMobileAttr(); FormMobileAttr formMobileAttr = new FormMobileAttr();
this.mobileToolBarPane.updateBean(caseMobileAttr); this.mobileToolBarPane.updateBean(formMobileAttr);
return caseMobileAttr; this.mobileUseHtmlGroupPane.updateBean(formMobileAttr);
return formMobileAttr;
} }
@Override @Override

29
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<FormMobileAttr> {
@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);
}
}
}
Loading…
Cancel
Save