Esempio n. 1
0
 private Car getCarFromStorage(JComboBox<String> cars, JComboBox<EngineKind> engine) {
   String carName = cars.getItemAt(cars.getSelectedIndex());
   Car car = null;
   for (Car carr : shop.getCars()) {
     if ((carr.getManufacturer() + " " + carr.getModel()).equals(carName)
         && carr.getEngineKind().equals(engine.getItemAt(engine.getSelectedIndex()))) {
       car = carr;
     }
   }
   return car;
 }
 protected Step createSelection(JComboBox combo, int index) {
   Step step = null;
   if (combo != null && index != -1) {
     ComponentReference cr = getResolver().addComponent(combo);
     String value = tester.getValueAsString(combo, list, combo.getItemAt(index), index);
     if (value == null) {
       step =
           new Action(
               getResolver(),
               null,
               "actionSelectIndex",
               new String[] {cr.getID(), String.valueOf(index)},
               javax.swing.JComboBox.class);
     } else {
       step =
           new Action(
               getResolver(),
               null,
               "actionSelectItem",
               new String[] {cr.getID(), value},
               javax.swing.JComboBox.class);
     }
   }
   return step;
 }
Esempio n. 3
0
  public SwingThreadFrame() {
    setTitle("SwingThreadTest");

    final JComboBox combo = new JComboBox();
    combo.insertItemAt(new Integer(Integer.MAX_VALUE), 0);
    combo.setPrototypeDisplayValue(combo.getItemAt(0));
    combo.setSelectedIndex(0);

    JPanel panel = new JPanel();

    JButton goodButton = new JButton("Good");
    goodButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            new Thread(new GoodWorkerRunnable(combo)).start();
          }
        });
    panel.add(goodButton);
    JButton badButton = new JButton("Bad");
    badButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            new Thread(new BadWorkerRunnable(combo)).start();
          }
        });
    panel.add(badButton);
    panel.add(combo);
    add(panel);
    pack();
  }
Esempio n. 4
0
  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);
  }
  private void handleEntryAction(ActionEvent actionEvent)
      throws IOException, ParserConfigurationException, XPathExpressionException, SAXException,
          NoItemException {
    if (this.getGazetteer() == null) {
      Util.getLogger().severe("No gazeteer is registered");
      return;
    }

    String lookupString;

    JComboBox cmb = ((JComboBox) actionEvent.getSource());
    lookupString = cmb.getSelectedItem().toString();

    if (lookupString == null || lookupString.length() < 1) return;

    java.util.List<PointOfInterest> results = this.gazetteer.findPlaces(lookupString);
    if (results == null || results.size() == 0) return;

    this.controller.moveToLocation(results.get(0));

    // Add it to the list if not already there
    for (int i = 0; i < cmb.getItemCount(); i++) {
      Object oi = cmb.getItemAt(i);
      if (oi != null && oi.toString().trim().equals(lookupString)) return; // item exists
    }
    cmb.insertItemAt(lookupString, 0);
  }
  public DataSourceQueryChooserDialog(
      Collection dataSourceQueryChoosers, Frame frame, String title, boolean modal) {
    super(frame, title, modal);
    init(dataSourceQueryChoosers);
    try {
      jbInit();
      pack();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    addComponentListener(
        new ComponentAdapter() {
          public void componentShown(ComponentEvent e) {
            okCancelPanel.setOKPressed(false);
          }
        });
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            // User may have hit OK, got a validation-error dialog, then hit the
            // X button. [Jon Aquino]
            okCancelPanel.setOKPressed(false);
          }
        });

    // Set the selected item to trigger the event that sets the panel. [Jon Aquino]
    formatComboBox.setSelectedItem(formatComboBox.getItemAt(0));
  }
