Browse Source

MOBILE-6262 FR9.0设计器提供手机端设计画布参考尺寸

master
plough 7 years ago
parent
commit
035ce709df
  1. 2
      designer-base/src/com/fr/design/designer/IntervalConstants.java
  2. 7
      designer-base/src/com/fr/design/dialog/mobile/MobileRadioCheckPane.java
  3. 26
      designer-form/src/com/fr/design/form/mobile/FormMobileAttrPane.java
  4. 160
      designer-form/src/com/fr/design/form/mobile/FormMobileTemplateSettingsPane.java
  5. 44
      designer-form/src/com/fr/design/mainframe/FormArea.java
  6. 20
      designer-form/src/com/fr/design/mainframe/JForm.java
  7. 16
      designer-form/src/com/fr/design/mainframe/actions/FormMobileAttrAction.java
  8. 12
      designer-realize/src/com/fr/design/actions/report/ReportMobileAttrAction.java
  9. 5
      designer-realize/src/com/fr/design/mainframe/form/FormElementCaseDesigner.java
  10. 4
      designer-realize/src/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java
  11. 118
      designer-realize/src/com/fr/design/report/PageSetupPane.java
  12. 9
      designer-realize/src/com/fr/design/report/mobile/ReportMobileAttrPane.java
  13. 102
      designer-realize/src/com/fr/design/report/mobile/ReportMobileTemplateSettingsPane.java
  14. 5
      designer-realize/src/com/fr/grid/GridUI.java

2
designer-base/src/com/fr/design/designer/IntervalConstants.java

@ -27,4 +27,6 @@ public class IntervalConstants {
public static final int INTERVAL_W3 = 49;
public static final int INTERVAL_W4 = 22;
}

7
designer-base/src/com/fr/design/dialog/mobile/MobileRadioCheckPane.java

@ -2,14 +2,13 @@ package com.fr.design.dialog.mobile;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.Inter;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.Component;
import java.util.ArrayList;
import java.util.List;

26
designer-form/src/com/fr/design/form/mobile/FormMobileAttrPane.java

@ -15,25 +15,29 @@ import java.awt.*;
public class FormMobileAttrPane extends BasicBeanPane<FormMobileAttr>{
//工具栏容器
private MobileToolBarPane mobileToolBarPane;
// 模版设置面板
private FormMobileTemplateSettingsPane formMobileTemplateSettingsPane;
static final int PADDINGHEIGHT = 10;
private static final int PADDING = 10;
public FormMobileAttrPane() {
this.initComponents();
}
//现在只有两个panel,填不满自适应对话框,只能为工具栏Panel和h5解析方式panel分别包裹上一层Panel再计算高度,不然会自动
//拉长两个Panel的高度去填满整个对话框。
private void initComponents() {
JPanel jPanel1 = new JPanel();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
jPanel1.setLayout(FRGUIPaneFactory.createBorderLayout());
jPanel1.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JPanel mobileToolBarPaneWrapper = new JPanel(new BorderLayout());
mobileToolBarPaneWrapper.setBorder(BorderFactory.createEmptyBorder(PADDING, PADDING, 0, PADDING));
this.mobileToolBarPane = new MobileToolBarPane();
//设置一个JPanel包裹mobileToolBarPane这个Panel,让jPanel的高度等于mobileToolBarPane高度加10,再放入this中
jPanel1.setPreferredSize(new Dimension(0, (int)this.mobileToolBarPane.getPreferredSize().getHeight() + PADDINGHEIGHT));
jPanel1.add("North", this.mobileToolBarPane);
this.add("North", jPanel1);
mobileToolBarPaneWrapper.add(this.mobileToolBarPane, BorderLayout.NORTH);
JPanel formMobileTemplateSettingsPaneWrapper = new JPanel(new BorderLayout());
formMobileTemplateSettingsPaneWrapper.setBorder(BorderFactory.createEmptyBorder(PADDING, PADDING, PADDING, PADDING));
this.formMobileTemplateSettingsPane = new FormMobileTemplateSettingsPane();
formMobileTemplateSettingsPaneWrapper.add(this.formMobileTemplateSettingsPane, BorderLayout.NORTH);
this.add(formMobileTemplateSettingsPaneWrapper, BorderLayout.NORTH);
this.add(mobileToolBarPaneWrapper, BorderLayout.CENTER);
}
@Override
@ -42,12 +46,14 @@ public class FormMobileAttrPane extends BasicBeanPane<FormMobileAttr>{
ob = new FormMobileAttr();
}
this.mobileToolBarPane.populateBean(ob);
this.formMobileTemplateSettingsPane.populateBean(ob);
}
@Override
public FormMobileAttr updateBean() {
FormMobileAttr formMobileAttr = new FormMobileAttr();
this.mobileToolBarPane.updateBean(formMobileAttr);
this.formMobileTemplateSettingsPane.updateBean(formMobileAttr);
return formMobileAttr;
}

