PromptUI.java 文件源码

java
阅读 17 收藏 0 点赞 0 评论 0

项目:Gamma-Music-Manager 作者:
/**
 * Prompt to export a selected playlist
 *
 * @param playlists list of playlists
 * @return selected playlist, null if prompt is canceled
 */
public static Pair<Playlist, File> exportPlaylist(List<Playlist> playlists) {
    if(playlists.isEmpty()) {
        customPromptError("Error", null, "Playlists not found");
        return null;
    }

    ChoiceDialog<Playlist> dialog = new ChoiceDialog<>(playlists.get(0), playlists);
    Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
    stage.getIcons().add(PROMPT_ICON);
    dialog.setTitle(EXPORT_PLAYLIST_TITLE);
    dialog.setHeaderText(EXPORT_PLAYLIST_HEADER);
    setDialogIcon(dialog, "export-playlist.png");
    dialog.setContentText(SELECT_PLAYLIST_LABEL);
    Optional<Playlist> result = dialog.showAndWait();

    if (result.isPresent()) {
        DirectoryChooser directory = new DirectoryChooser();
        File selectedFile = directory.showDialog(null);
        if (selectedFile != null) {
            return new Pair<>(result.get(), selectedFile);
        }
    }
    return null;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号