Exemple #1
0
  /** Writes view contents to the underlying model. */
  @Override
  protected void updateModel() {
    Track track = getTrack();

    // compare any fields that may have changed.
    if (!StringUtils.equals(track.getName(), titleField.getText())) {
      track.setName(titleField.getText());
    }
    if (!StringUtils.equalsIgnoreCase(track.getTrackNumber(), trackNumber.getText())) {
      track.setTrackNumber(trackNumber.getText());
    }
    if (!StringUtils.equalsIgnoreCase(track.getComment(), comment.getText())) {
      track.setComment(comment.getText());
    }

    if (musicTag != null) {
      musicTag.setTitle(titleField.getText());
      musicTag.setTrack(trackNumber.getText());
      musicTag.setComment(comment.getText());
    }
  }
Exemple #2
0
  /** Reads view contents from the underlying model. */
  @Override
  protected void updateView() {
    final String currentCoverUrl;
    Track track = getTrack();
    titleField.setText(track.getName());
    trackNumber.setText(track.getTrackNumber());
    comment.setText(track.getComment());
    location.setText(track.getTrackUrl());
    location.setToolTipText(track.getTrackUrl());
    createdDateLabel.setText(DATE_FORMAT.format(track.getCreatedDate()));
    createdByLabel.setText(track.getCreatedUser());
    modifiedDateLabel.setText(DATE_FORMAT.format(track.getModifiedDate()));
    modifiedByLabel.setText(track.getModifiedUser());
    albumImage.setDisc(track.getDisc());
    if (this.getSettings().isCopyImagesToDirectory()) {
      currentCoverUrl =
          ImageFactory.standardImageFileName(
              track.getDisc().getArtist().getName(),
              track.getDisc().getName(),
              track.getDisc().getYear());
    } else {
      currentCoverUrl = track.getDisc().getCoverUrl();
    }
    if (StringUtils.isNotBlank(currentCoverUrl)) {
      int dimension = this.getSettings().getCoverSizeSmall();
      albumImage.setImage(
          ImageFactory.getScaledImage(currentCoverUrl, dimension, dimension).getImage());
    } else {
      albumImage.setImage(null);
    }

    // try and open the tag, but fail safely
    try {
      // AZ: verify if file is accessible
      final File file = new File(track.getTrackUrl());
      if (file.exists()) {
        musicTag = TagFactory.getTag(track.getTrackUrl());
        duration.setText(musicTag.getTrackLengthAsString());
        layer.setText(musicTag.getLayer());
        version.setText(musicTag.getVersion());
        bitRate.setText(musicTag.getBitRateAsString());
        frequency.setText(musicTag.getFrequency() + " Hz");
        mode.setText(musicTag.getMode());
        fileSize.setText(FileUtils.byteCountToDisplaySize(musicTag.getFile().length()));
        emphasis.setText(musicTag.getEmphasis());
        copyrighted.setText(musicTag.getCopyrighted());
      } else {
        LOG.debug("File: " + track.getTrackUrl() + " is not accessible");
        duration.setText("");
        layer.setText("");
        version.setText("");
        bitRate.setText("");
        frequency.setText("");
        mode.setText("");
        fileSize.setText("");
        emphasis.setText("");
        copyrighted.setText("");
        musicTag = null;
      }
    } catch (MusicTagException ex) {
      LOG.info(ex.getMessage(), ex);
      duration.setText("");
      layer.setText("");
      version.setText("");
      bitRate.setText("");
      frequency.setText("");
      mode.setText("");
      fileSize.setText("");
      emphasis.setText("");
      copyrighted.setText("");
      musicTag = null;
    }
  }