160
designer-form/src/com/fr/design/form/mobile/FormMobileTemplateSettingsPane.java

@ -0,0 +1,160 @@
package com.fr.design.form.mobile;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.mobile.MobileRadioCheckPane;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.icheckbox.UICheckBox;
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.form.main.mobile.FormMobileAttr;
import com.fr.general.Inter;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by plough on 2018/1/4.
*/
public class FormMobileTemplateSettingsPane extends BasicBeanPane<FormMobileAttr> {
private UICheckBox mobileOnlyCheck; // 设置为手机端专属模版
private UICheckBox mobileCanvasSizeCheck; // 设置为手机模版画布大小
private UICheckBox adaptivePropertyAutoMatchCheck; // 自适应属性自动匹配
public FormMobileTemplateSettingsPane() {
this.initComponents();
}
private void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel borderPane = FRGUIPaneFactory.createTitledBorderPane(this.title4PopupWindow());
JPanel contentPane = new JPanel(FRGUIPaneFactory.createBorderLayout());
contentPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L5, IntervalConstants.INTERVAL_L2, 0));
JPanel mobileSettingsPane = new JPanel(FRGUIPaneFactory.createBorderLayout());
mobileSettingsPane.setVisible(false);
mobileSettingsPane.add(getMobileCanvasSizeCheckPane(), BorderLayout.NORTH);
mobileSettingsPane.add(getAdaptivePropertyAutoMatchCheckPane(), BorderLayout.CENTER);
mobileOnlyCheck = new UICheckBox(Inter.getLocText("FR-Designer_Set_Mobile_Only_Template"));
mobileOnlyCheck.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
boolean mobileOnlyCheckSelected = mobileOnlyCheck.isSelected();
mobileSettingsPane.setVisible(mobileOnlyCheckSelected);
if (mobileOnlyCheckSelected) {
adaptivePropertyAutoMatchCheck.setSelected(true);
}
}
});
contentPane.add(mobileOnlyCheck, BorderLayout.NORTH);
contentPane.add(mobileSettingsPane, BorderLayout.CENTER);
borderPane.add(contentPane);
this.add(borderPane);
}
private JPanel getMobileCanvasSizeCheckPane() {
JPanel panel = new JPanel(FRGUIPaneFactory.createBorderLayout());
mobileCanvasSizeCheck = new UICheckBox(Inter.getLocText("FR-Designer_Set_Mobile_Canvas_Size"));
// 默认勾选,不可取消
mobileCanvasSizeCheck.setSelected(true);
mobileCanvasSizeCheck.setEnabled(false);
panel.add(mobileCanvasSizeCheck, BorderLayout.NORTH);
panel.add(getCanvasDescPane(), BorderLayout.CENTER);
panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L6, 0));
return panel;
}
private JPanel getAdaptivePropertyAutoMatchCheckPane() {
JPanel panel = new JPanel(FRGUIPaneFactory.createBorderLayout());
adaptivePropertyAutoMatchCheck = new UICheckBox();
adaptivePropertyAutoMatchCheck.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
adaptivePropertyAutoMatchCheck.setText(Inter.getLocText("FR-Designer_Adaptive_Property_Auto_Match"));
}
});
adaptivePropertyAutoMatchCheck.setSelected(true);
panel.add(adaptivePropertyAutoMatchCheck, BorderLayout.NORTH);
panel.add(getAdaptivePropertyAutoMatchDescPane(), BorderLayout.CENTER);
return panel;
}
private JPanel getCanvasDescPane() {
UILabel desc1 = createDescLabel(Inter.getLocText("FR-Designer_Canvas_Size_Lock_Desc"));
UILabel desc2 = createDescLabel(Inter.getLocText("FR-Designer_Mobile_Screen_Match_Desc"));
UILabel desc3 = createDescLabel(Inter.getLocText("FR-Designer_Mobile_Screen_Zoom_In_Desc"));
UILabel desc4 = createDescLabel(Inter.getLocText("FR-Designer_Mobile_Screen_Zoom_Out_Desc"));
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}};
Component[][] components = new Component[][]{
new Component[]{desc1, null},
new Component[]{desc2, null},
new Component[]{desc3, null},
new Component[]{desc4, null}
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1);
panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_W4, IntervalConstants.INTERVAL_L1, 0));
return panel;
}
private JPanel getAdaptivePropertyAutoMatchDescPane() {
UILabel desc1 = createDescLabel(Inter.getLocText("FR-Designer_Adaptive_Property_Auto_Match_Desc"));
JPanel panel = new JPanel(FRGUIPaneFactory.createBorderLayout());
panel.add(desc1, BorderLayout.CENTER);
panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_W4, IntervalConstants.INTERVAL_L1, 0));
return panel;
}
private UILabel createDescLabel(String desc) {
UILabel label = new UILabel(desc);
label.setForeground(Color.gray);
return label;
}
@Override
public void populateBean(FormMobileAttr ob) {
if (ob == null) {
ob = new FormMobileAttr();
}
// this.mobileOnlyCheckPane.populateBean(ob.isRefresh());
mobileOnlyCheck.setSelected(ob.isMobileOnly());
adaptivePropertyAutoMatchCheck.setSelected(ob.isAdaptivePropertyAutoMatch());
}
@Override
public FormMobileAttr updateBean() {
return null;
}
@Override
public void updateBean(FormMobileAttr mobileAttr) {
if(mobileAttr != null) {
mobileAttr.setMobileOnly(mobileOnlyCheck.isSelected());
mobileAttr.setAdaptivePropertyAutoMatch(adaptivePropertyAutoMatchCheck.isSelected());
}
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer_Template_Settings");
}
}