Esempio n. 7
0
 /*
  * Metodo mostrarLibro()
  * sin parametros, sin retorno, muestra los datos del elemento del vector seleccionado
  */
 private void mostrarLibro() {
   int seleccion = librosCombo.getSelectedIndex();
   Libro l = (Libro) librosCombo.getItemAt(seleccion);
   tituloLibro.setText(l.getTituloLibro());
   autorNombres.setText(l.getAutorNombres());
   apellidosAutor.setText(l.getApellidosAutor());
   nombreEditorial.setText(l.getNombreEditorial());
   añoPublicacion.setText(String.valueOf(l.getAñoPublicacion()));
   codigoISBN.setText(l.getCodigoISBN());
   lugarPublicacion.setText(l.getLugarPublicacion());
   numeroPaginas.setText(String.valueOf(l.getNumeroPaginas()));
   descripcionArea.setText(l.getDescripcionLibro());
   subgeneroCombo.setSelectedItem(l.getSubgeneroLibro());
   // generoLiricoRadio.setSelected(true);
   // semestreSpinner.setValue(1);}
   if (l.getGenero() == 'N') {
     generoNarrativoRadio.setSelected(true);
   } else if (l.getGenero() == 'D') {
     generoDramaRadio.setSelected(true);
   } else {
     generoLiricoRadio.setSelected(true);
   }
   españolCheck.setSelected(l.isEspañolCheck());
   inglesCheck.setSelected(l.isInglesCheck());
   mandarinCheck.setSelected(l.isMandarinCheck());
 }
Esempio n. 8
0
 public static List getItems(JComboBox comboBox) {
   List result = new ArrayList();
   for (int i = 0; i < comboBox.getItemCount(); i++) {
     Object element = comboBox.getItemAt(i);
     result.add(element);
   }
   return result;
 }
  public void setSelectedFormat(String format) {
    for (int i = 0; i < formatComboBox.getItemCount(); i++) {
      DataSourceQueryChooser chooser = (DataSourceQueryChooser) formatComboBox.getItemAt(i);
      if (chooser.toString().equals(format)) {
        formatComboBox.setSelectedIndex(i);

        return;
      }
    }
  }
      private void prepareTextComboBox(final Object propertyValue) {
        // _textComboBox wird in der letzten Zeile editierbar gemacht, und es wird
        // der übergebene Wert in diese Zeile eingetragen und selektiert, wenn er nicht
        // einem der anderen Einträge entspricht.

        if (propertyValue != null) {
          String propertyValueAsString = (String) propertyValue;
          final int size = _textComboBox.getModel().getSize();
          boolean propertyValueFound = false;
          for (int i = 0; i < size - 1; i++) {
            if (propertyValueAsString.equals((String) _textComboBox.getItemAt(i))) {
              propertyValueFound = true;
              _textComboBox.setSelectedIndex(i);
              break;
            }
          }
          if (!propertyValueFound) {
            _textComboBox.removeItemAt(size - 1);
            _textComboBox.addItem(propertyValueAsString);
            _textComboBox.setSelectedIndex(size - 1);
          }
        }

        ItemListener textComboBoxItemListener =
            new ItemListener() {
              public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                  if (_textComboBox.getSelectedIndex()
                      == DOTPointPainter.DYNAMIC_TEXT_ITEMS.length - 1) {
                    _textComboBox.setEditable(true);
                  } else {
                    _textComboBox.setEditable(false);
                  }
                }
              }
            };
        _textComboBox.addItemListener(textComboBoxItemListener);

        ActionListener editorActionListener =
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                final int length = DOTPointPainter.DYNAMIC_TEXT_ITEMS.length;
                final int index = length - 1;
                final ComboBoxEditor editor = _textComboBox.getEditor();
                String editedItem = (String) editor.getItem();
                _textComboBox.insertItemAt(editedItem, index);
                final DefaultComboBoxModel model = (DefaultComboBoxModel) _textComboBox.getModel();
                if (model.getSize()
                    > length) { // Sieht komisch aus, aber der direkte Weg ging nicht.
                  model.removeElementAt(length);
                }
              }
            };
        _textComboBox.getEditor().addActionListener(editorActionListener);
      }
  @Override
  public void actionPerformed(ActionEvent e) {

    Object source = e.getSource();

    if (source == annuler) {
      this.setVisible(false);
    }

    if (source == validate) {

      // ***************here we test if the field is filled or not************
      if (tot_pop.getText().equals("")) {

        JOptionPane.showMessageDialog(errorMsg, "Fill the initial population");
      } else {

        total_popInt = Integer.parseInt(tot_pop.getText());
        // Animal a=new Animal(0,typef.getText(),total);
        int index = typef.getSelectedIndex();
        String typeAnim = (typef.getItemAt(index)).toString();
        // ****************here we test if what we insert exist with the function above********
        if (testingInit("cow")) {
          write = new fileWriting("init_pop", typeAnim + " " + total_popInt);
          anima = new AnimalType(total_popInt, typeAnim);
          this.setVisible(false);
          // JOptionPane.showMessageDialog(null, "The animal type is created successfully");
        } else {
          JOptionPane.showMessageDialog(errorMsg, "Information on this date already given");
        }

        switch (typeAnim) {
          case "Cow":
            AppFrame.totalPopulationCOW = AppFrame.totalPopulationCOW + total_popInt;
            initialPopCOW = total_popInt;
            break;
          case "Deer":
            AppFrame.totalPopulationDEER = AppFrame.totalPopulationDEER + total_popInt;
            initialPopDEER = total_popInt;
            break;
          case "Horse":
            AppFrame.totalPopulationHORSE = AppFrame.totalPopulationHORSE + total_popInt;
            initialPopHORSE = total_popInt;
            break;
          default:
            System.out.println("Switch in Initialize is not working");
            break;
        }
        Main.totalPopulation = Main.totalPopulation + total_popInt;
        new AnimalDetails(
            "2009", "01", CreateAnimal.animalTypeToEnum(typeAnim), total_popInt, 0, "Winter");
        new CreateAnimal(CreateAnimal.animalTypeToEnum(typeAnim), total_popInt);
      }
    }
  }
