/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package GUIS; import DB.CouchDbAccess; import Helpers.SwingUtils; import java.util.LinkedList; /* * A améliorer: * -Package gestion exception -> fait * -enlever merge useless -> fait * -prendre image sur webfs -> fait * -Corriger certification (qui doit etre en dernier pour que ça marche); -> pas vu pas fait */ /** * * @author Greenlamp */ public class Main extends javax.swing.JFrame { /** * Creates new form Main */ private LinkedList<String[]> listeCriteres = null; public Main() { initComponents(); listeCriteres = new LinkedList<>(); initComboBoxCertification(); initComboBoxGenre(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); Lidentifiant = new javax.swing.JLabel(); Gidentifiant = new javax.swing.JTextField(); Gacteur = new javax.swing.JTextField(); Grealisateur = new javax.swing.JTextField(); Gtitre = new javax.swing.JTextField(); GpopulariteMin = new javax.swing.JTextField(); Lacteur = new javax.swing.JLabel(); Lrealisateur = new javax.swing.JLabel(); Ltitre = new javax.swing.JLabel(); Lpopularite = new javax.swing.JLabel(); GnbVoteMin = new javax.swing.JTextField(); LnbVote = new javax.swing.JLabel(); Gclassification = new javax.swing.JComboBox(); Lclassification = new javax.swing.JLabel(); Bidentifiant = new javax.swing.JButton(); Brealisateur = new javax.swing.JButton(); Bacteur = new javax.swing.JButton(); Btitre = new javax.swing.JButton(); Bpopularite = new javax.swing.JButton(); BnbVote = new javax.swing.JButton(); Bclassification = new javax.swing.JButton(); GpopulariteMax = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); GnbVoteMax = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); BdateSortie = new javax.swing.JButton(); LdateSortie = new javax.swing.JLabel(); Ggenre = new javax.swing.JComboBox(); Bgenre = new javax.swing.JButton(); Lgenre = new javax.swing.JLabel(); GdateSortieMin = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); GdateSortieMax = new javax.swing.JTextField(); jPanel2 = new javax.swing.JPanel(); LlisteCritere = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); GlisteCritere = new javax.swing.JList(); Benlever = new javax.swing.JButton(); Bvider = new javax.swing.JButton(); Brechercher = new javax.swing.JButton(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); Mquitter = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); Mabout = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("AlimCB"); Lidentifiant.setText("Identifiant"); Lacteur.setText("Acteur"); Lrealisateur.setText("Réalisateur"); Ltitre.setText("Titre"); Lpopularite.setText("Popularité"); LnbVote.setText("Nombre vote:"); Lclassification.setText("Classification:"); Bidentifiant.setText("+"); Bidentifiant.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BidentifiantActionPerformed(evt); } }); Brealisateur.setText("+"); Brealisateur.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BrealisateurActionPerformed(evt); } }); Bacteur.setText("+"); Bacteur.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BacteurActionPerformed(evt); } }); Btitre.setText("+"); Btitre.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BtitreActionPerformed(evt); } }); Bpopularite.setText("+"); Bpopularite.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BpopulariteActionPerformed(evt); } }); BnbVote.setText("+"); BnbVote.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BnbVoteActionPerformed(evt); } }); Bclassification.setText("+"); Bclassification.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BclassificationActionPerformed(evt); } }); jLabel1.setText("-"); jLabel2.setText("-"); BdateSortie.setText("+"); BdateSortie.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BdateSortieActionPerformed(evt); } }); LdateSortie.setText("Date de sortie:"); Bgenre.setText("+"); Bgenre.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BgenreActionPerformed(evt); } }); Lgenre.setText("Genre:"); jLabel3.setText("-"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(Lidentifiant) .addComponent(Lacteur) .addComponent(Lrealisateur) .addComponent(Ltitre) .addComponent(Lpopularite) .addComponent(LnbVote) .addComponent(Lclassification) .addComponent(LdateSortie) .addComponent(Lgenre)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(Ggenre, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(Gtitre) .addComponent(Grealisateur) .addComponent(Gacteur) .addComponent(Gidentifiant) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(GnbVoteMin, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(GpopulariteMin, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(GpopulariteMax, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE) .addComponent(GnbVoteMax))) .addComponent(Gclassification, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(GdateSortieMin) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(GdateSortieMax))) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(Bidentifiant) .addComponent(Brealisateur) .addComponent(Bacteur, javax.swing.GroupLayout.Alignment.TRAILING)) .addComponent(Btitre, javax.swing.GroupLayout.Alignment.TRAILING)) .addComponent(Bpopularite, javax.swing.GroupLayout.Alignment.TRAILING)) .addComponent(BnbVote, javax.swing.GroupLayout.Alignment.TRAILING)) .addComponent(BdateSortie) .addComponent(Bclassification, javax.swing.GroupLayout.Alignment.TRAILING))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(Bgenre))) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(Lidentifiant) .addComponent(Gidentifiant, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Bidentifiant)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(Gacteur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Bacteur))) .addComponent(Lacteur)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(Grealisateur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Brealisateur))) .addComponent(Lrealisateur)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(Gtitre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Btitre))) .addComponent(Ltitre)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(GpopulariteMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Lpopularite) .addComponent(Bpopularite) .addComponent(GpopulariteMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(GnbVoteMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(LnbVote) .addComponent(BnbVote) .addComponent(GnbVoteMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(Gclassification, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Bclassification)) .addComponent(Lclassification)) .addGap(12, 12, 12) .addComponent(LdateSortie)) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(GdateSortieMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(GdateSortieMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3)) .addComponent(BdateSortie))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(Ggenre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Bgenre) .addComponent(Lgenre)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); LlisteCritere.setText("Liste des critères actifs:"); jScrollPane1.setViewportView(GlisteCritere); Benlever.setText("Enlever"); Benlever.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BenleverActionPerformed(evt); } }); Bvider.setText("Vider"); Bvider.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BviderActionPerformed(evt); } }); Brechercher.setText("Rechercher"); Brechercher.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BrechercherActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(Bvider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(LlisteCritere) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(Benlever, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(Brechercher, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(LlisteCritere) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(Bvider) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(Benlever) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(Brechercher) .addContainerGap()) ); jMenu1.setText("Fichier"); Mquitter.setText("Quitter"); Mquitter.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { MquitterActionPerformed(evt); } }); jMenu1.add(Mquitter); jMenuBar1.add(jMenu1); jMenu2.setText("?"); Mabout.setText("About"); jMenu2.add(Mabout); jMenuBar1.add(jMenu2); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); pack(); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); java.awt.Dimension dialogSize = getSize(); setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2); }// </editor-fold>//GEN-END:initComponents private void BidentifiantActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BidentifiantActionPerformed if(!Gidentifiant.getText().isEmpty()){ SwingUtils.addToList(GlisteCritere, "id value:" + Gidentifiant.getText()); String[] critere = {"id", Gidentifiant.getText()}; listeCriteres.add(critere); Gidentifiant.setText(null); } }//GEN-LAST:event_BidentifiantActionPerformed private void BacteurActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BacteurActionPerformed if(!Gacteur.getText().isEmpty()){ SwingUtils.addToList(GlisteCritere, "acteur value:" + Gacteur.getText()); String[] critere = {"acteur", Gacteur.getText()}; listeCriteres.add(critere); Gacteur.setText(null); } }//GEN-LAST:event_BacteurActionPerformed private void BrealisateurActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BrealisateurActionPerformed if(!Grealisateur.getText().isEmpty()){ SwingUtils.addToList(GlisteCritere, "realisateur value:" + Grealisateur.getText()); String[] critere = {"realisateur", Grealisateur.getText()}; listeCriteres.add(critere); Grealisateur.setText(null); } }//GEN-LAST:event_BrealisateurActionPerformed private void BtitreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtitreActionPerformed if(!Gtitre.getText().isEmpty()){ SwingUtils.addToList(GlisteCritere, "titre value:" + Gtitre.getText()); String[] critere = {"titre", Gtitre.getText()}; listeCriteres.add(critere); Gtitre.setText(null); } }//GEN-LAST:event_BtitreActionPerformed private void BpopulariteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BpopulariteActionPerformed if(!GpopulariteMin.getText().isEmpty() && !GpopulariteMax.getText().isEmpty()){ SwingUtils.addToList(GlisteCritere, "popularite value:" + GpopulariteMin.getText() + "-" + GpopulariteMax.getText()); String[] critere = {"populariteMin", GpopulariteMin.getText()}; listeCriteres.add(critere); String[] critere2 = {"populariteMax", GpopulariteMax.getText()}; listeCriteres.add(critere2); GpopulariteMin.setText(null); GpopulariteMax.setText(null); } }//GEN-LAST:event_BpopulariteActionPerformed private void BnbVoteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BnbVoteActionPerformed if(!GnbVoteMin.getText().isEmpty() && !GnbVoteMax.getText().isEmpty()){ SwingUtils.addToList(GlisteCritere, "nbVote value:" + GnbVoteMin.getText() + "-" + GnbVoteMax.getText()); String[] critere = {"nbVoteMin", GnbVoteMin.getText()}; listeCriteres.add(critere); String[] critere2 = {"nbVoteMax", GnbVoteMax.getText()}; listeCriteres.add(critere2); GnbVoteMin.setText(null); GnbVoteMax.setText(null); } }//GEN-LAST:event_BnbVoteActionPerformed private void BclassificationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BclassificationActionPerformed SwingUtils.addToList(GlisteCritere, "classification value:" + Gclassification.getSelectedItem().toString()); String[] critere = {"classification", Gclassification.getSelectedItem().toString()}; listeCriteres.add(critere); }//GEN-LAST:event_BclassificationActionPerformed private void BviderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BviderActionPerformed if(listeCriteres.isEmpty()) return; SwingUtils.emptyList(GlisteCritere); listeCriteres.clear(); }//GEN-LAST:event_BviderActionPerformed private void BenleverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BenleverActionPerformed if(listeCriteres.isEmpty()) return; String selected = (String)GlisteCritere.getSelectedValue(); String[] split = selected.split(" value:"); String gauche = split[0]; String droite = split[1]; LinkedList<String[]> listeTemp = new LinkedList<>(); listeTemp.addAll(listeCriteres); for(String[] critere : listeTemp){ if(gauche.equals("popularite")){ String[] popuSplit = droite.split("-"); String min = popuSplit[0]; String max = popuSplit[1]; if(critere[0].equals("populariteMin") && critere[1].equals(min)){ listeCriteres.remove(critere); } if(critere[0].equals("populariteMax") && critere[1].equals(max)){ listeCriteres.remove(critere); SwingUtils.removeToList(GlisteCritere, selected); } }else if(gauche.contains("nbVote")){ String[] nbVoteSplit = droite.split("-"); String min = nbVoteSplit[0]; String max = nbVoteSplit[1]; if(critere[0].equals("nbVoteMin") && critere[1].equals(min)){ listeCriteres.remove(critere); } if(critere[0].equals("nbVoteMax") && critere[1].equals(max)){ listeCriteres.remove(critere); SwingUtils.removeToList(GlisteCritere, selected); } }else if(gauche.contains("dateSortie")){ String[] nbVoteSplit = droite.split("-"); String min = nbVoteSplit[0]; String max = nbVoteSplit[1]; if(critere[0].equals("dateSortieMin") && critere[1].equals(min)){ listeCriteres.remove(critere); } if(critere[0].equals("dateSortieMax") && critere[1].equals(max)){ listeCriteres.remove(critere); SwingUtils.removeToList(GlisteCritere, selected); } }else if(critere[0].equals(gauche) && critere[1].equals(droite)){ listeCriteres.remove(critere); SwingUtils.removeToList(GlisteCritere, selected); return; } } System.out.println("Size:" + listeCriteres.size()); }//GEN-LAST:event_BenleverActionPerformed private void BrechercherActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BrechercherActionPerformed if(listeCriteres.isEmpty()) return; Selection selection = new Selection(this, true, listeCriteres); selection.show(); }//GEN-LAST:event_BrechercherActionPerformed private void MquitterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MquitterActionPerformed this.dispose(); }//GEN-LAST:event_MquitterActionPerformed private void BdateSortieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BdateSortieActionPerformed if(!GdateSortieMin.getText().isEmpty() && !GdateSortieMax.getText().isEmpty()){ SwingUtils.addToList(GlisteCritere, "dateSortie value:" + GdateSortieMin.getText() + "-" + GdateSortieMax.getText()); String[] critere = {"dateSortieMin", GdateSortieMin.getText()}; listeCriteres.add(critere); String[] critere2 = {"dateSortieMax", GdateSortieMax.getText()}; listeCriteres.add(critere2); GdateSortieMin.setText(null); GdateSortieMax.setText(null); } }//GEN-LAST:event_BdateSortieActionPerformed private void BgenreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BgenreActionPerformed SwingUtils.addToList(GlisteCritere, "genre value:" + Ggenre.getSelectedItem().toString()); String[] critere = {"genre", Ggenre.getSelectedItem().toString()}; listeCriteres.add(critere); }//GEN-LAST:event_BgenreActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Main().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton Bacteur; private javax.swing.JButton Bclassification; private javax.swing.JButton BdateSortie; private javax.swing.JButton Benlever; private javax.swing.JButton Bgenre; private javax.swing.JButton Bidentifiant; private javax.swing.JButton BnbVote; private javax.swing.JButton Bpopularite; private javax.swing.JButton Brealisateur; private javax.swing.JButton Brechercher; private javax.swing.JButton Btitre; private javax.swing.JButton Bvider; private javax.swing.JTextField Gacteur; private javax.swing.JComboBox Gclassification; private javax.swing.JTextField GdateSortieMax; private javax.swing.JTextField GdateSortieMin; private javax.swing.JComboBox Ggenre; private javax.swing.JTextField Gidentifiant; private javax.swing.JList GlisteCritere; private javax.swing.JTextField GnbVoteMax; private javax.swing.JTextField GnbVoteMin; private javax.swing.JTextField GpopulariteMax; private javax.swing.JTextField GpopulariteMin; private javax.swing.JTextField Grealisateur; private javax.swing.JTextField Gtitre; private javax.swing.JLabel Lacteur; private javax.swing.JLabel Lclassification; private javax.swing.JLabel LdateSortie; private javax.swing.JLabel Lgenre; private javax.swing.JLabel Lidentifiant; private javax.swing.JLabel LlisteCritere; private javax.swing.JLabel LnbVote; private javax.swing.JLabel Lpopularite; private javax.swing.JLabel Lrealisateur; private javax.swing.JLabel Ltitre; private javax.swing.JMenuItem Mabout; private javax.swing.JMenuItem Mquitter; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane jScrollPane1; // End of variables declaration//GEN-END:variables private void initComboBoxCertification() { String[] listeCertification = { "G", "MA", "NC-17", "NR", "PG", "PG-13", "R", "TV-14", "XXX" }; for(String certification: listeCertification){ SwingUtils.addToComboBox(Gclassification, certification); } } private void initComboBoxGenre() { LinkedList<String> listeGenre = new LinkedList<>(); CouchDbAccess couch = new CouchDbAccess(); couch.getGenres(listeGenre); for(String genre : listeGenre){ SwingUtils.addToComboBox(Ggenre, genre); } } }