This class represents the highest level DisplayableFilter in the filter hierarchy. A FilterBar is a filter which contains a set of other DisplayableFilters. At the bottom of a FilterBar is a region of space with an arrow at the center. When this is clicked all of the children filters will be hidden
| 48 | * be hidden from view. |
| 49 | */ |
| 50 | public class FilterBar<C, E> extends JPanel implements DisplayableFilter<C, E> |
| 51 | { |
| 52 | |
| 53 | private final JPanel filterPanel = new JPanel(new FilterLayout()); |
| 54 | private final List<DisplayableFilter<? super C, ? super E>> filters = new ArrayList<>(); |
| 55 | private FilterHandler filterHandler; |
| 56 | |
| 57 | public FilterBar() |
| 58 | { |
| 59 | this(true); |
| 60 | } |
| 61 | |
| 62 | public FilterBar(boolean collapsable) |
| 63 | { |
| 64 | setLayout(new BorderLayout()); |
| 65 | add(filterPanel, BorderLayout.CENTER); |
| 66 | |
| 67 | final ArrowButton arrowbutton = new ArrowButton(); |
| 68 | arrowbutton.addMouseListener(new MouseAdapter() |
| 69 | { |
| 70 | |
| 71 | @Override |
| 72 | public void mousePressed(MouseEvent e) |
| 73 | { |
| 74 | boolean closed = !arrowbutton.isOpen(); |
| 75 | arrowbutton.setOpen(closed); |
| 76 | filterPanel.setVisible(closed); |
| 77 | } |
| 78 | |
| 79 | }); |
| 80 | if (collapsable) |
| 81 | { |
| 82 | add(arrowbutton, BorderLayout.SOUTH); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | public void addDisplayableFilter(DisplayableFilter<? super C, ? super E> filter) |
| 87 | { |
| 88 | filterPanel.add(filter.getFilterComponent()); |
| 89 | filters.add(filter); |
| 90 | filter.setFilterHandler(filterHandler); |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public Component getFilterComponent() |
| 95 | { |
| 96 | return this; |
| 97 | } |
| 98 | |
| 99 | @Override |
| 100 | public void setFilterHandler(FilterHandler handler) |
| 101 | { |
| 102 | this.filterHandler = handler; |
| 103 | for (DisplayableFilter<? super C, ? super E> displayableFilter : filters) |
| 104 | { |
| 105 | displayableFilter.setFilterHandler(handler); |
| 106 | } |
| 107 | } |
nothing calls this directly
no outgoing calls
no test coverage detected