Esempio n. 12
0
  // Вид формы при изменении сотрудника
  public void sotrDiaUpdate(Sotrudnik s) {
    label_id_hidden.setText(Integer.toString(s.getId_sotrudnika()));
    textField_familiya.setText(s.getFamiliya());
    textField_imya.setText(s.getImya());
    textField_otchestvo.setText(s.getOtchestvo());
    textField_phone.setText(s.getPhone());
    textField_date.setText(s.getData_priema().toString());
    comboBox_doljnost.removeAllItems();
    comboBox_kvalification.removeAllItems();

    try {
      DBClass db = new DBClass();
      ArrayList<Doljnost> d = db.doljnostFromDB();
      DBClass db2 = new DBClass();
      Doljnost dd = db2.doljnostFromDB(s);
      for (int i = 0; i < d.size(); i++) {
        comboBox_doljnost.addItem(d.get(i));
        Doljnost ddd = (Doljnost) comboBox_doljnost.getItemAt(i);
        if (dd.getNazvanie_doljnosti().equals(ddd.getNazvanie_doljnosti())) dd = ddd;
      }
      comboBox_doljnost.setSelectedItem(dd);

      DBClass db3 = new DBClass();
      ArrayList<Kvalification> k = db3.kvalificationFromDB();
      DBClass db4 = new DBClass();
      Kvalification kk = db4.kvalificationFromDB(s);
      for (int i = 0; i < k.size(); i++) {
        comboBox_kvalification.addItem(k.get(i));
        Kvalification kkk = (Kvalification) comboBox_kvalification.getItemAt(i);
        if (kk.getNazvanie_kvalification().equals(kkk.getNazvanie_kvalification())) kk = kkk;
      }

      comboBox_kvalification.setSelectedItem(kk);

    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(panelException, e.getMessage());
    } catch (SQLException ee) {
      ee.printStackTrace();
      JOptionPane.showMessageDialog(panelException, ee.getMessage());
    }
  }
