Example #1
0
  /**
   * Update URL and gauge of the progress form.
   *
   * @param url new URL, null to remove, "" to not change
   * @param size 0 if unknown, else size of object to download in K bytes
   * @param gaugeLabel label for progress gauge
   */
  private void updateProgressForm(String url, int size, String gaugeLabel) {
    Gauge oldProgressGauge;
    Gauge progressGauge;
    StringItem urlItem;

    // We need to prevent "flashing" on fast development platforms.
    while (System.currentTimeMillis() - lastDisplayChange < GraphicalInstaller.ALERT_TIMEOUT) ;

    if (size <= 0) {
      progressGauge = new Gauge(gaugeLabel, false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING);
    } else {
      progressGauge = new Gauge(gaugeLabel, false, size, 0);
    }

    oldProgressGauge = (Gauge) progressForm.get(progressGaugeIndex);
    progressForm.set(progressGaugeIndex, progressGauge);

    // this ends the background thread of gauge.
    oldProgressGauge.setValue(Gauge.CONTINUOUS_IDLE);

    if (url == null) {
      urlItem = new StringItem("", "");
      progressForm.set(progressUrlIndex, urlItem);
    } else if (url.length() != 0) {
      urlItem = new StringItem(Resource.getString(ResourceConstants.AMS_WEBSITE) + ": ", url);
      progressForm.set(progressUrlIndex, urlItem);
    }

    lastDisplayChange = System.currentTimeMillis();
  }