diff --git a/designer/src/com/fr/design/dscolumn/DSColumnAdvancedPane.java b/designer/src/com/fr/design/dscolumn/DSColumnAdvancedPane.java index 0c3d6f9d7..59fdb2205 100644 --- a/designer/src/com/fr/design/dscolumn/DSColumnAdvancedPane.java +++ b/designer/src/com/fr/design/dscolumn/DSColumnAdvancedPane.java @@ -1,548 +1,553 @@ -package com.fr.design.dscolumn; - -import com.fr.base.Formula; -import com.fr.data.util.SortOrder; -import com.fr.design.data.DesignTableDataManager; -import com.fr.design.dialog.BasicPane; -import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.formula.*; -import com.fr.design.gui.ibutton.UIButton; -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.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.report.cell.cellattr.core.group.DSColumn; -import com.fr.report.cell.cellattr.core.group.SelectCount; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -public class DSColumnAdvancedPane extends BasicPane { - - private static final String InsetText = " "; - private SortPane sortPane; - private SelectCountPane selectCountPane; - private ValuePane valuePane; - private UICheckBox horizontalExtendableCheckBox; - private UICheckBox verticalExtendableCheckBox; -// private UICheckBox isCoverCheckBox; - private UICheckBox useMultiplyNumCheckBox; - private UISpinner multiNumSpinner; - - public DSColumnAdvancedPane() { - this(DSColumnPane.SETTING_ALL); - } - - public DSColumnAdvancedPane(int setting) { - this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - - sortPane = new SortPane(); - sortPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Sort-Sort_Order"),null)); - - if (setting > DSColumnPane.SETTING_DSRELATED) { - selectCountPane = new SelectCountPane(); - selectCountPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("BindColumn-Results_Filter"),null)); - } - - valuePane = new ValuePane(); - valuePane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("BindColumn-Custom_Data_Appearance"),null)); - - - JPanel extendablePane = null; - if (setting > DSColumnPane.SETTING_DSRELATED) { - // extendableDirectionPane - 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"))); - - extendablePane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("ExpandD-Expandable")); - extendablePane.setLayout(new BorderLayout()); - extendablePane.add(extendableDirectionPane, BorderLayout.CENTER); - } - - JPanel multiNumPane = null; - if (setting > DSColumnPane.SETTING_DSRELATED) { - multiNumPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Fill_blank_Data")); - useMultiplyNumCheckBox = new UICheckBox(Inter.getLocText("Column_Multiple")); - multiNumPane.add(useMultiplyNumCheckBox); - multiNumPane.add(new UILabel(InsetText)); - - 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; - if (setting > DSColumnPane.SETTING_DSRELATED) { - components = new Component[][]{ - {sortPane}, - {selectCountPane}, - {valuePane}, - {extendablePane}, - {multiNumPane} - }; - } else { - components = new Component[][]{ - {sortPane}, - {valuePane} - }; - } - this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); - } - - @Override - protected String title4PopupWindow() { - return Inter.getLocText("Advanced"); - } - - public void populate(TemplateCellElement cellElement) { - if (cellElement == null) { - return; - } - - sortPane.populate(cellElement); - valuePane.populate(cellElement); - - if (selectCountPane != null) { - selectCountPane.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) { - this.useMultiplyNumCheckBox.setSelected(false); - } else { - this.useMultiplyNumCheckBox.setSelected(true); - this.multiNumSpinner.setValue(cellExpandAttr.getMultipleNumber()); - } - - this.checkButtonEnabled(); - } - } - - public void update(TemplateCellElement cellElement) { - if (cellElement == null) { - return; - } - - sortPane.update(cellElement); - valuePane.update(cellElement); - - if (selectCountPane != null) { - selectCountPane.update(cellElement); - - CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); - if (cellExpandAttr == null) { - cellExpandAttr = new CellExpandAttr(); - cellElement.setCellExpandAttr(cellExpandAttr); - } - - // extendable - 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) this.multiNumSpinner.getValue()); - } else { - cellExpandAttr.setMultipleNumber(-1); - } - } - } - - private static class SortPane extends SortFormulaPane { - private CellElement cellElement; - - @Override - public void formulaAction() { - if (cellElement == null) { - return; - } - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - - String[] displayNames = DesignTableDataManager.getSelectedColumnNames( - DesignTableDataManager.getEditingTableDataSource(), ((DSColumn) value).getDSName()); - - showFormulaDialog(displayNames); - } - - 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) value; - - int sort = dSColumn.getOrder(); - this.sortOrderComboBox.setSortOrder(new SortOrder(sort)); - - String sortFormula = dSColumn.getSortFormula(); - if (sortFormula != null && sortFormula.length() >= 1) { - sortFormulaTextField.setText(sortFormula); - } else { - sortFormulaTextField.setText(sortFormula); - } - } - - 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()); - - dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder()); - //lance:sort formula - - String sText = null; - if (!(sortFormulaTextField.getText() == null || sortFormulaTextField.getText().trim().equals("") || sortFormulaTextField.getText().trim().equals("$$$"))) { - sText = new String(sortFormulaTextField.getText()); - } - if (!(sText == null || sText.length() < 1)) { - dSColumn.setSortFormula(sText); - } else { - dSColumn.setSortFormula(null); - } - } - } - - private static class SelectCountPane extends JPanel { - - CellElement cellElement; - // private Comparator sortComparator; - private UIComboBox selectCountComboBox; - private JPanel selectCountCardPane; - private UITextField serialTextField; - - JFormulaField topFormulaPane; - 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(InsetText), selectCountComboBox, - new UILabel(InsetText), 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 JFormulaField("-1"); - bottomFormulaPane = new 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; - } - } - } - - 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(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); - } - }; - } - - private static class ValuePane extends JPanel { - private JFormulaField formulaField; - - public ValuePane() { - this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); - - this.add(new UILabel(InsetText + Inter.getLocText("Value") + ":")); - this.add(Box.createHorizontalStrut(2)); - this.add((formulaField = new 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()); - } - } - - private void checkButtonEnabled() { - if (useMultiplyNumCheckBox.isSelected()) { - multiNumSpinner.setEnabled(true); - } else { - multiNumSpinner.setEnabled(false); - } - } +package com.fr.design.dscolumn; + +import com.fr.base.Formula; +import com.fr.data.util.SortOrder; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.formula.CustomVariableResolver; +import com.fr.design.formula.FormulaFactory; +import com.fr.design.formula.SortFormulaPane; +import com.fr.design.formula.UIFormula; +import com.fr.design.gui.ibutton.UIButton; +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.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.report.cell.cellattr.core.group.DSColumn; +import com.fr.report.cell.cellattr.core.group.SelectCount; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.*; + +public class DSColumnAdvancedPane extends BasicPane { + + private static final String InsetText = " "; + private SortPane sortPane; + private SelectCountPane selectCountPane; + private ValuePane valuePane; + private UICheckBox horizontalExtendableCheckBox; + private UICheckBox verticalExtendableCheckBox; + private UICheckBox useMultiplyNumCheckBox; + private UISpinner multiNumSpinner; + + public DSColumnAdvancedPane() { + this(DSColumnPane.SETTING_ALL); + } + + public DSColumnAdvancedPane(int setting) { + this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + sortPane = new SortPane(); + sortPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Sort-Sort_Order"), null)); + + if (setting > DSColumnPane.SETTING_DSRELATED) { + selectCountPane = new SelectCountPane(); + selectCountPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("BindColumn-Results_Filter"), null)); + } + + valuePane = new ValuePane(); + valuePane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("BindColumn-Custom_Data_Appearance"), null)); + + + JPanel extendablePane = null; + if (setting > DSColumnPane.SETTING_DSRELATED) { + // extendableDirectionPane + 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"))); + + extendablePane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("ExpandD-Expandable")); + extendablePane.setLayout(new BorderLayout()); + extendablePane.add(extendableDirectionPane, BorderLayout.CENTER); + } + + JPanel multiNumPane = null; + if (setting > DSColumnPane.SETTING_DSRELATED) { + multiNumPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Fill_blank_Data")); + useMultiplyNumCheckBox = new UICheckBox(Inter.getLocText("Column_Multiple")); + multiNumPane.add(useMultiplyNumCheckBox); + multiNumPane.add(new UILabel(InsetText)); + + 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; + if (setting > DSColumnPane.SETTING_DSRELATED) { + components = new Component[][]{ + {sortPane}, + {selectCountPane}, + {valuePane}, + {extendablePane}, + {multiNumPane} + }; + } else { + components = new Component[][]{ + {sortPane}, + {valuePane} + }; + } + this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("Advanced"); + } + + public void populate(TemplateCellElement cellElement) { + if (cellElement == null) { + return; + } + + sortPane.populate(cellElement); + valuePane.populate(cellElement); + + if (selectCountPane != null) { + selectCountPane.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) { + this.useMultiplyNumCheckBox.setSelected(false); + } else { + this.useMultiplyNumCheckBox.setSelected(true); + this.multiNumSpinner.setValue(cellExpandAttr.getMultipleNumber()); + } + + this.checkButtonEnabled(); + } + } + + public void update(TemplateCellElement cellElement) { + if (cellElement == null) { + return; + } + + sortPane.update(cellElement); + valuePane.update(cellElement); + + if (selectCountPane != null) { + selectCountPane.update(cellElement); + + CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); + if (cellExpandAttr == null) { + cellExpandAttr = new CellExpandAttr(); + cellElement.setCellExpandAttr(cellExpandAttr); + } + + // extendable + 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) this.multiNumSpinner.getValue()); + } else { + cellExpandAttr.setMultipleNumber(-1); + } + } + } + + private static class SortPane extends SortFormulaPane { + private CellElement cellElement; + + @Override + public void formulaAction() { + if (cellElement == null) { + return; + } + Object value = cellElement.getValue(); + if (value == null || !(value instanceof DSColumn)) { + return; + } + + String[] displayNames = DesignTableDataManager.getSelectedColumnNames( + DesignTableDataManager.getEditingTableDataSource(), ((DSColumn) value).getDSName()); + + showFormulaDialog(displayNames); + } + + 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) value; + + int sort = dSColumn.getOrder(); + this.sortOrderComboBox.setSortOrder(new SortOrder(sort)); + + String sortFormula = dSColumn.getSortFormula(); + if (sortFormula != null && sortFormula.length() >= 1) { + sortFormulaTextField.setText(sortFormula); + } else { + sortFormulaTextField.setText(sortFormula); + } + } + + 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()); + + dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder()); + //lance:sort formula + + String sText = null; + if (!(sortFormulaTextField.getText() == null || sortFormulaTextField.getText().trim().equals("") || sortFormulaTextField.getText().trim().equals("$$$"))) { + sText = new String(sortFormulaTextField.getText()); + } + if (!(sText == null || sText.length() < 1)) { + dSColumn.setSortFormula(sText); + } else { + dSColumn.setSortFormula(null); + } + } + } + + private static class SelectCountPane extends JPanel { + + CellElement cellElement; + // private Comparator sortComparator; + private UIComboBox selectCountComboBox; + private JPanel selectCountCardPane; + private UITextField serialTextField; + + JFormulaField topFormulaPane; + 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(InsetText), selectCountComboBox, + new UILabel(InsetText), 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 JFormulaField("-1"); + bottomFormulaPane = new 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 == TOP.getValue()) { + this.topFormulaPane.populate(selectCount.getFormulaCount()); + } else if (selectCountType == BOTTOM.getValue()) { + this.bottomFormulaPane.populate(selectCount.getFormulaCount()); + } else if (selectCountType == SPECIFY.getValue()) { + 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 == TOP.getValue()) { + selectCount.setFormulaCount(this.topFormulaPane.getFormulaText()); + } else if (selectCountSelectIndex == BOTTOM.getValue()) { + selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText()); + } else if (selectCountSelectIndex == SPECIFY.getValue()) { + 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; + } + } + } + + 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(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); + } + }; + } + + private static class ValuePane extends JPanel { + private JFormulaField formulaField; + + public ValuePane() { + this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); + + this.add(new UILabel(InsetText + Inter.getLocText("Value") + ":")); + this.add(Box.createHorizontalStrut(2)); + this.add((formulaField = new 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()); + } + } + + private void checkButtonEnabled() { + if (useMultiplyNumCheckBox.isSelected()) { + multiNumSpinner.setEnabled(true); + } else { + multiNumSpinner.setEnabled(false); + } + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java b/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java index 072b34b6c..dd1a6dad7 100644 --- a/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java +++ b/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java @@ -89,7 +89,9 @@ public class MobileRadioGroupPane extends BasicBeanPane{ * 选中指定index的按钮 */ public void selectIndexButton(int index) { - if (index < 0 || index > radioButtons.size() - 1) { + //这里删了默认按钮,所以这边判断的时候不能-1了 +// if (index < 0 || index > radioButtons.size() - 1) { fanglei: 这个注释不要删!不然以后可能忘记这个问题 + if (index < 0 || index > radioButtons.size()) { return; } diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index e7ccd7710..bd702a29c 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -34,6 +34,7 @@ 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.FilterTypeEnum; import com.fr.report.cell.cellattr.core.group.SelectCount; import javax.swing.*; @@ -46,6 +47,9 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; +import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.*; + + /** * 单元格元素 数据列编辑器 * @@ -58,10 +62,6 @@ public class CellDSColumnEditor extends CellQuickEditor { private static final double P = TableLayout.PREFERRED, F = TableLayout.FILL; private static final Color TIP_FONT_COLOR = new Color(0x7F333334, true); - private enum FilterType { - //前N个 后N个 奇数 偶数 自定义 未定义 - TOP, BOTTOM, ODD, EVEN, SPECIFY, UNDEFINE - } private JPanel dsColumnRegion; private JPanel centerPane; @@ -669,6 +669,69 @@ public class CellDSColumnEditor extends CellQuickEditor { private JFormulaField topFormulaPane; private JFormulaField bottomFormulaPane; + private ActionListener actionListener = new ActionListener() { + public void actionPerformed(ActionEvent evt) { + int selectIndex = rsComboBox.getSelectedIndex(); + CardLayout setCardPaneLayout = (CardLayout) setCardPane.getLayout(); + CardLayout tipCardPaneLayout = (CardLayout) tipCardPane.getLayout(); + if (selectIndex == TOP.getValue()) { + //前N个 + setCardPaneLayout.show(setCardPane, TOP.name()); + tipCardPaneLayout.show(tipCardPane, TOP.name()); + //隐藏tip 显示set + setCardPane.setPreferredSize(new Dimension(156, 20)); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); + tipCardPane.setPreferredSize(new Dimension(0, 0)); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); + } else if (selectIndex == BOTTOM.getValue()) { + //后N个 + setCardPaneLayout.show(setCardPane, BOTTOM.name()); + tipCardPaneLayout.show(tipCardPane, BOTTOM.name()); + //隐藏tip 显示set + setCardPane.setPreferredSize(new Dimension(156, 20)); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); + tipCardPane.setPreferredSize(new Dimension(0, 0)); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); + } else if (selectIndex == ODD.getValue()) { + //奇数 + setCardPaneLayout.show(setCardPane, ODD.name()); + tipCardPaneLayout.show(tipCardPane, ODD.name()); + //隐藏set 显示tip + setCardPane.setPreferredSize(new Dimension(0, 0)); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); + tipCardPane.setPreferredSize(new Dimension(224, 40)); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, VGAP_INNER); + } else if (selectIndex == EVEN.getValue()) { + //偶数 + setCardPaneLayout.show(setCardPane, EVEN.name()); + tipCardPaneLayout.show(tipCardPane, EVEN.name()); + //隐藏set 显示tip + setCardPane.setPreferredSize(new Dimension(0, 0)); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); + tipCardPane.setPreferredSize(new Dimension(224, 40)); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, VGAP_INNER); + } else if (selectIndex == SPECIFY.getValue()) { + //指定 + setCardPaneLayout.show(setCardPane, SPECIFY.name()); + tipCardPaneLayout.show(tipCardPane, SPECIFY.name()); + //显示set和tip + setCardPane.setPreferredSize(new Dimension(156, 20)); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); + tipCardPane.setPreferredSize(new Dimension(224, 40)); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, VGAP_INNER); + } else { + //未定义 + setCardPaneLayout.show(setCardPane, UNDEFINE.name()); + tipCardPaneLayout.show(tipCardPane, UNDEFINE.name()); + //隐藏set和tip + setCardPane.setPreferredSize(new Dimension(0, 0)); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); + tipCardPane.setPreferredSize(new Dimension(0, 0)); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); + } + } + }; + public ResultSetFilterConfigPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); UILabel filterLabel = new UILabel(Inter.getLocText("BindColumn-Results_Filter")); @@ -681,65 +744,7 @@ public class CellDSColumnEditor extends CellQuickEditor { 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) { - //前N个 - setCardPaneLayout.show(setCardPane, FilterType.TOP.name()); - tipCardPaneLayout.show(tipCardPane, FilterType.TOP.name()); - //隐藏tip 显示set - setCardPane.setPreferredSize(new Dimension(156, 20)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); - tipCardPane.setPreferredSize(new Dimension(0, 0)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); - } else if (selectIndex == 2) { - //后N个 - setCardPaneLayout.show(setCardPane, FilterType.BOTTOM.name()); - tipCardPaneLayout.show(tipCardPane, FilterType.BOTTOM.name()); - //隐藏tip 显示set - setCardPane.setPreferredSize(new Dimension(156, 20)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); - tipCardPane.setPreferredSize(new Dimension(0, 0)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); - } else if (selectIndex == 3) { - //奇数 - setCardPaneLayout.show(setCardPane, FilterType.ODD.name()); - tipCardPaneLayout.show(tipCardPane, FilterType.ODD.name()); - //隐藏set 显示tip - setCardPane.setPreferredSize(new Dimension(0, 0)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); - tipCardPane.setPreferredSize(new Dimension(224, 40)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, VGAP_INNER); - } else if (selectIndex == 4) { - setCardPaneLayout.show(setCardPane, FilterType.EVEN.name()); - tipCardPaneLayout.show(tipCardPane, FilterType.EVEN.name()); - //隐藏set 显示tip - setCardPane.setPreferredSize(new Dimension(0, 0)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); - tipCardPane.setPreferredSize(new Dimension(224, 40)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, VGAP_INNER); - } else if (selectIndex == 5) { - setCardPaneLayout.show(setCardPane, FilterType.SPECIFY.name()); - tipCardPaneLayout.show(tipCardPane, FilterType.SPECIFY.name()); - //显示set和tip - setCardPane.setPreferredSize(new Dimension(156, 20)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); - tipCardPane.setPreferredSize(new Dimension(224, 40)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, VGAP_INNER); - } else { - setCardPaneLayout.show(setCardPane, FilterType.UNDEFINE.name()); - tipCardPaneLayout.show(tipCardPane, FilterType.UNDEFINE.name()); - //隐藏set和tip - setCardPane.setPreferredSize(new Dimension(0, 0)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); - tipCardPane.setPreferredSize(new Dimension(0, 0)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); - } - } - }); + rsComboBox.addActionListener(actionListener); //配置展示CardLayout setCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); //提示信息展示CardLayout @@ -747,36 +752,36 @@ public class CellDSColumnEditor extends CellQuickEditor { //前N个 topFormulaPane = new JFormulaField(DEFAULT_VALUE); - setCardPane.add(topFormulaPane, FilterType.TOP.name()); - tipCardPane.add(new JPanel(), FilterType.TOP.name()); + setCardPane.add(topFormulaPane, TOP.name()); + tipCardPane.add(new JPanel(), TOP.name()); //后N个 bottomFormulaPane = new JFormulaField(DEFAULT_VALUE); - setCardPane.add(bottomFormulaPane, FilterType.BOTTOM.name()); - tipCardPane.add(new JPanel(), FilterType.BOTTOM.name()); + setCardPane.add(bottomFormulaPane, BOTTOM.name()); + tipCardPane.add(new JPanel(), BOTTOM.name()); //自定义值下方没有提示信息,也没有输入框 - setCardPane.add(new JPanel(), FilterType.UNDEFINE.name()); - tipCardPane.add(new JPanel(), FilterType.UNDEFINE.name()); + setCardPane.add(new JPanel(), UNDEFINE.name()); + tipCardPane.add(new JPanel(), UNDEFINE.name()); //奇数 UILabel 占一行作为提示信息 - setCardPane.add(new JPanel(), FilterType.ODD.name()); + setCardPane.add(new JPanel(), ODD.name()); MultilineLabel oddTip = new MultilineLabel(Inter.getLocText("FS-Designer_DS_Filter_Odd_Tip")); oddTip.setForeground(TIP_FONT_COLOR); - tipCardPane.add(oddTip, FilterType.ODD.name()); + tipCardPane.add(oddTip, ODD.name()); //偶数 UILabel 占一行作为提示信息 - setCardPane.add(new JPanel(), FilterType.EVEN.name()); + setCardPane.add(new JPanel(), EVEN.name()); MultilineLabel evenTip = new MultilineLabel(Inter.getLocText("FS-Designer_DS_Filter_Even_Tip")); evenTip.setForeground(TIP_FONT_COLOR); - tipCardPane.add(evenTip, FilterType.EVEN.name()); + tipCardPane.add(evenTip, EVEN.name()); //输入框占用右半边,提示信息占一行 serialTextField = new UITextField(16); - setCardPane.add(serialTextField, FilterType.SPECIFY.name()); + setCardPane.add(serialTextField, SPECIFY.name()); MultilineLabel specifyTip = new MultilineLabel(Inter.getLocText("FS-Designer_DS_Filter_Specify_Tip")); specifyTip.setForeground(TIP_FONT_COLOR); - tipCardPane.add(specifyTip, FilterType.SPECIFY.name()); + tipCardPane.add(specifyTip, SPECIFY.name()); contentPane = TableLayoutHelper.createDiffVGapTableLayoutPane(new Component[][]{ {filterLabel, rsComboBox}, {null, setCardPane}, @@ -787,6 +792,7 @@ public class CellDSColumnEditor extends CellQuickEditor { } public void populate(CellElement cellElement) { + rsComboBox.removeActionListener(actionListener); if (cellElement != null) { Object value = cellElement.getValue(); if (value != null && value instanceof DSColumn) { @@ -794,42 +800,59 @@ public class CellDSColumnEditor extends CellQuickEditor { SelectCount selectCount = dSColumn.getSelectCount(); this.topFormulaPane.populateElement(cellElement); this.bottomFormulaPane.populateElement(cellElement); + CardLayout setCardPaneLayout = (CardLayout) setCardPane.getLayout(); + CardLayout tipCardPaneLayout = (CardLayout) tipCardPane.getLayout(); if (selectCount != null) { int selectCountType = selectCount.getType(); this.rsComboBox.setSelectedIndex(selectCountType); - switch (selectCountType) { - case SelectCount.TOP: + switch (FilterTypeEnum.getFilterByValue(selectCountType)) { + case TOP: this.topFormulaPane.populate(selectCount.getFormulaCount()); + //前N个 + setCardPaneLayout.show(setCardPane, TOP.name()); + tipCardPaneLayout.show(tipCardPane, TOP.name()); //隐藏tip 显示set setCardPane.setPreferredSize(new Dimension(156, 20)); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); tipCardPane.setPreferredSize(new Dimension(0, 0)); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); break; - case SelectCount.BOTTOM: + case BOTTOM: this.bottomFormulaPane.populate(selectCount.getFormulaCount()); + //后N个 + setCardPaneLayout.show(setCardPane, BOTTOM.name()); + tipCardPaneLayout.show(tipCardPane, BOTTOM.name()); //隐藏tip 显示set setCardPane.setPreferredSize(new Dimension(156, 20)); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); tipCardPane.setPreferredSize(new Dimension(0, 0)); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); break; - case SelectCount.SPECIFY: + case SPECIFY: this.serialTextField.setText(selectCount.getSerial()); + //指定 + setCardPaneLayout.show(setCardPane, SPECIFY.name()); + tipCardPaneLayout.show(tipCardPane, SPECIFY.name()); //显示set和tip setCardPane.setPreferredSize(new Dimension(156, 20)); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); tipCardPane.setPreferredSize(new Dimension(224, 40)); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, VGAP_INNER); break; - case SelectCount.EVEN: + case EVEN: + //偶数 + setCardPaneLayout.show(setCardPane, EVEN.name()); + tipCardPaneLayout.show(tipCardPane, EVEN.name()); //隐藏set 显示tip setCardPane.setPreferredSize(new Dimension(0, 0)); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); tipCardPane.setPreferredSize(new Dimension(224, 40)); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, VGAP_INNER); break; - case SelectCount.ODD: + case ODD: + //奇数 + setCardPaneLayout.show(setCardPane, ODD.name()); + tipCardPaneLayout.show(tipCardPane, ODD.name()); //隐藏set 显示tip setCardPane.setPreferredSize(new Dimension(0, 0)); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); @@ -837,6 +860,9 @@ public class CellDSColumnEditor extends CellQuickEditor { TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, VGAP_INNER); break; default: + //未定义 + setCardPaneLayout.show(setCardPane, UNDEFINE.name()); + tipCardPaneLayout.show(tipCardPane, UNDEFINE.name()); //隐藏set和tip setCardPane.setPreferredSize(new Dimension(0, 0)); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); @@ -844,6 +870,9 @@ public class CellDSColumnEditor extends CellQuickEditor { TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); } } else { + //未定义 + setCardPaneLayout.show(setCardPane, UNDEFINE.name()); + tipCardPaneLayout.show(tipCardPane, UNDEFINE.name()); //隐藏set和tip setCardPane.setPreferredSize(new Dimension(0, 0)); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); @@ -852,6 +881,7 @@ public class CellDSColumnEditor extends CellQuickEditor { } } } + rsComboBox.addActionListener(actionListener); } public void update(CellElement cellElement) { @@ -866,11 +896,11 @@ public class CellDSColumnEditor extends CellQuickEditor { SelectCount selectCount = new SelectCount(); selectCount.setType(selectedFilterIndex); dSColumn.setSelectCount(selectCount); - if (selectedFilterIndex == SelectCount.TOP) { + if (selectedFilterIndex == TOP.getValue()) { selectCount.setFormulaCount(this.topFormulaPane.getFormulaText()); - } else if (selectedFilterIndex == SelectCount.BOTTOM) { + } else if (selectedFilterIndex == BOTTOM.getValue()) { selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText()); - } else if (selectedFilterIndex == SelectCount.SPECIFY) { + } else if (selectedFilterIndex == SPECIFY.getValue()) { selectCount.setSerial(this.serialTextField.getText()); } } @@ -887,6 +917,7 @@ public class CellDSColumnEditor extends CellQuickEditor { topFormulaPane.addListener(formulaListener); bottomFormulaPane.addListener(formulaListener); rsComboBox.registerChangeListener(formulaListener); + serialTextField.registerChangeListener(formulaListener); } } diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java index c5e12fa69..a148fd3b8 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java @@ -214,6 +214,7 @@ public abstract class UIListControlPane extends UIControlPane { @Override public void populate(Nameable[] nameableArray) { isPopulating = true; // 加一个标识位,避免切换单元格时,触发 saveSettings + nameableList.getCellEditor().stopCellEditing(); DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); listModel.removeAllElements(); if (ArrayUtils.isEmpty(nameableArray)) { @@ -582,6 +583,7 @@ public abstract class UIListControlPane extends UIControlPane { UIListControlPane.this.nameableList.getCellEditor() .stopCellEditing(); } catch (Exception ignored) { + // do nothing } // bug:在选中一个NameObject并删除,会遗留下Name. doBeforeRemove();