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 bfddee38c2..071d587067 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 @@ -75,7 +75,7 @@ public abstract class AbstractSortPane extends JPanel { int row = cellElement.getRow(); int column = cellElement.getColumn(); selfSortArea = ColumnRow.valueOf(column, row).toString(); - if (row > 1) { + if (row > 0) { defaultHeaderArea = ColumnRow.valueOf(column, row - 1).toString(); } else { defaultHeaderArea = 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 68824f012d..31057c724b 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 @@ -42,8 +42,8 @@ public class HeaderAreaPane extends JPanel { this.add(areaJLayeredPane); } - public void populateBean(ColumnRow columnRow) { - areaJLayeredPane.populateBean(columnRow); + public void populateBean(ColumnRow columnRow, boolean showHeaderArea) { + areaJLayeredPane.populateBean(columnRow, showHeaderArea); } public ColumnRow updateBean() { @@ -97,8 +97,8 @@ public class HeaderAreaPane extends JPanel { this.add(jLayeredPane); } - public void populateBean(ColumnRow columnRow) { - if (SortColumnRowPane.isAvailableColumnRow(columnRow)) { + public void populateBean(ColumnRow columnRow, boolean showHeaderArea) { + if (showHeaderArea) { uiComboBox.setSelectedIndex(1); } else { uiComboBox.setSelectedIndex(0); 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 2dcd3bc487..71ecf9ced2 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 @@ -36,7 +36,7 @@ public class HeaderSortRulePane extends JPanel { HeaderSortRulePane() { initComponents(); - initState(); + initState(true); this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); } @@ -62,12 +62,24 @@ public class HeaderSortRulePane extends JPanel { double[] columnSize = {80, 30}; JPanel sortRuleItem = TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, 0); this.add(sortRuleItem, BorderLayout.CENTER); + initUICheckBoxChange(ascUICheckBox, ascIconButton); + initUICheckBoxChange(desUICheckBox, desIconButton); + initUICheckBoxChange(nosortUICheckBox, nosortIconButton); } - void initState() { - ascUICheckBox.setSelected(false); - desUICheckBox.setSelected(false); - nosortUICheckBox.setSelected(false); + void initUICheckBoxChange(UICheckBox uiCheckBox, IconButton iconButton) { + uiCheckBox.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + iconButton.setActiveState(uiCheckBox.isSelected()); + } + }); + } + + void initState(boolean selected) { + ascUICheckBox.setSelected(selected); + desUICheckBox.setSelected(selected); + nosortUICheckBox.setSelected(selected); ascIconButton.refreshIconLabelColor(new Color(33, 33, 34)); desIconButton.refreshIconLabelColor(new Color(33, 33, 34)); nosortIconButton.refreshIconLabelColor(new Color(33, 33, 34)); @@ -81,21 +93,36 @@ public class HeaderSortRulePane extends JPanel { Color color; BufferedImage bufferedImage; UIObserverListener uiObserverListener; + boolean activeState; + UILabel borderUiLabel; IconButton(String iconTemplatePath) { this.iconTemplatePath = iconTemplatePath; initComponents(); } + public boolean isActiveState() { + return activeState; + } + + public void setActiveState(boolean activeState) { + if (activeState) { + borderUiLabel.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); + colorButton.setVisible(true); + } else { + borderUiLabel.setBorder(null); + colorButton.setVisible(false); + } + this.activeState = activeState; + } + void initComponents() { jLayeredPane = new JLayeredPane(); iconLabel = getIconLabel(iconTemplatePath); - - - UILabel emptyUiLabel = new UILabel(); - emptyUiLabel.setSize(16, 16); - emptyUiLabel.setOpaque(true); - emptyUiLabel.setBackground(Color.WHITE); + borderUiLabel = new UILabel(); + borderUiLabel.setSize(16, 16); + borderUiLabel.setOpaque(true); + borderUiLabel.setBackground(Color.WHITE); iconLabel.setSize(16, 16); colorButton = new ColorListPane.ColorButton(Color.CYAN); colorButton.setSize(16, 16); @@ -110,7 +137,7 @@ public class HeaderSortRulePane extends JPanel { jLayeredPane.setPreferredSize(new Dimension(16, 16)); jLayeredPane.add(iconLabel, JLayeredPane.POPUP_LAYER); - jLayeredPane.add(emptyUiLabel, JLayeredPane.MODAL_LAYER); + jLayeredPane.add(borderUiLabel, JLayeredPane.MODAL_LAYER); jLayeredPane.add(colorButton, JLayeredPane.PALETTE_LAYER); this.add(jLayeredPane); } @@ -192,7 +219,7 @@ public class HeaderSortRulePane extends JPanel { } public void populateBean(SortHeader.SortItem[] sortItems) { - initState(); + initState(sortItems == null); if (sortItems != null) { for (SortHeader.SortItem sortItem : sortItems) { SortRule sortRule = sortItem.getSortRule(); 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 7aecb30008..0235a10fb9 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 @@ -1,5 +1,6 @@ package com.fr.design.sort.header; +import com.fr.design.sort.common.SortColumnRowPane; import com.fr.report.core.sort.header.SortHeader; import com.fr.stable.ColumnRow; @@ -33,16 +34,17 @@ public class SortHeaderPane extends JPanel { public void populateBean(SortHeader sortHeader, String defaultHeaderArea) { this.sortHeader = sortHeader; + boolean showHeaderArea = false; ColumnRow columnRow = null; SortHeader.SortItem[] sortItems = null; String headerArea = defaultHeaderArea; if (sortHeader != null) { headerArea = sortHeader.getHeaderArea(); sortItems = sortHeader.getSortItems(); + showHeaderArea = SortColumnRowPane.isAvailableColumnRow(ColumnRow.valueOf(headerArea)); } columnRow = ColumnRow.valueOf(headerArea); - - headerAreaPane.populateBean(columnRow); + headerAreaPane.populateBean(columnRow, showHeaderArea); headerSettingPane.populateBean(sortItems); }