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