Esempio n. 13
0
 /*
  * Metodo eliminar()
  * sin parametros, sin retorno, elimina el elemento seleccionado del vector
  */
 private void eliminar() {
   int seleccion = librosCombo.getSelectedIndex();
   String nombre =
       librosCombo.getItemAt(seleccion).getAutorNombres()
           + " "
           + librosCombo.getItemAt(seleccion).getApellidosAutor();
   int opcion =
       JOptionPane.showConfirmDialog(
           this,
           "Está seguro que desea borrar el registro del alumno\n" + nombre,
           "Eliminar Alumno",
           JOptionPane.YES_NO_OPTION,
           JOptionPane.QUESTION_MESSAGE);
   if (opcion == JOptionPane.YES_OPTION) {
     librosCombo.removeItemAt(seleccion);
     JOptionPane.showMessageDialog(
         this, "Registro eliminado con éxito", "Eliminar Alumno", JOptionPane.INFORMATION_MESSAGE);
     revisarCombo();
   }
 }
Esempio n. 14
0
 /** Set the default projection to display */
 void setDefaultProjection() {
   // let the first projection class be the default
   ProjectionClass selectedClass = (ProjectionClass) projClassCB.getItemAt(0);
   if (selectedClass == null) {
     System.out.println("Projection Manager: no Default Projection available");
     return;
   }
   ProjectionImpl proj = selectedClass.makeDefaultProjection();
   setProjection(proj);
   startingName = "";
 }
 public void finalizeAssetType(AssetType type) {
   mySelectedAssetType = type;
   myTemplateState.put(ATTR_ASSET_TYPE, type.name());
   for (int i = 0; i < myAssetTypeComboBox.getItemCount(); ++i) {
     if (((ComboBoxItem) myAssetTypeComboBox.getItemAt(i)).id.equals(type.name())) {
       myAssetTypeComboBox.setSelectedIndex(i);
       break;
     }
   }
   hide(myAssetTypeComboBox, myAssetTypeLabel);
   update();
 }
 private void applySelectedValue(JComboBox comboBox, Object value) {
   comboBox.removeItemListener(this);
   ValueLabelItem currentItem;
   for (int i = 0; i < comboBox.getItemCount(); i++) {
     currentItem = (ValueLabelItem) comboBox.getItemAt(i);
     if (currentItem.getValue().equals(value)) {
       comboBox.setSelectedIndex(i);
       break;
     }
   }
   comboBox.addItemListener(this);
 }
Esempio n. 17
0
 private void selectThread(ThreadReferenceProxyImpl toSelect) {
   int count = myThreadsCombo.getItemCount();
   for (int idx = 0; idx < count; idx++) {
     ThreadDescriptorImpl item = (ThreadDescriptorImpl) myThreadsCombo.getItemAt(idx);
     if (toSelect.equals(item.getThreadReference())) {
       if (!item.equals(myThreadsCombo.getSelectedItem())) {
         myThreadsCombo.setSelectedIndex(idx);
       }
       return;
     }
   }
 }
Esempio n. 18
0
 public void setAgent(String agentName) {
   int index = 0;
   debug("scanning " + agents.getItemCount() + " agents");
   for (int i = 0; i < agents.getItemCount(); i++) {
     if (agents.getItemAt(i).toString().equals(agentName)) {
       index = i;
       debug("matched " + agentName);
     } else {
       debug("not matched " + agentName);
     }
   }
   agents.setSelectedIndex(index);
 }
