/** * Selects the specified search category. If the selected category is changed, this method updates * the sorted list. */ @Override public void setSelectedCategory(SearchCategory selectedCategory) { if (this.selectedCategory != selectedCategory) { this.selectedCategory = selectedCategory; // Dispose of existing visible and sorted lists. if (visibleResultList != null) { visibleResultList.dispose(); sortedResultList.dispose(); } // Update visible and sorted lists. EventList<VisualSearchResult> filteredList = getCategorySearchResults(selectedCategory); sortedResultList = GlazedListsFactory.sortedList(filteredList, null); visibleResultList = GlazedListsFactory.filterList(sortedResultList, new VisibleMatcher()); sortedResultList.setComparator( (sortOption != null) ? SortFactory.getSortComparator(sortOption) : null); } }
/** Sets the sort option. This method updates the sorted list by changing the sort comparator. */ @Override public void setSortOption(SortOption sortOption) { this.sortOption = sortOption; sortedResultList.setComparator( (sortOption != null) ? SortFactory.getSortComparator(sortOption) : null); }