44
designer-form/src/com/fr/design/mainframe/FormArea.java

@ -7,25 +7,47 @@ import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.scrollruler.*;
import com.fr.design.scrollruler.BaseRuler;
import com.fr.design.scrollruler.HorizontalRuler;
import com.fr.design.scrollruler.RulerLayout;
import com.fr.design.scrollruler.ScrollRulerComponent;
import com.fr.design.scrollruler.VerticalRuler;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.main.mobile.FormMobileAttr;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.general.FRScreen;
import com.fr.general.Inter;
import javax.swing.*;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.*;
import java.awt.AWTEvent;
import java.awt.Adjustable;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
public class FormArea extends JComponent implements ScrollRulerComponent {
@ -36,6 +58,8 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
private static final int SHOWVALMAX = 400;
private static final int SHOWVALMIN = 10;
private static final int RESIZE_PANE_GAP = 8;
private static final int MOBILE_ONLY_WIDTH = 375;
private static final int MOBILE_ONLY_HEIGHT = 560;
private FormDesigner designer;
private int horizontalValue = 0;
private int verticalValue = 0;
@ -79,6 +103,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
this.add(FormRulerLayout.VERTICAL, verScrollBar);
this.add(FormRulerLayout.HIRIZONTAL, horScrollBar);
enableEvents(AWTEvent.MOUSE_WHEEL_EVENT_MASK);
widthPane.setEnabled(!designer.getTarget().getFormMobileAttr().isMobileOnly());
} else {
// 报表参数界面只要标尺和中心pane
this.setLayout(new RulerLayout());
@ -89,6 +114,17 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
this.designer.addMouseWheelListener(showValSpinnerMouseWheelListener);
}
public void onMobileAttrModified() {
FormMobileAttr formMobileAttr = designer.getTarget().getFormMobileAttr();
if (formMobileAttr.isMobileOnly()) {
widthPane.setValue(MOBILE_ONLY_WIDTH);
changeWidthPaneValue(MOBILE_ONLY_WIDTH);
heightPane.setValue(MOBILE_ONLY_HEIGHT);
changeHeightPaneValue(MOBILE_ONLY_HEIGHT);
}
widthPane.setEnabled(!formMobileAttr.isMobileOnly());
}
MouseWheelListener showValSpinnerMouseWheelListener = new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {

20
designer-form/src/com/fr/design/mainframe/JForm.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.PaperSize;
import com.fr.design.DesignState;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.actions.file.WebPreviewUtils;
@ -55,6 +56,8 @@ import com.fr.form.ui.container.WLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.page.PaperSettingProvider;
import com.fr.report.worksheet.FormElementCase;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants;
import com.fr.stable.bridge.StableFactory;
@ -809,6 +812,14 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
}
}
/**
* 模板更新
*/
public void fireTargetModified() {
super.fireTargetModified();
WidgetPropertyPane.getInstance().refreshDockingView();
}
/**
* 在Form和ElementCase, 以及ElementCase和ElementCase之间切换
*
@ -834,8 +845,13 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
HashMap<String, Class> designerClass = new HashMap<String, Class>();
designerClass.put(Constants.ARG_0, FormElementCaseProvider.class);
Object[] designerArg = new Object[]{formDesign.getElementCase()};
return StableFactory.getMarkedInstanceObjectFromClass(FormECDesignerProvider.XML_TAG, designerArg, designerClass, FormECDesignerProvider.class);
Object[] designerArg = new Object[]{formDesign.getElementCase(), getTarget()};
FormECDesignerProvider formECDesigner = StableFactory.getMarkedInstanceObjectFromClass(FormECDesignerProvider.XML_TAG, designerArg, designerClass, FormECDesignerProvider.class);
// 如果是移动端专属模版,需要修改页面大小并显示边缘线
PaperSettingProvider paperSetting = ((FormElementCase)formECDesigner.getEditingElementCase()).getReportSettings().getPaperSetting();
paperSetting.setPaperSize(getTarget().getFormMobileAttr().isMobileOnly() ? PaperSize.PAPERSIZE_MOBILE : new PaperSize());
return formECDesigner;
}
/**

16
designer-form/src/com/fr/design/mainframe/actions/FormMobileAttrAction.java

@ -6,13 +6,17 @@ import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.form.mobile.FormMobileAttrPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.JForm;
import com.fr.design.menu.MenuKeySet;
import com.fr.form.main.Form;
import com.fr.form.main.mobile.FormMobileAttr;
import com.fr.general.Inter;
import com.fr.plugin.ExtraClassManager;
import com.fr.stable.ReportFunctionProcessor;
import com.fr.stable.fun.FunctionProcessor;
import javax.swing.*;
import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
/**
@ -47,8 +51,16 @@ public class FormMobileAttrAction extends JTemplateAction<JForm> {
BasicDialog dialog = mobileAttrPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
formTpl.setFormMobileAttr(mobileAttrPane.updateBean());
FormMobileAttr formMobileAttr = mobileAttrPane.updateBean();
formTpl.setFormMobileAttr(formMobileAttr);
((FormArea)jf.getFormDesign().getParent()).onMobileAttrModified();
jf.fireTargetModified();
if (formMobileAttr.isMobileOnly()) {
FunctionProcessor processor = ExtraClassManager.getInstance().getFunctionProcessor();
if (processor != null) {
processor.recordFunction(ReportFunctionProcessor.MOBILE_TEMPLATE_FRM);
}
}
}
});
dialog.setVisible(true);

12
designer-realize/src/com/fr/design/actions/report/ReportMobileAttrAction.java

@ -11,7 +11,10 @@ import com.fr.design.report.mobile.ReportMobileAttrPane;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.main.TemplateWorkBook;
import com.fr.plugin.ExtraClassManager;
import com.fr.report.mobile.ElementCaseMobileAttr;
import com.fr.stable.ReportFunctionProcessor;
import com.fr.stable.fun.FunctionProcessor;
import javax.swing.*;
import java.awt.event.ActionEvent;
@ -50,8 +53,15 @@ public class ReportMobileAttrAction extends JWorkBookAction{
BasicDialog dialog = mobileAttrPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
wbTpl.setReportMobileAttr(mobileAttrPane.updateBean());
ElementCaseMobileAttr elementCaseMobileAttr = mobileAttrPane.updateBean();
wbTpl.setReportMobileAttr(elementCaseMobileAttr);
jwb.fireTargetModified();
if (elementCaseMobileAttr.isMobileCanvasSize()) {
FunctionProcessor processor = ExtraClassManager.getInstance().getFunctionProcessor();
if (processor != null) {
processor.recordFunction(ReportFunctionProcessor.MOBILE_TEMPLATE_CPT);
}
}
}
});
dialog.setVisible(true);

5
designer-realize/src/com/fr/design/mainframe/form/FormElementCaseDesigner.java

@ -27,6 +27,7 @@ import com.fr.design.selection.SelectableElement;
import com.fr.design.selection.Selectedable;
import com.fr.design.selection.SelectionListener;
import com.fr.form.FormElementCaseProvider;
import com.fr.form.main.Form;
import com.fr.general.Inter;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection;
@ -54,11 +55,11 @@ public class FormElementCaseDesigner<T extends FormElementCaseProvider, E extend
return elementCasePane;
}
public FormElementCaseDesigner(T sheet) {
public FormElementCaseDesigner(T sheet, Form form) {
super(sheet);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
elementCasePane = new FormElementCasePaneDelegate((FormElementCase) sheet);
elementCasePane = new FormElementCasePaneDelegate((FormElementCase) sheet, form);
elementCasePane.setSelection(getDefaultSelectElement());
this.add(elementCasePane, BorderLayout.CENTER);
elementCasePane.addTargetModifiedListener(new TargetModifiedListener() {

4
designer-realize/src/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java

@ -20,6 +20,7 @@ import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.present.ConditionAttributesGroupPane;
import com.fr.form.main.Form;
import com.fr.js.NameJavaScriptGroup;
import com.fr.page.ReportSettingsProvider;
import com.fr.report.elementcase.TemplateElementCase;
@ -31,8 +32,9 @@ import com.fr.design.selection.SelectionListener;
*/
public class FormElementCasePaneDelegate extends ElementCasePane<FormElementCase>{
public FormElementCasePaneDelegate(FormElementCase sheet) {
public FormElementCasePaneDelegate(FormElementCase sheet, Form form) {
super(sheet);
this.getGrid().setShowPaginateLine(form.getFormMobileAttr().isMobileOnly());
this.addSelectionChangeListener(new SelectionListener() {
@Override
public void selectionChanged(SelectionEvent e) {

118
designer-realize/src/com/fr/design/report/PageSetupPane.java

@ -73,14 +73,6 @@ public class PageSetupPane extends BasicPane {
private OtherPane otherPane;
private UILabel zeroMarginWarn;
public final static PaperSize MOBILE_SMAIL_SIZE = new PaperSize(new MM(142.8f), new MM(254));
public final static PaperSize MOBILE_LARGE_SIZE = new PaperSize(new MM(190.5f), new MM(338.7f));
public static final Object[][] MOBILE_NAME_SIZE_ARRAY = {
{Inter.getLocText("FR-Designer_PaperSize-Mobile-Large"),MOBILE_LARGE_SIZE},
{Inter.getLocText("FR-Designer_PaperSize-Mobile-Small"),MOBILE_SMAIL_SIZE}
};
public PageSetupPane() {
this.initComponents();
}
@ -135,12 +127,10 @@ public class PageSetupPane extends BasicPane {
private UIRadioButton landscapeRadioButton;
private UIRadioButton predefinedRadioButton;
private UIRadioButton mobileRadioButton;
private UIRadioButton customRadioButton;
private UIComboBox predefinedComboBox;
private UIComboBox mobileComboBox;
private UIBasicSpinner paperWidthSpinner;
private UIBasicSpinner paperHeightSpinner;
private UIComboBox switchInch;
@ -206,24 +196,16 @@ public class PageSetupPane extends BasicPane {
paperSizePane.add(innerpaperSizePane);
defaultPane.add(paperSizePane);
predefinedRadioButton = new UIRadioButton(Inter.getLocText("PageSetup-Predefined") + ":");
predefinedRadioButton.setMnemonic('P');
predefinedRadioButton.addActionListener(previewListener);
mobileRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_MobilePhone") + " :");
mobileRadioButton.setMnemonic('M');
mobileRadioButton.addActionListener(previewListener);
customRadioButton = new UIRadioButton(Inter.getLocText("Custom") + ":");
customRadioButton.setMnemonic('C');
customRadioButton.addActionListener(previewListener);
predefinedComboBox = new UIComboBox();
mobileComboBox = new UIComboBox();
paperWidthSpinner = new UIBasicSpinner(new SpinnerNumberModel(0.0, 0.0, Double.MAX_VALUE, 1.0));
((JSpinner.DefaultEditor) paperWidthSpinner.getEditor()).getTextField().setColumns(7);
paperHeightSpinner = new UIBasicSpinner(new SpinnerNumberModel(0.0, 0.0, Double.MAX_VALUE, 1.0));
@ -239,9 +221,7 @@ public class PageSetupPane extends BasicPane {
predefinedComboBox.setRenderer(paperSizeCellRenderere);
predefinedComboBox.addItemListener(paperSizeItemListener);
mobileComboBox.setRenderer(paperSizeMobileCellRenderere);
mobileComboBox.addItemListener(paperSizeItemMobileListener);
((JSpinner.DefaultEditor) paperWidthSpinner.getEditor()).getTextField().getDocument().addDocumentListener(customTextListener);
((JSpinner.DefaultEditor) paperHeightSpinner.getEditor()).getTextField().getDocument().addDocumentListener(customTextListener);
@ -253,11 +233,6 @@ public class PageSetupPane extends BasicPane {
Object[] tmpPaperSizeNameArray = ReportConstants.PaperSizeNameSizeArray[i];
predefinedComboBox.addItem(tmpPaperSizeNameArray[1]);
}
for(int i=0; i<MOBILE_NAME_SIZE_ARRAY.length;i++){
Object[] tmpPaperSizeNameArray = MOBILE_NAME_SIZE_ARRAY[i];
mobileComboBox.addItem(tmpPaperSizeNameArray[1]);
}
// tow radio buttons.
@ -266,17 +241,9 @@ public class PageSetupPane extends BasicPane {
radioButtonPane.add(predefinedRadioButton);
radioButtonPane.add(predefinedComboBox);
// tow radio buttons.
JPanel mobileButtonPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
innerpaperSizePane.add(mobileButtonPane);
mobileButtonPane.add(mobileRadioButton);
mobileButtonPane.add(mobileComboBox);
ButtonGroup paperSizeRadioButtonGroup = new ButtonGroup();
paperSizeRadioButtonGroup.add(predefinedRadioButton);
paperSizeRadioButtonGroup.add(mobileRadioButton);
paperSizeRadioButtonGroup.add(customRadioButton);
// size and textfields.
@ -457,17 +424,27 @@ public class PageSetupPane extends BasicPane {
break;
}
}
for(int i=0; i<MOBILE_NAME_SIZE_ARRAY.length; i++){
Object[] mobileNameSizeArray = MOBILE_NAME_SIZE_ARRAY[i];
if(ComparatorUtils.equals(paperSize, mobileNameSizeArray[1])){
this.mobileComboBox.setSelectedIndex(i);
this.mobileRadioButton.setSelected(true);
isCustomed = false;
break;
}
}
setAndPopulate(isCustomed, unitType);
populateMargin();
checkMobileSetting(report);
}
private void checkMobileSetting(Report report) {
if (report.getBook().getReportMobileAttr().isMobileCanvasSize()) {
// 当勾选移动端画布大小后,自定义选项不可修改;限制宽度范围
predefinedRadioButton.setEnabled(false);
predefinedComboBox.setEnabled(false);
double maxWidth;
if (unitType == Constants.UNIT_MM) { // 毫米
maxWidth = PaperSize.PAPERSIZE_MOBILE.getWidth().toMMValue4Scale2();
} else { // 英寸
maxWidth = PaperSize.PAPERSIZE_MOBILE.getWidth().toINCHValue4Scale3();
}
maxWidth = Math.round(maxWidth * 100) / 100.0; // 保留两位小数
((SpinnerNumberModel)paperWidthSpinner.getModel()).setMaximum(maxWidth);
}
}
private void unitSet(int unitType) {
@ -539,13 +516,6 @@ public class PageSetupPane extends BasicPane {
} catch (CloneNotSupportedException cloneNotSupportedException) {
// do nothing
}
}else if(this.mobileRadioButton.isSelected()){
try {
psetting.setPaperSize((PaperSize) ((PaperSize) mobileComboBox.getSelectedItem()).clone());
} catch (CloneNotSupportedException cloneNotSupportedException) {
// do nothing
}
} else if (this.customRadioButton.isSelected()) {
if (unitType == Constants.UNIT_CM) {
psetting.setPaperSize(new PaperSize(new CM(((Number) this.paperWidthSpinner.getValue()).floatValue()), new CM(
@ -616,10 +586,7 @@ public class PageSetupPane extends BasicPane {
if (this.predefinedRadioButton.isSelected()) {
ps = (PaperSize) predefinedComboBox.getSelectedItem();
showPagePaneByType(ps,ori);
} else if(this.mobileRadioButton.isSelected()){
ps = (PaperSize) mobileComboBox.getSelectedItem();
showPagePaneByType(ps, ori);
}else if (this.customRadioButton.isSelected()) {
} else if (this.customRadioButton.isSelected()) {
showPagePane.populate(((Number) this.paperWidthSpinner.getValue()).doubleValue(),
((Number) this.paperHeightSpinner.getValue()).doubleValue(), ori, unitType == Constants.UNIT_MM);
}
@ -691,34 +658,7 @@ public class PageSetupPane extends BasicPane {
}
sbuf.append(']');
}
/**
* Paper size cell renderer.
*/
private UIComboBoxRenderer paperSizeMobileCellRenderere = new UIComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof PaperSize) {
PaperSize paperSize = (PaperSize) value;
for (int i = 0; i < MOBILE_NAME_SIZE_ARRAY.length; i++) {
Object[] tmpPaperSizeNameArray = MOBILE_NAME_SIZE_ARRAY[i];
if (ComparatorUtils.equals(paperSize, tmpPaperSizeNameArray[1])) {
StringBuffer sbuf = new StringBuffer(tmpPaperSizeNameArray[0].toString());
adjustCellRenderByType(sbuf,paperSize);
this.setText(sbuf.toString());
break;
}
}
}
return this;
}
};
/**
* Paper size item listener.
@ -744,18 +684,6 @@ public class PageSetupPane extends BasicPane {
paperHeightSpinner.setValue(new Float(paperSize.getHeight().toMMValue4Scale2()));
}
}
/**
* Paper size item listener.
*/
private ItemListener paperSizeItemMobileListener = new ItemListener() {
public void itemStateChanged(ItemEvent evt) {
PaperSize paperSize = (PaperSize) mobileComboBox.getSelectedItem();
adjustSpinnerValueByType(paperSize);
mobileRadioButton.setSelected(true);
previewShowPagePane();
}
};
// text listener.
DocumentListener customTextListener = new DocumentListener() {

9
designer-realize/src/com/fr/design/report/mobile/ReportMobileAttrPane.java

@ -13,8 +13,8 @@ import javax.swing.*;
public class ReportMobileAttrPane extends BasicBeanPane<ElementCaseMobileAttr>{
private ReportMobileTemplateSettingsPane reportMobileTemplateSettingsPane; // 模版设置面板
private AppFitBrowserPane appFitBrowserPane;
//工具栏容器
private MobileToolBarPane mobileToolBarPane;
@ -28,6 +28,10 @@ public class ReportMobileAttrPane extends BasicBeanPane<ElementCaseMobileAttr>{
JPanel jPanel = new JPanel();
jPanel.setLayout(new BoxLayout(jPanel, BoxLayout.Y_AXIS));
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
reportMobileTemplateSettingsPane = new ReportMobileTemplateSettingsPane();
jPanel.add(reportMobileTemplateSettingsPane);
appFitBrowserPane = new AppFitBrowserPane();
appFitBrowserPane.setAppFitPreviewPane(appFitPreviewPane);
jPanel.add(appFitBrowserPane);
@ -46,13 +50,14 @@ public class ReportMobileAttrPane extends BasicBeanPane<ElementCaseMobileAttr>{
}
appFitBrowserPane.populateBean(ob);
mobileToolBarPane.populateBean(ob);
reportMobileTemplateSettingsPane.populateBean(ob);
}
@Override
public ElementCaseMobileAttr updateBean() {
ElementCaseMobileAttr caseMobileAttr = appFitBrowserPane.updateBean();
mobileToolBarPane.updateBean(caseMobileAttr);
reportMobileTemplateSettingsPane.updateBean(caseMobileAttr);
return caseMobileAttr;
}

102
designer-realize/src/com/fr/design/report/mobile/ReportMobileTemplateSettingsPane.java

@ -0,0 +1,102 @@
package com.fr.design.report.mobile;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.icheckbox.UICheckBox;
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.*;
/**
* Created by plough on 2018/1/8.
*/
public class ReportMobileTemplateSettingsPane extends BasicBeanPane<ElementCaseMobileAttr> {
private UICheckBox mobileCanvasSizeCheck; // 设置为手机模版画布大小
public ReportMobileTemplateSettingsPane() {
this.initComponents();
}
private void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel borderPane = FRGUIPaneFactory.createTitledBorderPane(this.title4PopupWindow());
JPanel contentPane = new JPanel(FRGUIPaneFactory.createBorderLayout());
contentPane.setBorder(BorderFactory.createEmptyBorder(0, IntervalConstants.INTERVAL_L2, 0, 0));
contentPane.add(getMobileCanvasSizeCheckPane(), BorderLayout.CENTER);
borderPane.add(contentPane);
this.add(borderPane);
}
private JPanel getMobileCanvasSizeCheckPane() {
JPanel panel = new JPanel(FRGUIPaneFactory.createBorderLayout());
mobileCanvasSizeCheck = new UICheckBox(Inter.getLocText("FR-Designer_Set_Mobile_Canvas_Size"));
panel.add(mobileCanvasSizeCheck, BorderLayout.NORTH);
panel.add(getCanvasDescPane(), BorderLayout.CENTER);
panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L6, 0));
return panel;
}
private JPanel getCanvasDescPane() {
UILabel desc1 = createDescLabel(Inter.getLocText("FR-Designer_Mobile_Screen_Match_Desc"));
UILabel desc2 = createDescLabel(Inter.getLocText("FR-Designer_Mobile_Screen_Zoom_In_Desc"));
UILabel desc3 = createDescLabel(Inter.getLocText("FR-Designer_Mobile_Screen_Zoom_Out_Desc"));
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}};
Component[][] components = new Component[][]{
new Component[]{desc1, null},
new Component[]{desc2, null},
new Component[]{desc3, null}
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1);
panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L7, IntervalConstants.INTERVAL_W4, IntervalConstants.INTERVAL_L1, 0));
return panel;
}
private UILabel createDescLabel(String desc) {
UILabel label = new UILabel(desc);
label.setForeground(Color.gray);
return label;
}
@Override
public void populateBean(ElementCaseMobileAttr ob) {
if (ob == null) {
ob = new ElementCaseMobileAttr();
}
mobileCanvasSizeCheck.setSelected(ob.isMobileCanvasSize());
}
@Override
public ElementCaseMobileAttr updateBean() {
ElementCaseMobileAttr mobileAttr = new ElementCaseMobileAttr();
mobileAttr.setMobileCanvasSize(mobileCanvasSizeCheck.isSelected());
return mobileAttr;
}
@Override
public void updateBean(ElementCaseMobileAttr mobileAttr) {
if(mobileAttr != null) {
mobileAttr.setMobileCanvasSize(mobileCanvasSizeCheck.isSelected());
}
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer_Template_Settings");
}
}

5
designer-realize/src/com/fr/grid/GridUI.java

@ -583,11 +583,6 @@ public class GridUI extends ComponentUI {
}
private void paintPaginateLines(Graphics g, Grid grid) {
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if(!jTemplate.isJWorkBook()){
//报表块无分页之说
return;
}
Graphics2D g2d = (Graphics2D) g;
// james 画分页线

Loading…
Cancel
Save