From 5efe0fc83dfd429a7aa486623e238e4306a9cd7c Mon Sep 17 00:00:00 2001 From: wtianye <10320502+wtianye@user.noreply.gitee.com> Date: Thu, 20 Jan 2022 16:53:29 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-66044=20=E5=8D=95=E5=85=83=E6=A0=BC?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E4=BB=A5=E5=90=8E=EF=BC=8C=E4=BC=9A=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E4=B8=A4=E4=B8=AA=E5=8D=95=E5=85=83=E6=A0=BC=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=90=8C=E4=B8=80=E4=B8=AA=E8=A1=A8=E5=A4=B4=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=20&&=20REPORT-66020=20=E7=82=B9=E5=87=BB=E6=99=BA?= =?UTF-8?q?=E8=83=BD=E6=A1=86=E9=80=89=E5=90=8E=E6=92=A4=E9=94=80=EF=BC=8C?= =?UTF-8?q?=E9=BC=A0=E6=A0=87=E7=8A=B6=E6=80=81=E6=B2=A1=E6=9C=89=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=E9=BB=98=E8=AE=A4=20&&=20REPORT-65994=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=8E=92=E5=BA=8F=E6=8C=89=E9=92=AE=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BA=A4=E4=BA=92=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=20&&=20REPORT-65993=20=E8=A1=A8=E5=A4=B4=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=E6=9C=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sort/common/AbstractSortGroupPane.java | 19 ++++++ .../design/sort/common/AbstractSortPane.java | 2 +- .../design/sort/common/SortColumnRowPane.java | 44 ++++++------- .../sort/common/SortUIExpandablePane.java | 9 ++- .../com/fr/design/sort/common/SortUtils.java | 24 ++++++++ .../fr/design/sort/header/HeaderAreaPane.java | 61 +++++++++---------- .../sort/header/HeaderSortRulePane.java | 1 + .../fr/design/sort/header/SortHeaderPane.java | 4 +- 8 files changed, 106 insertions(+), 58 deletions(-) create mode 100644 designer-realize/src/main/java/com/fr/design/sort/common/SortUtils.java 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 db6f574bd6..8a90b960e0 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 @@ -123,11 +123,30 @@ public abstract class AbstractSortGroupPane extends JPanel implements ComponentC } protected void refresh() { + freshAddSortItemBarTip(); + freshSortUIExpandablePaneTip(); validate(); repaint(); revalidate(); } + void freshAddSortItemBarTip() { + if (sortUIExpandablePanes != null) { + int itemCount = sortUIExpandablePanes.size(); + uiButton.setText(itemCount == 0 ? Toolkit.i18nText("Fine-Design_Sort_Add_Main_Sort") : Toolkit.i18nText("Fine-Design_Sort_Add_Second_Sort")); + } + } + + void freshSortUIExpandablePaneTip() { + for (int i = 0; i < sortUIExpandablePanes.size(); i++) { + if (i == 0) { + sortUIExpandablePanes.get(i).freshHeaderPaneTip(Toolkit.i18nText("Fine-Design_Sort_Main_Sort")); + } else { + sortUIExpandablePanes.get(i).freshHeaderPaneTip(Toolkit.i18nText("Fine-Design_Sort_Second_Sort")); + } + } + } + class AddSortItemBar extends JPanel { AbstractSortGroupPane sortGroupPane; 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 6491d04a8e..227708e7a1 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 @@ -65,7 +65,7 @@ public abstract class AbstractSortPane extends JPanel { if (cellSortAttr != null) { sortHeader = cellSortAttr.getSortHeader(); } - sortHeaderPane.populateBean(sortHeader, defaultHeaderArea); + sortHeaderPane.populateBean(sortHeader, defaultHeaderArea, cellElement); } 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 653ce86c8c..e9ebbd882c 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 @@ -50,6 +50,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver { private final static Icon DISABLED_ICON = IconUtils.readIcon("/com/fr/design/images/buttonicon/select_disabled.svg"); private final static Icon ENABLE_ICON = IconUtils.readIcon("/com/fr/design/images/buttonicon/select_normal.svg"); private boolean enabled; + SelectActionListener selectActionListener; HeaderAreaPane.CellSelectionManager cellSelectionManager; @@ -94,7 +95,8 @@ public class SortColumnRowPane extends JPanel implements UIObserver { void initSelectButton() { selectButton = new UIButton(ENABLE_ICON); - selectButton.addMouseListener(new SelectActionListener(this)); + selectActionListener = new SelectActionListener(this); + selectButton.addMouseListener(selectActionListener); this.add(selectButton); } @@ -147,6 +149,11 @@ public class SortColumnRowPane extends JPanel implements UIObserver { return true; } + + public void cancelSelectState() { + selectActionListener.recoverSelectHeader(SortUtils.getCurrentElementCase()); + } + class SelectActionListener extends MouseAdapter { SortColumnRowPane columnRowPane; ColumnRow oldColumnRow; @@ -161,7 +168,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver { @Override public void mouseClicked(MouseEvent e) { if (enabled) { - ElementCasePane elementCasePane = getCurrentElementCase(); + ElementCasePane elementCasePane = SortUtils.getCurrentElementCase(); if (elementCasePane == null || isAlreadyAddListener) { return; } @@ -201,15 +208,21 @@ public class SortColumnRowPane extends JPanel implements UIObserver { } columnRowPane.setColumnRow(columnRow); } + } + recoverSelectHeader(elementCasePane); + } + + private void recoverSelectHeader(ElementCasePane elementCasePane) { + if (isAlreadyAddListener) { restoreDisableHeaderCellsStyle(elementCasePane.getEditingElementCase()); + elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener); + isAlreadyAddListener = false; + elementCasePane.getGrid().setNotShowingTableSelectPane(true); + elementCasePane.setRepeatSelection(false); + elementCasePane.setEditable(true); + elementCasePane.repaint(); + oldColumnRow = null; } - elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener); - isAlreadyAddListener = false; - elementCasePane.getGrid().setNotShowingTableSelectPane(true); - elementCasePane.setRepeatSelection(false); - elementCasePane.setEditable(true); - elementCasePane.repaint(); - oldColumnRow = null; } private void ashDisableHeaderCellsStyle(TemplateElementCase elementCase) { @@ -263,17 +276,4 @@ public class SortColumnRowPane extends JPanel implements UIObserver { repaint(); revalidate(); } - - public static 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; - } } \ No newline at end of file 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 6de6636f4c..eef21bb060 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 @@ -63,7 +63,12 @@ public class SortUIExpandablePane extends JPanel { headerPane.setShow(show); } + public void freshHeaderPaneTip(String tip) { + headerPane.tipUILabel.setText(tip); + } + class HeaderPane extends JPanel implements UIObserver { + UILabel tipUILabel; UILabel iconUiLabel; UILabel closeButton; AbstractSortGroupPane sortGroupPane; @@ -78,8 +83,8 @@ public class SortUIExpandablePane extends JPanel { private void initComponents() { iconUiLabel = new UILabel(); this.add(iconUiLabel); - UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Sort_Second_Sort")); - this.add(uiLabel); + tipUILabel = new UILabel(Toolkit.i18nText("Fine-Design_Sort_Second_Sort")); + this.add(tipUILabel); this.add(AbstractSortPane.createIntervalUILabel(108)); closeButton = new UILabel(IconUtils.readIcon("/com/fr/design/images/control/close.png")); diff --git a/designer-realize/src/main/java/com/fr/design/sort/common/SortUtils.java b/designer-realize/src/main/java/com/fr/design/sort/common/SortUtils.java new file mode 100644 index 0000000000..32ee1a764c --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/common/SortUtils.java @@ -0,0 +1,24 @@ +package com.fr.design.sort.common; + +import com.fr.design.designer.TargetComponent; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.JTemplate; +import com.fr.log.FineLoggerFactory; + +public class SortUtils { + public static ElementCasePane getCurrentElementCase() { + try { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jTemplate != null) { + TargetComponent targetComponent = jTemplate.getCurrentElementCasePane(); + if (targetComponent instanceof ElementCasePane) { + return (ElementCasePane) targetComponent; + } + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + return null; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/sort/header/HeaderAreaPane.java b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderAreaPane.java index 95da80c8ca..25641340cb 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/header/HeaderAreaPane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderAreaPane.java @@ -8,6 +8,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.sort.common.AbstractSortPane; import com.fr.design.sort.common.SortColumnRowPane; +import com.fr.design.sort.common.SortUtils; import com.fr.log.FineLoggerFactory; import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.CellExpandAttr; @@ -35,6 +36,7 @@ public class HeaderAreaPane extends JPanel { protected int headerAreaPaneWidth; protected int headerAreaPaneRightWidth; private CellSelectionManager cellSelectionManager = new CellSelectionManager(); + TemplateCellElement cellElement; AreaJLayeredPane areaJLayeredPane; @@ -62,9 +64,10 @@ public class HeaderAreaPane extends JPanel { this.add(areaJLayeredPane); } - public void populateBean(ColumnRow columnRow, boolean showHeaderArea) { + public void populateBean(ColumnRow columnRow, boolean showHeaderArea, TemplateCellElement cellElement) { + this.cellElement = cellElement; boolean enabled = true; - ElementCasePane elementCasePane = getCurrentElementCase(); + ElementCasePane elementCasePane = SortUtils.getCurrentElementCase(); if (elementCasePane != null) { enabled = elementCasePane.isSelectedOneCell(); } @@ -72,7 +75,7 @@ public class HeaderAreaPane extends JPanel { } public ColumnRow updateBean(TemplateCellElement cellElement) { - ElementCasePane elementCasePane = getCurrentElementCase(); + ElementCasePane elementCasePane = SortUtils.getCurrentElementCase(); if (elementCasePane != null) { if (!elementCasePane.isSelectedOneCell()) { return getOldColumnRow(cellElement); @@ -96,19 +99,6 @@ public class HeaderAreaPane extends JPanel { } } - 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; - } - class AreaJLayeredPane extends JPanel { SortColumnRowPane columnRowPane; JLayeredPane jLayeredPane; @@ -151,6 +141,7 @@ public class HeaderAreaPane extends JPanel { } } else { cellSelectionManager.removeNotSelectables(columnRowPane.updateBean()); + columnRowPane.cancelSelectState(); } } @@ -176,7 +167,8 @@ public class HeaderAreaPane extends JPanel { } public void populateBean(ColumnRow columnRow, boolean showHeaderArea, boolean enabled) { - cellSelectionManager.build(); + cellSelectionManager.build(cellElement, columnRow); + columnRow = cellSelectionManager.buildCurrentCell(cellElement, columnRow); columnRowPane.populateBean(columnRow, enabled, cellSelectionManager); setSortColumnRowPaneShow(showHeaderArea); uiComboBox.setSelectedIndex(showHeaderArea ? 1 : 0); @@ -203,15 +195,26 @@ public class HeaderAreaPane extends JPanel { ElementCasePane elementCase; java.util.List notSelectables = new ArrayList<>(); - void build() { - ElementCasePane elementCase = SortColumnRowPane.getCurrentElementCase(); + void build(TemplateCellElement templateCellElement, ColumnRow headerColumnRow) { + ElementCasePane elementCase = SortUtils.getCurrentElementCase(); if (elementCase != null) { this.elementCase = elementCase; notSelectables = new ArrayList<>(); - buildNotSelectables(elementCase.getEditingElementCase()); + buildNotSelectables(elementCase.getEditingElementCase(), templateCellElement); } } + private ColumnRow buildCurrentCell(TemplateCellElement templateCellElement, ColumnRow headerColumnRow) { + if (isNotSelectables(headerColumnRow)) { + SortHeader sortHeader = templateCellElement.getCellExpandAttr().getCellSortAttr().getSortHeader(); + headerColumnRow = ColumnRow.ERROR; + sortHeader.setHeaderArea(headerColumnRow.toString()); + } else { + handleDisableHeaderCell(templateCellElement); + } + return headerColumnRow; + } + public java.util.List getNotSelectables() { return this.notSelectables; } @@ -232,24 +235,20 @@ public class HeaderAreaPane extends JPanel { notSelectables.remove(columnRow); } - private void buildNotSelectables(TemplateElementCase elementCase) { + private void buildNotSelectables(TemplateElementCase elementCase, TemplateCellElement excludeTemplateCellElement) { Iterator iterator = elementCase.cellIterator(); while (iterator.hasNext()) { TemplateCellElement templateCellElement = (TemplateCellElement) iterator.next(); - CellExpandAttr cellExpandAttr = templateCellElement.getCellExpandAttr(); - if (cellExpandAttr != null) { - handleDisableHeaderCell(cellExpandAttr); - } - Object value = templateCellElement.getValue(); - if (value instanceof DSColumn) { - handleDisableHeaderCell((DSColumn) value); + if (templateCellElement != excludeTemplateCellElement) { + handleDisableHeaderCell(templateCellElement); } } } - private void handleDisableHeaderCell(CellSortable cellSortable) { - if (cellSortable.getCellSortAttr() != null) { - SortHeader sortHeader = cellSortable.getCellSortAttr().getSortHeader(); + private void handleDisableHeaderCell(TemplateCellElement templateCellElement) { + CellExpandAttr cellExpandAttr = templateCellElement.getCellExpandAttr(); + if (cellExpandAttr != null && cellExpandAttr.getCellSortAttr() != null) { + SortHeader sortHeader = cellExpandAttr.getCellSortAttr().getSortHeader(); if (sortHeader != null) { String headerArea = sortHeader.getHeaderArea(); if (headerArea != null) { diff --git a/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java index 172db28aec..27c03e9e01 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java @@ -135,6 +135,7 @@ public class HeaderSortRulePane extends JPanel { } void refreshIconLabelColor(FineColor fineColor) { + this.fineColor = fineColor; Icon icon = getIcon(fineColor); refreshIconLabel(icon); } diff --git a/designer-realize/src/main/java/com/fr/design/sort/header/SortHeaderPane.java b/designer-realize/src/main/java/com/fr/design/sort/header/SortHeaderPane.java index a68d0eebe6..77802429ca 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/header/SortHeaderPane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/header/SortHeaderPane.java @@ -34,7 +34,7 @@ public class SortHeaderPane extends JPanel { this.add(headerSettingPane); } - public void populateBean(SortHeader sortHeader, String defaultHeaderArea) { + public void populateBean(SortHeader sortHeader, String defaultHeaderArea,TemplateCellElement cellElement) { this.sortHeader = sortHeader; boolean showHeaderArea = false; SortHeader.SortItem[] sortItems = null; @@ -48,7 +48,7 @@ public class SortHeaderPane extends JPanel { columnRow = ColumnRow.valueOf(headerArea); } } - headerAreaPane.populateBean(columnRow, showHeaderArea); + headerAreaPane.populateBean(columnRow, showHeaderArea, cellElement); headerSettingPane.populateBean(sortItems); }