From f4e24d403178410a2e74dbf4c8a3c96ff925d459 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Tue, 8 Aug 2017 15:49:47 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E6=8E=A7=E4=BB=B6=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=BD=91=E9=A1=B5=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widget/ui/IframeEditorDefinePane.java | 185 +++++++++++------- .../frpane/ReportletParameterViewPane.java | 183 +++++++++-------- .../itableeditorpane/UITableEditorPane.java | 179 +++++++++-------- 3 files changed, 303 insertions(+), 244 deletions(-) diff --git a/designer/src/com/fr/design/widget/ui/IframeEditorDefinePane.java b/designer/src/com/fr/design/widget/ui/IframeEditorDefinePane.java index cf7797e813..e154a022c4 100644 --- a/designer/src/com/fr/design/widget/ui/IframeEditorDefinePane.java +++ b/designer/src/com/fr/design/widget/ui/IframeEditorDefinePane.java @@ -1,17 +1,13 @@ package com.fr.design.widget.ui; -import java.awt.*; -import java.util.List; - -import javax.swing.BorderFactory; - import com.fr.design.constants.LayoutConstants; +import com.fr.design.dialog.DialogActionListener; +import com.fr.design.dialog.UIDialog; import com.fr.design.foldablepane.UIExpandablePane; -import com.fr.design.gui.ilable.UILabel; -import javax.swing.JPanel; - import com.fr.design.gui.frpane.ReportletParameterViewPane; +import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; @@ -20,68 +16,115 @@ import com.fr.form.ui.IframeEditor; import com.fr.general.Inter; import com.fr.stable.ParameterProvider; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + public class IframeEditorDefinePane extends AbstractDataModify { - private UITextField srcTextField; - private ReportletParameterViewPane parameterViewPane; - private UICheckBox horizontalCheck; - private UICheckBox verticalCheck; - - public IframeEditorDefinePane() { - this.initComponents(); - } - - private void initComponents() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - contentPane.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); - JPanel attr = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - attr.add(horizontalCheck = new UICheckBox(Inter.getLocText("Preference-Horizontal_Scroll_Bar_Visible"))); - attr.add(verticalCheck = new UICheckBox(Inter.getLocText("Preference-Vertical_Scroll_Bar_Visible"))); - contentPane.add(attr); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] rowSize = { p, p, p, p }; - double[] columnSize = { p, f }; - - java.awt.Component[][] coms = { - { horizontalCheck, null }, - { verticalCheck, null }, - { new UILabel(Inter.getLocText("Form-Url") + ":"), srcTextField = new UITextField() }, - { new UILabel(Inter.getLocText("Parameter") + ":"), parameterViewPane = new ReportletParameterViewPane() } }; - int[][] rowCount = {{1, 1},{1, 1},{1, 1}, {1, 1}}; - JPanel panel = TableLayoutHelper.createGapTableLayoutPane(coms, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, 5); - - - contentPane.add(panel); - - UIExpandablePane uiExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 280, 20, contentPane); - this.add(uiExpandablePane, BorderLayout.NORTH); - - } - - - @Override - protected String title4PopupWindow() { - return "iframe"; - } - - @Override - public void populateBean(IframeEditor e) { - srcTextField.setText(e.getSrc()); - parameterViewPane.populate(e.getParameters()); - this.horizontalCheck.setSelected(e.isOverflowx()); - this.verticalCheck.setSelected(e.isOverflowy()); - } - - @Override - public IframeEditor updateBean() { - IframeEditor ob = new IframeEditor(); - ob.setSrc(srcTextField.getText()); - List parameterList = parameterViewPane.update(); - ob.setParameters(parameterList.toArray(new ParameterProvider[parameterList.size()])); - ob.setOverflowx(this.horizontalCheck.isSelected()); - ob.setOverflowy(this.verticalCheck.isSelected()); - return ob; - } + + private static final int P_W = 610; + private static final int P_H = 580; + private UITextField srcTextField; + private ReportletParameterViewPane parameterViewPane; + private UICheckBox horizontalCheck; + private UICheckBox verticalCheck; + private UIButton parameterViewPaneButton; + private List list; + + + public IframeEditorDefinePane() { + this.initComponents(); + } + + private void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); + contentPane.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); + JPanel attr = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); + attr.add(horizontalCheck = new UICheckBox(Inter.getLocText("Preference-Horizontal_Scroll_Bar_Visible"))); + attr.add(verticalCheck = new UICheckBox(Inter.getLocText("Preference-Vertical_Scroll_Bar_Visible"))); + contentPane.add(attr); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p, p, p, p}; + double[] columnSize = {p, f}; + + parameterViewPaneButton = new UIButton(Inter.getLocText("FR-Designer_Edit")); + parameterViewPaneButton.addActionListener(parameterListener); + parameterViewPane = new ReportletParameterViewPane(); + + java.awt.Component[][] coms = { + {horizontalCheck, null}, + {verticalCheck, null}, + {new UILabel(Inter.getLocText("Form-Url")), srcTextField = new UITextField()}, + {new UILabel(Inter.getLocText("FR-Designer_Parameters")), parameterViewPaneButton}}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}}; + JPanel panel = TableLayoutHelper.createGapTableLayoutPane(coms, rowSize, columnSize, rowCount, 45, LayoutConstants.VGAP_LARGE); + + + contentPane.add(panel); + + UIExpandablePane uiExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 280, 24, contentPane); + this.add(uiExpandablePane, BorderLayout.NORTH); + + } + + ActionListener parameterListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + List paraList = parameterViewPane.update(); + list = new ArrayList(); + ParameterProvider pr = null; + for (ParameterProvider parameterProvider : paraList) { + try { + pr = (ParameterProvider) parameterProvider.clone(); + } catch (CloneNotSupportedException e1) { + e1.printStackTrace(); + } + list.add(pr); + } + + UIDialog dialog = parameterViewPane.showUnsizedWindow(SwingUtilities.getWindowAncestor(new JPanel()), new DialogActionListener() { + @Override + public void doOk() { +// list = parameterViewPane.update(); + } + + @Override + public void doCancel() { + parameterViewPane.update(list); + } + }); + dialog.setSize(P_W, P_H); + dialog.setVisible(true); + } + }; + + @Override + protected String title4PopupWindow() { + return "iframe"; + } + + @Override + public void populateBean(IframeEditor e) { + srcTextField.setText(e.getSrc()); + parameterViewPane.populate(e.getParameters()); + this.horizontalCheck.setSelected(e.isOverflowx()); + this.verticalCheck.setSelected(e.isOverflowy()); + } + + @Override + public IframeEditor updateBean() { + IframeEditor ob = new IframeEditor(); + ob.setSrc(srcTextField.getText()); + List parameterList = parameterViewPane.update(); + ob.setParameters(parameterList.toArray(new ParameterProvider[parameterList.size()])); + ob.setOverflowx(this.horizontalCheck.isSelected()); + ob.setOverflowy(this.verticalCheck.isSelected()); + return ob; + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/frpane/ReportletParameterViewPane.java b/designer_base/src/com/fr/design/gui/frpane/ReportletParameterViewPane.java index a9cea2cf13..084b11ee48 100644 --- a/designer_base/src/com/fr/design/gui/frpane/ReportletParameterViewPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/ReportletParameterViewPane.java @@ -23,115 +23,124 @@ import java.util.List; /** * Defin hyperlink. * in fact,this is a TablEditorPane + * * @editor zhou * @since 2012-3-23下午3:48:10 */ public class ReportletParameterViewPane extends BasicPane { - private UITableEditorPane editorPane; + private UITableEditorPane editorPane; - public ReportletParameterViewPane() { - this(null, ParameterTableModel.NO_CHART_USE); - } + public ReportletParameterViewPane() { + this(null, ParameterTableModel.NO_CHART_USE); + } - // kunsnat: 控制是否用Chart的热点链接actions - public ReportletParameterViewPane(int useParaType) { - this(null, useParaType); - } + // kunsnat: 控制是否用Chart的热点链接actions + public ReportletParameterViewPane(int useParaType) { + this(null, useParaType); + } - public ReportletParameterViewPane(UITableEditAction[] actions, int useParaType) { - this(actions, useParaType, ValueEditorPaneFactory.createVallueEditorPaneWithUseType(useParaType), - ValueEditorPaneFactory.createVallueEditorPaneWithUseType(useParaType)); - } + public ReportletParameterViewPane(UITableEditAction[] actions, int useParaType) { + this(actions, useParaType, ValueEditorPaneFactory.createVallueEditorPaneWithUseType(useParaType), + ValueEditorPaneFactory.createVallueEditorPaneWithUseType(useParaType)); + } - public ReportletParameterViewPane(int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) { - this(null, useParaType, valueEditorPane, valueRenderPane); - } + public ReportletParameterViewPane(int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) { + this(null, useParaType, valueEditorPane, valueRenderPane); + } - public ReportletParameterViewPane(UITableEditAction[] actions, int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) { - this.initComponent(actions, useParaType, valueEditorPane, valueRenderPane); - } + public ReportletParameterViewPane(UITableEditAction[] actions, int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) { + this.initComponent(actions, useParaType, valueEditorPane, valueRenderPane); + } /** * 初始化组件 - * @param actions Chart的热点链接actions - * @param useParaType 类型 + * + * @param actions Chart的热点链接actions + * @param useParaType 类型 */ - public void initComponent(final UITableEditAction[] actions, int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - - if (useParaType != ParameterTableModel.NO_CHART_USE) { - ParameterTableModel model = new ParameterTableModel(valueEditorPane, valueRenderPane, this) { - @Override - public UITableEditAction[] createAction() { - UITableEditAction[] tableEditActions = new UITableEditAction[] { new AddChartParameterAction(), new DeleteAction(this.component), - new MoveUpAction(), new MoveDownAction() }; - return (UITableEditAction[]) ArrayUtils.addAll(tableEditActions, actions); - } - }; - editorPane = new UITableEditorPane(model); - } else { - editorPane = new UITableEditorPane(new ParameterTableModel() { - @Override - public UITableEditAction[] createAction() { - return (UITableEditAction[]) ArrayUtils.addAll(super.createAction(), actions); - } - }); - } - - this.add(editorPane, BorderLayout.CENTER); - } + public void initComponent(final UITableEditAction[] actions, int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + if (useParaType != ParameterTableModel.NO_CHART_USE) { + ParameterTableModel model = new ParameterTableModel(valueEditorPane, valueRenderPane, this) { + @Override + public UITableEditAction[] createAction() { + UITableEditAction[] tableEditActions = new UITableEditAction[]{new AddChartParameterAction(), new DeleteAction(this.component), + new MoveUpAction(), new MoveDownAction()}; + return (UITableEditAction[]) ArrayUtils.addAll(tableEditActions, actions); + } + }; + editorPane = new UITableEditorPane(model); + } else { + editorPane = new UITableEditorPane(new ParameterTableModel() { + @Override + public UITableEditAction[] createAction() { + return (UITableEditAction[]) ArrayUtils.addAll(super.createAction(), actions); + } + }); + } + + this.add(editorPane, BorderLayout.CENTER); + } /** * 增加事件监听 - * @param l 加的东东 + * + * @param l 加的东东 */ - public void addTableEditorListener(TableModelListener l) { - editorPane.addTableListener(l); - } - - @Override - protected String title4PopupWindow() { - return Inter.getLocText("Parameters"); - } - - public void populate(ParameterProvider[] parameters) { - if (parameters == null) { - return; - } - editorPane.populate(parameters); - } - - public void populate(KV[] kv) { - if (kv == null) { - return; - } - Parameter[] parameters = new Parameter[kv.length]; - for (int i = 0; i < kv.length; i++) { - parameters[i] = new Parameter(kv[i].getKey(), kv[i].getValue()); - } - this.populate(parameters); - } - - public List update() { - return editorPane.update(); - } + public void addTableEditorListener(TableModelListener l) { + editorPane.addTableListener(l); + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("Parameters"); + } + + public void populate(ParameterProvider[] parameters) { + if (parameters == null) { + return; + } + editorPane.populate(parameters); + } + + public void populate(KV[] kv) { + if (kv == null) { + return; + } + Parameter[] parameters = new Parameter[kv.length]; + for (int i = 0; i < kv.length; i++) { + parameters[i] = new Parameter(kv[i].getKey(), kv[i].getValue()); + } + this.populate(parameters); + } + + public List update() { + return editorPane.update(); + } + + public void update(List list) { + editorPane.update(list); + } + /** * 更新 - * @return 数组 + * + * @return 数组 */ - public KV[] updateKV() { - List list = this.update(); - int length = list.size(); - KV[] kv = new KV[length]; - for (int i = 0; i < length; i++) { - kv[i] = new KV(); - kv[i].setKey(list.get(i).getName()); - kv[i].setValue( list.get(i).getValue()); - } - return kv; - } + public KV[] updateKV() { + List list = this.update(); + int length = list.size(); + KV[] kv = new KV[length]; + for (int i = 0; i < length; i++) { + kv[i] = new KV(); + kv[i].setKey(list.get(i).getName()); + kv[i].setValue(list.get(i).getValue()); + } + return kv; + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/itableeditorpane/UITableEditorPane.java b/designer_base/src/com/fr/design/gui/itableeditorpane/UITableEditorPane.java index a0c09a8486..c75f231d39 100644 --- a/designer_base/src/com/fr/design/gui/itableeditorpane/UITableEditorPane.java +++ b/designer_base/src/com/fr/design/gui/itableeditorpane/UITableEditorPane.java @@ -1,12 +1,12 @@ package com.fr.design.gui.itableeditorpane; -import com.fr.design.constants.UIConstants; import com.fr.design.border.UIRoundedBorder; +import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.dialog.BasicPane; import com.fr.general.Inter; import javax.swing.*; @@ -16,56 +16,56 @@ import java.util.List; /** * 表格编辑面板,一般是两列.键-值 用泛型实现,用的时候请定义T.model里面的T要一样 - * + * * @editor zhou * @since 2012-3-28下午3:06:30 */ public class UITableEditorPane extends BasicPane { - /** - * - */ - private static final long serialVersionUID = 6855793816972735815L; - private JTable editTable; - // 放置action 的按钮. - private UITableModelAdapter tableModel; - private String leftLabelName; + /** + * + */ + private static final long serialVersionUID = 6855793816972735815L; + private JTable editTable; + // 放置action 的按钮. + private UITableModelAdapter tableModel; + private String leftLabelName; private JPanel buttonPane; - public UITableEditorPane(UITableModelAdapter model) { - this.tableModel = model; - this.initComponent(model.createAction()); - } - - public UITableEditorPane(UITableModelAdapter model, String s) { - leftLabelName = s; - this.tableModel = model; - this.initComponent(model.createAction()); - } - - private void initComponent(UITableEditAction[] action) { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - JPanel pane = new JPanel(new BorderLayout(4, 4)); - this.add(pane, BorderLayout.CENTER); - - UILabel l = new UILabel(leftLabelName); - editTable = tableModel.createTable(); - - UIScrollPane scrollPane = new UIScrollPane(editTable); - scrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); - pane.add(scrollPane, BorderLayout.CENTER); - initbuttonPane(action); - JPanel controlPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - controlPane.add(buttonPane, BorderLayout.EAST); - controlPane.add(l, BorderLayout.WEST); - pane.add(controlPane, BorderLayout.NORTH); - - } - - public UITableModelAdapter getTableModel(){ + public UITableEditorPane(UITableModelAdapter model) { + this.tableModel = model; + this.initComponent(model.createAction()); + } + + public UITableEditorPane(UITableModelAdapter model, String s) { + leftLabelName = s; + this.tableModel = model; + this.initComponent(model.createAction()); + } + + private void initComponent(UITableEditAction[] action) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel pane = new JPanel(new BorderLayout(4, 4)); + this.add(pane, BorderLayout.CENTER); + + UILabel l = new UILabel(leftLabelName); + editTable = tableModel.createTable(); + + UIScrollPane scrollPane = new UIScrollPane(editTable); + scrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); + pane.add(scrollPane, BorderLayout.CENTER); + initbuttonPane(action); + JPanel controlPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + controlPane.add(buttonPane, BorderLayout.EAST); + controlPane.add(l, BorderLayout.WEST); + pane.add(controlPane, BorderLayout.NORTH); + + } + + public UITableModelAdapter getTableModel() { return tableModel; } - private void initbuttonPane(UITableEditAction[] action){ + private void initbuttonPane(UITableEditAction[] action) { buttonPane = new JPanel(); if (action != null) { @@ -87,54 +87,61 @@ public class UITableEditorPane extends BasicPane { /** * 增加事件监听 - * @param l 加的东东 + * + * @param l 加的东东 */ - public void addTableListener(TableModelListener l) { - tableModel.addTableModelListener(l); - } + public void addTableListener(TableModelListener l) { + tableModel.addTableModelListener(l); + } /** * 移除事件监听 - * @param l 去的东东 + * + * @param l 去的东东 */ - public void removeTableListener(TableModelListener l) { - tableModel.removeTableModelListener(l); - } - - @Override - protected String title4PopupWindow() { - return Inter.getLocText("TableData_Dynamic_Parameter_Setting"); - } - - public void populate(T[] objs) { - tableModel.clear(); - if(objs==null){ - return; - } - for (T obj : objs) { - tableModel.addRow(obj); - } - this.tableModel.fireTableDataChanged(); - if (objs.length > 0) { - this.editTable.getSelectionModel().setSelectionInterval(0, 0); - } - } - - // TODO:august这个最好还是返回数组 - public List update() { - tableModel.stopCellEditing(); - return tableModel.getList(); - } - - public int getSelectedRow() { - return this.editTable.getSelectedRow(); - } - - public int getSelectedColumn() { - return this.editTable.getSelectedColumn(); - } - - public JPanel getbuttonPane(){ + public void removeTableListener(TableModelListener l) { + tableModel.removeTableModelListener(l); + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("TableData_Dynamic_Parameter_Setting"); + } + + public void populate(T[] objs) { + tableModel.clear(); + if (objs == null) { + return; + } + for (T obj : objs) { + tableModel.addRow(obj); + } + this.tableModel.fireTableDataChanged(); + if (objs.length > 0) { + this.editTable.getSelectionModel().setSelectionInterval(0, 0); + } + } + + // TODO:august这个最好还是返回数组 + public List update() { + tableModel.stopCellEditing(); + return tableModel.getList(); + } + + public void update(List list) { + tableModel.stopCellEditing(); + tableModel.setList(list); + } + + public int getSelectedRow() { + return this.editTable.getSelectedRow(); + } + + public int getSelectedColumn() { + return this.editTable.getSelectedColumn(); + } + + public JPanel getbuttonPane() { return buttonPane; }