Esempio n. 19
0
    /**
     * Set the fields from the ProjectionClass
     *
     * @param projClass projection class to use
     */
    private void setFieldsWithClassParams(ProjectionClass projClass) {

      // set the projection in the JComboBox
      String want = projClass.toString();
      for (int i = 0; i < projClassCB.getItemCount(); i++) {
        ProjectionClass pc = (ProjectionClass) projClassCB.getItemAt(i);
        if (pc.toString().equals(want)) {
          projClassCB.setSelectedItem((Object) pc);
          break;
        }
      }

      // set the parameter fields
      paramPanel.removeAll();
      paramPanel.setVisible(0 < projClass.paramList.size());

      List widgets = new ArrayList();
      for (int i = 0; i < projClass.paramList.size(); i++) {
        ProjectionParam pp = (ProjectionParam) projClass.paramList.get(i);
        // construct the label
        String name = pp.name;
        String text = "";
        // Create a decent looking label
        for (int cIdx = 0; cIdx < name.length(); cIdx++) {
          char c = name.charAt(cIdx);
          if (cIdx == 0) {
            c = Character.toUpperCase(c);
          } else {
            if (Character.isUpperCase(c)) {
              text += " ";
              c = Character.toLowerCase(c);
            }
          }
          text += c;
        }
        widgets.add(GuiUtils.rLabel(text + ": "));
        // text input field
        JTextField tf = new JTextField();
        pp.setTextField(tf);
        tf.setColumns(12);
        widgets.add(tf);
      }
      GuiUtils.tmpInsets = new Insets(4, 4, 4, 4);
      JPanel widgetPanel = GuiUtils.doLayout(widgets, 2, GuiUtils.WT_N, GuiUtils.WT_N);

      paramPanel.add("North", widgetPanel);
      paramPanel.add("Center", GuiUtils.filler());
    }
  public MarkForm(JFrame frame) {
    loginFacade = new LoginFacade();
    filteringFacade = new FilteringFacade(manager);
    facade = new Facade();

    manager = (Manager) loginFacade.getUser(personId);
    mark = facade.getMark(markId);

    setupMark();

    cancelBnt.addActionListener(e -> frame.dispose());
    saveBtn.addActionListener(
        e -> {
          facade.updateMark(mark, commentTF.getText(), markCB.getItemAt(markCB.getSelectedIndex()));
          frame.dispose();
        });
  }
Esempio n. 21
0
 public void setSelectedDisplayOption(MatrixType[] options, boolean control) {
   if (control) {
     MatrixType originalMatrixType = (MatrixType) displayOptionComboBox.getSelectedItem();
     displayOptionComboBox.setModel(new DefaultComboBoxModel<MatrixType>(options));
     int indx = 0;
     for (int i = 0; i < displayOptionComboBox.getItemCount(); i++) {
       if (originalMatrixType.equals(displayOptionComboBox.getItemAt(i))) {
         indx = i;
         break;
       }
     }
     displayOptionComboBox.setSelectedIndex(indx);
   } else {
     displayOptionComboBox.setModel(new DefaultComboBoxModel<MatrixType>(options));
     displayOptionComboBox.setSelectedIndex(0);
   }
 }
Esempio n. 22
0
  public void keyReleased(KeyEvent e) {
    char ch = e.getKeyChar();
    if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch)) return;
    int pos = m_editor.getCaretPosition();
    String str = m_editor.getText();
    if (str.length() == 0) return;

    for (int k = 0; k < m_comboBox.getItemCount(); k++) {
      String item = m_comboBox.getItemAt(k).toString();
      if (item.startsWith(str)) {
        m_editor.setText(item);
        m_editor.setCaretPosition(item.length());
        m_editor.moveCaretPosition(pos);
        m_comboBox.setSelectedItem(item);
        break;
      }
    }
  }
Esempio n. 23
0
 public void setMessage(int i) {
   String m = menu.getItemAt(i);
   System.out.println(m);
   setMessage(Q.get(m));
 }
Esempio n. 24
0
 public void setItem(int i) {
   String m = (String) menu.getItemAt(i);
   System.out.println(m);
   setMessage(map.get(m));
 }
