From dcc26061060613abb8e2f786adb960eeb1878ad1 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Tue, 14 Dec 2021 20:13:16 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-62440=20=E8=A1=A8=E5=A4=B4=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E5=86=85=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/dscolumn/DSColumnAdvancedPane.java | 95 ++++------ .../cell/settingpane/CellExpandAttrPane.java | 13 -- .../CellDSColumnSortGroupPane.java | 18 +- .../sort/common/AbstractSortGroupPane.java | 9 +- .../design/sort/common/AbstractSortPane.java | 30 ++-- .../design/sort/common/SortColumnRowPane.java | 165 ++++++++++++++---- .../sort/common/SortUIExpandablePane.java | 1 + .../expressionpane/CustomSequencePane.java | 6 +- .../CustomSequenceSortExpressionPane.java | 6 +- .../FormulaSortExpressionPane.java | 4 +- .../cellquick/CellDSColumnEditor.java | 144 +-------------- 11 files changed, 212 insertions(+), 279 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java index 1061b63635..de223b511e 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java @@ -13,6 +13,7 @@ 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.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.itextfield.UITextField; @@ -20,6 +21,7 @@ import com.fr.design.gui.style.TextFormatPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.sort.celldscolumn.CellDSColumnSortPane; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.report.cell.CellElement; import com.fr.report.cell.TemplateCellElement; @@ -47,14 +49,26 @@ public class DSColumnAdvancedPane extends BasicPane { private UICheckBox verticalExtendableCheckBox; private UICheckBox useMultiplyNumCheckBox; private UISpinner multiNumSpinner; + private JPanel contentPane; public DSColumnAdvancedPane() { this(DSColumnPane.SETTING_ALL); } public DSColumnAdvancedPane(int setting) { - this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); - this.setLayout(FRGUIPaneFactory.createBorderLayout()); + initContentPane(setting); + initScrollPane(); + } + + private void initScrollPane() { + ScrollPane scrollPane = new ScrollPane(contentPane); + this.add(scrollPane); + } + + private void initContentPane(int setting) { + contentPane = new JPanel(); + contentPane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); + contentPane.setLayout(FRGUIPaneFactory.createBorderLayout()); sortPane = new SortPane(); sortPane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order"))); @@ -124,7 +138,7 @@ public class DSColumnAdvancedPane extends BasicPane { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; double[] columnSize = {TableLayout.FILL}; - this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); + contentPane.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); } @Override @@ -137,7 +151,7 @@ public class DSColumnAdvancedPane extends BasicPane { return; } - sortPane.populate(cellElement); + sortPane.populateBean(cellElement); valuePane.populate(cellElement); formatAttrPane.populate(cellElement); @@ -187,7 +201,7 @@ public class DSColumnAdvancedPane extends BasicPane { return; } - sortPane.update(cellElement); + sortPane.updateBean(cellElement); valuePane.update(cellElement); formatAttrPane.update(cellElement); @@ -223,66 +237,25 @@ public class DSColumnAdvancedPane extends BasicPane { } } - private static class SortPane extends SortFormulaPane { - private CellElement cellElement; + private static class ScrollPane extends UIScrollPane { + ScrollPane(Component component) { + super(component); + this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + } @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); + public Dimension getPreferredSize() { + return new Dimension(DSColumnPane.DEFAULT_DIMENSION.width - 20, DSColumnPane.DEFAULT_DIMENSION.height - 100); } + } - 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(); - sortFormulaTextField.setText(sortFormula); + private static class SortPane extends CellDSColumnSortPane { + SortPane() { + this.setLayout(new FlowLayout(FlowLayout.LEFT)); } - 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); - } + protected boolean needSortHeaderPane() { + return false; } } @@ -540,12 +513,12 @@ public class DSColumnAdvancedPane extends BasicPane { public static class FormatAttrPane extends TextFormatPane { protected void initLayout() { - JPanel settingPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 4, 0); + JPanel settingPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 4, 0); settingPane.add(typeComboBox); settingPane.add(textField); settingPane.add(roundingBox); - addComponents(4, new JComponent[] { settingPane, previewLabel}); + addComponents(4, new JComponent[]{settingPane, previewLabel}); } @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java index 2a9aab95de..9549a3a7e8 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java @@ -4,7 +4,6 @@ import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.expand.ExpandLeftFatherPane; import com.fr.design.expand.ExpandUpFatherPane; -import com.fr.design.expand.SortExpandAttrPane; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icheckbox.UICheckBox; @@ -39,7 +38,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { private ExpandUpFatherPane rightFatherPane; private UICheckBox horizontalExpandableCheckBox; private UICheckBox verticalExpandableCheckBox; - private SortExpandAttrPane sortAfterExpand; private JPanel layoutPane; private JPanel basicPane; private JPanel seniorPane; @@ -64,7 +62,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { rightFatherPane = new ExpandUpFatherPane(); horizontalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable")); verticalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable")); - sortAfterExpand = new SortExpandAttrPane(); initAllNames(); return layoutPane(); } @@ -124,16 +121,12 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { private JPanel seniorPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - UILabel expendSort = new UILabel(Toolkit.i18nText("Fine-Design_Report_Expend_Sort"), SwingConstants.LEFT); - JPanel expendSortPane = new JPanel(new BorderLayout()); - expendSortPane.add(expendSort, BorderLayout.NORTH); horizontalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); verticalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); Component[][] components = new Component[][]{ new Component[]{null, null}, new Component[]{horizontalExpandableCheckBox, null}, new Component[]{verticalExpandableCheckBox, null}, - new Component[]{expendSortPane, sortAfterExpand}, }; double[] rowSize = {p, p, p, p, p}; double[] columnSize = {p, f}; @@ -174,8 +167,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { } } - sortAfterExpand.populate(cellExpandAttr); - extraPane.populate(cellElement); cellExpandSortPane.populateBean(cellElement); } @@ -223,10 +214,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { } } - if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand"))) { - sortAfterExpand.update(cellExpandAttr); - } - extraPane.update(cellElement); cellExpandSortPane.updateBean(cellElement); } diff --git a/designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java b/designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java index c74c3c9e3e..788f1a57cb 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortGroupPane.java @@ -15,22 +15,24 @@ public class CellDSColumnSortGroupPane extends AbstractSortGroupPane { super(sortGroupPaneWidth, sortGroupPaneRightWidth); } - public void populateDsColumn( DSColumn dsColumn){ + public void populateDsColumn(DSColumn dsColumn) { this.dsColumn = dsColumn; } @Override protected AbstractSortItemPane refreshSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth, SortExpression sortExpression) { - CellDSColumnSortItemPane cellDSColumnSortItemPane = new CellDSColumnSortItemPane( sortItemPaneWidth, sortItemPaneRightWidth); + CellDSColumnSortItemPane cellDSColumnSortItemPane = new CellDSColumnSortItemPane(sortItemPaneWidth, sortItemPaneRightWidth); java.util.Map tableDataWrapperMap = DesignTableDataManager.getAllEditingDataSet(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget()); TableDataWrapper tableDataWrapper = tableDataWrapperMap.get(dsColumn.getDSName()); - java.util.List columnNameList = tableDataWrapper.calculateColumnNameList(); - String[] columnNames = new String[columnNameList.size()]; - columnNameList.toArray(columnNames); - cellDSColumnSortItemPane.sortAreaUiComboBox.removeAllItems(); - for (String columnName : columnNames) { - cellDSColumnSortItemPane.sortAreaUiComboBox.addItem(columnName); + if (tableDataWrapper != null) { + java.util.List columnNameList = tableDataWrapper.calculateColumnNameList(); + String[] columnNames = new String[columnNameList.size()]; + columnNameList.toArray(columnNames); + cellDSColumnSortItemPane.sortAreaUiComboBox.removeAllItems(); + for (String columnName : columnNames) { + cellDSColumnSortItemPane.sortAreaUiComboBox.addItem(columnName); + } } cellDSColumnSortItemPane.populateBean(sortExpression); return cellDSColumnSortItemPane; diff --git a/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java b/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java index 85cd58ec94..6cdde9eb4a 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java @@ -18,6 +18,8 @@ import java.util.List; public abstract class AbstractSortGroupPane extends JPanel implements ComponentChangeObserver { + private static final int SECOND_SORT_LENGTH_REDUCTION = 13; + protected int sortGroupPaneWidth; protected int sortGroupPaneRightWidth; List sortExpressions; @@ -95,8 +97,8 @@ public abstract class AbstractSortGroupPane extends JPanel implements ComponentC int sortItemPaneWidth = sortGroupPaneWidth; int sortItemPaneRightWidth = sortGroupPaneRightWidth; if (!mainSort) { - sortItemPaneWidth -= 12; - sortItemPaneRightWidth -= 12; + sortItemPaneWidth -= SECOND_SORT_LENGTH_REDUCTION; + sortItemPaneRightWidth -= SECOND_SORT_LENGTH_REDUCTION; } if (sortExpression == null) { sortExpression = new CellSortExpression(selfSortArea); @@ -131,12 +133,13 @@ public abstract class AbstractSortGroupPane extends JPanel implements ComponentC AddSortItemBar(AbstractSortGroupPane sortGroupPane) { init(); this.sortGroupPane = sortGroupPane; + this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5)); } void init() { uiButton = new UIButton(Toolkit.i18nText("Fine-Design_Sort_Add_Second_Sort"), IconUtils.readIcon("/com/fr/design/images/sort/add.png")); - uiButton.setPreferredSize(new Dimension(sortGroupPaneWidth - 4, 20)); + uiButton.setPreferredSize(new Dimension(sortGroupPaneWidth - 4, AbstractSortPane.PANE_COMPONENT_HEIGHT)); this.add(uiButton); uiButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { diff --git a/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java b/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java index 7dd539361a..bfddee38c2 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java @@ -34,13 +34,19 @@ public abstract class AbstractSortPane extends JPanel { private void initComponents() { initSortGroupPane(); - sortHeaderPane = new SortHeaderPane(sortPaneWidth, sortPaneRightWidth + 5); - this.add(sortHeaderPane); + if (needSortHeaderPane()) { + sortHeaderPane = new SortHeaderPane(sortPaneWidth, sortPaneRightWidth + 5); + this.add(sortHeaderPane); + } } protected abstract void initSortGroupPane(); + protected boolean needSortHeaderPane() { + return true; + } + protected abstract CellSortAttr getCellSortAttr(TemplateCellElement cellElement); public void populateBean(TemplateCellElement cellElement) { @@ -55,11 +61,13 @@ public abstract class AbstractSortPane extends JPanel { sortExpressions.add(new CellSortExpression(selfSortArea)); } sortGroupPane.populateBean(sortExpressions, selfSortArea); - SortHeader sortHeader = null; - if (cellSortAttr != null) { - sortHeader = cellSortAttr.getSortHeader(); + if (needSortHeaderPane()) { + SortHeader sortHeader = null; + if (cellSortAttr != null) { + sortHeader = cellSortAttr.getSortHeader(); + } + sortHeaderPane.populateBean(sortHeader, defaultHeaderArea); } - sortHeaderPane.populateBean(sortHeader, defaultHeaderArea); refresh(); } @@ -76,13 +84,15 @@ public abstract class AbstractSortPane extends JPanel { public void updateBean(TemplateCellElement cellElement) { List sortExpressions = sortGroupPane.updateBean(); - SortHeader sortHeader = sortHeaderPane.updateBean(); CellSortAttr cellSortAttr = getCellSortAttr(cellElement); cellSortAttr.setSortExpressions(sortExpressions); - if (sortHeader != null) { - sortHeader.setSortArea(selfSortArea); + if (needSortHeaderPane()) { + SortHeader sortHeader = sortHeaderPane.updateBean(); + if (sortHeader != null) { + sortHeader.setSortArea(selfSortArea); + } + cellSortAttr.setSortHeader(sortHeader); } - cellSortAttr.setSortHeader(sortHeader); } protected void refresh() { diff --git a/designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java b/designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java index e8371b3e1b..cc276711a3 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java @@ -1,5 +1,7 @@ package com.fr.design.sort.common; +import com.fr.base.Style; +import com.fr.base.background.ColorBackground; import com.fr.base.svg.IconUtils; import com.fr.design.designer.TargetComponent; import com.fr.design.event.UIObserver; @@ -10,9 +12,18 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionListener; +import com.fr.design.ui.util.UIUtil; +import com.fr.general.Background; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; import com.fr.log.FineLoggerFactory; +import com.fr.report.cell.DefaultTemplateCellElement; +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.core.sort.common.CellSortable; +import com.fr.report.core.sort.header.SortHeader; +import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.ColumnRow; import com.fr.stable.EssentialUtils; import com.fr.stable.StringUtils; @@ -21,6 +32,12 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; public class SortColumnRowPane extends JPanel implements UIObserver { int paneWidth; @@ -75,7 +92,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver { void initSelectButton() { selectButton = new UIButton(IconUtils.readIcon("/com/fr/design/images/buttonicon/select.png")); - selectButton.addActionListener(new SelectActionListener(this)); + selectButton.addMouseListener(new SelectActionListener(this)); this.add(selectButton); } @@ -90,7 +107,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver { refresh(); } - public void setColumnRow(ColumnRow columnRow){ + public void setColumnRow(ColumnRow columnRow) { populateBean(columnRow); uiObserverListener.doChange(); } @@ -112,59 +129,145 @@ public class SortColumnRowPane extends JPanel implements UIObserver { return true; } - class SelectActionListener implements ActionListener { + class SelectActionListener extends MouseAdapter { SortColumnRowPane columnRowPane; + Map disableHeaderCellsStyleMap = new HashMap<>(); + java.util.List tempHeaderCells = new ArrayList<>(); + SelectActionListener(SortColumnRowPane columnRowPane) { this.columnRowPane = columnRowPane; } @Override - public void actionPerformed(ActionEvent e) { + public void mouseClicked(MouseEvent e) { ElementCasePane elementCasePane = getCurrentElementCase(); if (elementCasePane == null || isAlreadyAddListener) { return; } - oldSelection = (CellSelection) elementCasePane.getSelection(); - elementCasePane.getGrid().setNotShowingTableSelectPane(false); - elementCasePane.setEditable(false); - elementCasePane.repaint(10); - + prepareSelectHeader(elementCasePane); gridSelectionChangeListener = new SelectionListener() { @Override public void selectionChanged(SelectionEvent e) { - Selection selection = elementCasePane.getSelection(); - if (selection instanceof CellSelection) { - CellSelection cellselection = (CellSelection) selection; - ColumnRow cr = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow()); - elementCasePane.setOldSelecton(oldSelection); - columnRowPane.setColumnRow(cr); - } - elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener); - isAlreadyAddListener = false; - elementCasePane.getGrid().setNotShowingTableSelectPane(true); - elementCasePane.setEditable(true); - elementCasePane.repaint(); + completeSelectHeader(elementCasePane); } }; elementCasePane.addSelectionChangeListener(gridSelectionChangeListener); isAlreadyAddListener = true; } - } - private ElementCasePane getCurrentElementCase() { - try { - TargetComponent targetComponent - = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); - if (targetComponent instanceof ElementCasePane) { - return (ElementCasePane) targetComponent; + private void prepareSelectHeader(ElementCasePane elementCasePane) { + ashDisableHeaderCellsStyle(elementCasePane.getEditingElementCase()); + oldSelection = (CellSelection) elementCasePane.getSelection(); + elementCasePane.getGrid().setNotShowingTableSelectPane(false); + elementCasePane.setEditable(false); + elementCasePane.repaint(10); + } + + private void completeSelectHeader(ElementCasePane elementCasePane) { + Selection selection = elementCasePane.getSelection(); + if (selection instanceof CellSelection) { + CellSelection cellselection = (CellSelection) selection; + ColumnRow columnRow = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow()); + elementCasePane.setOldSelecton(oldSelection); + oldSelection.getQuickEditor(elementCasePane); + if (!disableHeaderCellsStyleMap.keySet().contains(columnRow)) { + columnRowPane.setColumnRow(columnRow); + } + restoreDisableHeaderCellsStyle(elementCasePane.getEditingElementCase()); + } + elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener); + isAlreadyAddListener = false; + elementCasePane.getGrid().setNotShowingTableSelectPane(true); + elementCasePane.setEditable(true); + elementCasePane.repaint(); + } + + private void ashDisableHeaderCellsStyle(TemplateElementCase elementCase) { + disableHeaderCellsStyleMap = new HashMap<>(); + tempHeaderCells = new ArrayList<>(); + Map disableHeaderCellsMap = getDisableHeaderCellsMap(elementCase); + for (ColumnRow headerColumnRow : disableHeaderCellsMap.keySet()) { + TemplateCellElement headerCell = disableHeaderCellsMap.get(headerColumnRow); + if (headerCell == null) { + headerCell = new DefaultTemplateCellElement(headerColumnRow.column, headerColumnRow.row); + elementCase.addCellElement(headerCell); + tempHeaderCells.add(headerCell); + } + Style style = headerCell.getStyle(); + disableHeaderCellsStyleMap.put(headerColumnRow, style); + style = style.deriveBackground(ColorBackground.getInstance(Color.gray)); + headerCell.setStyle(style); } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e, e.getMessage()); } - return null; + + private void restoreDisableHeaderCellsStyle(TemplateElementCase elementCase) { + try { + for (ColumnRow headerColumnRow : disableHeaderCellsStyleMap.keySet()) { + TemplateCellElement headerTemplateCellElement + = elementCase.getTemplateCellElement(headerColumnRow.column, headerColumnRow.row); + headerTemplateCellElement.setStyle(disableHeaderCellsStyleMap.get(headerColumnRow)); + } + for (TemplateCellElement templateCellElement : tempHeaderCells) { + elementCase.removeCellElement(templateCellElement); + } + disableHeaderCellsStyleMap = new HashMap<>(); + tempHeaderCells = new ArrayList<>(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + } + + private Map getDisableHeaderCellsMap(TemplateElementCase elementCase) { + Map headerCellsMap = new HashMap<>(); + Iterator iterator = elementCase.cellIterator(); + while (iterator.hasNext()) { + TemplateCellElement templateCellElement = (TemplateCellElement) iterator.next(); + CellExpandAttr cellExpandAttr = templateCellElement.getCellExpandAttr(); + if (cellExpandAttr != null) { + handleDisableHeaderCell(elementCase, cellExpandAttr, headerCellsMap); + } + Object value = templateCellElement.getValue(); + if (value instanceof DSColumn) { + handleDisableHeaderCell(elementCase, (DSColumn) value, headerCellsMap); + } + } + return headerCellsMap; + } + + private void handleDisableHeaderCell(TemplateElementCase elementCase, CellSortable cellSortable, Map headerCellsMap) { + if (cellSortable.getCellSortAttr() != null) { + SortHeader sortHeader = cellSortable.getCellSortAttr().getSortHeader(); + if (sortHeader != null) { + String headerArea = sortHeader.getHeaderArea(); + if (headerArea != null) { + ColumnRow headerColumnRow = ColumnRow.valueOf(headerArea); + ColumnRow columnRow = columnRowPane.updateBean(); + if (!headerColumnRow.equals(columnRow)) { + TemplateCellElement headerCell + = elementCase.getTemplateCellElement(headerColumnRow.column, headerColumnRow.row); + headerCellsMap.put(headerColumnRow, headerCell); + } + } + } + } + } + + private ElementCasePane getCurrentElementCase() { + try { + TargetComponent targetComponent + = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); + if (targetComponent instanceof ElementCasePane) { + return (ElementCasePane) targetComponent; + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + return null; + } } + protected void refresh() { validate(); repaint(); diff --git a/designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java b/designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java index c5537ff533..3e9dece09d 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java @@ -31,6 +31,7 @@ public class SortUIExpandablePane extends JPanel { initComponents(); wrapPane.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); wrapPane.setBackground(Color.WHITE); + this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 5)); } diff --git a/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java index 5a15f78c16..50344f1b64 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java @@ -1,6 +1,5 @@ package com.fr.design.sort.expressionpane; -import com.fr.base.BaseUtils; import com.fr.base.svg.IconUtils; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.ibutton.UIButton; @@ -29,11 +28,10 @@ public class CustomSequencePane extends JPanel { protected void initComponents(int width) { textField = new UITextField(); textField.setEditable(false); - textField.setPreferredSize(new Dimension(width - 20, 20)); + textField.setPreferredSize(new Dimension(width - 20, AbstractSortPane.PANE_COMPONENT_HEIGHT)); Icon icon = IconUtils.readIcon("/com/fr/design/images/control/refresh.png"); button = new UIButton(icon); button.setBackground(Color.RED); - button.setPreferredSize(new Dimension(24, 20)); button.setOpaque(false); button.setCursor(new Cursor(Cursor.HAND_CURSOR)); button.addActionListener(new ActionListener() { @@ -48,7 +46,7 @@ public class CustomSequencePane extends JPanel { }, new Dimension(700, 400)).setVisible(true); } }); - button.setPreferredSize(new Dimension(24, AbstractSortPane.PANE_COMPONENT_HEIGHT)); + button.setPreferredSize(new Dimension(20, AbstractSortPane.PANE_COMPONENT_HEIGHT)); this.add(textField); this.add(button); diff --git a/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java index 3e20d5de92..69dac2a2ab 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java @@ -13,10 +13,8 @@ public class CustomSequenceSortExpressionPane extends SortExpressionPane数据集>高级设置>结果排序设置面板 - * - * @see com.fr.design.expand.SortExpandAttrPane - * @see DSColumnAdvancedPane.SortPane - */ - public class ResultSetSortConfigPane extends JPanel { - private static final String DEFAULT_VALUE = "="; - private JPanel contentPane; - private UIButtonGroup sortTypePane; - private JFormulaField formulaField; - private CardLayout cardLayout; - private JPanel centerPane; - - - public ResultSetSortConfigPane() { - this.setLayout(new BorderLayout()); - 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 = {Toolkit.i18nText("Fine-Design_Report_Sort_Original"), Toolkit.i18nText("Fine-Design_Report_Sort_Ascending"), Toolkit.i18nText("Fine-Design_Report_Sort_Descending")}; - sortTypePane = new UIButtonGroup(iconArray); - sortTypePane.setAllToolTips(nameArray); - sortTypePane.setGlobalName(Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand")); - - cardLayout = new CardLayout(); - centerPane = new JPanel(cardLayout); - formulaField = new JFormulaField(DEFAULT_VALUE); - centerPane.add(new JPanel(), "none"); - centerPane.add(formulaField, "content"); - UILabel sortLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order")); - sortLabel.setPreferredSize(LABEL_DIMENSION); - sortTypePane.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - boolean noContent = sortTypePane.getSelectedIndex() == 0; - cardLayout.show(centerPane, noContent ? "none" : "content"); - if (noContent) { - centerPane.setPreferredSize(new Dimension(0, 0)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); - } else { - centerPane.setPreferredSize(new Dimension(165, 20)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); - } - } - }); - - Component[][] components = new Component[][]{ - new Component[]{sortLabel, sortTypePane}, - new Component[]{null, centerPane} - }; - - double[] rowSize = {P, P}, columnSize = {P, F}; - contentPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); - this.add(contentPane, BorderLayout.CENTER); - } - - - /** - * 刷新面板信息 - * - * @param cellElement 单元格 - */ - public void populate(TemplateCellElement cellElement) { - if (cellElement != null) { - Object value = cellElement.getValue(); - if (value instanceof DSColumn) { - this.formulaField.populateElement(cellElement); - DSColumn dSColumn = (DSColumn) value; - int sort = dSColumn.getOrder(); - this.sortTypePane.setSelectedIndex(sort); - boolean noContent = sortTypePane.getSelectedIndex() == 0; - cardLayout.show(centerPane, noContent ? "none" : "content"); - if (noContent) { - centerPane.setPreferredSize(new Dimension(0, 0)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); - } else { - centerPane.setPreferredSize(new Dimension(156, 20)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); - } - String sortFormula = dSColumn.getSortFormula(); - if (sortFormula != null && sortFormula.length() >= 1) { - this.formulaField.populate(sortFormula); - } else { - this.formulaField.populate(DEFAULT_VALUE); - } - } - } - } - - /** - * 保存面板配置信息 - * - * @param cellElement 单元格 - */ - public void update(CellElement cellElement) { - if (cellElement != null) { - Object value = cellElement.getValue(); - if (value instanceof DSColumn) { - DSColumn dSColumn = (DSColumn) value; - dSColumn.setOrder(this.sortTypePane.getSelectedIndex()); - dSColumn.setSortFormula(this.formulaField.getFormulaText()); - } - } - } - - /** - * 添加事件监听器 - * - * @param formulaChangeListener 公式输入框改动事件监听器 - * @param changeListener 排序类型下拉框改动事件监听器 - */ - public void addListener(UIObserverListener formulaChangeListener, ChangeListener changeListener) { - formulaField.addListener(formulaChangeListener); - sortTypePane.addChangeListener(changeListener); - } - - /** - * 去除事件监听器 - * - * @param changeListener 排序类型下拉框改动事件监听器 - */ - public void removeListener(ChangeListener changeListener) { - formulaField.removeListener(); - sortTypePane.removeChangeListener(changeListener); - } - } - /** * 单元格元素>数据集>高级设置>结果集筛选设置面板 *