コード例 #1
0
  /**
   * Methode qui gere la recherche lorsque le bouton recherche est cliqué
   *
   * @param event
   */
  @FXML
  void activerRecherche(ActionEvent event) {

    if (radioMotExact.isSelected()) {

      if (!motInput.getText().isEmpty() && motInput.getText().length() > 2) {

        model.rechMotExact(motInput.getText());

        if (checkBoxImage.isSelected()) {
          model.rechSelonImage();
        }

        if (checkBoxSaisieApres.isSelected() && datePickerSaisieApres.getValue() != null) {
          model.rechApresDateSaisie(datePickerSaisieApres.getValue());
        }

        if (checkBoxSaisieAvant.isSelected() && datePickerSaisieAvant.getValue() != null) {
          model.rechAvantDateSaisie(datePickerSaisieAvant.getValue());
        }

        if (checkBoxModifApres.isSelected() && datePickerModifApres.getValue() != null) {
          model.rechApresDateModif(datePickerModifApres.getValue());
        }

        if (checkBoxModifAvant.isSelected() && datePickerModifAvant.getValue() != null) {
          model.rechAvantDateModif(datePickerModifAvant.getValue());
        }

        if (model.listeResultats.isEmpty()) {

          Alert alert = new Alert(AlertType.ERROR);
          alert.setTitle("Dictionnaire");
          alert.setContentText("Mot introuvable.");
          alert.setHeaderText(null);
          alert.showAndWait();
        }

        model.notifyObs(model.listeResultats);

        for (Mot m : model.listeResultats) {

          System.out.println(m.getLibelle());
        }

      } else {

        Alert alert = new Alert(AlertType.ERROR);
        alert.setTitle("Dictionnaire");
        alert.setContentText("L'expression doit contenir minimum 3 lettres.");
        alert.setHeaderText(null);
        alert.showAndWait();
      }

    } else {

      if (!motInput.getText().isEmpty() && motInput.getText().length() > 2) {

        model.rechMotPartiel(".*" + motInput.getText() + ".*");

        if (checkBoxImage.isSelected()) {

          model.rechSelonImage();
        }

        if (checkBoxSaisieApres.isSelected() && datePickerSaisieApres.getValue() != null) {

          model.rechApresDateSaisie(datePickerSaisieApres.getValue());
        }

        if (checkBoxSaisieAvant.isSelected() && datePickerSaisieAvant.getValue() != null) {

          model.rechAvantDateSaisie(datePickerSaisieAvant.getValue());
        }

        if (checkBoxModifApres.isSelected() && datePickerModifApres.getValue() != null) {

          model.rechApresDateModif(datePickerModifApres.getValue());
        }

        if (checkBoxModifAvant.isSelected() && datePickerModifAvant.getValue() != null) {

          model.rechAvantDateModif(datePickerModifAvant.getValue());
        }

        if (model.listeResultats.isEmpty()) {

          Alert alert = new Alert(AlertType.ERROR);
          alert.setTitle("Dictionnaire");
          alert.setContentText("Mot introuvable.");
          alert.setHeaderText(null);
          alert.showAndWait();
        }

        model.notifyObs(model.listeResultats);

        for (Mot m : model.listeResultats) {

          System.out.println(m.getLibelle());
        }
      } else {

        Alert alert = new Alert(AlertType.ERROR);
        alert.setTitle("Dictionnaire");
        alert.setContentText("L'expression doit contenir minimum 3 lettres.");
        alert.setHeaderText(null);
        alert.showAndWait();
      }
    }
  }