/**
  * Reset this panel so an existing song can be edited.
  *
  * <p>
  *
  * @param song the song to edit.
  */
 public void resetEditSong(SongDisplayable song) {
   getTitleField().setText(song.getTitle());
   getAuthorField().setText(song.getAuthor());
   getLyricsField().replaceText(song.getLyrics(true, true));
   getLyricsField().refreshStyle();
   getLyricsField().requestFocus();
 }
  /**
   * Remove the selected song from the database.
   *
   * <p>
   *
   * @param t the action event.
   */
  @Override
  public void handle(ActionEvent t) {
    MainWindow mainWindow = QueleaApp.get().getMainWindow();
    final LibrarySongList songList =
        mainWindow.getMainPanel().getLibraryPanel().getLibrarySongPanel().getSongList();
    int index = songList.getListView().getSelectionModel().getSelectedIndex();
    if (index == -1) {
      return;
    }
    final SongDisplayable song = songList.getListView().itemsProperty().get().get(index);
    if (song == null) {
      return;
    }
    yes = false;
    Dialog.buildConfirmation(
            LabelGrabber.INSTANCE.getLabel("confirm.remove.text"),
            LabelGrabber.INSTANCE
                .getLabel("confirm.remove.question")
                .replace("$1", song.getTitle()))
        .addYesButton(
            new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent t) {
                yes = true;
              }
            })
        .addNoButton(
            new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent t) {}
            })
        .build()
        .showAndWait();
    if (yes) {
      songList.setLoading(true);
      new Thread() {
        @Override
        public void run() {
          if (!SongManager.get().removeSong(song)) {
            Platform.runLater(
                new Runnable() {
                  @Override
                  public void run() {
                    Dialog.showError(
                        LabelGrabber.INSTANCE.getLabel("error.text"),
                        LabelGrabber.INSTANCE.getLabel("error.removing.song.db"));
                  }
                });
          } else {
            song.setID(-1);
            Platform.runLater(
                new Runnable() {

                  @Override
                  public void run() {
                    songList.getListView().itemsProperty().get().remove(song);
                    songList.setLoading(false);
                  }
                });
          }
        }
      }.start();
    }
  }