From 11d33dfd80714f11d9f6838b9e451c35b2ff73a4 Mon Sep 17 00:00:00 2001 From: xiaxiang <1438003374@qq.com> Date: Mon, 30 May 2016 16:03:56 +0800 Subject: [PATCH 1/2] rt --- .../report/ReportMobileAttrAction.java | 2 +- .../report/mobile/AppFitBrowserPane.java | 89 +++++++++++++++++++ .../report/mobile/AppFitPreviewPane.java | 71 +++++++++++++++ .../report/mobile/ReportMobileAttrPane.java | 33 +++---- 4 files changed, 172 insertions(+), 23 deletions(-) create mode 100644 designer/src/com/fr/design/report/mobile/AppFitBrowserPane.java create mode 100644 designer/src/com/fr/design/report/mobile/AppFitPreviewPane.java diff --git a/designer/src/com/fr/design/actions/report/ReportMobileAttrAction.java b/designer/src/com/fr/design/actions/report/ReportMobileAttrAction.java index 3248370ef6..2bf3856908 100644 --- a/designer/src/com/fr/design/actions/report/ReportMobileAttrAction.java +++ b/designer/src/com/fr/design/actions/report/ReportMobileAttrAction.java @@ -45,7 +45,7 @@ public class ReportMobileAttrAction extends JWorkBookAction{ final ReportMobileAttrPane mobileAttrPane = new ReportMobileAttrPane(); mobileAttrPane.populateBean(mobileAttr); - BasicDialog dialog = mobileAttrPane.showMediumWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + BasicDialog dialog = mobileAttrPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { wbTpl.setReportMobileAttr(mobileAttrPane.updateBean()); diff --git a/designer/src/com/fr/design/report/mobile/AppFitBrowserPane.java b/designer/src/com/fr/design/report/mobile/AppFitBrowserPane.java new file mode 100644 index 0000000000..7714a6bac5 --- /dev/null +++ b/designer/src/com/fr/design/report/mobile/AppFitBrowserPane.java @@ -0,0 +1,89 @@ +package com.fr.design.report.mobile; + +import com.fr.base.mobile.MobileFitAttrState; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.Inter; +import com.fr.report.mobile.ElementCaseMobileAttr; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * Created by 夏翔 on 2016/5/28. + */ +public class AppFitBrowserPane extends BasicBeanPane { + //横屏设置面板 + private MobileRadioGroupPane horizionPane; + //竖屏设置面板 + private MobileRadioGroupPane verticalPane; + //效果预览面板 + private AppFitPreviewPane appFitPreviewPane; + + + public AppFitBrowserPane(){ + initComponents(); + + } + + private void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel borderPane = FRGUIPaneFactory.createTitledBorderPane(this.title4PopupWindow()); + JPanel fitOpsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + horizionPane = new MobileRadioGroupPane(Inter.getLocText("FR-Designer_Mobile-Horizontal")); + verticalPane = new MobileRadioGroupPane(Inter.getLocText("FR-Designer_Mobile-Vertical")); + fitOpsPane.add(horizionPane, BorderLayout.NORTH); + fitOpsPane.add(verticalPane, BorderLayout.SOUTH); + borderPane.add(fitOpsPane); + this.add(borderPane); + + } + + public void setAppFitPreviewPane(AppFitPreviewPane appFitPreviewPane) { + this.appFitPreviewPane = appFitPreviewPane; + } + + //纵向和横向独立设置 + public int[] getCurrentFitOptions() { + return new int[]{horizionPane.getSelectRadioIndex(), verticalPane.getSelectRadioIndex()}; + } + + @Override + public void populateBean(ElementCaseMobileAttr ob) { + if (ob == null) { + ob = new ElementCaseMobileAttr(); + } + ActionListener actionListener = getAppPreviewActionListener(); + horizionPane.addActionListener(actionListener); + verticalPane.addActionListener(actionListener); + horizionPane.populateBean(ob.getHorziontalAttr()); + verticalPane.populateBean(ob.getVerticalAttr()); + appFitPreviewPane.refreshPreview(getCurrentFitOptions()); + + } + + @Override + public ElementCaseMobileAttr updateBean() { + MobileFitAttrState horizonState = horizionPane.updateBean(); + MobileFitAttrState verticalState = verticalPane.updateBean(); + + return new ElementCaseMobileAttr(horizonState, verticalState); + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("FR-Designer_Fit-App"); + } + + private ActionListener getAppPreviewActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int[] fitOptions = getCurrentFitOptions(); + appFitPreviewPane.refreshPreview(fitOptions); + } + }; + } +} diff --git a/designer/src/com/fr/design/report/mobile/AppFitPreviewPane.java b/designer/src/com/fr/design/report/mobile/AppFitPreviewPane.java new file mode 100644 index 0000000000..86bcdf6adf --- /dev/null +++ b/designer/src/com/fr/design/report/mobile/AppFitPreviewPane.java @@ -0,0 +1,71 @@ +package com.fr.design.report.mobile; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.IOUtils; +import com.fr.general.Inter; + +import javax.swing.*; +import java.util.ArrayList; + +/** + * Created by 夏翔 on 2016/5/28. + */ +public class AppFitPreviewPane extends BasicPane{ + + private UILabel horizontalImageLabel; + + private UILabel verticalImagelabel; + + private ArrayList cachedVerticalPreviewImage = new ArrayList(); + + private ArrayList cachedHorizonPreviewImage = new ArrayList(); + + + public AppFitPreviewPane() { + //初始化缓存图片 + initCacheImage(); + //初始化组件 + initComponents(); + } + + private void initCacheImage() { + cachedVerticalPreviewImage.add(new ImageIcon(IOUtils.readImage("/com/fr/base/images/dialog/appfit/" + "V0.png"))); + cachedVerticalPreviewImage.add(new ImageIcon(IOUtils.readImage("/com/fr/base/images/dialog/appfit/" + "V1.png"))); + cachedVerticalPreviewImage.add(new ImageIcon(IOUtils.readImage("/com/fr/base/images/dialog/appfit/" + "V2.png"))); + cachedVerticalPreviewImage.add(new ImageIcon(IOUtils.readImage("/com/fr/base/images/dialog/appfit/" + "V3.png"))); + cachedHorizonPreviewImage.add(new ImageIcon(IOUtils.readImage("/com/fr/base/images/dialog/appfit/" + "H0.png"))); + cachedHorizonPreviewImage.add(new ImageIcon(IOUtils.readImage("/com/fr/base/images/dialog/appfit/" + "H1.png"))); + cachedHorizonPreviewImage.add(new ImageIcon(IOUtils.readImage("/com/fr/base/images/dialog/appfit/" + "H2.png"))); + cachedHorizonPreviewImage.add(new ImageIcon(IOUtils.readImage("/com/fr/base/images/dialog/appfit/" + "H3.png"))); + } + + private void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + JPanel outnorthPane = FRGUIPaneFactory.createTitledBorderPane(this.title4PopupWindow()); + this.add(outnorthPane); + + horizontalImageLabel = new UILabel(); + horizontalImageLabel.setIcon(cachedHorizonPreviewImage.get(1)); + outnorthPane.add(horizontalImageLabel); + + verticalImagelabel = new UILabel(); + verticalImagelabel.setIcon(cachedVerticalPreviewImage.get(0)); + outnorthPane.add(verticalImagelabel); + } + + public void refreshPreview(int[] index) { + ImageIcon newHorizonImageIcon = cachedHorizonPreviewImage.get(index[0]) ; + ImageIcon newVerticalImageIcon = cachedVerticalPreviewImage.get(index[1]); + horizontalImageLabel.setIcon(newHorizonImageIcon); + verticalImagelabel.setIcon(newVerticalImageIcon); + + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("FR-Plugin_Preview"); + } +} diff --git a/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java b/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java index 67f0ab825b..1d2d399319 100644 --- a/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java +++ b/designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java @@ -1,40 +1,33 @@ package com.fr.design.report.mobile; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.Inter; import com.fr.report.mobile.ElementCaseMobileAttr; -import com.fr.base.mobile.MobileFitAttrState; import javax.swing.*; -import java.awt.*; /** * Created by Administrator on 2016/5/12/0012. */ public class ReportMobileAttrPane extends BasicBeanPane{ - //横屏设置面板 - private MobileRadioGroupPane horizionPane; - //竖屏设置面板 - private MobileRadioGroupPane verticalPane; + + private AppFitBrowserPane appFitBrowserPane; public ReportMobileAttrPane() { initComponents(); } private void initComponents() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - JPanel borderPane = FRGUIPaneFactory.createTitledBorderPane(this.title4PopupWindow()); + this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + AppFitPreviewPane appFitPreviewPane = new AppFitPreviewPane(); - JPanel fitOpsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - horizionPane = new MobileRadioGroupPane(Inter.getLocText("FR-Designer_Mobile-Horizontal")); - verticalPane = new MobileRadioGroupPane(Inter.getLocText("FR-Designer_Mobile-Vertical")); - fitOpsPane.add(horizionPane, BorderLayout.NORTH); - fitOpsPane.add(verticalPane, BorderLayout.SOUTH); + appFitBrowserPane = new AppFitBrowserPane(); + appFitBrowserPane.setAppFitPreviewPane(appFitPreviewPane); + this.add(appFitBrowserPane); - borderPane.add(fitOpsPane); - this.add(borderPane); + this.add(appFitPreviewPane); } @Override @@ -42,17 +35,13 @@ public class ReportMobileAttrPane extends BasicBeanPane{ if (ob == null) { ob = new ElementCaseMobileAttr(); } + appFitBrowserPane.populateBean(ob); - horizionPane.populateBean(ob.getHorziontalAttr()); - verticalPane.populateBean(ob.getVerticalAttr()); } @Override public ElementCaseMobileAttr updateBean() { - MobileFitAttrState horizonState = horizionPane.updateBean(); - MobileFitAttrState verticalState = verticalPane.updateBean(); - - return new ElementCaseMobileAttr(horizonState, verticalState); + return appFitBrowserPane.updateBean(); } @Override From f2b3034ddbeb377a60999972d20185bd385dc3a3 Mon Sep 17 00:00:00 2001 From: xiaxiang <1438003374@qq.com> Date: Mon, 30 May 2016 16:13:51 +0800 Subject: [PATCH 2/2] rt --- .../src/com/fr/design/report/mobile/AppFitBrowserPane.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/designer/src/com/fr/design/report/mobile/AppFitBrowserPane.java b/designer/src/com/fr/design/report/mobile/AppFitBrowserPane.java index 7714a6bac5..8a28187a11 100644 --- a/designer/src/com/fr/design/report/mobile/AppFitBrowserPane.java +++ b/designer/src/com/fr/design/report/mobile/AppFitBrowserPane.java @@ -34,6 +34,9 @@ public class AppFitBrowserPane extends BasicBeanPane { JPanel fitOpsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); horizionPane = new MobileRadioGroupPane(Inter.getLocText("FR-Designer_Mobile-Horizontal")); verticalPane = new MobileRadioGroupPane(Inter.getLocText("FR-Designer_Mobile-Vertical")); + ActionListener actionListener = getAppPreviewActionListener(); + horizionPane.addActionListener(actionListener); + verticalPane.addActionListener(actionListener); fitOpsPane.add(horizionPane, BorderLayout.NORTH); fitOpsPane.add(verticalPane, BorderLayout.SOUTH); borderPane.add(fitOpsPane); @@ -55,9 +58,6 @@ public class AppFitBrowserPane extends BasicBeanPane { if (ob == null) { ob = new ElementCaseMobileAttr(); } - ActionListener actionListener = getAppPreviewActionListener(); - horizionPane.addActionListener(actionListener); - verticalPane.addActionListener(actionListener); horizionPane.populateBean(ob.getHorziontalAttr()); verticalPane.populateBean(ob.getVerticalAttr()); appFitPreviewPane.refreshPreview(getCurrentFitOptions());