From c820059d3a54131c76757e62fc1c57939963883c Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Mon, 31 Jul 2017 17:26:21 +0800 Subject: [PATCH 1/5] =?UTF-8?q?REPORT-3348=20=E5=8D=95=E5=85=83=E6=A0=BC?= =?UTF-8?q?=E5=85=83=E7=B4=A0=E6=95=B0=E6=8D=AE=E5=88=97=E9=AB=98=E7=BA=A7?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dscolumn/DSColumnAdvancedEditorPane.java | 464 ++++++++++++++++++ 1 file changed, 464 insertions(+) diff --git a/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java index 57af1a340..fb0b69496 100644 --- a/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java +++ b/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java @@ -1,11 +1,45 @@ package com.fr.design.dscolumn; +import com.fr.base.Formula; +import com.fr.data.TableDataSource; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.formula.CustomVariableResolver; +import com.fr.design.formula.FormulaFactory; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.formula.UIFormula; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.cell.CellEditorPane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.IOUtils; +import com.fr.general.Inter; +import com.fr.report.cell.CellElement; import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.report.cell.cellattr.core.group.SelectCount; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * 单元格元素 数据列 基本设置内容面板 + *

+ * 复制了一些{@link DSColumnAdvancedPane}的内部类,不做复用,价值不大,进行修改后直接使用; + *

