Exemplo n.º 1
0
  public void showAllRecordForm() {
    fmAllRecords = new Form("All records");
    try {
      RecordEnumeration recEnum = rs.enumerateRecords(null, null, false);
      while (recEnum.hasNextElement()) {
        try {
          // System.out.println(new String(recEnum.nextRecord()));
          String name = "Nenacetl jsem";
          int number = 0;
          try {
            byte[] record = recEnum.nextRecord();
            ByteArrayInputStream buffer = new ByteArrayInputStream(record);
            DataInputStream dis = new DataInputStream(buffer);
            name = dis.readUTF();
            number = dis.readInt();
            dis.close();
          } catch (Exception e) {
          }

          fmAllRecords.append(name + " " + String.valueOf(number) + "\n");
        } catch (Exception e) {
          System.out.println(e.getMessage());
        }

        //
      }
    } catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
    fmAllRecords.addCommand(cmdMenu);
    fmAllRecords.setCommandListener(this);
    dsp.setCurrent(fmAllRecords);
  }
Exemplo n.º 2
0
    /**
     * Get the list of suites for the user to install. The suites that are listed are the links on a
     * web page that end with .jad.
     */
    public void run() {
      StreamConnection conn = null;
      InputStreamReader in = null;
      String errorMessage;
      long startTime;

      startTime = System.currentTimeMillis();

      try {
        parent.displayProgressForm(
            Resource.getString(ResourceConstants.AMS_DISC_APP_GET_INSTALL_LIST),
            "",
            url,
            0,
            Resource.getString(ResourceConstants.AMS_GRA_INTLR_CONN_GAUGE_LABEL));
        conn = (StreamConnection) Connector.open(url, Connector.READ);
        in = new InputStreamReader(conn.openInputStream());
        try {
          parent.updateProgressForm(
              "", 0, Resource.getString(ResourceConstants.AMS_DISC_APP_GAUGE_LABEL_DOWNLOAD));

          parent.installList = SuiteDownloadInfo.getDownloadInfoFromPage(in);

          if (parent.installList.size() > 0) {
            parent.installListBox =
                new List(
                    Resource.getString(ResourceConstants.AMS_DISC_APP_SELECT_INSTALL),
                    Choice.IMPLICIT);

            // Add each suite
            for (int i = 0; i < parent.installList.size(); i++) {
              SuiteDownloadInfo suite = (SuiteDownloadInfo) installList.elementAt(i);
              parent.installListBox.append(suite.label, (Image) null);
            }

            parent.installListBox.addCommand(parent.backCmd);
            parent.installListBox.addCommand(parent.installCmd);
            parent.installListBox.setCommandListener(parent);

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

            parent.display.setCurrent(parent.installListBox);
            return;
          }

          errorMessage = Resource.getString(ResourceConstants.AMS_DISC_APP_CHECK_URL_MSG);
        } catch (IllegalArgumentException ex) {
          errorMessage = Resource.getString(ResourceConstants.AMS_DISC_APP_URL_FORMAT_MSG);
        } catch (Exception ex) {
          errorMessage = ex.getMessage();
        }
      } catch (Exception ex) {
        errorMessage = Resource.getString(ResourceConstants.AMS_DISC_APP_CONN_FAILED_MSG);
      } finally {
        if (parent.progressForm != null) {
          // end the background thread of progress gauge.
          Gauge progressGauge = (Gauge) parent.progressForm.get(parent.progressGaugeIndex);
          progressGauge.setValue(Gauge.CONTINUOUS_IDLE);
        }

        try {
          conn.close();
          in.close();
        } catch (Exception e) {
          if (Logging.REPORT_LEVEL <= Logging.WARNING) {
            Logging.report(Logging.WARNING, LogChannels.LC_AMS, "close threw an Exception");
          }
        }
      }

      Alert a =
          new Alert(
              Resource.getString(ResourceConstants.ERROR), errorMessage, null, AlertType.ERROR);
      a.setTimeout(Alert.FOREVER);
      parent.display.setCurrent(a, parent.urlTextBox);
    }