Browse Source

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

newui
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() {
initComponents();
initState(true, null);
initState(true);
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);
desUICheckBox.setSelected(selected);
nosortUICheckBox.setSelected(selected);
if(items==null){
ascIconButton.refreshIconLabelColor(new FineColor(defaultColor));
desIconButton.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)));
}
ascIconButton.refreshIconLabelColor(new FineColor(defaultColor));
desIconButton.refreshIconLabelColor(new FineColor(defaultColor));
nosortIconButton.refreshIconLabelColor(new FineColor(defaultColor));
}
class IconButton extends JPanel implements UIObserver, PopupHider {
@ -230,19 +219,23 @@ public class HeaderSortRulePane extends JPanel {
}
public void populateBean(SortHeader.SortItem[] sortItems) {
initState(sortItems == null, sortItems);
initState(sortItems == null);
if (sortItems != null) {
for (SortHeader.SortItem sortItem : sortItems) {
SortRule sortRule = sortItem.getSortRule();
BufferedImage bufferedImage = sortItem.getBufferedImage();
FineColor fineColor = sortItem.getFineColor();
if (sortRule == SortRule.ASC) {
ascIconButton.refreshIconLabel(bufferedImage);
ascIconButton.refreshIconLabelColor(fineColor);
ascUICheckBox.setSelected(true);
} else if (sortRule == SortRule.DES) {
desIconButton.refreshIconLabel(bufferedImage);
desIconButton.refreshIconLabelColor(fineColor);
desUICheckBox.setSelected(true);
} else if (sortRule == SortRule.NO_SORT) {
nosortIconButton.refreshIconLabel(bufferedImage);
nosortIconButton.refreshIconLabelColor(fineColor);
nosortUICheckBox.setSelected(true);
}
}

Loading…
Cancel
Save