private void removeSelectedRecords() { if (arbre.getSelectionCount() >= 1 && onlySelectFeuille()) { int option = -1; if (arbre.getSelectionCount() == 1) { option = JOptionPane.showConfirmDialog( null, "Voulez-vous supprimer cet enregistrement ?\n(Notez que la catégorie sera conservée)", "Suppression", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); } else { option = JOptionPane.showConfirmDialog( null, "Êtes-vous sûr de vouloir ces enregistrements ?\n(Notez que les catégories seront conservées)", "Suppression", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); } if (option == JOptionPane.OK_OPTION) { for (int i = 0; i < arbre.getSelectionPaths().length; i++) { if (arbre.getSelectionPaths()[i].getLastPathComponent() instanceof Feuille) { try { bdd.supprimerEnregistrement( ((Feuille) arbre.getSelectionPaths()[i].getLastPathComponent()).getId()); } catch (DBException exception) { GraphicalUserInterface.popupErreur( "Impossible de supprimer l'enregistrement : " + exception.getMessage()); } } } } } }
public File getRecordCacheFile(int id) throws IOException, DBException { final String fileName = id + ".wav"; if (!cache.fileExists(fileName)) { byte[] contenu = bdd.recupererEnregistrement(id); cache.createFile(fileName, contenu); } return cache.getFile(fileName); }
private void removeSelectedSubjects() { if (typeTrie == PanneauArbre.TYPE_TRIE_SUJET && arbre.getSelectionCount() >= 1 && onlySelectBranche()) { int option = -1; if (arbre.getSelectionCount() == 1) { option = JOptionPane.showConfirmDialog( null, "Êtes-vous sûr de vouloir supprimer ce sujet ?\n", "Suppression", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); } else { option = JOptionPane.showConfirmDialog( null, "Êtes-vous sûr de vouloir supprimer ces sujets ?\n", "Suppression", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); } if (option == JOptionPane.OK_OPTION) { for (TreePath treePath : arbre.getSelectionPaths()) { try { if (!(treePath.getLastPathComponent() instanceof Feuille)) { String nomSujet = treePath.getLastPathComponent().toString(); List<LigneEnregistrement> liste = bdd.getListeEnregistrementSujet(bdd.getSujet(nomSujet)); if (!liste.isEmpty()) { GraphicalUserInterface.popupErreur( "Un sujet ne peut être supprimé que quand il n'a plus d'enregistrements.", "Erreur"); } else { bdd.supprimerSujet(bdd.getSujet(nomSujet)); } } } catch (DBException e1) { GraphicalUserInterface.popupErreur(e1.getMessage()); } } } } }