/** Returns a list of filtered results for the specified search category. */ @Override public EventList<VisualSearchResult> getCategorySearchResults(SearchCategory searchCategory) { if (searchCategory == SearchCategory.ALL) { return filteredResultList; } else { // Get filtered list from cache. Category category = searchCategory.getCategory(); FilterList<VisualSearchResult> filteredList = categoryListMap.get(category); // Create filtered list if necessary, and add to cache. if (filteredList == null) { filteredList = GlazedListsFactory.filterList(filteredResultList, new CategoryMatcher(category)); categoryListMap.put(category, filteredList); } return filteredList; } }
/** * Updates the title icon and text in the container. For search results, the title includes the * category name, search title, and result counts. */ private void updateTitle() { // Get result counts. int total = searchResultsModel.getUnfilteredList().size(); int actual = searchResultsModel.getFilteredList().size(); if (browseTitle != null) { // Set browse title. searchTitleLabel.setText( (actual == total) ? // {0}: browse title, {1}: total count I18n.tr("Browse {0} ({1})", browseTitle, total) : // {0}: browse title, {1}: actual count, {2}: total count I18n.tr("Browse {0} - Showing {1} of {2}", browseTitle, actual, total)); } else { // Get search category and title. SearchCategory displayCategory = searchResultsModel.getSelectedCategory(); String title = searchResultsModel.getSearchTitle(); // Set title icon based on category. Icon icon = (displayCategory == SearchCategory.ALL) ? null : categoryIconManager.getIcon(displayCategory.getCategory()); searchTitleLabel.setIcon(icon); // Set title text. switch (displayCategory) { case ALL: searchTitleLabel.setText( (actual == total) ? // {0}: search title, {1}: total count I18n.tr("All results for {0} ({1})", title, total) : // {0}: search title, {1}: actual count, {2}: total count I18n.tr("All results for {0} - Showing {1} of {2}", title, actual, total)); break; case AUDIO: searchTitleLabel.setText( (actual == total) ? // {0}: search title, {1}: total count I18n.tr("Audio results for {0} ({1})", title, total) : // {0}: search title, {1}: actual count, {2}: total count I18n.tr("Audio results for {0} - Showing {1} of {2}", title, actual, total)); break; case VIDEO: searchTitleLabel.setText( (actual == total) ? // {0}: search title, {1}: total count I18n.tr("Video results for {0} ({1})", title, total) : // {0}: search title, {1}: actual count, {2}: total count I18n.tr("Video results for {0} - Showing {1} of {2}", title, actual, total)); break; case IMAGE: searchTitleLabel.setText( (actual == total) ? // {0}: search title, {1}: total count I18n.tr("Image results for {0} ({1})", title, total) : // {0}: search title, {1}: actual count, {2}: total count I18n.tr("Image results for {0} - Showing {1} of {2}", title, actual, total)); break; case DOCUMENT: searchTitleLabel.setText( (actual == total) ? // {0}: search title, {1}: total count I18n.tr("Document results for {0} ({1})", title, total) : // {0}: search title, {1}: actual count, {2}: total count I18n.tr("Document results for {0} - Showing {1} of {2}", title, actual, total)); break; case PROGRAM: searchTitleLabel.setText( (actual == total) ? // {0}: search title, {1}: total count I18n.tr("Program results for {0} ({1})", title, total) : // {0}: search title, {1}: actual count, {2}: total count I18n.tr("Program results for {0} - Showing {1} of {2}", title, actual, total)); break; case OTHER: searchTitleLabel.setText( (actual == total) ? // {0}: search title, {1}: total count I18n.tr("Other results for {0} ({1})", title, total) : // {0}: search title, {1}: actual count, {2}: total count I18n.tr("Other results for {0} - Showing {1} of {2}", title, actual, total)); break; default: throw new IllegalStateException("Invalid search category " + displayCategory); } } }