Browse Source

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

newui
obo 1 year ago
parent
commit
654c82e2b2
  1. 19
      designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java

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

@ -24,6 +24,8 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class HeaderSortRulePane extends JPanel { public class HeaderSortRulePane extends JPanel {
IconButton ascIconButton; IconButton ascIconButton;
@ -37,7 +39,7 @@ public class HeaderSortRulePane extends JPanel {
HeaderSortRulePane() { HeaderSortRulePane() {
initComponents(); initComponents();
initState(true); initState(true, null);
this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15));
} }
@ -78,13 +80,24 @@ public class HeaderSortRulePane extends JPanel {
}); });
} }
void initState(boolean selected) { void initState(boolean selected, SortHeader.SortItem[] items) {
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 {
@ -217,7 +230,7 @@ public class HeaderSortRulePane extends JPanel {
} }
public void populateBean(SortHeader.SortItem[] sortItems) { public void populateBean(SortHeader.SortItem[] sortItems) {
initState(sortItems == null); initState(sortItems == null, sortItems);
if (sortItems != null) { if (sortItems != null) {
for (SortHeader.SortItem sortItem : sortItems) { for (SortHeader.SortItem sortItem : sortItems) {
SortRule sortRule = sortItem.getSortRule(); SortRule sortRule = sortItem.getSortRule();

Loading…
Cancel
Save