private void setUpClearAllAction ( ) { /* if one or fewer of the filter menus are visible then we don't need the clear all menus button */ int visibleMenus = 0 ; if ( firstNameFilterMenu . isVisible ( ) ) { visibleMenus ++ ; } if ( lastNameFilterMenu . isVisible ( ) ) { visibleMenus ++ ; } if ( dobFilterMenu . isVisible ( ) ) { visibleMenus ++ ; } clearAllFiltersButton . setVisible ( visibleMenus > 1 ) ; /* enable/disable the clear all filters action: * if we have not initialised the lists then we do not need the button (though in this case it will not be visible); * otherwise if the size of the full list is the same as the size of the filtered list then we have not filtered the * list so we do not need to clear the filters and the button can be disabled; * otherwise enable the button because we have applied at least one filter. */ if ( clearAllFiltersButton . isVisible ( ) ) { List < ? > fullList = getFilterableTableModel ( ) . getFullBeanList ( ) ; List < ? > filteredList = getFilterableTableModel ( ) . getBeanList ( ) ; clearAllFiltersButton . setDisabled ( fullList == null || filteredList == null || fullList . size ( ) == filteredList . size ( ) ) ; } }
Sets the state of the clearAllActions button based on the visibility of the filter menus and if the button is visible sets its disabled state if nothing is filtered .