/** * Updates the Table based on the selection of the given table. Perform lookups to remove any * store files from the shared folder view and to only display store files in the store view */ void updateTableFiles(DirectoryHolder dirHolder) { if (dirHolder == null) { return; } if (dirHolder instanceof MediaTypeSavedFilesDirectoryHolder) { MediaType mediaType = ((MediaTypeSavedFilesDirectoryHolder) dirHolder).getMediaType(); setMediaType(mediaType); if (mediaType.equals(MediaType.getAudioMediaType())) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_AUDIO); } else if (mediaType == MediaType.getImageMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_PICTURES); } else if (mediaType == MediaType.getDocumentMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_DOCUMENTS); } else if (mediaType == MediaType.getVideoMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_VIDEOS); } else if (mediaType == MediaType.getTorrentMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_TORRENTS); } else if (mediaType == MediaType.getProgramMediaType()) { UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_APPLICATIONS); } } else { setMediaType(MediaType.getAnyTypeMediaType()); } clearTable(); List<List<File>> partitionedFiles = split(100, Arrays.asList(dirHolder.getFiles())); for (List<File> partition : partitionedFiles) { final List<File> fPartition = partition; BackgroundExecutorService.schedule( new Runnable() { @Override public void run() { for (final File file : fPartition) { GUIMediator.safeInvokeLater( new Runnable() { public void run() { addUnsorted(file); } }); } GUIMediator.safeInvokeLater( new Runnable() { public void run() { LibraryMediator.instance().getLibrarySearch().addResults(fPartition.size()); } }); } }); } forceResort(); }
/** * Handles the selection rows in the library window, enabling or disabling buttons and chat menu * items depending on the values in the selected rows. * * @param row the index of the first row that is selected */ public void handleSelection(int row) { int[] sel = TABLE.getSelectedRows(); if (sel.length == 0) { handleNoSelection(); return; } File selectedFile = getFile(sel[0]); // always turn on Launch, Delete, Magnet Lookup, Bitzi Lookup LAUNCH_ACTION.setEnabled(true); LAUNCH_OS_ACTION.setEnabled(true); DELETE_ACTION.setEnabled(true); if (selectedFile != null && !selectedFile.getName().endsWith(".torrent")) { CREATE_TORRENT_ACTION.setEnabled(sel.length == 1); } if (selectedFile != null) { SEND_TO_FRIEND_ACTION.setEnabled(sel.length == 1); if (getMediaType().equals(MediaType.getAnyTypeMediaType())) { boolean atLeastOneIsPlayable = false; for (int i : sel) { File f = getFile(i); if (MediaPlayer.isPlayableFile(f) || hasExtension(f.getAbsolutePath(), "mp4")) { atLeastOneIsPlayable = true; break; } } SEND_TO_ITUNES_ACTION.setEnabled(atLeastOneIsPlayable); } else { SEND_TO_ITUNES_ACTION.setEnabled( getMediaType().equals(MediaType.getAudioMediaType()) || hasExtension(selectedFile.getAbsolutePath(), "mp4")); } } if (sel.length == 1 && selectedFile.isFile() && selectedFile.getParentFile() != null) { OPEN_IN_FOLDER_ACTION.setEnabled(true); } else { OPEN_IN_FOLDER_ACTION.setEnabled(false); } if (sel.length == 1) { LibraryMediator.instance().getLibraryCoverArt().setFile(selectedFile); } // boolean anyBeingShared = isAnyBeingShared(); // WIFI_SHARE_ACTION.setEnabled(!anyBeingShared); // WIFI_UNSHARE_ACTION.setEnabled(!anyBeingShared); }
/** * Specialized constructor for creating a "dummy" result panel. This should only be called once at * search window creation-time. */ SearchResultMediator(JPanel overlay) { super(SEARCH_TABLE); setupFakeTable(overlay); SEARCH_INFO = SearchInformation.createKeywordSearch("", null, MediaType.getAnyTypeMediaType()); FILTER = null; this.token = 0; this.searchTokens = null; setButtonEnabled(SearchButtons.TORRENT_DETAILS_BUTTON_INDEX, false); // disable dnd for overlay panel TABLE.setDragEnabled(false); TABLE.setTransferHandler(null); SOUTH_PANEL.setVisible(false); }
/** Returns a menu with a 'repeat search' and 'repeat search no clear' action. */ protected final JMenu createSearchAgainMenu(SearchResultDataLine line) { JMenu menu = new SkinMenu(I18n.tr("Search More")); menu.add(new SkinMenuItem(new RepeatSearchAction())); if (line == null) { menu.setEnabled(isRepeatSearchEnabled()); return menu; } menu.addSeparator(); String keywords = QueryUtils.createQueryString(line.getFilename()); SearchInformation info = SearchInformation.createKeywordSearch(keywords, null, MediaType.getAnyTypeMediaType()); if (SearchMediator.validateInfo(info) == SearchMediator.QUERY_VALID) { menu.add( new SkinMenuItem(new SearchAction(info, I18nMarker.marktr("Search for Keywords: {0}")))); } return menu; }