Esempio n. 25
0
  public void gererEventBouttons(ActionEvent e) {
    if (e.getSource() == modeButton[0]) { // Boutton precedent
      // Verify
      if (comboCollection.getItemAt(comboCollection.getSelectedIndex() - 1) == null) {
        // modeButton[0].setVisible(false);
        modeButton[0].setEnabled(false);
        // messageErreur("Il n'y a pas d'element precedent a la collection");
        messageErreur(MSG_ERREUR_BTN_PRECEDENT);

      } else {
        comboCollection.setSelectedIndex(comboCollection.getSelectedIndex() - 1);
        // Get
        Video video =
            this.obtenirVideo(
                comboCollection
                    .getItemAt(comboCollection.getSelectedIndex())
                    .toString()); // String titre
        String catos =
            this.obtenirCategoriesEnString(
                comboCollection.getItemAt(comboCollection.getSelectedIndex()).toString());
        afficherFilmChoisis(video.getTitre());
        modeButton[1].setVisible(true);
        modeButton[1].setEnabled(true);
        if (comboCollection.getItemAt(comboCollection.getSelectedIndex() - 1) == null) {
          modeButton[0].setEnabled(false);
        }
      }

    } else if (e.getSource() == modeButton[1]) { // Boutton suivant
      // Verify
      if (comboCollection.getItemAt(comboCollection.getSelectedIndex() + 1) == null) {
        // modeButton[1].setVisible(false);
        modeButton[1].setEnabled(false);
        // messageErreur("Il n'y a pas d'element suivant a la collection");
        messageErreur(MSG_ERREUR_BTN_SUIVANT);
      } else {
        comboCollection.setSelectedIndex(comboCollection.getSelectedIndex() + 1);
        // Get
        Video video =
            this.obtenirVideo(
                comboCollection
                    .getItemAt(comboCollection.getSelectedIndex())
                    .toString()); // String titre
        String catos =
            this.obtenirCategoriesEnString(
                comboCollection.getItemAt(comboCollection.getSelectedIndex()).toString());
        afficherFilmChoisis(video.getTitre());
        modeButton[0].setVisible(true);
        modeButton[0].setEnabled(true);
        if (comboCollection.getItemAt(comboCollection.getSelectedIndex() + 1) == null) {
          modeButton[1].setEnabled(false);
        }
      }
    } else if (e.getSource() == modeButton[2]) { // Boutton ajouter
      // Verify
      if (textTitre.getText() == null || textTitre.getText().equals("")) {
        messageErreur(MSG_ERREUR_CHAMPS_TITRE);
      } else if (textAnnee.getText() == null
          || textAnnee.getText().equals("")
          || !textAnnee.getText().matches("^[0-9]+$")) {
        messageErreur(MSG_ERREUR_CHAMPS_ANNEE);
      } /*else if(textCommentaires.getText() == null){
            messageErreur("Champs commentaires null");
        } */ else if (textCategories.getText() == null) {
        messageErreur(MSG_ERREUR_CHAMP_CAT);
      } else {
        boolean type;
        if (comboType.getSelectedIndex() == 0) {
          messageErreur(MSG_ERREUR_CHAMP_TYPE);
          type = false;
        } else {
          if (comboType.getSelectedIndex() == 1) {
            type = true;
          } else {
            type = false;
          }
          int eval;
          if (comboEval.getSelectedIndex() == 0) {
            messageErreur(MSG_ERREUR_EVALUATION);
          } else {
            eval = comboEval.getSelectedIndex();
            // Place
            this.ajouterVideo(
                textTitre.getText(),
                Integer.parseInt(textAnnee.getText()),
                type,
                eval,
                textCommentaires.getText(),
                textCategories
                    .getText()); // String titre, int annee, boolean type, int eval, String
                                 // comments, String categories
          }
        }
      }

    } else if (e.getSource() == modeButton[3]) { // Boutton modifier
      // Verify
      if (textTitre.getText() == null || textTitre.getText().equals("")) {
        messageErreur(MSG_ERREUR_CHAMPS_TITRE);
      } else if (textAnnee.getText() == null
          || textAnnee.getText().equals("")
          || !textAnnee.getText().matches("^[0-9]+$")) {
        messageErreur(MSG_ERREUR_CHAMPS_ANNEE);
      } /*else if(textCommentaires.getText() == null){
            messageErreur("Champs commentaires null");
        } */ else if (textCategories.getText() == null) {
        messageErreur(MSG_ERREUR_CHAMP_CAT);
      } else {

        int eval;
        if (comboEval.getSelectedIndex() == 0) {
          messageErreur(MSG_ERREUR_EVALUATION);
        } else {
          eval = comboEval.getSelectedIndex();

          boolean type;
          if (comboType.getSelectedIndex() == 0) {
            messageErreur(MSG_ERREUR_CHAMP_TYPE);
            type = false;
          } else if (comboType.getSelectedIndex() == 1) {
            type = true;
          } else {
            type = false;
          }
          // Place
          if (this.modifierVideo(
              comboCollection.getSelectedItem().toString(),
              textTitre.getText(),
              Integer.parseInt(textAnnee.getText()),
              eval,
              type,
              textCommentaires.getText(),
              textCategories
                  .getText())) { // String titre, int annee, int eval, boolean type, String
                                 // comments, String categories
            messageSuccess("La video a ete modifier.");
          } else {
            messageSuccess("La video n'a pas ete modifier.");
          }
        }
      }

    } else if (e.getSource() == modeButton[4]) { // Boutton supprimer
      // Verify ... nothing...

      // Place
      if (this.supprimerVideo(comboCollection.getSelectedItem().toString())) {
        JOptionPane.showMessageDialog(
            fenetre,
            comboCollection.getSelectedItem().toString() + " a ete retirer de la collection!");
      } else {
        messageErreur(MSG_ERREUR_FIM_NON_SUPPRIMER);
      }

    } else if (e.getSource() == modeButton[5]) { // Boutton rechercher
      int eval = comboEval.getSelectedIndex();
      /*
      -1:  Pas de recherche par evaluation
       0:  0 étoile
       1:  1 étoile
       2:  2 étoiles
       3:  3 étoiles
       4:  4 étoiles
       5:  5 étoiles
      */

      /*
      -1: Pas de recherche par type
       0: FILM
       1: SERIE TV
      */
      int type = comboType.getSelectedIndex() - 1;

      ArrayList<Video> videosTrouver = new ArrayList<Video>();

      if (!textAnnee.getText().equals("")) {
        videosTrouver =
            rechercherVideos(
                textTitre.getText(),
                Integer.parseInt(textAnnee.getText()),
                eval,
                type,
                textCategories.getText());
      } else {
        videosTrouver =
            rechercherVideos(textTitre.getText(), -1, eval, type, textCategories.getText());
      }

      // comboCollection.removeAllItems();
      ArrayList itemsInComboCollection = new ArrayList();
      for (Video video : videosTrouver) {
        if (!itemsInComboCollection.contains(video)) {
          itemsInComboCollection.add(video);
          comboCollection.addItem(video.getTitre());
        }
      }
      comboCollection.setEnabled(true);

      modeButton[0].setVisible(true);
      modeButton[1].setVisible(true);
      if (comboCollection.getSelectedIndex() != 0 && comboCollection.getItemCount() != 0) {
        modeButton[0].setEnabled(true);
      } else {
        modeButton[0].setEnabled(false);
      }

      if (comboCollection.getSelectedIndex() != comboCollection.getItemCount()
          && comboCollection.getItemCount() != 0) {
        modeButton[1].setEnabled(true);
      } else {
        modeButton[1].setEnabled(false);
      }
      modeButton[5].setVisible(false);
      modeButton[6].setVisible(true);

    } else if (e.getSource() == modeButton[6]) { // Bouton Nouvelle Recherche
      modeRecherche();
    } else if (e.getSource() == optionCategories[0]) { // Boutton ajouter categorie
      // Get
      String[] categoriesDuFilm = textCategories.getText().split("\n");
      ArrayList listeDeCategories = ArrayToArrayList(categoriesDuFilm);
      if (listeDeCategories.get(0).equals("")) {
        listeDeCategories.clear();
      }
      selectionCategorie.removeAllItems();
      ArrayList cater = new ArrayList();
      for (String categorie : liste.obtenirCles()) {
        if (!cater.contains(categorie)) {
          cater.add(categorie);
          selectionCategorie.addItem(categorie);
        }
      }
      popUpSelection.add(selectionCategorie);
      fenetre.getContentPane().add(popUpSelection);
      int action =
          JOptionPane.showConfirmDialog(
              null,
              popUpSelection,
              "Categorie",
              JOptionPane.OK_CANCEL_OPTION,
              JOptionPane.QUESTION_MESSAGE);

      switch (action) {
        case 0:
          if (((String) selectionCategorie.getSelectedItem()).equals("Autres...")) {
            popUpSelection.remove(selectionCategorie);
            String categorieEntree =
                JOptionPane.showInputDialog(popUpSelection, "Ajouter une categorie");
            if (categorieEntree != null) {
              if (!categorieExiste(listeDeCategories, categorieEntree)) {
                if (listeDeCategories.isEmpty()) {
                  textCategories.setText(categorieEntree);
                } else {
                  textCategories.setText(textCategories.getText() + "\n" + categorieEntree);
                }
                optionCategories[1].setEnabled(true);
              } else {
                messageErreur(MSG_ERREUR_CAT_EXST);
              }
            } else {
              messageErreur(MSG_ERREUR_ENTREE_NULL);
            }
          } else {
            if (!categorieExiste(
                listeDeCategories, (String) selectionCategorie.getSelectedItem())) {
              if (listeDeCategories.isEmpty()) {
                textCategories.setText(selectionCategorie.getSelectedItem().toString());
              } else {
                textCategories.setText(
                    textCategories.getText()
                        + "\n"
                        + (String) selectionCategorie.getSelectedItem());
              }
            } else {
              messageErreur(MSG_ERREUR_CAT_EXST);
            }
          }
          break;
        case 1:
          break;
      }
    } else if (e.getSource() == optionCategories[1]) { // Boutton supprimer categorie
      // Get
      String[] categoriesDuFilm = textCategories.getText().trim().split("\\n");
      ArrayList listeDeCategories = ArrayToArrayList(categoriesDuFilm);
      selectionCategorie.removeAllItems();
      for (Object categorie : listeDeCategories) {
        selectionCategorie.addItem(categorie.toString());
      }
      popUpSelection.add(selectionCategorie);
      fenetre.getContentPane().add(popUpSelection);
      int action =
          JOptionPane.showConfirmDialog(
              null,
              popUpSelection,
              "Categorie",
              JOptionPane.OK_CANCEL_OPTION,
              JOptionPane.QUESTION_MESSAGE);
      switch (action) {
        case 0:
          String categorieASupprimer = (String) selectionCategorie.getSelectedItem();
          String output = "";
          if (!listeDeCategories.isEmpty()) {
            listeDeCategories.remove(categorieASupprimer);
            for (int i = 0; i < listeDeCategories.size(); i++) {
              output += (String) listeDeCategories.get(i);
              if (i + 1 != listeDeCategories.size()) {
                output += "\n";
              }
            }
            textCategories.setText(output);
          } else {
            optionCategories[1].setEnabled(false);
          }
          break;
        case 1:
          break;
      }
    }
  }