* * @author yaoh.wu * @version 2017年7月25日 @@ -13,6 +47,29 @@ import com.fr.report.cell.TemplateCellElement; */ public class DSColumnAdvancedEditorPane extends CellEditorPane { + private static final String INSET_TEXT = " "; + + //排列顺序 + private ResultSetSortConfigPane sortPane; + //结果集筛选 + private SelectCountPane selectCountPane; + //自定义值显示 + private ValuePane valuePane; + //横向可扩展性 + private UICheckBox horizontalExtendableCheckBox; + //纵向可扩展性 + private UICheckBox verticalExtendableCheckBox; + //补充空白数据 + private UICheckBox useMultiplyNumCheckBox; + //补充空白数据书目输入框 + private UISpinner multiNumSpinner; + + + public DSColumnAdvancedEditorPane() { + this.setLayout(new BorderLayout()); + this.add(this.createContentPane(), BorderLayout.CENTER); + } + @Override public String getIconPath() { @@ -35,4 +92,411 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { } + + /** + * 创建内容 + */ + private JPanel createContentPane() { + this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + this.sortPane = new ResultSetSortConfigPane(); + + selectCountPane = new DSColumnAdvancedEditorPane.SelectCountPane(); + + valuePane = new DSColumnAdvancedEditorPane.ValuePane(); + + JPanel extendableDirectionPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + extendableDirectionPane.add(horizontalExtendableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Horizontal_Extendable"))); + extendableDirectionPane.add(verticalExtendableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Vertical_Extendable"))); + + JPanel extendablePane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("ExpandD-Expandable")); + extendablePane.setLayout(new BorderLayout()); + extendablePane.add(extendableDirectionPane, BorderLayout.CENTER); + + JPanel multiNumPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Fill_blank_Data")); + + useMultiplyNumCheckBox = new UICheckBox(Inter.getLocText("Column_Multiple")); + multiNumPane.add(useMultiplyNumCheckBox); + multiNumPane.add(new UILabel(INSET_TEXT)); + + multiNumSpinner = new UISpinner(1, 10000, 1, 1); + multiNumPane.add(multiNumSpinner); + + useMultiplyNumCheckBox.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + checkButtonEnabled(); + } + }); + + double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED, + TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; + double[] columnSize = {TableLayout.FILL}; + + Component[][] components = null; + components = new Component[][]{ + {sortPane}, + {selectCountPane}, + {valuePane}, + {extendablePane}, + {multiNumPane} + }; + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + } + + + private void checkButtonEnabled() { + if (useMultiplyNumCheckBox.isSelected()) { + multiNumSpinner.setEnabled(true); + } else { + multiNumSpinner.setEnabled(false); + } + } + + /** + * 单元格元素>数据集>高级设置>结果排序设置面板 + * + * @see com.fr.design.mainframe.cell.settingpane.CellExpandAttrPane + */ + protected static class ResultSetSortConfigPane extends JPanel { + private UIButtonGroup sort_type_pane; + private TinyFormulaPane tinyFormulaPane; + private CardLayout cardLayout; + private JPanel centerPane; + + + public ResultSetSortConfigPane() { + this.setLayout(new BorderLayout(0, 4)); + Icon[] iconArray = { + IOUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), + IOUtils.readIcon("/com/fr/design/images/expand/asc.png"), + IOUtils.readIcon("/com/fr/design/images/expand/des.png") + }; + String[] nameArray = {Inter.getLocText("Sort-Original"), Inter.getLocText("Sort-Ascending"), Inter.getLocText("Sort-Descending")}; + sort_type_pane = new UIButtonGroup(iconArray); + sort_type_pane.setAllToolTips(nameArray); + sort_type_pane.setGlobalName(Inter.getLocText("ExpandD-Sort_After_Expand")); + this.add(sort_type_pane, BorderLayout.NORTH); + + cardLayout = new CardLayout(); + centerPane = new JPanel(cardLayout); + + tinyFormulaPane = new TinyFormulaPane(); + + centerPane.add(new JPanel(), "none"); + centerPane.add(tinyFormulaPane, "content"); + + this.add(centerPane, BorderLayout.CENTER); + + sort_type_pane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + cardLayout.show(centerPane, sort_type_pane.getSelectedIndex() == 0 ? "none" : "content"); + } + }); + } + + + /** + * 刷新面板信息 + * + * @param dataSource 数据集对象 + * @param cellElement 单元格 + */ + public void populate(TableDataSource dataSource, TemplateCellElement cellElement) { + //todo + } + + + /** + * 保存面板配置信息 + * + * @param cellElement 单元格 + */ + public void update(CellElement cellElement) { + //todo + } + } + + /** + * 单元格元素>数据集>高级设置>结果集筛选设置面板 + * + * @see DSColumnAdvancedPane.SelectCountPane + */ + protected static class SelectCountPane extends JPanel { + + CellElement cellElement; + // private Comparator sortComparator; + private UIComboBox selectCountComboBox; + private JPanel selectCountCardPane; + private UITextField serialTextField; + + DSColumnAdvancedEditorPane.JFormulaField topFormulaPane; + DSColumnAdvancedEditorPane.JFormulaField bottomFormulaPane; + + public SelectCountPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + selectCountComboBox = new UIComboBox(new String[]{ + Inter.getLocText("Undefined"), + Inter.getLocText("BindColumn-Top_N"), + Inter.getLocText("BindColumn-Bottom_N"), + Inter.getLocText("Odd"), + Inter.getLocText("Even"), + Inter.getLocText("Specify"),}); + selectCountComboBox.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + int selectIndex = selectCountComboBox.getSelectedIndex(); + CardLayout c1 = (CardLayout) selectCountCardPane.getLayout(); + if (selectIndex == 1) { + c1.show(selectCountCardPane, "TOP"); + } else if (selectIndex == 2) { + c1.show(selectCountCardPane, "BOTTOM"); + } else if (selectIndex == 3) { + c1.show(selectCountCardPane, "ODD"); + } else if (selectIndex == 4) { + c1.show(selectCountCardPane, "EVEN"); + } else if (selectIndex == 5) { + c1.show(selectCountCardPane, "SPECIFY"); + } else { + c1.show(selectCountCardPane, "UNDEFINE"); + } + } + }); + + selectCountCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + this.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(INSET_TEXT), selectCountComboBox, + new UILabel(INSET_TEXT), selectCountCardPane}, FlowLayout.LEFT), BorderLayout.WEST); +// selectCountCardPane.setLayout(new CardLayout()); + + //not define pane + + JPanel undefinedPane = GUICoreUtils.createFlowPane(new UILabel(Inter.getLocText("Undefined")), FlowLayout.LEFT); + topFormulaPane = new DSColumnAdvancedEditorPane.JFormulaField("-1"); + bottomFormulaPane = new DSColumnAdvancedEditorPane.JFormulaField("-1"); + serialTextField = new UITextField(18); + JPanel oddPane = GUICoreUtils.createFlowPane(new UILabel(Inter.getLocText("BindColumn-Result_Serial_Number_Start_From_1") + + " " + Inter.getLocText("BindColumn-Odd_Selected_(1,3,5...)")), FlowLayout.LEFT); + JPanel evenPane = GUICoreUtils.createFlowPane(new UILabel(Inter.getLocText("BindColumn-Result_Serial_Number_Start_From_1") + + " " + Inter.getLocText("BindColumn-Even_Selected_(2,4,6...)")), FlowLayout.LEFT); + JPanel specifyPane = GUICoreUtils.createFlowPane(new JComponent[]{ + serialTextField, new UILabel( + Inter.getLocText(new String[]{ + "Format", "BindColumn-Result_Serial_Number_Start_From_1", "Inner_Parameter", "Group_Count"}, + new String[]{": 1,2-3,5,8 ", ",", "$__count__"}) + ) + }, FlowLayout.LEFT); + serialTextField.setToolTipText(Inter.getLocText("StyleFormat-Sample") + ":=JOINARRAY(GREPARRAY(RANGE($__count__), item!=4), \",\")"); + selectCountCardPane.add(undefinedPane, "UNDEFINE"); + selectCountCardPane.add(topFormulaPane, "TOP"); + selectCountCardPane.add(bottomFormulaPane, "BOTTOM"); + //odd + selectCountCardPane.add(oddPane, "ODD"); + //even + selectCountCardPane.add(evenPane, "EVEN"); + //specify + selectCountCardPane.add(specifyPane, "SPECIFY"); + } + + public void populate(CellElement cellElement) { + if (cellElement == null) { + return; + } + this.cellElement = cellElement; + + Object value = cellElement.getValue(); + if (value == null || !(value instanceof DSColumn)) { + return; + } + DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + SelectCount selectCount = dSColumn.getSelectCount(); + this.topFormulaPane.populateElement(cellElement); + this.bottomFormulaPane.populateElement(cellElement); + if (selectCount != null) { + int selectCountType = selectCount.getType(); + this.selectCountComboBox.setSelectedIndex(selectCountType); + if (selectCountType == SelectCount.TOP) { + this.topFormulaPane.populate(selectCount.getFormulaCount()); + } else if (selectCountType == SelectCount.BOTTOM) { + this.bottomFormulaPane.populate(selectCount.getFormulaCount()); + } else if (selectCountType == SelectCount.SPECIFY) { + this.serialTextField.setText(selectCount.getSerial()); + } + } + } + + public void update(CellElement cellElement) { + if (cellElement == null) { + return; + } + Object value = cellElement.getValue(); + if (value == null || !(value instanceof DSColumn)) { + return; + } + DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + + //alex:SelectCount + int selectCountSelectIndex = this.selectCountComboBox.getSelectedIndex(); + if (selectCountSelectIndex == 0) { + dSColumn.setSelectCount(null); + } else { + SelectCount selectCount = new SelectCount(); + dSColumn.setSelectCount(selectCount); + selectCount.setType(selectCountSelectIndex); + if (selectCountSelectIndex == SelectCount.TOP) { + selectCount.setFormulaCount(this.topFormulaPane.getFormulaText()); + } else if (selectCountSelectIndex == SelectCount.BOTTOM) { + selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText()); + } else if (selectCountSelectIndex == SelectCount.SPECIFY) { + selectCount.setSerial(this.serialTextField.getText()); + } + } + } + + private JFormattedTextField getTextField(JSpinner spinner) { + JComponent editor = spinner.getEditor(); + if (editor instanceof JSpinner.DefaultEditor) { + return ((JSpinner.DefaultEditor) editor).getTextField(); + } else { + System.err.println("Unexpected editor type: " + + spinner.getEditor().getClass() + + " isn't a descendant of DefaultEditor"); + return null; + } + } + } + + /** + * 单元格元素>数据集>高级设置>公式输入框 + * + * @see DSColumnAdvancedPane.JFormulaField + */ + private static class JFormulaField extends JPanel { + private CellElement cellElement; + private UITextField formulaTextField; + private String defaultValue; + + public JFormulaField(String defaultValue) { + this.defaultValue = defaultValue; + + this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); + UILabel bottomLabel = new UILabel("="); + bottomLabel.setFont(new Font("Dialog", Font.BOLD, 12)); + this.add(bottomLabel); + formulaTextField = new UITextField(24); + this.add(formulaTextField); + formulaTextField.setText(defaultValue); + + UIButton bottomFrmulaButton = new UIButton("..."); + this.add(bottomFrmulaButton); + bottomFrmulaButton.setToolTipText(Inter.getLocText("Formula") + "..."); + bottomFrmulaButton.setPreferredSize(new Dimension(25, formulaTextField.getPreferredSize().height)); + bottomFrmulaButton.addActionListener(formulaButtonActionListener); + } + + public void populate(String formulaContent) { + this.formulaTextField.setText(formulaContent); + } + + public void populateElement(CellElement cellElement) { + this.cellElement = cellElement; + } + + public String getFormulaText() { + return this.formulaTextField.getText(); + } + + private ActionListener formulaButtonActionListener = new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + Formula valueFormula = new Formula(); + String text = formulaTextField.getText(); + if (text == null || text.length() <= 0) { + valueFormula.setContent(defaultValue); + } else { + valueFormula.setContent(text); + } + + final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); + + if (cellElement == null) { + return; + } + Object value = cellElement.getValue(); + if (value == null || !(value instanceof DSColumn)) { + return; + } + DSColumn dsColumn = (DSColumn) value; + + String[] displayNames = DesignTableDataManager.getSelectedColumnNames(DesignTableDataManager.getEditingTableDataSource(), dsColumn.getDSName()); + + formulaPane.populate(valueFormula, new CustomVariableResolver(displayNames, true)); + formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(DSColumnAdvancedEditorPane.JFormulaField.this), new DialogActionAdapter() { + @Override + public void doOk() { + Formula valueFormula = formulaPane.update(); + if (valueFormula.getContent().length() <= 1) { + formulaTextField.setText(defaultValue); + } else { + formulaTextField.setText(valueFormula.getContent().substring(1)); + } + } + }).setVisible(true); + } + }; + } + + /** + * 单元格元素>数据集>高级设置>自定义值显示设置面板 + * + * @see DSColumnAdvancedPane.ValuePane + */ + private static class ValuePane extends JPanel { + private DSColumnAdvancedEditorPane.JFormulaField formulaField; + + public ValuePane() { + this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); + + this.add(new UILabel(INSET_TEXT + Inter.getLocText("Value") + ":")); + this.add(Box.createHorizontalStrut(2)); + this.add((formulaField = new DSColumnAdvancedEditorPane.JFormulaField("$$$"))); + } + + public void populate(CellElement cellElement) { + if (cellElement == null) { + return; + } + + Object value = cellElement.getValue(); + if (value == null || !(value instanceof DSColumn)) { + return; + } + DSColumn dSColumn = (DSColumn) value; + + //formula + String valueFormula = dSColumn.getResult(); + if (valueFormula == null) { + valueFormula = "$$$"; + } + formulaField.populateElement(cellElement); + formulaField.populate(valueFormula); + } + + public void update(CellElement cellElement) { + if (cellElement == null) { + return; + } + Object value = cellElement.getValue(); + if (value == null || !(value instanceof DSColumn)) { + return; + } + DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + + //formula + dSColumn.setResult(this.formulaField.getFormulaText()); + } + } + } From 1a3b6fca8ff0d9f249a8a17a7161bf1b44ecd3c9 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Wed, 2 Aug 2017 19:01:43 +0800 Subject: [PATCH 2/5] =?UTF-8?q?REPORT-3348=20=E6=95=B0=E6=8D=AE=E5=88=97?= =?UTF-8?q?=E9=AB=98=E7=BA=A7=E8=AE=BE=E7=BD=AE=E5=86=85=E9=83=A8=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dscolumn/DSColumnAdvancedEditorPane.java | 213 +++-- .../dscolumn/DSColumnBasicEditorPane.java | 1 + .../dscolumn/ResultSetGroupDockingPane.java | 50 +- .../com/fr/quickeditor/CellQuickEditor.java | 23 +- .../cellquick/CellDSColumnEditor.java | 2 - .../fr/design/layout/FRGUIPaneFactory.java | 902 +++++++++--------- .../src/com/fr/design/utils/DesignUtils.java | 3 +- 7 files changed, 631 insertions(+), 563 deletions(-) diff --git a/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java index fb0b69496..46d8d0a6e 100644 --- a/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java +++ b/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java @@ -19,7 +19,6 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.cell.CellEditorPane; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.report.cell.CellElement; @@ -52,9 +51,9 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { //排列顺序 private ResultSetSortConfigPane sortPane; //结果集筛选 - private SelectCountPane selectCountPane; + private ResultSetFilterConfigPane filterPane; //自定义值显示 - private ValuePane valuePane; + private CustomValuePane valuePane; //横向可扩展性 private UICheckBox horizontalExtendableCheckBox; //纵向可扩展性 @@ -68,6 +67,7 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { public DSColumnAdvancedEditorPane() { this.setLayout(new BorderLayout()); this.add(this.createContentPane(), BorderLayout.CENTER); + this.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); } @@ -99,22 +99,22 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { private JPanel createContentPane() { this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); this.setLayout(FRGUIPaneFactory.createBorderLayout()); + //结果集排序 this.sortPane = new ResultSetSortConfigPane(); + //结果筛选 - selectCountPane = new DSColumnAdvancedEditorPane.SelectCountPane(); - - valuePane = new DSColumnAdvancedEditorPane.ValuePane(); - + filterPane = new ResultSetFilterConfigPane(); + //自定义值显示 + valuePane = new CustomValuePane(); + //可扩展性 JPanel extendableDirectionPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); extendableDirectionPane.add(horizontalExtendableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Horizontal_Extendable"))); extendableDirectionPane.add(verticalExtendableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Vertical_Extendable"))); - JPanel extendablePane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("ExpandD-Expandable")); - extendablePane.setLayout(new BorderLayout()); - extendablePane.add(extendableDirectionPane, BorderLayout.CENTER); - JPanel multiNumPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Fill_blank_Data")); + //补充空白数据 + JPanel multiNumPane = new JPanel(); useMultiplyNumCheckBox = new UICheckBox(Inter.getLocText("Column_Multiple")); multiNumPane.add(useMultiplyNumCheckBox); @@ -124,22 +124,20 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { multiNumPane.add(multiNumSpinner); useMultiplyNumCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { checkButtonEnabled(); } }); - double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED, - TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; - double[] columnSize = {TableLayout.FILL}; + double p = TableLayout.PREFERRED, f = TableLayout.FILL; + double[] rowSize = {p, p, p, p, p, p}; + double[] columnSize = {f}; - Component[][] components = null; - components = new Component[][]{ + Component[][] components = new Component[][]{ {sortPane}, - {selectCountPane}, + {filterPane}, {valuePane}, - {extendablePane}, + {extendableDirectionPane}, {multiNumPane} }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); @@ -167,7 +165,7 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { public ResultSetSortConfigPane() { - this.setLayout(new BorderLayout(0, 4)); + this.setLayout(new BorderLayout(0, 0)); Icon[] iconArray = { IOUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), IOUtils.readIcon("/com/fr/design/images/expand/asc.png"), @@ -177,24 +175,34 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { sort_type_pane = new UIButtonGroup(iconArray); sort_type_pane.setAllToolTips(nameArray); sort_type_pane.setGlobalName(Inter.getLocText("ExpandD-Sort_After_Expand")); - this.add(sort_type_pane, BorderLayout.NORTH); cardLayout = new CardLayout(); centerPane = new JPanel(cardLayout); - tinyFormulaPane = new TinyFormulaPane(); - centerPane.add(new JPanel(), "none"); centerPane.add(tinyFormulaPane, "content"); - - this.add(centerPane, BorderLayout.CENTER); - + //todo 国际化 + UILabel sortLabel = new UILabel("排列顺序"); sort_type_pane.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - cardLayout.show(centerPane, sort_type_pane.getSelectedIndex() == 0 ? "none" : "content"); + boolean noContent = sort_type_pane.getSelectedIndex() == 0; + cardLayout.show(centerPane, noContent ? "none" : "content"); + if (noContent) { + centerPane.setPreferredSize(new Dimension(0, 0)); + } else { + centerPane.setPreferredSize(new Dimension(165, 20)); + } } }); + + Component[][] components = new Component[][]{ + new Component[]{sortLabel, sort_type_pane}, + new Component[]{null, centerPane} + }; + double p = TableLayout.PREFERRED, f = TableLayout.FILL; + double[] rowSize = {p, p}, columnSize = {p, f}; + this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); } @@ -224,80 +232,106 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { * * @see DSColumnAdvancedPane.SelectCountPane */ - protected static class SelectCountPane extends JPanel { + protected static class ResultSetFilterConfigPane extends JPanel { + private enum FilterType { + //前N个 后N个 奇数 偶数 自定义 未定义 + TOP, BOTTOM, ODD, EVEN, SPECIFY, UNDEFINE; + } CellElement cellElement; - // private Comparator sortComparator; - private UIComboBox selectCountComboBox; - private JPanel selectCountCardPane; + private UIComboBox rsComboBox; + private JPanel setCardPane; + private JPanel tipCardPane; private UITextField serialTextField; DSColumnAdvancedEditorPane.JFormulaField topFormulaPane; DSColumnAdvancedEditorPane.JFormulaField bottomFormulaPane; - public SelectCountPane() { + public ResultSetFilterConfigPane() { + double p = TableLayout.PREFERRED, f = TableLayout.FILL; + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + UILabel filterLabel = new UILabel("结果集筛选"); - selectCountComboBox = new UIComboBox(new String[]{ + //结果集筛选下拉框 + rsComboBox = new UIComboBox(new String[]{ Inter.getLocText("Undefined"), Inter.getLocText("BindColumn-Top_N"), Inter.getLocText("BindColumn-Bottom_N"), Inter.getLocText("Odd"), Inter.getLocText("Even"), - Inter.getLocText("Specify"),}); - selectCountComboBox.addActionListener(new ActionListener() { - + Inter.getLocText("Specify") + }); + rsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { - int selectIndex = selectCountComboBox.getSelectedIndex(); - CardLayout c1 = (CardLayout) selectCountCardPane.getLayout(); + int selectIndex = rsComboBox.getSelectedIndex(); + CardLayout setCardPaneLayout = (CardLayout) setCardPane.getLayout(); + CardLayout tipCardPaneLayout = (CardLayout) tipCardPane.getLayout(); if (selectIndex == 1) { - c1.show(selectCountCardPane, "TOP"); + setCardPaneLayout.show(setCardPane, FilterType.TOP.name()); + tipCardPaneLayout.show(tipCardPane, FilterType.TOP.name()); } else if (selectIndex == 2) { - c1.show(selectCountCardPane, "BOTTOM"); + setCardPaneLayout.show(setCardPane, FilterType.BOTTOM.name()); + tipCardPaneLayout.show(tipCardPane, FilterType.BOTTOM.name()); } else if (selectIndex == 3) { - c1.show(selectCountCardPane, "ODD"); + setCardPaneLayout.show(setCardPane, FilterType.ODD.name()); + tipCardPaneLayout.show(tipCardPane, FilterType.ODD.name()); } else if (selectIndex == 4) { - c1.show(selectCountCardPane, "EVEN"); + setCardPaneLayout.show(setCardPane, FilterType.EVEN.name()); + tipCardPaneLayout.show(tipCardPane, FilterType.EVEN.name()); } else if (selectIndex == 5) { - c1.show(selectCountCardPane, "SPECIFY"); + setCardPaneLayout.show(setCardPane, FilterType.SPECIFY.name()); + tipCardPaneLayout.show(tipCardPane, FilterType.SPECIFY.name()); } else { - c1.show(selectCountCardPane, "UNDEFINE"); + setCardPaneLayout.show(setCardPane, FilterType.UNDEFINE.name()); + tipCardPaneLayout.show(tipCardPane, FilterType.UNDEFINE.name()); } } }); - - selectCountCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); - this.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(INSET_TEXT), selectCountComboBox, - new UILabel(INSET_TEXT), selectCountCardPane}, FlowLayout.LEFT), BorderLayout.WEST); -// selectCountCardPane.setLayout(new CardLayout()); - - //not define pane - - JPanel undefinedPane = GUICoreUtils.createFlowPane(new UILabel(Inter.getLocText("Undefined")), FlowLayout.LEFT); - topFormulaPane = new DSColumnAdvancedEditorPane.JFormulaField("-1"); - bottomFormulaPane = new DSColumnAdvancedEditorPane.JFormulaField("-1"); - serialTextField = new UITextField(18); - JPanel oddPane = GUICoreUtils.createFlowPane(new UILabel(Inter.getLocText("BindColumn-Result_Serial_Number_Start_From_1") - + " " + Inter.getLocText("BindColumn-Odd_Selected_(1,3,5...)")), FlowLayout.LEFT); - JPanel evenPane = GUICoreUtils.createFlowPane(new UILabel(Inter.getLocText("BindColumn-Result_Serial_Number_Start_From_1") - + " " + Inter.getLocText("BindColumn-Even_Selected_(2,4,6...)")), FlowLayout.LEFT); - JPanel specifyPane = GUICoreUtils.createFlowPane(new JComponent[]{ - serialTextField, new UILabel( + //配置展示CardLayout + setCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + //提示信息展示CardLayout + tipCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + + //前N个 + topFormulaPane = new DSColumnAdvancedEditorPane.JFormulaField("="); + setCardPane.add(topFormulaPane, FilterType.TOP.name()); + tipCardPane.add(new JPanel(), FilterType.TOP.name()); + + //后N个 + bottomFormulaPane = new DSColumnAdvancedEditorPane.JFormulaField("="); + setCardPane.add(bottomFormulaPane, FilterType.BOTTOM.name()); + tipCardPane.add(new JPanel(), FilterType.BOTTOM.name()); + + //自定义值下方没有提示信息,也没有输入框 + JPanel undefinedPane = new JPanel(); + setCardPane.add(new JPanel(), FilterType.UNDEFINE.name()); + tipCardPane.add(new JPanel(), FilterType.UNDEFINE.name()); + + //奇数 UILabel 占一行作为提示信息 + setCardPane.add(new JPanel(), FilterType.ODD.name()); + tipCardPane.add(new UILabel(Inter.getLocText("BindColumn-Result_Serial_Number_Start_From_1") + + "," + Inter.getLocText("BindColumn-Odd_Selected_(1,3,5...)")), FilterType.ODD.name()); + + + //偶数 UILabel 占一行作为提示信息 + setCardPane.add(new JPanel(), FilterType.EVEN.name()); + tipCardPane.add(new UILabel(Inter.getLocText("BindColumn-Result_Serial_Number_Start_From_1") + + "," + Inter.getLocText("BindColumn-Even_Selected_(2,4,6...)")), FilterType.ODD.name()); + + //输入框占用右半边,提示信息占一行 + serialTextField = new UITextField(16); + setCardPane.add(serialTextField, FilterType.SPECIFY.name()); + tipCardPane.add(new UILabel( Inter.getLocText(new String[]{ "Format", "BindColumn-Result_Serial_Number_Start_From_1", "Inner_Parameter", "Group_Count"}, - new String[]{": 1,2-3,5,8 ", ",", "$__count__"}) - ) - }, FlowLayout.LEFT); - serialTextField.setToolTipText(Inter.getLocText("StyleFormat-Sample") + ":=JOINARRAY(GREPARRAY(RANGE($__count__), item!=4), \",\")"); - selectCountCardPane.add(undefinedPane, "UNDEFINE"); - selectCountCardPane.add(topFormulaPane, "TOP"); - selectCountCardPane.add(bottomFormulaPane, "BOTTOM"); - //odd - selectCountCardPane.add(oddPane, "ODD"); - //even - selectCountCardPane.add(evenPane, "EVEN"); - //specify - selectCountCardPane.add(specifyPane, "SPECIFY"); + new String[]{": 1,2-3,5,8 ", ",", "$__count__"})), FilterType.SPECIFY.name()); + + this.add(TableLayoutHelper.createTableLayoutPane(new Component[][]{ + {filterLabel, rsComboBox}, + {null, setCardPane}, + {tipCardPane, null} + }, new double[]{p, p, p}, new double[]{p, f}), BorderLayout.CENTER); } public void populate(CellElement cellElement) { @@ -316,7 +350,7 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { this.bottomFormulaPane.populateElement(cellElement); if (selectCount != null) { int selectCountType = selectCount.getType(); - this.selectCountComboBox.setSelectedIndex(selectCountType); + this.rsComboBox.setSelectedIndex(selectCountType); if (selectCountType == SelectCount.TOP) { this.topFormulaPane.populate(selectCount.getFormulaCount()); } else if (selectCountType == SelectCount.BOTTOM) { @@ -338,7 +372,7 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { DSColumn dSColumn = (DSColumn) (cellElement.getValue()); //alex:SelectCount - int selectCountSelectIndex = this.selectCountComboBox.getSelectedIndex(); + int selectCountSelectIndex = this.rsComboBox.getSelectedIndex(); if (selectCountSelectIndex == 0) { dSColumn.setSelectCount(null); } else { @@ -381,19 +415,16 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { public JFormulaField(String defaultValue) { this.defaultValue = defaultValue; - this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); - UILabel bottomLabel = new UILabel("="); - bottomLabel.setFont(new Font("Dialog", Font.BOLD, 12)); - this.add(bottomLabel); - formulaTextField = new UITextField(24); + this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + formulaTextField = new UITextField(11); this.add(formulaTextField); formulaTextField.setText(defaultValue); - UIButton bottomFrmulaButton = new UIButton("..."); - this.add(bottomFrmulaButton); - bottomFrmulaButton.setToolTipText(Inter.getLocText("Formula") + "..."); - bottomFrmulaButton.setPreferredSize(new Dimension(25, formulaTextField.getPreferredSize().height)); - bottomFrmulaButton.addActionListener(formulaButtonActionListener); + UIButton formulaButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); + this.add(formulaButton); + formulaButton.setToolTipText(Inter.getLocText("Formula") + "..."); + formulaButton.setPreferredSize(new Dimension(20, formulaTextField.getPreferredSize().height)); + formulaButton.addActionListener(formulaButtonActionListener); } public void populate(String formulaContent) { @@ -453,13 +484,12 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { * * @see DSColumnAdvancedPane.ValuePane */ - private static class ValuePane extends JPanel { + private static class CustomValuePane extends JPanel { private DSColumnAdvancedEditorPane.JFormulaField formulaField; - public ValuePane() { + public CustomValuePane() { this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); - - this.add(new UILabel(INSET_TEXT + Inter.getLocText("Value") + ":")); + UILabel customValueLabel = new UILabel("显示值"); this.add(Box.createHorizontalStrut(2)); this.add((formulaField = new DSColumnAdvancedEditorPane.JFormulaField("$$$"))); } @@ -493,7 +523,6 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { return; } DSColumn dSColumn = (DSColumn) (cellElement.getValue()); - //formula dSColumn.setResult(this.formulaField.getFormulaText()); } diff --git a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java index ef0c5e0b5..b369e66c5 100644 --- a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java +++ b/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java @@ -33,6 +33,7 @@ public class DSColumnBasicEditorPane extends CellEditorPane { this.groupPane = groupPane; this.conditionPane = conditionPane; this.add(this.createContentPane(), BorderLayout.CENTER); + this.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); } diff --git a/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java b/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java index b7cc3b5ae..c2ef1b8a9 100644 --- a/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java +++ b/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java @@ -1,35 +1,31 @@ package com.fr.design.dscolumn; -import java.awt.*; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - -import com.fr.design.gui.ilable.UILabel; -import javax.swing.JPanel; - - import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.FunctionComboBox; +import com.fr.design.gui.icombobox.UIComboBox; +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.mainframe.ElementCasePane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.CellExpandAttr; -import com.fr.report.cell.cellattr.core.group.CustomGrouper; -import com.fr.report.cell.cellattr.core.group.DSColumn; -import com.fr.report.cell.cellattr.core.group.FunctionGrouper; -import com.fr.report.cell.cellattr.core.group.RecordGrouper; -import com.fr.report.cell.cellattr.core.group.SummaryGrouper; +import com.fr.report.cell.cellattr.core.group.*; import com.fr.stable.Constants; -import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; /** * 这个pane是选中数据列后,在上方QuickRegion处显示的pane * - * @author zhou + * @author zhou, yaoh.wu + * @version 2017年8月2日14点55分 + * @since 8.0 */ public class ResultSetGroupDockingPane extends ResultSetGroupPane { private static final int BIND_GROUP = 0; @@ -42,7 +38,7 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { private CardLayout cardLayout; private UIComboBox goBox; - ItemListener l; + private ItemListener listener; public ResultSetGroupDockingPane(ElementCasePane ePane) { super(); @@ -58,15 +54,13 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { } private JPanel layoutPane() { - double vs = 4; - double vg = 6; double p = TableLayout.PREFERRED; double f = TableLayout.FILL; Component[][] components = new Component[][] { new Component[]{new UILabel(Inter.getLocText("Data_Setting")), goBox}, - new Component[]{cardPane, null} + new Component[]{null, cardPane} }; goBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ee) { @@ -86,7 +80,7 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { double[] columnSize = {p, f}; double[] rowSize = {p, p}; - return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } private void initCardPane() { @@ -190,15 +184,15 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { } } - public void addListener(ItemListener l) { - goBox.addItemListener(l); - groupComboBox.addItemListener(l); - functionComboBox.addItemListener(l); - this.l = l; + public void addListener(ItemListener listener) { + goBox.addItemListener(listener); + groupComboBox.addItemListener(listener); + functionComboBox.addItemListener(listener); + this.listener = listener; } void fireTargetChanged() { - l.itemStateChanged(null); + listener.itemStateChanged(null); } @Override diff --git a/designer/src/com/fr/quickeditor/CellQuickEditor.java b/designer/src/com/fr/quickeditor/CellQuickEditor.java index 7ae3dbba3..730a1577d 100644 --- a/designer/src/com/fr/quickeditor/CellQuickEditor.java +++ b/designer/src/com/fr/quickeditor/CellQuickEditor.java @@ -37,18 +37,33 @@ public abstract class CellQuickEditor extends QuickEditor { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] columnSize = {p, f}; - double[] rowSize = {p, p, p}; + double[] rowSize = {p, p}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(" " + Inter.getLocText("Cell")), columnRowTextField = initColumnRowTextField()}, - new Component[]{new UILabel(Inter.getLocText("HF-Insert_Content") + " "), cellElementEditButton = initCellElementEditButton()}, + new Component[]{initTopContent(), null}, new Component[]{createCenterBody(), null} }; JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); this.setLayout(new BorderLayout()); - this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + this.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); this.add(panel, BorderLayout.CENTER); } + + private JPanel initTopContent() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p}; + Component[][] components = new Component[][]{ + new Component[]{new UILabel(" " + Inter.getLocText("Cell")), columnRowTextField = initColumnRowTextField()}, + new Component[]{new UILabel(Inter.getLocText("HF-Insert_Content") + " "), cellElementEditButton = initCellElementEditButton()}, + }; + JPanel topContent = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + topContent.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); + return topContent; + } + + /** * 初始化添加按钮 * TODO 9.0 换成下拉菜单后原来的快捷键不好处理,先跳过。 diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index 321da63fb..3493967af 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -175,7 +175,6 @@ public class CellDSColumnEditor extends CellQuickEditor { */ private void createPanes() { paneList = new ArrayList<>(); - /*基本设置面板*/ this.dataPane = new SelectedDataColumnPane(); this.groupPane = new ResultSetGroupDockingPane(tc); @@ -194,7 +193,6 @@ public class CellDSColumnEditor extends CellQuickEditor { dataPane.addListener(dataListener); groupPane.addListener(groupListener); paneList.add(new DSColumnBasicEditorPane(cellElement, dataPane, groupPane, conditionPane)); - /*高级设置面板*/ paneList.add(new DSColumnAdvancedEditorPane()); } diff --git a/designer_base/src/com/fr/design/layout/FRGUIPaneFactory.java b/designer_base/src/com/fr/design/layout/FRGUIPaneFactory.java index 00fde425f..ef1abd7fb 100644 --- a/designer_base/src/com/fr/design/layout/FRGUIPaneFactory.java +++ b/designer_base/src/com/fr/design/layout/FRGUIPaneFactory.java @@ -1,456 +1,486 @@ package com.fr.design.layout; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Color; -import java.awt.FlowLayout; -import java.awt.LayoutManager; - -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; -import javax.swing.Icon; +import com.fr.design.border.UITitledBorder; import com.fr.design.gui.ilable.UILabel; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import com.fr.design.border.UITitledBorder; +import javax.swing.*; +import java.awt.*; public class FRGUIPaneFactory { - private FRGUIPaneFactory() { - } + public static final float WIDTH_PARA_F = 80.0f; + public static final int WIDTH_OFFSET_N = 60; + public static final int WIDTH_OFFSET_M = 20; + public static final int WIDTH_PARA_INT = 80; + public static final float WIDTHABS_PARA_F = 2.0f; + public static final int HEIGHT_PARA = 25; + public static final int HEIGHT_OFFSET = 50; - public static final float WIDTH_PARA_F = 80.0f; - public static final int WIDTH_OFFSET_N = 60; - public static final int WIDTH_OFFSET_M = 20; - public static final int WIDTH_PARA_INT = 80; - public static final float WIDTHABS_PARA_F = 2.0f; - public static final int HEIGHT_PARA = 25; - public static final int HEIGHT_OFFSET = 50; + private FRGUIPaneFactory() { + } /** * 创建一个靠右靠左的水平间隙为2的流式布局 + * * @return FlowLayout对象 */ - public static LayoutManager createBoxFlowLayout() { // createBoxFlowLayout 图表用到的比较多 - return new FlowLayout(FlowLayout.LEFT, 2, 0); - } + public static LayoutManager createBoxFlowLayout() { // createBoxFlowLayout 图表用到的比较多 + return new FlowLayout(FlowLayout.LEFT, 2, 0); + } - /** - * 创建一个靠左的布局 - * @return FlowLayout对象 - */ - public static LayoutManager createLeftZeroLayout() { - return new FlowLayout(FlowLayout.LEFT, 0, 0); - } + /** + * 创建一个靠左的布局 + * + * @return FlowLayout对象 + */ + public static LayoutManager createLeftZeroLayout() { + return new FlowLayout(FlowLayout.LEFT, 0, 0); + } /** * 创建一个靠左的水平和垂直间隙均为5的流式布局 + * + * @return FlowLayout对象 + */ + public static LayoutManager createLabelFlowLayout() { // createLabelFlowLayout + return new FlowLayout(FlowLayout.LEFT); // 默认 5, 5 + } + + /** + * 创建一个靠左流式布局,间距10,10 + * + * @return FlowLayout对象 + */ + public static LayoutManager createL_FlowLayout() { + return new FlowLayout(FlowLayout.LEFT, 10, 10); + } + + /** + * 创建一个居中流式布局 + * * @return FlowLayout对象 */ - public static LayoutManager createLabelFlowLayout() { // createLabelFlowLayout - return new FlowLayout(FlowLayout.LEFT); // 默认 5, 5 - } - - /** - * 创建一个靠左流式布局,间距10,10 - * @return FlowLayout对象 - */ - public static LayoutManager createL_FlowLayout() { - return new FlowLayout(FlowLayout.LEFT, 10, 10); - } - - /** - * 创建一个居中流式布局 - * @return FlowLayout对象 - */ - public static LayoutManager createCenterFlowLayout() { - return new FlowLayout(FlowLayout.CENTER); - } - - /** - * 创建一个靠右流式布局 - * @return FlowLayout对象 - */ - public static LayoutManager createRightFlowLayout() { - return new FlowLayout(FlowLayout.RIGHT); - } - - /** - * 创建一个边框布局 - * @return BorderLayout对象 - */ - public static LayoutManager createBorderLayout() { - return new BorderLayout(); - } - - /** - * 创建一个边框布局,间距4,4 - * @return BorderLayout对象 - */ - public static LayoutManager createM_BorderLayout() { - return new BorderLayout(4,4); - } - - // TODO 删掉 - - /** - * 创建一个1列的网格布局 - * @return FRGridLayout对象 - */ - public static LayoutManager create1ColumnGridLayout() { - return new FRGridLayout(1); - } - - /** - * 创建一个2列的网格布局 - * @return FRGridLayout对象 - */ - public static LayoutManager create2ColumnGridLayout() { - return new FRGridLayout(2); - } - - /** - * 创建一个n列的网格布局 - * @param nColumn 列数 - * @return FRGridLayout对象 - */ - public static LayoutManager createNColumnGridLayout(int nColumn) { - return new FRGridLayout(nColumn); - } - - /** - * 创建一个带标题边框面板 - * @param string 边框标题 - * @return JPanel对象 - */ - public static JPanel createTitledBorderPane(String string) { - JPanel jp = new JPanel(); - UITitledBorder explainBorder = UITitledBorder.createBorderWithTitle(string); - jp.setBorder(explainBorder); - jp.setLayout(new FlowLayout(FlowLayout.LEFT)); - return jp; - } - - /** - * 创建一个带标题边框面板并且居中显示 - * @param borderTitle 边框标题 - * @return JPanel对象 - */ - public static JPanel createTitledBorderPaneCenter(String borderTitle) { - JPanel jp = new JPanel(); - UITitledBorder explainBorder = UITitledBorder.createBorderWithTitle(borderTitle); - jp.setBorder(explainBorder); - jp.setLayout(new FlowLayout(FlowLayout.CENTER)); - return jp; - } - - /** - * 创建一个靠左空边框布局,间隔大 - * @return JPanel对象 - */ - public static JPanel createBigHGapFlowInnerContainer_M_Pane() { - JPanel jp = new JPanel(); - jp.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); - jp.setLayout(new FRLeftFlowLayout(5, 60, 5)); - return jp; - } - - /** - * 创建一个靠左空边框面板,间隔中等 - * @return JPanel对象 - */ - public static JPanel createMediumHGapFlowInnerContainer_M_Pane() { - JPanel jp = new JPanel(); - jp.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); - jp.setLayout(new FRLeftFlowLayout(5, 20, 5)); - return jp; - } - - /** - * 创建一个靠左空边框面板,间隔中等 - * @return JPanel对象 - */ - public static JPanel createMediumHGapHighTopFlowInnerContainer_M_Pane() { - JPanel jp = new JPanel(); - jp.setBorder(BorderFactory.createEmptyBorder(50, 5, 0, 0)); - jp.setLayout(new FRLeftFlowLayout(5, 20, 5)); - return jp; - } - - /** - * 创建一个正常靠左空边框面板 - * @return JPanel对象 - */ - public static JPanel createNormalFlowInnerContainer_M_Pane() { - JPanel jp = new JPanel(); - jp.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); - jp.setLayout(new FlowLayout(FlowLayout.LEFT)); - return jp; - } - - /** - * 创建一个靠左0间距边框面板 - * @return JPanel对象 - */ - public static JPanel createLeftFlowZeroGapBorderPane() { - JPanel jp = new JPanel(); - jp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - jp.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - return jp; - } - - /** - * 创建一个靠左流式布局,正常流式内嵌 - * @return JPanel对象 - */ - public static JPanel createNormalFlowInnerContainer_S_Pane() { - JPanel jp = new JPanel(); - jp.setLayout(new FlowLayout(FlowLayout.LEFT)); - return jp; - } - - /** - * 创建一个靠左流式布局,流式内嵌 - * @return JPanel对象 - */ - public static JPanel createBoxFlowInnerContainer_S_Pane() { - JPanel jp = new JPanel(); - jp.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 2)); - return jp; - } - - /** - * 创建一个靠右面板 - * @return JPanel对象 - */ - public static JPanel createRightFlowInnerContainer_S_Pane() { - JPanel jp = new JPanel(); - jp.setLayout(new FlowLayout(FlowLayout.RIGHT)); - return jp; - } - - /** - * 创建一个居中面板 - * @return JPanel对象 - */ - public static JPanel createCenterFlowInnerContainer_S_Pane() { - JPanel jp = new JPanel(); - jp.setLayout(new FlowLayout(FlowLayout.CENTER)); - return jp; - } - - /** - * 创建一个居中0间距面板 - * @return JPanel对象 - */ - public static JPanel createCenterFlowZeroGapBorderPane() { - JPanel jp = new JPanel(); - jp.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); - jp.setBorder(BorderFactory.createEmptyBorder()); - return jp; - } - - /** - * 创建纵向排列面板 - * @return JPanel对象 - */ - public static JPanel createY_AXISBoxInnerContainer_L_Pane() { - JPanel jp = new JPanel(); - jp.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); - return jp; - } - - /** - * 创建纵向边框面板 - * @return JPanel对象 - */ - public static JPanel createYBoxEmptyBorderPane() { - JPanel jp = new JPanel(); - jp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); - return jp; - } - - /** - * 创建横向面板 - * @return JPanel对象 - */ - public static JPanel createX_AXISBoxInnerContainer_L_Pane() { - JPanel jp = new JPanel(); - jp.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - jp.setLayout(new BoxLayout(jp, BoxLayout.X_AXIS)); - return jp; - } - - /** - * 创建纵向面板M - * @return JPanel对象 - */ - public static JPanel createY_AXISBoxInnerContainer_M_Pane() { - JPanel jp = new JPanel(); - jp.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); - jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); - return jp; - } - - /** - * 创建横向内置boxlayout的面板 - * @return JPanel对象 - */ - public static JPanel createX_AXISBoxInnerContainer_M_Pane() { - JPanel jp = new JPanel(); - jp.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); - jp.setLayout(new BoxLayout(jp, BoxLayout.X_AXIS)); - return jp; - } - - /** - * 创建纵向内置boxlayout的面板 - * @return JPanel对象 - */ - public static JPanel createY_AXISBoxInnerContainer_S_Pane() { - JPanel jp = new JPanel(); - jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); - return jp; - } - - /** - * 创建横向内置boxlayout的面板 - * @return JPanel对象 - */ - public static JPanel createX_AXISBoxInnerContainer_S_Pane() { - JPanel jp = new JPanel(); - jp.setLayout(new BoxLayout(jp, BoxLayout.X_AXIS)); - return jp; - } - - /** - * 创建n列网格面板 - * @param nColumn 列数 - * @return JPanel对象 - */ - public static JPanel createNColumnGridInnerContainer_S_Pane(int nColumn) { - JPanel jp = new JPanel(); - jp.setLayout(new FRGridLayout(nColumn)); - return jp; - } - - /** - * 创建n列网格面板 - * @param nColumn 列数 - * @param h 水平间距 - * @param v 垂直间距 - * @return JPanel对象 - */ - public static JPanel createNColumnGridInnerContainer_Pane(int nColumn, int h, int v) { - JPanel jp = new JPanel(); - jp.setLayout(new FRGridLayout(nColumn, h, v)); - return jp; - } - - /** - * 创建顶格n列网格面板 - * @param nColumn 列数 - * @return JPanel对象 - */ - public static JPanel createFillColumnPane(int nColumn) { - JPanel jp = new JPanel(); - jp.setLayout(new FRGridLayout(nColumn, 0, 0)); - return jp; - } - - /** - * 创建边框面板L - * @return JPanel对象 - */ - public static JPanel createBorderLayout_L_Pane() { - JPanel jp = new JPanel(); - jp.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - jp.setLayout(FRGUIPaneFactory.createBorderLayout()); - return jp; - } - - /** - * 创建边框面板M - * @return JPanel对象 - */ - public static JPanel createBorderLayout_M_Pane() { - JPanel jp = new JPanel(); - jp.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - jp.setLayout(FRGUIPaneFactory.createM_BorderLayout()); - return jp; - } - - /** - * 创建边框面板S - * @return JPanel对象 - */ - public static JPanel createBorderLayout_S_Pane() { - JPanel jp = new JPanel(); - jp.setLayout(FRGUIPaneFactory.createBorderLayout()); - return jp; - } - - /** - * 创建卡片式布局 - * @return JPanel对象 - */ - public static JPanel createCardLayout_S_Pane() { - JPanel jp = new JPanel(); - jp.setLayout(new CardLayout()); - return jp; - } - - /** - * 创建图标IconRadio面板 - * @param icon 图标 - * @param jradiobtn 按钮 - * @return JPanel对象 - */ - public static JPanel createIconRadio_S_Pane(Icon icon, - JRadioButton jradiobtn) { - jradiobtn.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); - jradiobtn.setBackground(new Color(255, 255, 255)); - JPanel iconRadioPane = new JPanel(); - iconRadioPane.setLayout(new BoxLayout(iconRadioPane, BoxLayout.X_AXIS)); - - iconRadioPane.add(new UILabel(icon)); - iconRadioPane.add(jradiobtn); - - return iconRadioPane; - } - - /** - * 计算宽度 - * @param width 宽度输入值 - * @return w 宽度输出值 - */ - public static int caculateWidth(int width) { - int w = 0; - float m = (width + WIDTH_OFFSET_M) / WIDTH_PARA_F; - float n = (width + WIDTH_OFFSET_N) / WIDTH_PARA_F; - float i = Math.abs((((int) m + (int) (m + 1)) / WIDTHABS_PARA_F) - m); - float j = Math.abs((((int) n + (int) (n + 1)) / WIDTHABS_PARA_F) - n); - float x = i > j ? i : j; - if (x == i) { - w = Math.round(m) * WIDTH_PARA_INT - WIDTH_OFFSET_M; - } else if (x == j) { - w = Math.round(n) * WIDTH_PARA_INT - WIDTH_OFFSET_N; - } - return w; - } - - /** - * 计算高度 - * @param height 高度输入值 - * @return 高度输出值 - */ - public static int caculateHeight(int height) { - int h = 0; - float x = (height + HEIGHT_OFFSET) / HEIGHT_PARA; - h = ((int) x + 1) * HEIGHT_PARA; - return h; - } + public static LayoutManager createCenterFlowLayout() { + return new FlowLayout(FlowLayout.CENTER); + } + + /** + * 创建一个靠右流式布局 + * + * @return FlowLayout对象 + */ + public static LayoutManager createRightFlowLayout() { + return new FlowLayout(FlowLayout.RIGHT); + } + + /** + * 创建一个边框布局 + * + * @return BorderLayout对象 + */ + public static LayoutManager createBorderLayout() { + return new BorderLayout(); + } + + /** + * 创建一个边框布局,间距4,4 + * + * @return BorderLayout对象 + */ + public static LayoutManager createM_BorderLayout() { + return new BorderLayout(4, 4); + } + + + /** + * 创建一个1列的网格布局 + * + * @return FRGridLayout对象 + */ + public static LayoutManager create1ColumnGridLayout() { + return new FRGridLayout(1); + } + + /** + * 创建一个2列的网格布局 + * + * @return FRGridLayout对象 + */ + public static LayoutManager create2ColumnGridLayout() { + return new FRGridLayout(2); + } + + /** + * 创建一个n列的网格布局 + * + * @param nColumn 列数 + * @return FRGridLayout对象 + */ + public static LayoutManager createNColumnGridLayout(int nColumn) { + return new FRGridLayout(nColumn); + } + + /** + * 创建一个带标题边框面板 + * + * @param string 边框标题 + * @return JPanel对象 + */ + public static JPanel createTitledBorderPane(String string) { + JPanel jp = new JPanel(); + UITitledBorder explainBorder = UITitledBorder.createBorderWithTitle(string); + jp.setBorder(explainBorder); + jp.setLayout(new FlowLayout(FlowLayout.LEFT)); + return jp; + } + + /** + * 创建一个带标题边框面板并且居中显示 + * + * @param borderTitle 边框标题 + * @return JPanel对象 + */ + public static JPanel createTitledBorderPaneCenter(String borderTitle) { + JPanel jp = new JPanel(); + UITitledBorder explainBorder = UITitledBorder.createBorderWithTitle(borderTitle); + jp.setBorder(explainBorder); + jp.setLayout(new FlowLayout(FlowLayout.CENTER)); + return jp; + } + + /** + * 创建一个靠左空边框布局,间隔大 + * + * @return JPanel对象 + */ + public static JPanel createBigHGapFlowInnerContainer_M_Pane() { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + jp.setLayout(new FRLeftFlowLayout(5, 60, 5)); + return jp; + } + + /** + * 创建一个靠左空边框面板,间隔中等 + * + * @return JPanel对象 + */ + public static JPanel createMediumHGapFlowInnerContainer_M_Pane() { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + jp.setLayout(new FRLeftFlowLayout(5, 20, 5)); + return jp; + } + + /** + * 创建一个靠左空边框面板,间隔中等 + * + * @return JPanel对象 + */ + public static JPanel createMediumHGapHighTopFlowInnerContainer_M_Pane() { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(50, 5, 0, 0)); + jp.setLayout(new FRLeftFlowLayout(5, 20, 5)); + return jp; + } + + /** + * 创建一个正常靠左空边框面板 + * + * @return JPanel对象 + */ + public static JPanel createNormalFlowInnerContainer_M_Pane() { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + jp.setLayout(new FlowLayout(FlowLayout.LEFT)); + return jp; + } + + /** + * 创建一个靠左0间距边框面板 + * + * @return JPanel对象 + */ + public static JPanel createLeftFlowZeroGapBorderPane() { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + jp.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + return jp; + } + + /** + * 创建一个靠左流式布局,正常流式内嵌 + * + * @return JPanel对象 + */ + public static JPanel createNormalFlowInnerContainer_S_Pane() { + JPanel jp = new JPanel(); + jp.setLayout(new FlowLayout(FlowLayout.LEFT)); + return jp; + } + + /** + * 创建一个靠左流式布局,流式内嵌 + * + * @return JPanel对象 + */ + public static JPanel createBoxFlowInnerContainer_S_Pane() { + JPanel jp = new JPanel(); + jp.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 2)); + return jp; + } + + /** + * 创建一个靠右面板 + * + * @return JPanel对象 + */ + public static JPanel createRightFlowInnerContainer_S_Pane() { + JPanel jp = new JPanel(); + jp.setLayout(new FlowLayout(FlowLayout.RIGHT)); + return jp; + } + + /** + * 创建一个居中面板 + * + * @return JPanel对象 + */ + public static JPanel createCenterFlowInnerContainer_S_Pane() { + JPanel jp = new JPanel(); + jp.setLayout(new FlowLayout(FlowLayout.CENTER)); + return jp; + } + + /** + * 创建一个居中0间距面板 + * + * @return JPanel对象 + */ + public static JPanel createCenterFlowZeroGapBorderPane() { + JPanel jp = new JPanel(); + jp.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); + jp.setBorder(BorderFactory.createEmptyBorder()); + return jp; + } + + /** + * 创建纵向排列面板 + * + * @return JPanel对象 + */ + public static JPanel createY_AXISBoxInnerContainer_L_Pane() { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); + return jp; + } + + /** + * 创建纵向边框面板 + * + * @return JPanel对象 + */ + public static JPanel createYBoxEmptyBorderPane() { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); + return jp; + } + + /** + * 创建横向面板 + * + * @return JPanel对象 + */ + public static JPanel createX_AXISBoxInnerContainer_L_Pane() { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + jp.setLayout(new BoxLayout(jp, BoxLayout.X_AXIS)); + return jp; + } + + /** + * 创建纵向面板M + * + * @return JPanel对象 + */ + public static JPanel createY_AXISBoxInnerContainer_M_Pane() { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); + return jp; + } + + /** + * 创建横向内置boxlayout的面板 + * + * @return JPanel对象 + */ + public static JPanel createX_AXISBoxInnerContainer_M_Pane() { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + jp.setLayout(new BoxLayout(jp, BoxLayout.X_AXIS)); + return jp; + } + + /** + * 创建纵向内置boxlayout的面板 + * + * @return JPanel对象 + */ + public static JPanel createY_AXISBoxInnerContainer_S_Pane() { + JPanel jp = new JPanel(); + jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); + return jp; + } + + /** + * 创建横向内置boxlayout的面板 + * + * @return JPanel对象 + */ + public static JPanel createX_AXISBoxInnerContainer_S_Pane() { + JPanel jp = new JPanel(); + jp.setLayout(new BoxLayout(jp, BoxLayout.X_AXIS)); + return jp; + } + + /** + * 创建n列网格面板 + * + * @param nColumn 列数 + * @return JPanel对象 + */ + public static JPanel createNColumnGridInnerContainer_S_Pane(int nColumn) { + JPanel jp = new JPanel(); + jp.setLayout(new FRGridLayout(nColumn)); + return jp; + } + + /** + * 创建n列网格面板 + * + * @param nColumn 列数 + * @param h 水平间距 + * @param v 垂直间距 + * @return JPanel对象 + */ + public static JPanel createNColumnGridInnerContainer_Pane(int nColumn, int h, int v) { + JPanel jp = new JPanel(); + jp.setLayout(new FRGridLayout(nColumn, h, v)); + return jp; + } + + /** + * 创建顶格n列网格面板 + * + * @param nColumn 列数 + * @return JPanel对象 + */ + public static JPanel createFillColumnPane(int nColumn) { + JPanel jp = new JPanel(); + jp.setLayout(new FRGridLayout(nColumn, 0, 0)); + return jp; + } + + /** + * 创建边框面板L + * + * @return JPanel对象 + */ + public static JPanel createBorderLayout_L_Pane() { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + jp.setLayout(FRGUIPaneFactory.createBorderLayout()); + return jp; + } + + /** + * 创建边框面板M + * + * @return JPanel对象 + */ + public static JPanel createBorderLayout_M_Pane() { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + jp.setLayout(FRGUIPaneFactory.createM_BorderLayout()); + return jp; + } + + /** + * 创建边框面板S + * + * @return JPanel对象 + */ + public static JPanel createBorderLayout_S_Pane() { + JPanel jp = new JPanel(); + jp.setLayout(FRGUIPaneFactory.createBorderLayout()); + return jp; + } + + /** + * 创建卡片式布局 + * + * @return JPanel对象 + */ + public static JPanel createCardLayout_S_Pane() { + JPanel jp = new JPanel(); + jp.setLayout(new CardLayout()); + return jp; + } + + /** + * 创建图标IconRadio面板 + * + * @param icon 图标 + * @param jradiobtn 按钮 + * @return JPanel对象 + */ + public static JPanel createIconRadio_S_Pane(Icon icon, + JRadioButton jradiobtn) { + jradiobtn.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); + jradiobtn.setBackground(new Color(255, 255, 255)); + JPanel iconRadioPane = new JPanel(); + iconRadioPane.setLayout(new BoxLayout(iconRadioPane, BoxLayout.X_AXIS)); + + iconRadioPane.add(new UILabel(icon)); + iconRadioPane.add(jradiobtn); + + return iconRadioPane; + } + + /** + * 计算宽度 + * + * @param width 宽度输入值 + * @return w 宽度输出值 + */ + public static int caculateWidth(int width) { + int w = 0; + float m = (width + WIDTH_OFFSET_M) / WIDTH_PARA_F; + float n = (width + WIDTH_OFFSET_N) / WIDTH_PARA_F; + float i = Math.abs((((int) m + (int) (m + 1)) / WIDTHABS_PARA_F) - m); + float j = Math.abs((((int) n + (int) (n + 1)) / WIDTHABS_PARA_F) - n); + float x = i > j ? i : j; + if (x == i) { + w = Math.round(m) * WIDTH_PARA_INT - WIDTH_OFFSET_M; + } else if (x == j) { + w = Math.round(n) * WIDTH_PARA_INT - WIDTH_OFFSET_N; + } + return w; + } + + /** + * 计算高度 + * + * @param height 高度输入值 + * @return 高度输出值 + */ + public static int caculateHeight(int height) { + int h = 0; + float x = (height + HEIGHT_OFFSET) / HEIGHT_PARA; + h = ((int) x + 1) * HEIGHT_PARA; + return h; + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/utils/DesignUtils.java b/designer_base/src/com/fr/design/utils/DesignUtils.java index 9dc0399d5..664dd9ae0 100644 --- a/designer_base/src/com/fr/design/utils/DesignUtils.java +++ b/designer_base/src/com/fr/design/utils/DesignUtils.java @@ -52,7 +52,8 @@ public class DesignUtils { public static boolean isStarted() { try { new Socket("localhost", port); - return true; +// return true; + return false; } catch (Exception exp) { } From e8df144eaf5ff281c7d0b350b2ae037bead1b1e0 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Thu, 3 Aug 2017 10:50:53 +0800 Subject: [PATCH 3/5] =?UTF-8?q?REPORT-3348=20=E5=A4=8D=E7=94=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=88=97=E5=AF=B9=E8=AF=9D=E6=A1=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=EF=BC=8C=E4=BF=9D=E7=95=99=E5=8E=9F=E5=A7=8B?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=A1=86=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dscolumn/DSColumnAdvancedEditorPane.java | 42 +++++-- .../fr/design/dscolumn/DSColumnBasicPane.java | 117 +++++++++--------- .../SelectedConfirmedDataColumnPane.java | 68 +++++----- .../dscolumn/SelectedDataColumnPane.java | 59 ++++++++- .../cellquick/CellDSColumnEditor.java | 2 +- 5 files changed, 180 insertions(+), 108 deletions(-) diff --git a/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java index 46d8d0a6e..93b63a5d7 100644 --- a/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java +++ b/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java @@ -2,6 +2,7 @@ package com.fr.design.dscolumn; import com.fr.base.Formula; import com.fr.data.TableDataSource; +import com.fr.design.constants.LayoutConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.formula.CustomVariableResolver; @@ -19,6 +20,7 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.cell.CellEditorPane; +import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.report.cell.CellElement; @@ -270,21 +272,26 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { if (selectIndex == 1) { setCardPaneLayout.show(setCardPane, FilterType.TOP.name()); tipCardPaneLayout.show(tipCardPane, FilterType.TOP.name()); + //隐藏tip } else if (selectIndex == 2) { setCardPaneLayout.show(setCardPane, FilterType.BOTTOM.name()); tipCardPaneLayout.show(tipCardPane, FilterType.BOTTOM.name()); + //隐藏tip } else if (selectIndex == 3) { setCardPaneLayout.show(setCardPane, FilterType.ODD.name()); tipCardPaneLayout.show(tipCardPane, FilterType.ODD.name()); + //隐藏set } else if (selectIndex == 4) { setCardPaneLayout.show(setCardPane, FilterType.EVEN.name()); tipCardPaneLayout.show(tipCardPane, FilterType.EVEN.name()); + //隐藏set } else if (selectIndex == 5) { setCardPaneLayout.show(setCardPane, FilterType.SPECIFY.name()); tipCardPaneLayout.show(tipCardPane, FilterType.SPECIFY.name()); } else { setCardPaneLayout.show(setCardPane, FilterType.UNDEFINE.name()); tipCardPaneLayout.show(tipCardPane, FilterType.UNDEFINE.name()); + //隐藏set和tip } } }); @@ -413,18 +420,29 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { private String defaultValue; public JFormulaField(String defaultValue) { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {f}; + double[] rowSize = {p}; this.defaultValue = defaultValue; - - this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - formulaTextField = new UITextField(11); - this.add(formulaTextField); + formulaTextField = new UITextField(); formulaTextField.setText(defaultValue); - UIButton formulaButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); - this.add(formulaButton); formulaButton.setToolTipText(Inter.getLocText("Formula") + "..."); - formulaButton.setPreferredSize(new Dimension(20, formulaTextField.getPreferredSize().height)); + formulaButton.setPreferredSize(new Dimension(24, formulaTextField.getPreferredSize().height)); formulaButton.addActionListener(formulaButtonActionListener); + Component[] buttonComponent = new Component[]{ + formulaButton + }; + JPanel pane = new JPanel(new BorderLayout(0, 0)); + pane.add(formulaTextField, BorderLayout.CENTER); + pane.add(GUICoreUtils.createFlowPane(buttonComponent, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.EAST); + Component[][] components = new Component[][]{ + new Component[]{pane} + }; + JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + this.setLayout(new BorderLayout()); + this.add(panel, BorderLayout.CENTER); } public void populate(String formulaContent) { @@ -485,13 +503,17 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane { * @see DSColumnAdvancedPane.ValuePane */ private static class CustomValuePane extends JPanel { - private DSColumnAdvancedEditorPane.JFormulaField formulaField; + private JFormulaField formulaField; public CustomValuePane() { + double p = TableLayout.PREFERRED, f = TableLayout.FILL; this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); UILabel customValueLabel = new UILabel("显示值"); - this.add(Box.createHorizontalStrut(2)); - this.add((formulaField = new DSColumnAdvancedEditorPane.JFormulaField("$$$"))); + formulaField = new JFormulaField("$$$"); + formulaField.setPreferredSize(new Dimension(159, 20)); + this.add(TableLayoutHelper.createTableLayoutPane(new Component[][]{ + {customValueLabel, formulaField}, + }, new double[]{p}, new double[]{p, f}), BorderLayout.CENTER); } public void populate(CellElement cellElement) { diff --git a/designer/src/com/fr/design/dscolumn/DSColumnBasicPane.java b/designer/src/com/fr/design/dscolumn/DSColumnBasicPane.java index 9ba61e547..07f02a7ef 100644 --- a/designer/src/com/fr/design/dscolumn/DSColumnBasicPane.java +++ b/designer/src/com/fr/design/dscolumn/DSColumnBasicPane.java @@ -1,25 +1,23 @@ package com.fr.design.dscolumn; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; - import com.fr.data.TableDataSource; +import com.fr.design.dialog.BasicPane; import com.fr.design.expand.ConditionParentPane; import com.fr.design.expand.ExpandDirectionPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.dialog.BasicPane; -import com.fr.general.Inter; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; import com.fr.report.cell.CellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.CellExpandAttr; -import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; public class DSColumnBasicPane extends BasicPane { @@ -30,54 +28,54 @@ public class DSColumnBasicPane extends BasicPane { private CellElement cellElement; public DSColumnBasicPane() { - this(DSColumnPane.SETTING_ALL); + this(DSColumnPane.SETTING_ALL); } - + public DSColumnBasicPane(int setting) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); if (setting > DSColumnPane.SETTING_DSRELATED) { - selectDataColumnPane = new SelectedDataColumnPane(); + selectDataColumnPane = new SelectedDataColumnPane(); } else { - selectDataColumnPane = new SelectedConfirmedDataColumnPane(); + selectDataColumnPane = new SelectedConfirmedDataColumnPane(); } - + selectDataColumnPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Select_DataColumn"), null)); if (setting > DSColumnPane.SETTING_DSRELATED) { - conditionParentPane = new ConditionParentPane(); - conditionParentPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("ParentCell_Setting"), null)); + conditionParentPane = new ConditionParentPane(); + conditionParentPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("ParentCell_Setting"), null)); } - + resultSetGroupPane = new ResultSetGroupPopUpPane(setting > DSColumnPane.SETTING_DSRELATED); resultSetGroupPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Data_Setting"), null)); if (setting > DSColumnPane.SETTING_DSRELATED) { - expandDirectionPane = new ExpandDirectionPane(); - expandDirectionPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("ExpandD-Expand_Direction"), null)); + expandDirectionPane = new ExpandDirectionPane(); + expandDirectionPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("ExpandD-Expand_Direction"), null)); } - + double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED, - TableLayout.PREFERRED, TableLayout.PREFERRED}; + TableLayout.PREFERRED, TableLayout.PREFERRED}; double[] columnSize = {TableLayout.FILL}; - + Component[][] components = null; - + if (setting > DSColumnPane.SETTING_DSRELATED) { - components = new Component[][]{ - {selectDataColumnPane}, - {conditionParentPane}, - {resultSetGroupPane}, - {expandDirectionPane} - }; + components = new Component[][]{ + {selectDataColumnPane}, + {conditionParentPane}, + {resultSetGroupPane}, + {expandDirectionPane} + }; } else { - components = new Component[][]{ - {selectDataColumnPane}, - {resultSetGroupPane}, - }; + components = new Component[][]{ + {selectDataColumnPane}, + {resultSetGroupPane}, + }; } - + this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); this.resultSetGroupPane.addListeners(summary_direction_ActionListener, otherGroup_direction_ActionListener, sdcUpdate_ActionListener); @@ -85,24 +83,24 @@ public class DSColumnBasicPane extends BasicPane { @Override protected String title4PopupWindow() { - return Inter.getLocText("Basic"); + return Inter.getLocText("Basic"); } - + public void populate(TableDataSource source, TemplateCellElement cellElement) { if (cellElement == null) { return; } this.cellElement = cellElement; - + selectDataColumnPane.populate(source, cellElement); CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); if (conditionParentPane != null) { - conditionParentPane.populate(cellExpandAttr); + conditionParentPane.populate(cellExpandAttr); } if (expandDirectionPane != null) { - expandDirectionPane.populate(cellExpandAttr); + expandDirectionPane.populate(cellExpandAttr); } resultSetGroupPane.populate(cellElement); @@ -128,27 +126,28 @@ public class DSColumnBasicPane extends BasicPane { } if (conditionParentPane != null) { - conditionParentPane.update(cellExpandAttr); + conditionParentPane.update(cellExpandAttr); } if (expandDirectionPane != null) { - expandDirectionPane.update(cellExpandAttr); + expandDirectionPane.update(cellExpandAttr); } resultSetGroupPane.update(); } + ActionListener summary_direction_ActionListener = new ActionListener() { public void actionPerformed(ActionEvent evt) { - if (expandDirectionPane != null) { - expandDirectionPane.setNoneRadioButtonSelected(true); - } + if (expandDirectionPane != null) { + expandDirectionPane.setNoneRadioButtonSelected(true); + } } }; ActionListener otherGroup_direction_ActionListener = new ActionListener() { public void actionPerformed(ActionEvent evt) { - if (expandDirectionPane != null) { - expandDirectionPane.setNoneRadioButtonSelected(false); - } + if (expandDirectionPane != null) { + expandDirectionPane.setNoneRadioButtonSelected(false); + } } }; ActionListener sdcUpdate_ActionListener = new ActionListener() { @@ -157,14 +156,16 @@ public class DSColumnBasicPane extends BasicPane { selectDataColumnPane.update(cellElement); } }; - public void putElementcase(ElementCasePane t){ - if (conditionParentPane != null) { - conditionParentPane.putElementcase(t); - } - } - public void putCellElement(TemplateCellElement tplEC2) { - if (conditionParentPane != null) { - conditionParentPane.putCellElement(tplEC2); - } - } + + public void putElementcase(ElementCasePane t) { + if (conditionParentPane != null) { + conditionParentPane.putElementcase(t); + } + } + + public void putCellElement(TemplateCellElement tplEC2) { + if (conditionParentPane != null) { + conditionParentPane.putCellElement(tplEC2); + } + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java b/designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java index 282367d27..4852aaa66 100644 --- a/designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java +++ b/designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java @@ -1,45 +1,45 @@ package com.fr.design.dscolumn; -import java.awt.Dimension; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.Iterator; - import com.fr.data.TableDataSource; import com.fr.design.data.datapane.TableDataComboBox; import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; import com.fr.main.impl.WorkBook; import com.fr.report.cell.TemplateCellElement; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.Iterator; + public class SelectedConfirmedDataColumnPane extends SelectedDataColumnPane { - public SelectedConfirmedDataColumnPane () { - super(false); - } - - protected void initTableNameComboBox() { - tableNameComboBox = new TableDataComboBox(new WorkBook()); - tableNameComboBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - columnNameComboBox.setLoaded(false); - } - }); - tableNameComboBox.setPreferredSize(new Dimension(100, 20)); - } - - public void populate(TableDataSource source, TemplateCellElement cell) { - tableNameComboBox.refresh(source); - tableNameComboBox.setEditable(false); - tableNameComboBox.setEnabled(false); - super.populate(source, cell); - try { - Iterator it = source.getTableDataNameIterator(); - String name = (String)it.next(); - TemplateTableDataWrapper wrapper = new TemplateTableDataWrapper(source.getTableData(name), name); - tableNameComboBox.setSelectedItem(wrapper); - tableNameComboBox.getModel().setSelectedItem(wrapper); - } catch (Exception e) { - } - } + public SelectedConfirmedDataColumnPane() { + super(false, false); + } + + protected void initTableNameComboBox() { + tableNameComboBox = new TableDataComboBox(new WorkBook()); + tableNameComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + columnNameComboBox.setLoaded(false); + } + }); + tableNameComboBox.setPreferredSize(new Dimension(100, 20)); + } + + public void populate(TableDataSource source, TemplateCellElement cell) { + tableNameComboBox.refresh(source); + tableNameComboBox.setEditable(false); + tableNameComboBox.setEnabled(false); + super.populate(source, cell); + try { + Iterator it = source.getTableDataNameIterator(); + String name = (String) it.next(); + TemplateTableDataWrapper wrapper = new TemplateTableDataWrapper(source.getTableData(name), name); + tableNameComboBox.setSelectedItem(wrapper); + tableNameComboBox.getModel().setSelectedItem(wrapper); + } catch (Exception e) { + } + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java b/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java index dd583e1ef..55f94fff7 100644 --- a/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java +++ b/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java @@ -39,8 +39,8 @@ import java.util.regex.Pattern; * 数据集列动态参数设置组件 * * @author yaoh.wu - * @version 2017年7月26日 - * 9.0设计器更新,修改动态参数注入按钮部分,使其显示动态参数按钮时能在右侧边栏正常显示 + * @version 2017年8月3日 + * 复用对话框代码,保留对话框原始布局 * @since 8.0 */ public class SelectedDataColumnPane extends BasicPane { @@ -54,11 +54,15 @@ public class SelectedDataColumnPane extends BasicPane { private UIButton paramButton; public SelectedDataColumnPane() { - this(true); + this(true, false); } - SelectedDataColumnPane(boolean showParameterButton) { - initComponent(showParameterButton); + public SelectedDataColumnPane(boolean showParameterButton, boolean verticalLayout) { + if (verticalLayout) { + initComponentVerticalLayout(true); + } else { + initComponent(showParameterButton); + } } /** @@ -67,6 +71,51 @@ public class SelectedDataColumnPane extends BasicPane { * @param showParameterButton 是否显示参数按钮 */ public void initComponent(boolean showParameterButton) { + initTableNameComboBox(); + if (showParameterButton) { + initWithParameterButton(); + } + columnNameComboBox = new LazyComboBox() { + + @Override + public Object[] load() { + List l = calculateColumnNameList(); + return l.toArray(new String[l.size()]); + } + + }; + columnNameComboBox.setEditable(true); + double p = TableLayout.PREFERRED; + UILabel label1 = new UILabel(Inter.getLocText("TableData") + ":"); + UILabel label2 = new UILabel(Inter.getLocText("DataColumn") + ":"); + if (showParameterButton) { + label1.setPreferredSize(new Dimension(200, 25)); + label2.setPreferredSize(new Dimension(200, 25)); + } + if (showParameterButton) { + Component[][] comps = {{label1, null, label2}, {tableNameComboBox, paramButton, columnNameComboBox}}; + this.add(TableLayoutHelper.createTableLayoutPane(comps, new double[]{p, p}, new double[]{p, p, p})); + } else { + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p}; + Component[][] components = new Component[][]{ + new Component[]{label1, tableNameComboBox}, + new Component[]{label2, columnNameComboBox} + }; + JPanel jPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + this.setLayout(new BorderLayout()); + this.add(jPanel, BorderLayout.CENTER); + } + } + + + /** + * 初始化组件 + * + * @param showParameterButton 是否显示参数按钮 + */ + public void initComponentVerticalLayout(boolean showParameterButton) { initTableNameComboBox(); if (showParameterButton) { initWithParameterButton(); diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index 3493967af..8afe3c691 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -176,7 +176,7 @@ public class CellDSColumnEditor extends CellQuickEditor { private void createPanes() { paneList = new ArrayList<>(); /*基本设置面板*/ - this.dataPane = new SelectedDataColumnPane(); + this.dataPane = new SelectedDataColumnPane(true, true); this.groupPane = new ResultSetGroupDockingPane(tc); double p = TableLayout.PREFERRED, f = TableLayout.FILL; double[] rowSize = {p}, columnSize = {p, f}; From 27c213d34cda587681f57ef7adb402340deba68b Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Thu, 3 Aug 2017 16:53:24 +0800 Subject: [PATCH 4/5] =?UTF-8?q?REPORT-3348=20=E9=87=8D=E6=9E=84=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E7=84=B6=E4=B8=8D=E8=83=BD=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../columnrow/DSColumnConditionAction.java | 17 +- .../dscolumn/DSColumnAdvancedEditorPane.java | 553 ------------ .../dscolumn/DSColumnBasicEditorPane.java | 85 -- .../design/mainframe/cell/CellEditorPane.java | 4 +- .../cellquick/CellDSColumnEditor.java | 806 ++++++++++++++++-- 5 files changed, 731 insertions(+), 734 deletions(-) delete mode 100644 designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java delete mode 100644 designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java diff --git a/designer/src/com/fr/design/actions/columnrow/DSColumnConditionAction.java b/designer/src/com/fr/design/actions/columnrow/DSColumnConditionAction.java index 0036b2806..8143409cf 100644 --- a/designer/src/com/fr/design/actions/columnrow/DSColumnConditionAction.java +++ b/designer/src/com/fr/design/actions/columnrow/DSColumnConditionAction.java @@ -1,36 +1,33 @@ package com.fr.design.actions.columnrow; import com.fr.base.BaseUtils; -import com.fr.design.data.DesignTableDataManager; import com.fr.design.actions.cell.AbstractCellElementAction; -import com.fr.design.dscolumn.DSColumnConditionsPane; +import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicPane; -import com.fr.general.Inter; +import com.fr.design.dscolumn.DSColumnConditionsPane; import com.fr.design.mainframe.ElementCasePane; +import com.fr.general.Inter; import com.fr.report.cell.TemplateCellElement; public class DSColumnConditionAction extends AbstractCellElementAction { - private boolean returnValue = false; - private TemplateCellElement editCellElement; - public DSColumnConditionAction(ElementCasePane t) { - super(t); - + super(t); + this.setName(Inter.getLocText("Filter")); this.setMnemonic('E'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/expand/cellAttr.gif")); } @Override - protected BasicPane populateBasicPane(TemplateCellElement cellElement) { + protected BasicPane populateBasicPane(TemplateCellElement cellElement) { DSColumnConditionsPane dSColumnConditionsPane = new DSColumnConditionsPane(); dSColumnConditionsPane.populate(DesignTableDataManager.getEditingTableDataSource(), cellElement); return dSColumnConditionsPane; } @Override - protected void updateBasicPane(BasicPane bp, TemplateCellElement cellElement) { + protected void updateBasicPane(BasicPane bp, TemplateCellElement cellElement) { ((DSColumnConditionsPane) bp).update(cellElement); } } \ No newline at end of file diff --git a/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java deleted file mode 100644 index 93b63a5d7..000000000 --- a/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java +++ /dev/null @@ -1,553 +0,0 @@ -package com.fr.design.dscolumn; - -import com.fr.base.Formula; -import com.fr.data.TableDataSource; -import com.fr.design.constants.LayoutConstants; -import com.fr.design.data.DesignTableDataManager; -import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.formula.CustomVariableResolver; -import com.fr.design.formula.FormulaFactory; -import com.fr.design.formula.TinyFormulaPane; -import com.fr.design.formula.UIFormula; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.ispinner.UISpinner; -import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.cell.CellEditorPane; -import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.IOUtils; -import com.fr.general.Inter; -import com.fr.report.cell.CellElement; -import com.fr.report.cell.TemplateCellElement; -import com.fr.report.cell.cellattr.core.group.DSColumn; -import com.fr.report.cell.cellattr.core.group.SelectCount; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - - -/** - * 单元格元素 数据列 基本设置内容面板 - *

- * 复制了一些{@link DSColumnAdvancedPane}的内部类,不做复用,价值不大,进行修改后直接使用; - *

- * - * @author yaoh.wu - * @version 2017年7月25日 - * @since 9.0 - */ -public class DSColumnAdvancedEditorPane extends CellEditorPane { - - private static final String INSET_TEXT = " "; - - //排列顺序 - private ResultSetSortConfigPane sortPane; - //结果集筛选 - private ResultSetFilterConfigPane filterPane; - //自定义值显示 - private CustomValuePane valuePane; - //横向可扩展性 - private UICheckBox horizontalExtendableCheckBox; - //纵向可扩展性 - private UICheckBox verticalExtendableCheckBox; - //补充空白数据 - private UICheckBox useMultiplyNumCheckBox; - //补充空白数据书目输入框 - private UISpinner multiNumSpinner; - - - public DSColumnAdvancedEditorPane() { - this.setLayout(new BorderLayout()); - this.add(this.createContentPane(), BorderLayout.CENTER); - this.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); - } - - - @Override - public String getIconPath() { - return "Advanced"; - } - - @Override - public String title4PopupWindow() { - return "Advanced"; - } - - - @Override - public void update() { - - } - - @Override - public void populate(TemplateCellElement cellElement) { - - } - - - /** - * 创建内容 - */ - private JPanel createContentPane() { - this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - //结果集排序 - - this.sortPane = new ResultSetSortConfigPane(); - //结果筛选 - - filterPane = new ResultSetFilterConfigPane(); - //自定义值显示 - valuePane = new CustomValuePane(); - //可扩展性 - JPanel extendableDirectionPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - extendableDirectionPane.add(horizontalExtendableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Horizontal_Extendable"))); - extendableDirectionPane.add(verticalExtendableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Vertical_Extendable"))); - - - //补充空白数据 - JPanel multiNumPane = new JPanel(); - - useMultiplyNumCheckBox = new UICheckBox(Inter.getLocText("Column_Multiple")); - multiNumPane.add(useMultiplyNumCheckBox); - multiNumPane.add(new UILabel(INSET_TEXT)); - - multiNumSpinner = new UISpinner(1, 10000, 1, 1); - multiNumPane.add(multiNumSpinner); - - useMultiplyNumCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - checkButtonEnabled(); - } - }); - - double p = TableLayout.PREFERRED, f = TableLayout.FILL; - double[] rowSize = {p, p, p, p, p, p}; - double[] columnSize = {f}; - - Component[][] components = new Component[][]{ - {sortPane}, - {filterPane}, - {valuePane}, - {extendableDirectionPane}, - {multiNumPane} - }; - return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - } - - - private void checkButtonEnabled() { - if (useMultiplyNumCheckBox.isSelected()) { - multiNumSpinner.setEnabled(true); - } else { - multiNumSpinner.setEnabled(false); - } - } - - /** - * 单元格元素>数据集>高级设置>结果排序设置面板 - * - * @see com.fr.design.mainframe.cell.settingpane.CellExpandAttrPane - */ - protected static class ResultSetSortConfigPane extends JPanel { - private UIButtonGroup sort_type_pane; - private TinyFormulaPane tinyFormulaPane; - private CardLayout cardLayout; - private JPanel centerPane; - - - public ResultSetSortConfigPane() { - this.setLayout(new BorderLayout(0, 0)); - Icon[] iconArray = { - IOUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), - IOUtils.readIcon("/com/fr/design/images/expand/asc.png"), - IOUtils.readIcon("/com/fr/design/images/expand/des.png") - }; - String[] nameArray = {Inter.getLocText("Sort-Original"), Inter.getLocText("Sort-Ascending"), Inter.getLocText("Sort-Descending")}; - sort_type_pane = new UIButtonGroup(iconArray); - sort_type_pane.setAllToolTips(nameArray); - sort_type_pane.setGlobalName(Inter.getLocText("ExpandD-Sort_After_Expand")); - - cardLayout = new CardLayout(); - centerPane = new JPanel(cardLayout); - tinyFormulaPane = new TinyFormulaPane(); - centerPane.add(new JPanel(), "none"); - centerPane.add(tinyFormulaPane, "content"); - //todo 国际化 - UILabel sortLabel = new UILabel("排列顺序"); - sort_type_pane.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - boolean noContent = sort_type_pane.getSelectedIndex() == 0; - cardLayout.show(centerPane, noContent ? "none" : "content"); - if (noContent) { - centerPane.setPreferredSize(new Dimension(0, 0)); - } else { - centerPane.setPreferredSize(new Dimension(165, 20)); - } - } - }); - - Component[][] components = new Component[][]{ - new Component[]{sortLabel, sort_type_pane}, - new Component[]{null, centerPane} - }; - double p = TableLayout.PREFERRED, f = TableLayout.FILL; - double[] rowSize = {p, p}, columnSize = {p, f}; - this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); - } - - - /** - * 刷新面板信息 - * - * @param dataSource 数据集对象 - * @param cellElement 单元格 - */ - public void populate(TableDataSource dataSource, TemplateCellElement cellElement) { - //todo - } - - - /** - * 保存面板配置信息 - * - * @param cellElement 单元格 - */ - public void update(CellElement cellElement) { - //todo - } - } - - /** - * 单元格元素>数据集>高级设置>结果集筛选设置面板 - * - * @see DSColumnAdvancedPane.SelectCountPane - */ - protected static class ResultSetFilterConfigPane extends JPanel { - private enum FilterType { - //前N个 后N个 奇数 偶数 自定义 未定义 - TOP, BOTTOM, ODD, EVEN, SPECIFY, UNDEFINE; - } - - CellElement cellElement; - private UIComboBox rsComboBox; - private JPanel setCardPane; - private JPanel tipCardPane; - private UITextField serialTextField; - - DSColumnAdvancedEditorPane.JFormulaField topFormulaPane; - DSColumnAdvancedEditorPane.JFormulaField bottomFormulaPane; - - public ResultSetFilterConfigPane() { - double p = TableLayout.PREFERRED, f = TableLayout.FILL; - - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - UILabel filterLabel = new UILabel("结果集筛选"); - - //结果集筛选下拉框 - rsComboBox = new UIComboBox(new String[]{ - Inter.getLocText("Undefined"), - Inter.getLocText("BindColumn-Top_N"), - Inter.getLocText("BindColumn-Bottom_N"), - Inter.getLocText("Odd"), - Inter.getLocText("Even"), - Inter.getLocText("Specify") - }); - rsComboBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - int selectIndex = rsComboBox.getSelectedIndex(); - CardLayout setCardPaneLayout = (CardLayout) setCardPane.getLayout(); - CardLayout tipCardPaneLayout = (CardLayout) tipCardPane.getLayout(); - if (selectIndex == 1) { - setCardPaneLayout.show(setCardPane, FilterType.TOP.name()); - tipCardPaneLayout.show(tipCardPane, FilterType.TOP.name()); - //隐藏tip - } else if (selectIndex == 2) { - setCardPaneLayout.show(setCardPane, FilterType.BOTTOM.name()); - tipCardPaneLayout.show(tipCardPane, FilterType.BOTTOM.name()); - //隐藏tip - } else if (selectIndex == 3) { - setCardPaneLayout.show(setCardPane, FilterType.ODD.name()); - tipCardPaneLayout.show(tipCardPane, FilterType.ODD.name()); - //隐藏set - } else if (selectIndex == 4) { - setCardPaneLayout.show(setCardPane, FilterType.EVEN.name()); - tipCardPaneLayout.show(tipCardPane, FilterType.EVEN.name()); - //隐藏set - } else if (selectIndex == 5) { - setCardPaneLayout.show(setCardPane, FilterType.SPECIFY.name()); - tipCardPaneLayout.show(tipCardPane, FilterType.SPECIFY.name()); - } else { - setCardPaneLayout.show(setCardPane, FilterType.UNDEFINE.name()); - tipCardPaneLayout.show(tipCardPane, FilterType.UNDEFINE.name()); - //隐藏set和tip - } - } - }); - //配置展示CardLayout - setCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); - //提示信息展示CardLayout - tipCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); - - //前N个 - topFormulaPane = new DSColumnAdvancedEditorPane.JFormulaField("="); - setCardPane.add(topFormulaPane, FilterType.TOP.name()); - tipCardPane.add(new JPanel(), FilterType.TOP.name()); - - //后N个 - bottomFormulaPane = new DSColumnAdvancedEditorPane.JFormulaField("="); - setCardPane.add(bottomFormulaPane, FilterType.BOTTOM.name()); - tipCardPane.add(new JPanel(), FilterType.BOTTOM.name()); - - //自定义值下方没有提示信息,也没有输入框 - JPanel undefinedPane = new JPanel(); - setCardPane.add(new JPanel(), FilterType.UNDEFINE.name()); - tipCardPane.add(new JPanel(), FilterType.UNDEFINE.name()); - - //奇数 UILabel 占一行作为提示信息 - setCardPane.add(new JPanel(), FilterType.ODD.name()); - tipCardPane.add(new UILabel(Inter.getLocText("BindColumn-Result_Serial_Number_Start_From_1") - + "," + Inter.getLocText("BindColumn-Odd_Selected_(1,3,5...)")), FilterType.ODD.name()); - - - //偶数 UILabel 占一行作为提示信息 - setCardPane.add(new JPanel(), FilterType.EVEN.name()); - tipCardPane.add(new UILabel(Inter.getLocText("BindColumn-Result_Serial_Number_Start_From_1") - + "," + Inter.getLocText("BindColumn-Even_Selected_(2,4,6...)")), FilterType.ODD.name()); - - //输入框占用右半边,提示信息占一行 - serialTextField = new UITextField(16); - setCardPane.add(serialTextField, FilterType.SPECIFY.name()); - tipCardPane.add(new UILabel( - Inter.getLocText(new String[]{ - "Format", "BindColumn-Result_Serial_Number_Start_From_1", "Inner_Parameter", "Group_Count"}, - new String[]{": 1,2-3,5,8 ", ",", "$__count__"})), FilterType.SPECIFY.name()); - - this.add(TableLayoutHelper.createTableLayoutPane(new Component[][]{ - {filterLabel, rsComboBox}, - {null, setCardPane}, - {tipCardPane, null} - }, new double[]{p, p, p}, new double[]{p, f}), BorderLayout.CENTER); - } - - public void populate(CellElement cellElement) { - if (cellElement == null) { - return; - } - this.cellElement = cellElement; - - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dSColumn = (DSColumn) (cellElement.getValue()); - SelectCount selectCount = dSColumn.getSelectCount(); - this.topFormulaPane.populateElement(cellElement); - this.bottomFormulaPane.populateElement(cellElement); - if (selectCount != null) { - int selectCountType = selectCount.getType(); - this.rsComboBox.setSelectedIndex(selectCountType); - if (selectCountType == SelectCount.TOP) { - this.topFormulaPane.populate(selectCount.getFormulaCount()); - } else if (selectCountType == SelectCount.BOTTOM) { - this.bottomFormulaPane.populate(selectCount.getFormulaCount()); - } else if (selectCountType == SelectCount.SPECIFY) { - this.serialTextField.setText(selectCount.getSerial()); - } - } - } - - public void update(CellElement cellElement) { - if (cellElement == null) { - return; - } - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dSColumn = (DSColumn) (cellElement.getValue()); - - //alex:SelectCount - int selectCountSelectIndex = this.rsComboBox.getSelectedIndex(); - if (selectCountSelectIndex == 0) { - dSColumn.setSelectCount(null); - } else { - SelectCount selectCount = new SelectCount(); - dSColumn.setSelectCount(selectCount); - selectCount.setType(selectCountSelectIndex); - if (selectCountSelectIndex == SelectCount.TOP) { - selectCount.setFormulaCount(this.topFormulaPane.getFormulaText()); - } else if (selectCountSelectIndex == SelectCount.BOTTOM) { - selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText()); - } else if (selectCountSelectIndex == SelectCount.SPECIFY) { - selectCount.setSerial(this.serialTextField.getText()); - } - } - } - - private JFormattedTextField getTextField(JSpinner spinner) { - JComponent editor = spinner.getEditor(); - if (editor instanceof JSpinner.DefaultEditor) { - return ((JSpinner.DefaultEditor) editor).getTextField(); - } else { - System.err.println("Unexpected editor type: " - + spinner.getEditor().getClass() - + " isn't a descendant of DefaultEditor"); - return null; - } - } - } - - /** - * 单元格元素>数据集>高级设置>公式输入框 - * - * @see DSColumnAdvancedPane.JFormulaField - */ - private static class JFormulaField extends JPanel { - private CellElement cellElement; - private UITextField formulaTextField; - private String defaultValue; - - public JFormulaField(String defaultValue) { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {f}; - double[] rowSize = {p}; - this.defaultValue = defaultValue; - formulaTextField = new UITextField(); - formulaTextField.setText(defaultValue); - UIButton formulaButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); - formulaButton.setToolTipText(Inter.getLocText("Formula") + "..."); - formulaButton.setPreferredSize(new Dimension(24, formulaTextField.getPreferredSize().height)); - formulaButton.addActionListener(formulaButtonActionListener); - Component[] buttonComponent = new Component[]{ - formulaButton - }; - JPanel pane = new JPanel(new BorderLayout(0, 0)); - pane.add(formulaTextField, BorderLayout.CENTER); - pane.add(GUICoreUtils.createFlowPane(buttonComponent, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.EAST); - Component[][] components = new Component[][]{ - new Component[]{pane} - }; - JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - this.setLayout(new BorderLayout()); - this.add(panel, BorderLayout.CENTER); - } - - public void populate(String formulaContent) { - this.formulaTextField.setText(formulaContent); - } - - public void populateElement(CellElement cellElement) { - this.cellElement = cellElement; - } - - public String getFormulaText() { - return this.formulaTextField.getText(); - } - - private ActionListener formulaButtonActionListener = new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - Formula valueFormula = new Formula(); - String text = formulaTextField.getText(); - if (text == null || text.length() <= 0) { - valueFormula.setContent(defaultValue); - } else { - valueFormula.setContent(text); - } - - final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); - - if (cellElement == null) { - return; - } - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dsColumn = (DSColumn) value; - - String[] displayNames = DesignTableDataManager.getSelectedColumnNames(DesignTableDataManager.getEditingTableDataSource(), dsColumn.getDSName()); - - formulaPane.populate(valueFormula, new CustomVariableResolver(displayNames, true)); - formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(DSColumnAdvancedEditorPane.JFormulaField.this), new DialogActionAdapter() { - @Override - public void doOk() { - Formula valueFormula = formulaPane.update(); - if (valueFormula.getContent().length() <= 1) { - formulaTextField.setText(defaultValue); - } else { - formulaTextField.setText(valueFormula.getContent().substring(1)); - } - } - }).setVisible(true); - } - }; - } - - /** - * 单元格元素>数据集>高级设置>自定义值显示设置面板 - * - * @see DSColumnAdvancedPane.ValuePane - */ - private static class CustomValuePane extends JPanel { - private JFormulaField formulaField; - - public CustomValuePane() { - double p = TableLayout.PREFERRED, f = TableLayout.FILL; - this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); - UILabel customValueLabel = new UILabel("显示值"); - formulaField = new JFormulaField("$$$"); - formulaField.setPreferredSize(new Dimension(159, 20)); - this.add(TableLayoutHelper.createTableLayoutPane(new Component[][]{ - {customValueLabel, formulaField}, - }, new double[]{p}, new double[]{p, f}), BorderLayout.CENTER); - } - - public void populate(CellElement cellElement) { - if (cellElement == null) { - return; - } - - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dSColumn = (DSColumn) value; - - //formula - String valueFormula = dSColumn.getResult(); - if (valueFormula == null) { - valueFormula = "$$$"; - } - formulaField.populateElement(cellElement); - formulaField.populate(valueFormula); - } - - public void update(CellElement cellElement) { - if (cellElement == null) { - return; - } - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dSColumn = (DSColumn) (cellElement.getValue()); - //formula - dSColumn.setResult(this.formulaField.getFormulaText()); - } - } - -} diff --git a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java deleted file mode 100644 index b369e66c5..000000000 --- a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.fr.design.dscolumn; - -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.cell.CellEditorPane; -import com.fr.report.cell.TemplateCellElement; - -import javax.swing.*; -import java.awt.*; - -/** - * 单元格元素 数据列 高级设置内容面板 - * - * @author yaoh.wu - * @version 2017年7月25日 - * @since 9.0 - */ -public class DSColumnBasicEditorPane extends CellEditorPane { - - //数据集和数据列 - private SelectedDataColumnPane dataPane; - //数据分组设置 - private ResultSetGroupDockingPane groupPane; - //当前编辑的单元格 - private TemplateCellElement cellElement; - //条件过滤按钮面板 - private JPanel conditionPane; - - public DSColumnBasicEditorPane(TemplateCellElement cellElement, SelectedDataColumnPane dataPane, ResultSetGroupDockingPane groupPane, JPanel conditionPane) { - this.setLayout(new BorderLayout()); - this.cellElement = cellElement; - this.dataPane = dataPane; - this.groupPane = groupPane; - this.conditionPane = conditionPane; - this.add(this.createContentPane(), BorderLayout.CENTER); - this.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); - } - - - @Override - public String getIconPath() { - return "Basic"; - } - - @Override - public String title4PopupWindow() { - return "Basic"; - } - - - @Override - public void update() { - dataPane.update(this.cellElement); - groupPane.update(); - } - - @Override - public void populate(TemplateCellElement cellElement) { - this.cellElement = cellElement; - dataPane.populate(null, cellElement); - groupPane.populate(cellElement); - } - - - /** - * 创建有内容的面板显示信息 - * - * @return content JPanel - */ - private JPanel createContentPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {f}; - double[] rowSize = {p, p, p}; - Component[][] components = new Component[][]{ - //数据集列选择 - new Component[]{this.dataPane}, - //数据分组设置 - new Component[]{this.groupPane}, - //条件过滤 - new Component[]{this.conditionPane} - }; - return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - } -} diff --git a/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java b/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java index b0f09af43..48b6d8a17 100644 --- a/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java +++ b/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java @@ -1,7 +1,6 @@ package com.fr.design.mainframe.cell; import com.fr.design.dialog.BasicPane; -import com.fr.report.cell.TemplateCellElement; /** * 右侧单元格元素面板抽象类 @@ -24,7 +23,6 @@ public abstract class CellEditorPane extends BasicPane { /** * 更新面板数据 * - * @param cellElement 单元格 */ - public abstract void populate(TemplateCellElement cellElement); + public abstract void populate(); } diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index 8afe3c691..1e1e9a578 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -1,21 +1,45 @@ package com.fr.quickeditor.cellquick; +import com.fr.base.Formula; import com.fr.design.actions.columnrow.DSColumnConditionAction; -import com.fr.design.dscolumn.DSColumnAdvancedEditorPane; -import com.fr.design.dscolumn.DSColumnBasicEditorPane; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dscolumn.DSColumnAdvancedPane; import com.fr.design.dscolumn.ResultSetGroupDockingPane; import com.fr.design.dscolumn.SelectedDataColumnPane; +import com.fr.design.formula.CustomVariableResolver; +import com.fr.design.formula.FormulaFactory; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.formula.UIFormula; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIHeadGroup; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.cell.CellEditorPane; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.IOUtils; +import com.fr.general.Inter; import com.fr.quickeditor.CellQuickEditor; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.CellExpandAttr; +import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.report.cell.cellattr.core.group.SelectCount; import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; @@ -29,75 +53,30 @@ import java.util.ArrayList; */ public class CellDSColumnEditor extends CellQuickEditor { + private static double P = TableLayout.PREFERRED, F = TableLayout.FILL; + + private enum FilterType { + //前N个 后N个 奇数 偶数 自定义 未定义 + TOP, BOTTOM, ODD, EVEN, SPECIFY, UNDEFINE + } + private JPanel dsColumnRegion; private JPanel centerPane; - //数据集列选择组件 - private SelectedDataColumnPane dataPane; - //数据分组设置组件 - private ResultSetGroupDockingPane groupPane; - //过滤条件面板 - private JPanel conditionPane; + // 基本和高级设置 private ArrayList paneList; // 基本和高级设置 卡片布局 private CardLayout card; // 基本和高级设置 容器面板 - private JPanel center; + private JPanel cardContainer; // 卡片布局TAB切换按钮 private UIHeadGroup tabsHeaderIconPane; - // 分组设置监听器 - private ItemListener groupListener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e == null) { - //分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存 - groupPane.update(); - fireTargetModified(); - return; - } - if (e.getStateChange() == ItemEvent.DESELECTED) { - if (!isEditing) { - return; - } - groupPane.update(); - fireTargetModified(); - } - } - }; - //数据集列设置监听器 - private ItemListener dataListener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - if (!isEditing) { - return; - } - dataPane.update(cellElement); - fireTargetModified(); - } - } - }; + private CellDSColumnEditor() { super(); } - /** - * Test Main - * - * @param args 参数 - */ - public static void main(String[] args) { - JFrame jf = new JFrame("test"); - jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - JPanel content = (JPanel) jf.getContentPane(); - content.setLayout(new BorderLayout()); - content.add(new CellDSColumnEditor(), BorderLayout.CENTER); - GUICoreUtils.centerWindow(jf); - jf.setSize(220, 400); - jf.setVisible(true); - } - /** * 创建面板占位 * @@ -109,7 +88,7 @@ public class CellDSColumnEditor extends CellQuickEditor { this.createSwitchTab(); dsColumnRegion = new JPanel(new BorderLayout()); dsColumnRegion.add(tabsHeaderIconPane, BorderLayout.NORTH); - dsColumnRegion.add(center, BorderLayout.CENTER); + dsColumnRegion.add(cardContainer, BorderLayout.CENTER); centerPane = new JPanel(new BorderLayout()); centerPane.add(dsColumnRegion, BorderLayout.CENTER); return centerPane; @@ -121,17 +100,16 @@ public class CellDSColumnEditor extends CellQuickEditor { */ @Override protected void refreshDetails() { - this.createPanes(); this.createSwitchTab(); dsColumnRegion = new JPanel(new BorderLayout()); dsColumnRegion.add(tabsHeaderIconPane, BorderLayout.NORTH); - dsColumnRegion.add(center, BorderLayout.CENTER); + dsColumnRegion.add(cardContainer, BorderLayout.CENTER); //必须removeAll之后再添加;重新再实例化一个centerJPanel,因为对象变了会显示不出来 centerPane.removeAll(); centerPane.add(dsColumnRegion, BorderLayout.CENTER); for (CellEditorPane cellEditorPane : paneList) { - cellEditorPane.populate(cellElement); + cellEditorPane.populate(); } this.validate(); } @@ -153,18 +131,18 @@ public class CellDSColumnEditor extends CellQuickEditor { private void createSwitchTab() { String[] iconArray = new String[paneList.size()]; card = new CardLayout(); - center = new JPanel(card); - center.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + cardContainer = new JPanel(card); + cardContainer.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); for (int i = 0; i < paneList.size(); i++) { CellEditorPane pane = paneList.get(i); iconArray[i] = pane.getIconPath(); - center.add(pane, pane.title4PopupWindow()); + cardContainer.add(pane, pane.title4PopupWindow()); } tabsHeaderIconPane = new UIHeadGroup(iconArray) { @Override public void tabChanged(int index) { - card.show(center, paneList.get(index).title4PopupWindow()); - paneList.get(index).populate(cellElement); + card.show(cardContainer, paneList.get(index).title4PopupWindow()); + paneList.get(index).populate(); } }; tabsHeaderIconPane.setNeedLeftRightOutLine(false); @@ -176,24 +154,686 @@ public class CellDSColumnEditor extends CellQuickEditor { private void createPanes() { paneList = new ArrayList<>(); /*基本设置面板*/ - this.dataPane = new SelectedDataColumnPane(true, true); - this.groupPane = new ResultSetGroupDockingPane(tc); - double p = TableLayout.PREFERRED, f = TableLayout.FILL; - double[] rowSize = {p}, columnSize = {p, f}; - UILabel uiLabel = new UILabel("filter"); - UIButton uiButton = new UIButton(); - if (tc != null) { - //第一次初始化时tc为空,引发NullPointerException - uiButton = new UIButton(new DSColumnConditionAction(tc)); - } - Component[][] components = new Component[][]{ - new Component[]{uiLabel, uiButton} - }; - this.conditionPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - dataPane.addListener(dataListener); - groupPane.addListener(groupListener); - paneList.add(new DSColumnBasicEditorPane(cellElement, dataPane, groupPane, conditionPane)); + paneList.add(new DSColumnBasicEditorPane()); /*高级设置面板*/ paneList.add(new DSColumnAdvancedEditorPane()); } + + /** + * 单元格元素 数据列 高级设置内容面板 + * + * @author yaoh.wu + * @version 2017年7月25日 + * @since 9.0 + */ + class DSColumnBasicEditorPane extends CellEditorPane { + + //数据集和数据列 + private SelectedDataColumnPane dataPane; + //数据分组设置 + private ResultSetGroupDockingPane groupPane; + //条件过滤按钮面板 + private JPanel conditionPane; + + // 分组设置监听器 + private ItemListener groupListener = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e == null) { + //分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存 + groupPane.update(); + fireTargetModified(); + return; + } + if (e.getStateChange() == ItemEvent.DESELECTED) { + groupPane.update(); + fireTargetModified(); + } + } + }; + //数据集列设置监听器 + private ItemListener dataListener = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + dataPane.update(cellElement); + fireTargetModified(); + } + } + }; + + DSColumnBasicEditorPane() { + this.setLayout(new BorderLayout()); + dataPane = new SelectedDataColumnPane(true, true); + groupPane = new ResultSetGroupDockingPane(tc); + dataPane.addListener(dataListener); + groupPane.addListener(groupListener); + + double[] rowSize = {P}, columnSize = {P, F}; + UILabel uiLabel = new UILabel("filter"); + UIButton uiButton = new UIButton(); + if (tc != null) { + //第一次初始化时tc为空,引发NullPointerException + uiButton = new UIButton(new DSColumnConditionAction(tc)); + } + Component[][] components = new Component[][]{ + new Component[]{uiLabel, uiButton} + }; + conditionPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + + this.add(this.createContentPane(), BorderLayout.CENTER); + this.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); + } + + + @Override + public String getIconPath() { + return "Basic"; + } + + @Override + public String title4PopupWindow() { + return "Basic"; + } + + + @Override + public void update() { + dataPane.update(cellElement); + groupPane.update(); + } + + @Override + public void populate() { + dataPane.populate(null, cellElement); + groupPane.populate(cellElement); + } + + + /** + * 创建有内容的面板显示信息 + * + * @return content JPanel + */ + private JPanel createContentPane() { + + double[] columnSize = {F}; + double[] rowSize = {P, P, P}; + Component[][] components = new Component[][]{ + //数据集列选择 + new Component[]{this.dataPane}, + //数据分组设置 + new Component[]{this.groupPane}, + //条件过滤 + new Component[]{this.conditionPane} + }; + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + } + } + + + class DSColumnAdvancedEditorPane extends CellEditorPane { + + private static final String INSET_TEXT = " "; + + //排列顺序 + private ResultSetSortConfigPane sortPane; + //结果集筛选 + private ResultSetFilterConfigPane filterPane; + //自定义值显示 + private CustomValuePane valuePane; + //横向可扩展性 + private UICheckBox horizontalExtendableCheckBox; + //纵向可扩展性 + private UICheckBox verticalExtendableCheckBox; + //补充空白数据 + private UICheckBox useMultiplyNumCheckBox; + //补充空白数据书目输入框 + private UISpinner multiNumSpinner; + + + public DSColumnAdvancedEditorPane() { + this.setLayout(new BorderLayout()); + this.add(this.createContentPane(), BorderLayout.CENTER); + this.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); + } + + + @Override + public String getIconPath() { + return "Advanced"; + } + + @Override + public String title4PopupWindow() { + return "Advanced"; + } + + + @Override + public void update() { + if (cellElement != null) { + sortPane.update(cellElement); + valuePane.update(cellElement); + filterPane.update(cellElement); + CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); + if (cellExpandAttr == null) { + cellExpandAttr = new CellExpandAttr(); + cellElement.setCellExpandAttr(cellExpandAttr); + } + if (horizontalExtendableCheckBox.isSelected()) { + if (verticalExtendableCheckBox.isSelected()) { + cellExpandAttr.setExtendable(CellExpandAttr.Both_EXTENDABLE); + } else { + cellExpandAttr.setExtendable(CellExpandAttr.Horizontal_EXTENDABLE); + } + } else { + if (verticalExtendableCheckBox.isSelected()) { + cellExpandAttr.setExtendable(CellExpandAttr.Vertical_EXTENDABLE); + } else { + cellExpandAttr.setExtendable(CellExpandAttr.None_EXTENDABLE); + } + } + if (this.useMultiplyNumCheckBox.isSelected()) { + cellExpandAttr.setMultipleNumber((int) multiNumSpinner.getValue()); + } else { + cellExpandAttr.setMultipleNumber(-1); + } + } + } + + @Override + public void populate() { + if (cellElement != null) { + sortPane.populate(cellElement); + valuePane.populate(cellElement); + filterPane.populate(cellElement); + CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); + if (cellExpandAttr == null) { + cellExpandAttr = new CellExpandAttr(); + cellElement.setCellExpandAttr(cellExpandAttr); + } + // extendable + switch (cellExpandAttr.getExtendable()) { + case CellExpandAttr.Both_EXTENDABLE: + horizontalExtendableCheckBox.setSelected(true); + verticalExtendableCheckBox.setSelected(true); + break; + case CellExpandAttr.Vertical_EXTENDABLE: + horizontalExtendableCheckBox.setSelected(false); + verticalExtendableCheckBox.setSelected(true); + break; + case CellExpandAttr.Horizontal_EXTENDABLE: + horizontalExtendableCheckBox.setSelected(true); + verticalExtendableCheckBox.setSelected(false); + break; + default: { + horizontalExtendableCheckBox.setSelected(false); + verticalExtendableCheckBox.setSelected(false); + } + } + if (cellExpandAttr.getMultipleNumber() == -1) { + useMultiplyNumCheckBox.setSelected(false); + } else { + useMultiplyNumCheckBox.setSelected(true); + multiNumSpinner.setValue(cellExpandAttr.getMultipleNumber()); + } + this.checkButtonEnabled(); + } + } + + /** + * 创建内容 + */ + + private JPanel createContentPane() { + this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + //结果集排序 + + sortPane = new ResultSetSortConfigPane(); + //结果筛选 + + filterPane = new ResultSetFilterConfigPane(); + //自定义值显示 + valuePane = new CustomValuePane(); + //可扩展性 + JPanel extendableDirectionPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + extendableDirectionPane.add(horizontalExtendableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Horizontal_Extendable"))); + extendableDirectionPane.add(verticalExtendableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Vertical_Extendable"))); + + + //补充空白数据 + JPanel multiNumPane = new JPanel(); + + useMultiplyNumCheckBox = new UICheckBox(Inter.getLocText("Column_Multiple")); + multiNumPane.add(useMultiplyNumCheckBox); + multiNumPane.add(new UILabel(INSET_TEXT)); + + multiNumSpinner = new UISpinner(1, 10000, 1, 1); + multiNumPane.add(multiNumSpinner); + + useMultiplyNumCheckBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + checkButtonEnabled(); + } + }); + + + double[] rowSize = {P, P, P, P, P, P}; + double[] columnSize = {F}; + + Component[][] components = new Component[][]{ + {sortPane}, + {filterPane}, + {valuePane}, + {extendableDirectionPane}, + {multiNumPane} + }; + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + } + + + private void checkButtonEnabled() { + if (useMultiplyNumCheckBox.isSelected()) { + multiNumSpinner.setEnabled(true); + } else { + multiNumSpinner.setEnabled(false); + } + } + + /** + * 单元格元素>数据集>高级设置>结果排序设置面板 + * + * @see com.fr.design.expand.SortExpandAttrPane + * @see DSColumnAdvancedPane.SortPane + */ + protected class ResultSetSortConfigPane extends JPanel { + //单元格 + private CellElement cellElement; + //面板 + private UIButtonGroup sort_type_pane; + private TinyFormulaPane tinyFormulaPane; + private CardLayout cardLayout; + private JPanel centerPane; + + + public ResultSetSortConfigPane() { + this.setLayout(new BorderLayout(0, 0)); + Icon[] iconArray = { + IOUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), + IOUtils.readIcon("/com/fr/design/images/expand/asc.png"), + IOUtils.readIcon("/com/fr/design/images/expand/des.png") + }; + String[] nameArray = {Inter.getLocText("Sort-Original"), Inter.getLocText("Sort-Ascending"), Inter.getLocText("Sort-Descending")}; + sort_type_pane = new UIButtonGroup(iconArray); + sort_type_pane.setAllToolTips(nameArray); + sort_type_pane.setGlobalName(Inter.getLocText("ExpandD-Sort_After_Expand")); + + cardLayout = new CardLayout(); + centerPane = new JPanel(cardLayout); + tinyFormulaPane = new TinyFormulaPane(); + centerPane.add(new JPanel(), "none"); + centerPane.add(tinyFormulaPane, "content"); + //todo 国际化 + UILabel sortLabel = new UILabel("排列顺序"); + sort_type_pane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + boolean noContent = sort_type_pane.getSelectedIndex() == 0; + cardLayout.show(centerPane, noContent ? "none" : "content"); + if (noContent) { + centerPane.setPreferredSize(new Dimension(0, 0)); + } else { + centerPane.setPreferredSize(new Dimension(165, 20)); + } + } + }); + + Component[][] components = new Component[][]{ + new Component[]{sortLabel, sort_type_pane}, + new Component[]{null, centerPane} + }; + + double[] rowSize = {P, P}, columnSize = {P, F}; + this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); + } + + + /** + * 刷新面板信息 + * + * @param cellElement 单元格 + */ + public void populate(TemplateCellElement cellElement) { + if (cellElement != null) { + this.cellElement = cellElement; + Object value = cellElement.getValue(); + if (value != null && value instanceof DSColumn) { + DSColumn dSColumn = (DSColumn) value; + int sort = dSColumn.getOrder(); + this.sort_type_pane.setSelectedIndex(sort); + boolean noContent = sort_type_pane.getSelectedIndex() == 0; + cardLayout.show(centerPane, noContent ? "none" : "content"); + if (noContent) { + centerPane.setPreferredSize(new Dimension(0, 0)); + } else { + centerPane.setPreferredSize(new Dimension(165, 20)); + } + String sortFormula = dSColumn.getSortFormula(); + if (sortFormula != null && sortFormula.length() >= 1) { + this.tinyFormulaPane.populateBean(sortFormula); + } + } + } + } + + /** + * 保存面板配置信息 + * + * @param cellElement 单元格 + */ + public void update(CellElement cellElement) { + if (cellElement != null) { + Object value = cellElement.getValue(); + if (value != null && value instanceof DSColumn) { + DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + dSColumn.setOrder(this.sort_type_pane.getSelectedIndex()); + dSColumn.setSortFormula(this.tinyFormulaPane.updateBean()); + } + } + } + } + + /** + * 单元格元素>数据集>高级设置>结果集筛选设置面板 + * + * @see DSColumnAdvancedPane.SelectCountPane + */ + protected class ResultSetFilterConfigPane extends JPanel { + + private CellElement cellElement; + private UIComboBox rsComboBox; + private JPanel setCardPane; + private JPanel tipCardPane; + private UITextField serialTextField; + private JFormulaField topFormulaPane; + private JFormulaField bottomFormulaPane; + + public ResultSetFilterConfigPane() { + + + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + UILabel filterLabel = new UILabel("结果集筛选"); + + //结果集筛选下拉框 + rsComboBox = new UIComboBox(new String[]{ + Inter.getLocText("Undefined"), + Inter.getLocText("BindColumn-Top_N"), + Inter.getLocText("BindColumn-Bottom_N"), + Inter.getLocText("Odd"), + Inter.getLocText("Even"), + Inter.getLocText("Specify") + }); + rsComboBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + int selectIndex = rsComboBox.getSelectedIndex(); + CardLayout setCardPaneLayout = (CardLayout) setCardPane.getLayout(); + CardLayout tipCardPaneLayout = (CardLayout) tipCardPane.getLayout(); + if (selectIndex == 1) { + setCardPaneLayout.show(setCardPane, FilterType.TOP.name()); + tipCardPaneLayout.show(tipCardPane, FilterType.TOP.name()); + //隐藏tip + } else if (selectIndex == 2) { + setCardPaneLayout.show(setCardPane, FilterType.BOTTOM.name()); + tipCardPaneLayout.show(tipCardPane, FilterType.BOTTOM.name()); + //隐藏tip + } else if (selectIndex == 3) { + setCardPaneLayout.show(setCardPane, FilterType.ODD.name()); + tipCardPaneLayout.show(tipCardPane, FilterType.ODD.name()); + //隐藏set + } else if (selectIndex == 4) { + setCardPaneLayout.show(setCardPane, FilterType.EVEN.name()); + tipCardPaneLayout.show(tipCardPane, FilterType.EVEN.name()); + //隐藏set + } else if (selectIndex == 5) { + setCardPaneLayout.show(setCardPane, FilterType.SPECIFY.name()); + tipCardPaneLayout.show(tipCardPane, FilterType.SPECIFY.name()); + } else { + setCardPaneLayout.show(setCardPane, FilterType.UNDEFINE.name()); + tipCardPaneLayout.show(tipCardPane, FilterType.UNDEFINE.name()); + //隐藏set和tip + } + } + }); + //配置展示CardLayout + setCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + //提示信息展示CardLayout + tipCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + + //前N个 + topFormulaPane = new DSColumnAdvancedEditorPane.JFormulaField("="); + setCardPane.add(topFormulaPane, FilterType.TOP.name()); + tipCardPane.add(new JPanel(), FilterType.TOP.name()); + + //后N个 + bottomFormulaPane = new DSColumnAdvancedEditorPane.JFormulaField("="); + setCardPane.add(bottomFormulaPane, FilterType.BOTTOM.name()); + tipCardPane.add(new JPanel(), FilterType.BOTTOM.name()); + + //自定义值下方没有提示信息,也没有输入框 + setCardPane.add(new JPanel(), FilterType.UNDEFINE.name()); + tipCardPane.add(new JPanel(), FilterType.UNDEFINE.name()); + + //奇数 UILabel 占一行作为提示信息 + setCardPane.add(new JPanel(), FilterType.ODD.name()); + tipCardPane.add(new UILabel(Inter.getLocText("BindColumn-Result_Serial_Number_Start_From_1") + + "," + Inter.getLocText("BindColumn-Odd_Selected_(1,3,5...)")), "ODD"); + + + //偶数 UILabel 占一行作为提示信息 + setCardPane.add(new JPanel(), FilterType.EVEN.name()); + tipCardPane.add(new UILabel(Inter.getLocText("BindColumn-Result_Serial_Number_Start_From_1") + + "," + Inter.getLocText("BindColumn-Even_Selected_(2,4,6...)")), "ODD"); + + //输入框占用右半边,提示信息占一行 + serialTextField = new UITextField(16); + setCardPane.add(serialTextField, FilterType.SPECIFY.name()); + tipCardPane.add(new UILabel( + Inter.getLocText(new String[]{ + "Format", "BindColumn-Result_Serial_Number_Start_From_1", "Inner_Parameter", "Group_Count"}, + new String[]{": 1,2-3,5,8 ", ",", "$__count__"})), "SPECIFY"); + + this.add(TableLayoutHelper.createTableLayoutPane(new Component[][]{ + {filterLabel, rsComboBox}, + {null, setCardPane}, + {tipCardPane, null} + }, new double[]{P, P, P}, new double[]{P, F}), BorderLayout.CENTER); + } + + public void populate(CellElement cellElement) { + if (cellElement != null) { + this.cellElement = cellElement; + Object value = cellElement.getValue(); + if (value != null && value instanceof DSColumn) { + DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + SelectCount selectCount = dSColumn.getSelectCount(); + this.topFormulaPane.populateElement(cellElement); + this.bottomFormulaPane.populateElement(cellElement); + if (selectCount != null) { + int selectCountType = selectCount.getType(); + this.rsComboBox.setSelectedIndex(selectCountType); + switch (selectCountType) { + case SelectCount.TOP: + this.topFormulaPane.populate(selectCount.getFormulaCount()); + break; + case SelectCount.BOTTOM: + this.bottomFormulaPane.populate(selectCount.getFormulaCount()); + break; + case SelectCount.SPECIFY: + this.serialTextField.setText(selectCount.getSerial()); + break; + case SelectCount.EVEN: + break; + case SelectCount.ODD: + break; + default: + } + } + } + } + } + + public void update(CellElement cellElement) { + if (cellElement != null) { + Object value = cellElement.getValue(); + if (value != null && value instanceof DSColumn) { + DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + int selectedFilterIndex = this.rsComboBox.getSelectedIndex(); + if (selectedFilterIndex == 0) { + dSColumn.setSelectCount(null); + } else { + SelectCount selectCount = new SelectCount(); + selectCount.setType(selectedFilterIndex); + dSColumn.setSelectCount(selectCount); + if (selectedFilterIndex == SelectCount.TOP) { + selectCount.setFormulaCount(this.topFormulaPane.getFormulaText()); + } else if (selectedFilterIndex == SelectCount.BOTTOM) { + selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText()); + } else if (selectedFilterIndex == SelectCount.SPECIFY) { + selectCount.setSerial(this.serialTextField.getText()); + } + } + } + } + } + } + + /** + * 单元格元素>数据集>高级设置>公式输入框 + * + * @see DSColumnAdvancedPane.JFormulaField + */ + private class JFormulaField extends JPanel { + private CellElement cellElement; + private UITextField formulaTextField; + private String defaultValue; + + public JFormulaField(String defaultValue) { + + double[] columnSize = {F}; + double[] rowSize = {P}; + this.defaultValue = defaultValue; + formulaTextField = new UITextField(); + formulaTextField.setText(defaultValue); + UIButton formulaButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); + formulaButton.setToolTipText(Inter.getLocText("Formula") + "..."); + formulaButton.setPreferredSize(new Dimension(24, formulaTextField.getPreferredSize().height)); + formulaButton.addActionListener(formulaButtonActionListener); + Component[] buttonComponent = new Component[]{ + formulaButton + }; + JPanel pane = new JPanel(new BorderLayout(0, 0)); + pane.add(formulaTextField, BorderLayout.CENTER); + pane.add(GUICoreUtils.createFlowPane(buttonComponent, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.EAST); + Component[][] components = new Component[][]{ + new Component[]{pane} + }; + JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + this.setLayout(new BorderLayout()); + this.add(panel, BorderLayout.CENTER); + } + + public void populate(String formulaContent) { + this.formulaTextField.setText(formulaContent); + } + + public void populateElement(CellElement cellElement) { + this.cellElement = cellElement; + } + + public String getFormulaText() { + return this.formulaTextField.getText(); + } + + private ActionListener formulaButtonActionListener = new ActionListener() { + public void actionPerformed(ActionEvent evt) { + Formula valueFormula = new Formula(); + String text = formulaTextField.getText(); + if (text == null || text.length() <= 0) { + valueFormula.setContent(defaultValue); + } else { + valueFormula.setContent(text); + } + final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); + if (cellElement != null) { + Object value = cellElement.getValue(); + if (value != null && value instanceof DSColumn) { + DSColumn dsColumn = (DSColumn) value; + String[] displayNames = DesignTableDataManager.getSelectedColumnNames(DesignTableDataManager.getEditingTableDataSource(), dsColumn.getDSName()); + formulaPane.populate(valueFormula, new CustomVariableResolver(displayNames, true)); + formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(DSColumnAdvancedEditorPane.JFormulaField.this), new DialogActionAdapter() { + @Override + public void doOk() { + Formula valueFormula = formulaPane.update(); + if (valueFormula.getContent().length() <= 1) { + formulaTextField.setText(defaultValue); + } else { + formulaTextField.setText(valueFormula.getContent().substring(1)); + } + } + }).setVisible(true); + } + } + } + }; + } + + /** + * 单元格元素>数据集>高级设置>自定义值显示设置面板 + * + * @see DSColumnAdvancedPane.ValuePane + */ + private class CustomValuePane extends JPanel { + private JFormulaField formulaField; + + public CustomValuePane() { + + this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); + UILabel customValueLabel = new UILabel("显示值"); + formulaField = new JFormulaField("$$$"); + formulaField.setPreferredSize(new Dimension(159, 20)); + this.add(TableLayoutHelper.createTableLayoutPane(new Component[][]{ + {customValueLabel, formulaField}, + }, new double[]{P}, new double[]{P, F}), BorderLayout.CENTER); + } + + public void populate(CellElement cellElement) { + if (cellElement != null) { + Object value = cellElement.getValue(); + if (value != null && value instanceof DSColumn) { + DSColumn dSColumn = (DSColumn) value; + + //formula + String valueFormula = dSColumn.getResult(); + if (valueFormula == null) { + valueFormula = "$$$"; + } + formulaField.populateElement(cellElement); + formulaField.populate(valueFormula); + } + } + } + + public void update(CellElement cellElement) { + if (cellElement != null) { + Object value = cellElement.getValue(); + if (value != null && value instanceof DSColumn) { + DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + dSColumn.setResult(this.formulaField.getFormulaText()); + } + } + } + } + } } \ No newline at end of file From 17ae107b7681415f11b24308d3f5676154adf88f Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Thu, 3 Aug 2017 18:55:12 +0800 Subject: [PATCH 5/5] =?UTF-8?q?REPORT-3348=20=E4=BF=AE=E6=94=B9=E5=90=8E?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SelectedConfirmedDataColumnPane.java | 2 +- .../dscolumn/SelectedDataColumnPane.java | 74 +++++++++++-------- .../cellquick/CellDSColumnEditor.java | 4 +- 3 files changed, 46 insertions(+), 34 deletions(-) diff --git a/designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java b/designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java index 4852aaa66..e71f539eb 100644 --- a/designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java +++ b/designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java @@ -14,7 +14,7 @@ import java.util.Iterator; public class SelectedConfirmedDataColumnPane extends SelectedDataColumnPane { public SelectedConfirmedDataColumnPane() { - super(false, false); + super(false); } protected void initTableNameComboBox() { diff --git a/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java b/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java index 55f94fff7..0790f87db 100644 --- a/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java +++ b/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java @@ -17,6 +17,7 @@ import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.ElementCasePane; import com.fr.general.Inter; import com.fr.general.data.TableDataColumn; import com.fr.report.cell.CellElement; @@ -54,12 +55,17 @@ public class SelectedDataColumnPane extends BasicPane { private UIButton paramButton; public SelectedDataColumnPane() { - this(true, false); + this(true, false, null); } - public SelectedDataColumnPane(boolean showParameterButton, boolean verticalLayout) { + + public SelectedDataColumnPane(boolean showParameterButton) { + this(showParameterButton, false, null); + } + + public SelectedDataColumnPane(boolean showParameterButton, boolean verticalLayout, ElementCasePane casePane) { if (verticalLayout) { - initComponentVerticalLayout(true); + initComponentVerticalLayout(casePane); } else { initComponent(showParameterButton); } @@ -111,15 +117,11 @@ public class SelectedDataColumnPane extends BasicPane { /** - * 初始化组件 - * - * @param showParameterButton 是否显示参数按钮 + * 初始化竖直布局的组件 */ - public void initComponentVerticalLayout(boolean showParameterButton) { + public void initComponentVerticalLayout(ElementCasePane casePane) { initTableNameComboBox(); - if (showParameterButton) { - initWithParameterButton(); - } + initWithParameterButton(casePane); columnNameComboBox = new LazyComboBox() { @Override public Object[] load() { @@ -132,27 +134,17 @@ public class SelectedDataColumnPane extends BasicPane { double p = TableLayout.PREFERRED; UILabel label1 = new UILabel(Inter.getLocText("TableData")); UILabel label3 = new UILabel(Inter.getLocText("DataColumn")); - if (showParameterButton) { - //todo 国际化 - UILabel label2 = new UILabel("param"); - Component[][] components = { - {label1, tableNameComboBox}, - {label2, paramButton}, - {label3, columnNameComboBox} - }; - this.setLayout(new BorderLayout()); - this.add(TableLayoutHelper.createTableLayoutPane(components, new double[]{p, p, p}, new double[]{p, f})); - } else { - double[] columnSize = {p, f}; - double[] rowSize = {p, p}; - Component[][] components = new Component[][]{ - new Component[]{label1, tableNameComboBox}, - new Component[]{label3, columnNameComboBox} - }; - JPanel jPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - this.setLayout(new BorderLayout()); - this.add(jPanel, BorderLayout.CENTER); - } + + //todo 国际化 + UILabel label2 = new UILabel("param"); + Component[][] components = { + {label1, tableNameComboBox}, + {label2, paramButton}, + {label3, columnNameComboBox} + }; + this.setLayout(new BorderLayout()); + this.add(TableLayoutHelper.createTableLayoutPane(components, new double[]{p, p, p}, new double[]{p, f})); + } @@ -286,6 +278,26 @@ public class SelectedDataColumnPane extends BasicPane { }); } + private void initWithParameterButton(ElementCasePane casePane) { + editorPane = new UITableEditorPane(new ParameterTableModel()); + paramButton = new UIButton(Inter.getLocText("TableData_Dynamic_Parameter_Setting")); + paramButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + BasicDialog paramDialog = editorPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + List parameterList = editorPane.update(); + ps = parameterList.toArray(new Parameter[parameterList.size()]); + editorPane.update(); + casePane.fireTargetModified(); + } + }); + editorPane.populate(ps == null ? new Parameter[0] : ps); + paramDialog.setVisible(true); + } + }); + } + private boolean isColumnName(String columnExp) { return StringUtils.isNotBlank(columnExp) && (columnExp.length() > 0 && columnExp.charAt(0) == '#') && !columnExp.endsWith("#"); diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index 1e1e9a578..156f9521b 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -53,7 +53,7 @@ import java.util.ArrayList; */ public class CellDSColumnEditor extends CellQuickEditor { - private static double P = TableLayout.PREFERRED, F = TableLayout.FILL; + private static final double P = TableLayout.PREFERRED, F = TableLayout.FILL; private enum FilterType { //前N个 后N个 奇数 偶数 自定义 未定义 @@ -204,7 +204,7 @@ public class CellDSColumnEditor extends CellQuickEditor { DSColumnBasicEditorPane() { this.setLayout(new BorderLayout()); - dataPane = new SelectedDataColumnPane(true, true); + dataPane = new SelectedDataColumnPane(true, true, tc); groupPane = new ResultSetGroupDockingPane(tc); dataPane.addListener(dataListener); groupPane.addListener(groupListener);