コード例 #1
0
  @SuppressWarnings({"UnusedDeclaration"})
  protected void startButtonActionPerformed(ActionEvent event) {
    for (BulkRetrievablePanel panel : this.retrievables) {
      if (panel.selectCheckBox.isSelected()) {
        BulkRetrievable retrievable = panel.retrievable;
        BulkRetrievalThread thread =
            retrievable.makeLocal(
                this.currentSector,
                0,
                this.cache,
                new BulkRetrievalListener() {
                  public void eventOccurred(BulkRetrievalEvent event) {
                    // This is how you'd include a retrieval listener. Uncomment below to monitor
                    // downloads.
                    // Be aware that the method is not invoked on the event dispatch thread, so any
                    // interaction
                    // with AWT or Swing must be within a SwingUtilities.invokeLater() runnable.

                    // System.out.printf("%s: item %s\n",
                    //    event.getEventType().equals(BulkRetrievalEvent.RETRIEVAL_SUCCEEDED) ?
                    // "Succeeded"
                    // : event.getEventType().equals(BulkRetrievalEvent.RETRIEVAL_FAILED) ? "Failed"
                    //    : "Unknown event type", event.getItem());
                  }
                });

        if (thread != null) this.monitorPanel.add(new DownloadMonitorPanel(thread));
      }
    }
    this.getTopLevelAncestor().validate();
  }
コード例 #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("-");
           }
         });
 }