コード例 #1
0
    protected void updateStatus() {
      // Update description
      String text = thread.getRetrievable().getName();
      text = text.length() > 30 ? text.substring(0, 27) + "..." : text;
      text +=
          " ("
              + BulkDownloadPanel.makeSizeDescription(this.progress.getCurrentSize())
              + " / "
              + BulkDownloadPanel.makeSizeDescription(this.progress.getTotalSize())
              + ")";
      this.descriptionLabel.setText(text);
      // Update progress bar
      int percent = 0;
      if (this.progress.getTotalCount() > 0)
        percent =
            (int) ((float) this.progress.getCurrentCount() / this.progress.getTotalCount() * 100f);
      this.progressBar.setValue(Math.min(percent, 100));
      // Update tooltip
      String tooltip = BulkDownloadPanel.makeSectorDescription(this.thread.getSector());
      this.descriptionLabel.setToolTipText(tooltip);
      this.progressBar.setToolTipText(makeProgressDescription());

      // Check for end of thread
      if (!this.thread.isAlive()) {
        // Thread is done
        this.cancelButton.setText("Remove");
        this.cancelButton.setBackground(Color.GREEN);
        this.updateTimer.stop();
      }
    }
コード例 #2
0
 protected void doUpdateDescription(final Sector sector) {
   if (sector != null) {
     try {
       long size = retrievable.getEstimatedMissingDataSize(sector, 0, cache);
       final String formattedSize = BulkDownloadPanel.makeSizeDescription(size);
       SwingUtilities.invokeLater(
           new Runnable() {
             public void run() {
               descriptionLabel.setText(formattedSize);
             }
           });
     } catch (Exception e) {
       SwingUtilities.invokeLater(
           new Runnable() {
             public void run() {
               descriptionLabel.setText("-");
             }
           });
     }
   } else
     SwingUtilities.invokeLater(
         new Runnable() {
           public void run() {
             descriptionLabel.setText("-");
           }
         });
 }