diff --git a/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java index 46d8d0a6e2..93b63a5d7f 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 9ba61e5475..07f02a7ef8 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 282367d273..4852aaa666 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 dd583e1efe..55f94fff74 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 3493967afe..8afe3c691e 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};