Browse Source

REPORT-62440 表头排序内置

feature/x
Henry.Wang 3 years ago
parent
commit
9d5349d34b
  1. 2
      designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java
  2. 8
      designer-realize/src/main/java/com/fr/design/sort/header/HeaderAreaPane.java
  3. 53
      designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java
  4. 6
      designer-realize/src/main/java/com/fr/design/sort/header/SortHeaderPane.java

2
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 row = cellElement.getRow();
int column = cellElement.getColumn(); int column = cellElement.getColumn();
selfSortArea = ColumnRow.valueOf(column, row).toString(); selfSortArea = ColumnRow.valueOf(column, row).toString();
if (row > 1) { if (row > 0) {
defaultHeaderArea = ColumnRow.valueOf(column, row - 1).toString(); defaultHeaderArea = ColumnRow.valueOf(column, row - 1).toString();
} else { } else {
defaultHeaderArea = null; defaultHeaderArea = null;

8
designer-realize/src/main/java/com/fr/design/sort/header/HeaderAreaPane.java

@ -42,8 +42,8 @@ public class HeaderAreaPane extends JPanel {
this.add(areaJLayeredPane); this.add(areaJLayeredPane);
} }
public void populateBean(ColumnRow columnRow) { public void populateBean(ColumnRow columnRow, boolean showHeaderArea) {
areaJLayeredPane.populateBean(columnRow); areaJLayeredPane.populateBean(columnRow, showHeaderArea);
} }
public ColumnRow updateBean() { public ColumnRow updateBean() {
@ -97,8 +97,8 @@ public class HeaderAreaPane extends JPanel {
this.add(jLayeredPane); this.add(jLayeredPane);
} }
public void populateBean(ColumnRow columnRow) { public void populateBean(ColumnRow columnRow, boolean showHeaderArea) {
if (SortColumnRowPane.isAvailableColumnRow(columnRow)) { if (showHeaderArea) {
uiComboBox.setSelectedIndex(1); uiComboBox.setSelectedIndex(1);
} else { } else {
uiComboBox.setSelectedIndex(0); uiComboBox.setSelectedIndex(0);

53
designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java

@ -36,7 +36,7 @@ public class HeaderSortRulePane extends JPanel {
HeaderSortRulePane() { HeaderSortRulePane() {
initComponents(); initComponents();
initState(); initState(true);
this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15));
} }
@ -62,12 +62,24 @@ public class HeaderSortRulePane extends JPanel {
double[] columnSize = {80, 30}; double[] columnSize = {80, 30};
JPanel sortRuleItem = TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, 0); JPanel sortRuleItem = TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, 0);
this.add(sortRuleItem, BorderLayout.CENTER); this.add(sortRuleItem, BorderLayout.CENTER);
initUICheckBoxChange(ascUICheckBox, ascIconButton);
initUICheckBoxChange(desUICheckBox, desIconButton);
initUICheckBoxChange(nosortUICheckBox, nosortIconButton);
} }
void initState() { void initUICheckBoxChange(UICheckBox uiCheckBox, IconButton iconButton) {
ascUICheckBox.setSelected(false); uiCheckBox.addChangeListener(new ChangeListener() {
desUICheckBox.setSelected(false); @Override
nosortUICheckBox.setSelected(false); 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)); ascIconButton.refreshIconLabelColor(new Color(33, 33, 34));
desIconButton.refreshIconLabelColor(new Color(33, 33, 34)); desIconButton.refreshIconLabelColor(new Color(33, 33, 34));
nosortIconButton.refreshIconLabelColor(new Color(33, 33, 34)); nosortIconButton.refreshIconLabelColor(new Color(33, 33, 34));
@ -81,21 +93,36 @@ public class HeaderSortRulePane extends JPanel {
Color color; Color color;
BufferedImage bufferedImage; BufferedImage bufferedImage;
UIObserverListener uiObserverListener; UIObserverListener uiObserverListener;
boolean activeState;
UILabel borderUiLabel;
IconButton(String iconTemplatePath) { IconButton(String iconTemplatePath) {
this.iconTemplatePath = iconTemplatePath; this.iconTemplatePath = iconTemplatePath;
initComponents(); 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() { void initComponents() {
jLayeredPane = new JLayeredPane(); jLayeredPane = new JLayeredPane();
iconLabel = getIconLabel(iconTemplatePath); iconLabel = getIconLabel(iconTemplatePath);
borderUiLabel = new UILabel();
borderUiLabel.setSize(16, 16);
UILabel emptyUiLabel = new UILabel(); borderUiLabel.setOpaque(true);
emptyUiLabel.setSize(16, 16); borderUiLabel.setBackground(Color.WHITE);
emptyUiLabel.setOpaque(true);
emptyUiLabel.setBackground(Color.WHITE);
iconLabel.setSize(16, 16); iconLabel.setSize(16, 16);
colorButton = new ColorListPane.ColorButton(Color.CYAN); colorButton = new ColorListPane.ColorButton(Color.CYAN);
colorButton.setSize(16, 16); colorButton.setSize(16, 16);
@ -110,7 +137,7 @@ public class HeaderSortRulePane extends JPanel {
jLayeredPane.setPreferredSize(new Dimension(16, 16)); jLayeredPane.setPreferredSize(new Dimension(16, 16));
jLayeredPane.add(iconLabel, JLayeredPane.POPUP_LAYER); jLayeredPane.add(iconLabel, JLayeredPane.POPUP_LAYER);
jLayeredPane.add(emptyUiLabel, JLayeredPane.MODAL_LAYER); jLayeredPane.add(borderUiLabel, JLayeredPane.MODAL_LAYER);
jLayeredPane.add(colorButton, JLayeredPane.PALETTE_LAYER); jLayeredPane.add(colorButton, JLayeredPane.PALETTE_LAYER);
this.add(jLayeredPane); this.add(jLayeredPane);
} }
@ -192,7 +219,7 @@ public class HeaderSortRulePane extends JPanel {
} }
public void populateBean(SortHeader.SortItem[] sortItems) { public void populateBean(SortHeader.SortItem[] sortItems) {
initState(); initState(sortItems == null);
if (sortItems != null) { if (sortItems != null) {
for (SortHeader.SortItem sortItem : sortItems) { for (SortHeader.SortItem sortItem : sortItems) {
SortRule sortRule = sortItem.getSortRule(); SortRule sortRule = sortItem.getSortRule();

6
designer-realize/src/main/java/com/fr/design/sort/header/SortHeaderPane.java

@ -1,5 +1,6 @@
package com.fr.design.sort.header; package com.fr.design.sort.header;
import com.fr.design.sort.common.SortColumnRowPane;
import com.fr.report.core.sort.header.SortHeader; import com.fr.report.core.sort.header.SortHeader;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
@ -33,16 +34,17 @@ public class SortHeaderPane extends JPanel {
public void populateBean(SortHeader sortHeader, String defaultHeaderArea) { public void populateBean(SortHeader sortHeader, String defaultHeaderArea) {
this.sortHeader = sortHeader; this.sortHeader = sortHeader;
boolean showHeaderArea = false;
ColumnRow columnRow = null; ColumnRow columnRow = null;
SortHeader.SortItem[] sortItems = null; SortHeader.SortItem[] sortItems = null;
String headerArea = defaultHeaderArea; String headerArea = defaultHeaderArea;
if (sortHeader != null) { if (sortHeader != null) {
headerArea = sortHeader.getHeaderArea(); headerArea = sortHeader.getHeaderArea();
sortItems = sortHeader.getSortItems(); sortItems = sortHeader.getSortItems();
showHeaderArea = SortColumnRowPane.isAvailableColumnRow(ColumnRow.valueOf(headerArea));
} }
columnRow = ColumnRow.valueOf(headerArea); columnRow = ColumnRow.valueOf(headerArea);
headerAreaPane.populateBean(columnRow, showHeaderArea);
headerAreaPane.populateBean(columnRow);
headerSettingPane.populateBean(sortItems); headerSettingPane.populateBean(sortItems);
} }

Loading…
Cancel
Save