void renameTrack() { if (interfaceDisabled) return; Playlist p = getSelectedPlaylist(); if (p == null) return; Track t = getSelectedTrack(); if (t == null) return; TextInputDialog dialog = new TextInputDialog(t.getTitle()); dialog.setTitle(res.getString("rename_track")); dialog.setHeaderText(res.getString("rename_track")); dialog.setContentText(res.getString("enter_new_title")); dialog.getDialogPane().getStylesheets().add("/styles/dialogs.css"); ((Stage) dialog.getDialogPane().getScene().getWindow()).getIcons().addAll(logoImages); Optional<String> result = dialog.showAndWait(); result.ifPresent( title -> { if (StringUtils.isEmpty(title)) { return; } Cache.renameTrack(t, p, title); Platform.runLater( () -> { loadSelectedPlaylist(); }); }); }
void menuAddToPlaylist() { Track t = getSelectedTrack(); if (t == null) { return; } ChoiceDialog<Playlist> dialog = playlistSelectionDialog(playlistsView.getItems()); Optional<Playlist> result = dialog.showAndWait(); result.ifPresent(playlist -> addToPlaylist(t, playlist)); }
void createOfflinePlaylist() { if (interfaceDisabled) return; TextInputDialog dialog = new TextInputDialog(res.getString("new_offline_playlist")); dialog.setTitle(res.getString("create_new_offline_playlist")); dialog.setHeaderText(res.getString("create_new_playlist")); dialog.setContentText(res.getString("enter_playlist_name")); dialog.getDialogPane().getStylesheets().add("/styles/dialogs.css"); ((Stage) dialog.getDialogPane().getScene().getWindow()).getIcons().addAll(logoImages); Optional<String> result = dialog.showAndWait(); result.ifPresent( title -> { Platform.runLater( () -> { Playlist newPlaylist = Cache.createPlaylist(title); Platform.runLater( () -> { playlistsView.getItems().add(newPlaylist); playlistsView.getSelectionModel().select(newPlaylist); }); }); }); }
void deletePlaylist() { if (interfaceDisabled) return; Playlist p = getSelectedPlaylist(); if (p == null) return; Alert alert = new Alert(AlertType.CONFIRMATION); ButtonType btYes = new ButtonType(res.getString("yes"), ButtonBar.ButtonData.YES); ButtonType btCancel = new ButtonType(res.getString("cancel"), ButtonBar.ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(btYes, btCancel); alert.setTitle(res.getString("delete_playlist")); alert.setHeaderText(res.getString("delete_playlist")); alert.setContentText(String.format(res.getString("delete_confirm"), p.getTitle())); alert.getDialogPane().getStylesheets().add("/styles/dialogs.css"); ((Stage) alert.getDialogPane().getScene().getWindow()).getIcons().addAll(logoImages); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == btYes) { Cache.deletePlaylist(p); Platform.runLater( () -> { updatePlaylists(); }); } }