Browse Source

REPORT-97591 排序按钮设置颜色后,新增排序规则保存并关闭模板,再次打开排序按钮颜色丢失

release/11.0
obo 1 year ago
parent
commit
d549821917
  1. 27
      designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java

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

@ -39,7 +39,7 @@ public class HeaderSortRulePane extends JPanel {
HeaderSortRulePane() { HeaderSortRulePane() {
initComponents(); initComponents();
initState(true, null); initState(true);
this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15));
} }
@ -80,24 +80,13 @@ public class HeaderSortRulePane extends JPanel {
}); });
} }
void initState(boolean selected, SortHeader.SortItem[] items) { void initState(boolean selected) {
ascUICheckBox.setSelected(selected); ascUICheckBox.setSelected(selected);
desUICheckBox.setSelected(selected); desUICheckBox.setSelected(selected);
nosortUICheckBox.setSelected(selected); nosortUICheckBox.setSelected(selected);
if(items==null){ ascIconButton.refreshIconLabelColor(new FineColor(defaultColor));
ascIconButton.refreshIconLabelColor(new FineColor(defaultColor)); desIconButton.refreshIconLabelColor(new FineColor(defaultColor));
desIconButton.refreshIconLabelColor(new FineColor(defaultColor)); nosortIconButton.refreshIconLabelColor(new FineColor(defaultColor));
nosortIconButton.refreshIconLabelColor(new FineColor(defaultColor));
} else {
Map<SortRule, FineColor> colorMap = new HashMap<>(items.length);
for (SortHeader.SortItem item : items) {
colorMap.put(item.getSortRule(), item.getFineColor());
}
ascIconButton.refreshIconLabelColor(colorMap.getOrDefault(SortRule.ASC, new FineColor(defaultColor)));
desIconButton.refreshIconLabelColor(colorMap.getOrDefault(SortRule.DES, new FineColor(defaultColor)));
nosortIconButton.refreshIconLabelColor(colorMap.getOrDefault(SortRule.NO_SORT, new FineColor(defaultColor)));
}
} }
class IconButton extends JPanel implements UIObserver, PopupHider { class IconButton extends JPanel implements UIObserver, PopupHider {
@ -230,19 +219,23 @@ public class HeaderSortRulePane extends JPanel {
} }
public void populateBean(SortHeader.SortItem[] sortItems) { public void populateBean(SortHeader.SortItem[] sortItems) {
initState(sortItems == null, sortItems); 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();
BufferedImage bufferedImage = sortItem.getBufferedImage(); BufferedImage bufferedImage = sortItem.getBufferedImage();
FineColor fineColor = sortItem.getFineColor();
if (sortRule == SortRule.ASC) { if (sortRule == SortRule.ASC) {
ascIconButton.refreshIconLabel(bufferedImage); ascIconButton.refreshIconLabel(bufferedImage);
ascIconButton.refreshIconLabelColor(fineColor);
ascUICheckBox.setSelected(true); ascUICheckBox.setSelected(true);
} else if (sortRule == SortRule.DES) { } else if (sortRule == SortRule.DES) {
desIconButton.refreshIconLabel(bufferedImage); desIconButton.refreshIconLabel(bufferedImage);
desIconButton.refreshIconLabelColor(fineColor);
desUICheckBox.setSelected(true); desUICheckBox.setSelected(true);
} else if (sortRule == SortRule.NO_SORT) { } else if (sortRule == SortRule.NO_SORT) {
nosortIconButton.refreshIconLabel(bufferedImage); nosortIconButton.refreshIconLabel(bufferedImage);
nosortIconButton.refreshIconLabelColor(fineColor);
nosortUICheckBox.setSelected(true); nosortUICheckBox.setSelected(true);
} }
} }

Loading…
Cancel
Save