/**
   * Speichert die Informationen aus dem {@link AudioFileEditorPanel} in die entsprechenden {@link
   * AudioFile}'s zurŸck.
   */
  public void saveTags() {
    saveValueFromEditedComboBox();

    Runnable saver =
        new Runnable() {
          public void run() {
            if (audioFiles != null && audioFiles.size() > 0) {

              ArrayList<AudioFile> wrongFiles = new ArrayList<AudioFile>();

              for (AudioFile audioFile : audioFiles) {
                try {
                  Tag tag = audioFile.getTag();

                  // Common-Tags setzen:
                  handleEditorValue(tag, TagFieldKey.TITLE, comTitle.getSelectedItem());
                  handleEditorValue(tag, TagFieldKey.ARTIST, comArtist.getSelectedItem());
                  handleEditorValue(tag, TagFieldKey.ALBUM, comAlbum.getSelectedItem());
                  handleEditorValue(tag, TagFieldKey.YEAR, txtYear.getText());
                  handleEditorValue(tag, TagFieldKey.GENRE, comGenre.getSelectedItem());

                  // Wenn mehrere AudioFiles geschrieben werden sollen,
                  // darf nur die Totale Anzahl Tracks geschrieben werden.
                  // Bei einem einzelnen AudioFile beides.
                  if (audioFiles.size() == 1) {
                    // Tracknumber:
                    String tracknumber = txtTracknumber.getText();
                    String totalTracks = txtTotalTracks.getText();
                    if (!totalTracks.equals("")) tracknumber = tracknumber + "/" + totalTracks;
                    tag.setTrack(tracknumber);

                    // Discs:
                    //								String discnumber = txtDiscnumber.getText();
                    //								String totalDiscs = txtTotalDiscs.getText();
                    //								if(!totalDiscs.equals("")) discnumber += "/" + totalDiscs;
                    //								tag.set(tag.createTagField(TagFieldKey.DISC_NO, discnumber));

                  } else {
                    // Tracknumber:
                    String totalTracks = txtTotalTracks.getText();
                    if (!totalTracks.equals("")) {
                      String[] currentTracknumber = splitNumberData(tag.getFirstTrack());
                      String tracknumber = currentTracknumber[0] + "/" + totalTracks;
                      tag.setTrack(tracknumber);
                    }

                    // Discs:
                    //								String discnumber = txtDiscnumber.getText();
                    //								String totalDiscs = txtTotalDiscs.getText();
                    //								String[] currentDiscnumber =
                    // splitNumberData(tag.getFirst(TagFieldKey.DISC_NO));
                    //
                    //								if(discnumber.equals("")) discnumber = currentDiscnumber[0];
                    //								if(!totalDiscs.equals("")) discnumber += "/" + totalDiscs;
                    //								tag.set(tag.createTagField(TagFieldKey.DISC_NO, discnumber));
                  }

                  // Artwork setzen (falls geŠndert):
                  if (imgArtwork.hasChanged()) {
                    tag.deleteTagField(TagFieldKey.COVER_ART);

                    BufferedImage image = imgArtwork.getArtwork();
                    if (image != null) {
                      Artwork artwork = new Artwork();
                      ByteArrayOutputStream out = new ByteArrayOutputStream();
                      ImageIO.write(image, "jpeg", out);
                      artwork.setBinaryData(out.toByteArray());
                      artwork.setMimeType("image/jpeg");
                      tag.createAndSetArtworkField(artwork);
                    }
                  }

                  /* Speichern: */
                  audioFile.commit();
                  editorChanged = false;
                } catch (Exception e) {
                  wrongFiles.add(audioFile);
                }
              }

              /* Fehler? */
              if (wrongFiles.size() > 0) {
                StringBuilder wrongFilesString = new StringBuilder();
                for (AudioFile wrongFile : wrongFiles)
                  wrongFilesString.append(" - " + wrongFile.getFile().getName() + "\n");

                JOptionPane.showMessageDialog(
                    SwingUtilities.getWindowAncestor(AudioFileEditorPanel.this),
                    "AudioTagger was not able to save the tags for the "
                        + "following audio files:\n"
                        + wrongFilesString.toString(),
                    "Tags not saved",
                    JOptionPane.ERROR_MESSAGE);
              }
            }
          }
        };

    /* WaitDialog: */
    // Alles in einen WaitDialog verpacken & anzeigen/durchfŸhren.
    WaitDialog waitDialog =
        new WaitDialog(
            SwingUtilities.getWindowAncestor(this),
            "Save tags",
            "Save tags. Please wait...",
            saver);
    waitDialog.setVisible(true);
  }