public void afficherFilmChoisis(String titre) { Video film = this.obtenirVideo(titre); String catos = this.obtenirCategoriesEnString( comboCollection.getItemAt(comboCollection.getSelectedIndex()).toString()); if (mode[0].isSelected()) { String filmOuSerie = "SERIE TV"; String eval = ""; if (film.getEval() == 1) { eval = String.valueOf(film.getEval()) + " etoile"; } else if (film.getEval() > 1) { eval = String.valueOf(film.getEval()) + " etoiles"; } if (film.isFilm()) { filmOuSerie = "FILM"; } infos_film[0].setText(titre); infos_film[1].setText(String.valueOf(film.getAnnee())); infos_film[2].setText(filmOuSerie); infos_film[3].setText(eval); } else { textTitre.setText(film.getTitre()); textAnnee.setText(String.valueOf(film.getAnnee())); comboEval.setSelectedIndex(film.getEval()); boolean isFilm = film.isFilm(); if (isFilm) { comboType.setSelectedIndex(1); } else { comboType.setSelectedIndex(2); } } textCommentaires.setText(film.getCommentaires()); textCategories.setText(catos); }
public void sauvegarder() { final String PATH = "./videos.txt"; File fichier = new File(PATH); String formatDeSortie = ""; for (Video video : this.obtenirCollection()) { String catos = this.obtenirCategoriesEnString(video.getTitre()); catos = catos.replace("\n", "::"); String comments = video.getCommentaires(); comments = comments.replace("\n", "[*]"); formatDeSortie += video.getTitre() + "::"; formatDeSortie += video.getAnnee() + "::"; if (video.isFilm()) { formatDeSortie += "FILM" + "::"; } else { formatDeSortie += "SÉRIE TV" + "::"; } formatDeSortie += video.getEval() + "::"; formatDeSortie += comments; // Comments formatDeSortie += "::"; formatDeSortie += catos; // Catos formatDeSortie += "\r\n"; // Petit fix pour que les new lines append au fichier txt } formatDeSortie = formatDeSortie.substring(0, formatDeSortie.length() - 1); try { FileWriter ecrivain = new FileWriter(fichier); ecrivain.write(formatDeSortie); ecrivain.close(); } catch (IOException io) { io.getMessage(); } }