@Override public void actionPerformed(ActionEvent arg0) { File selectedFile = DATA_MODEL.getFile(TABLE.getSelectedRow()); // can't create torrents out of empty folders. if (selectedFile.isDirectory() && selectedFile.listFiles().length == 0) { JOptionPane.showMessageDialog( null, I18n.tr("The folder you selected is empty."), I18n.tr("Invalid Folder"), JOptionPane.ERROR_MESSAGE); return; } // can't create torrents if the folder/file can't be read if (!selectedFile.canRead()) { JOptionPane.showMessageDialog( null, I18n.tr("Error: You can't read on that file/folder."), I18n.tr("Error"), JOptionPane.ERROR_MESSAGE); return; } CreateTorrentDialog dlg = new CreateTorrentDialog(GUIMediator.getAppFrame()); dlg.setChosenContent( selectedFile, selectedFile.isFile() ? JFileChooser.FILES_ONLY : JFileChooser.DIRECTORIES_ONLY); dlg.setVisible(true); }
public void handleActionKey() { LibraryFilesTableDataLine line = DATA_MODEL.get(TABLE.getSelectedRow()); if (line == null || line.getFile() == null) { return; } if (getMediaType().equals(MediaType.getAudioMediaType()) && MediaPlayer.isPlayableFile(line.getFile())) { MediaPlayer.instance() .asyncLoadMedia(new MediaSource(line.getFile()), true, false, true, null, getFilesView()); UXStats.instance().log(UXAction.LIBRARY_PLAY_AUDIO_FROM_FILE); return; } int[] rows = TABLE.getSelectedRows(); // LibraryTableModel ltm = DATA_MODEL; // File file; for (int i = 0; i < rows.length; i++) { // file = ltm.getFile(rows[i]); // if it's a directory try to select it in the library tree // if it could be selected return // if (file.isDirectory() // && LibraryMediator.setSelectedDirectory(file)) // return; } launch(true); }
/** Refreshes the enabledness of the Enqueue button based on the player enabling state. */ public void setPlayerEnabled(boolean value) { handleSelection(TABLE.getSelectedRow()); }