/** @throws IOException error */
 public final void loadImage() throws IOException {
   BufferedImage img;
   try {
     Stage stage = (Stage) Main.getWindow();
     FileChooser fileChooser = new FileChooser();
     fileChooser.setTitle("Open Image File");
     FileChooser.ExtensionFilter extFilterJPG =
         new FileChooser.ExtensionFilter("JPG files (*.jpg)", "*.JPG");
     FileChooser.ExtensionFilter extFilterPNG =
         new FileChooser.ExtensionFilter("PNG files (*.png)", "*.PNG");
     fileChooser.getExtensionFilters().addAll(extFilterJPG, extFilterPNG);
     File f = fileChooser.showOpenDialog(stage);
     if (f != null) {
       logger.info(f.getName());
       img = ImageIO.read(f);
       contactImage = new ContactImage(img);
       if ((contactImage.getHeight() >= 300 || contactImage.getHeight() <= 1000)
           && (contactImage.getWidth() >= 300 || contactImage.getWidth() <= 1000)) {
         contactImage.set(img);
         Image temp = SwingFXUtils.toFXImage(img, null);
         image.setImage(temp);
       } else {
         throw new ImageNotValidException("Foto ist zu groß!");
       }
     }
   } catch (Exception e) {
     logger.log(Level.SEVERE, "Error: " + e.getMessage());
   }
 }
  /** Back to main menu. */
  public final void onBtnBackClick() {

    try {
      Parent root = FXMLLoader.load(getClass().getResource("/view/Main.fxml"));
      Scene scene = new Scene(root);
      Main.getWindow().setScene(scene);
    } catch (IOException e) {
      logger.log(Level.SEVERE, "Couldn't change scene as expected: " + e.getMessage());
    }
  }
  /**
   * @param event event of button
   * @throws GroupNotValidException not valid
   * @throws IDNotValidException not valid
   * @throws StringNotValidException not valid
   */
  public final void onBtnGroupClick(final ActionEvent event)
      throws GroupNotValidException, IDNotValidException, StringNotValidException {

    try {
      Object item = disabled.getSelectionModel().getSelectedItem();
      Button button = (Button) event.getSource();

      // add a group
      if (button.getText().equals("<<")) {

        if (item.toString().equals("Arbeit")) {
          INACTIVEDATA.remove(item);
          ACTIVEDATA.add(item);
          c.addToGroup(Main.getWorkGroup());
        }
        if (item.toString().equals("Familie")) {
          INACTIVEDATA.remove(item);
          ACTIVEDATA.add(item);
          c.addToGroup(Main.getFamilyGroup());
        }
        if (item.toString().equals("Freunde")) {
          INACTIVEDATA.remove(item);
          ACTIVEDATA.add(item);
          c.addToGroup(Main.getFriendsGroup());
        }
      }

      // remove a group
      item = enabled.getSelectionModel().getSelectedItem();
      if (button.getText().equals(">>")) {

        if (item.toString().equals("Arbeit")) {
          ACTIVEDATA.remove(item);
          INACTIVEDATA.add(item);
          c.removeFromGroup(Main.getWorkGroup());
        }
        if (item.toString().equals("Familie")) {
          ACTIVEDATA.remove(item);
          INACTIVEDATA.add(item);
          c.removeFromGroup(Main.getFamilyGroup());
        }
        if (item.toString().equals("Freunde")) {
          ACTIVEDATA.remove(item);
          INACTIVEDATA.add(item);
          c.removeFromGroup(Main.getFriendsGroup());
        }
      }

    } catch (Exception e) {

      Alert alert = new Alert(AlertType.ERROR);
      alert.setTitle("Keine gültige Gruppe erkannt.");
      alert.setHeaderText("");
      alert.setContentText("Es wurde keine gültige Gruppe erkannt. Klicke auf gültige Gruppe.");
      alert.showAndWait();

      logger.log(Level.SEVERE, "Error: " + e.getMessage());
    }
  }
  @Override
  public final void initialize(final URL location, final ResourceBundle resources) {

    c =
        cgu.getContactFromGroup(
            Main.getDefaultGroup(),
            MainPresenter.getData()
                .get(
                    MainPresenter.getMainPresenterInstance()
                        .getMainTable()
                        .getSelectionModel()
                        .getSelectedIndex())
                .getId());
    setupGroups();
    try {
      setupTextFields();
    } catch (IOException e) {
      logger.log(Level.SEVERE, "Error loading image");
    }
  }