Пример #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();
  }
  private void switchType() {
    int index = choiseType.getSelectedIndex();
    try {
      Object rfocus = StaticData.getInstance().roster.getFocusedObject();
      switch (index) {
        case 0: // jid
          if (targetList != null)
            if (rfocus instanceof Contact) {
              textValue.setString(((Contact) rfocus).getBareJid());
            }
          form.set(2, textValue);
          break;
        case 1: // group
          if (targetList != null)
            textValue.setString(
                ((rfocus instanceof Group) ? (Group) rfocus : ((Contact) rfocus).getGroup())
                    .getName());

          form.set(2, textValue);
          break;
        case 2: // subscription
          form.set(2, choiceSubscr);
          break;

        case 3:
          form.set(2, new StringItem(null, "(ANY)"));
      }
      /*if (index==2) {
          form.set(2, choiceSubscr);
      } else {
          textValue.setLabel(PrivacyItem.types[index]);
          form.set(2, textValue);
      }
       */
    } catch (Exception e) {
      /* При смене на самого себя */
    }
  }
  public void itemStateChanged(Item item) {
    if (item == tGrpList) {
      int index = tGrpList.getSelectedIndex();
      if (index == tGrpList.size() - 1) {
        f.set(grpFIndex, tGroup);
      }
      // tGroup.setString(group(index));
    }

    // if (item==tGroup) {
    //    updateChoise(tGroup.getString(), tGrpList);
    // }

    if (item == tTranspList) {
      int index = tTranspList.getSelectedIndex();
      if (index == tTranspList.size() - 1) return;

      String transport = tTranspList.getString(index);

      String jid = tJid.getString();
      StringBuffer jidBuf = new StringBuffer(jid);

      int at = jid.indexOf('@');
      if (at < 0) at = tJid.size();

      jidBuf.setLength(at);
      jidBuf.append('@');
      jidBuf.append(transport);
      tJid.setString(jidBuf.toString());
    }
    if (item == tJid) {
      String s1 = tJid.getString();
      int at = tJid.getString().indexOf('@');
      try {
        updateChoise(s1.substring(at + 1), tTranspList);
      } catch (Exception e) {
      }
    }
  }