Пример #1
0
  /**
   * Display the connecting form to the user, let call set actions.
   *
   * @param action action to put in the form's title
   * @param name name to in the form's title
   * @param url URL of a JAD
   * @param size 0 if unknown, else size of object to download in K bytes
   * @param gaugeLabel label for progress gauge
   * @return displayed form
   */
  private Form displayProgressForm(
      String action, String name, String url, int size, String gaugeLabel) {
    Gauge progressGauge;
    StringItem urlItem;

    progressForm = new Form(null);

    progressForm.setTitle(action + " " + name);

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

    progressGaugeIndex = progressForm.append(progressGauge);

    if (url == null) {
      urlItem = new StringItem("", "");
    } else {
      urlItem = new StringItem(Resource.getString(ResourceConstants.AMS_WEBSITE) + ": ", url);
    }

    progressUrlIndex = progressForm.append(urlItem);

    display.setCurrent(progressForm);
    lastDisplayChange = System.currentTimeMillis();

    return progressForm;
  }
  public Form getSupportMe() {
    if (frmSupportMe == null) {
      // ---------------------------------------------
      // Form f = ...
      frmSupportMe = new Form("Support Me");
      frmSupportMe.setLayout(new BorderLayout());

      Image bimage = null;
      try {
        bimage = Image.createImage("/images/metaLabSmall.png");
      } catch (IOException ex) {
        ex.printStackTrace();
      }

      Label bottomText = new Label(bimage);
      bottomText.setAlignment(Component.CENTER);
      bottomText.setText("Our Logo");
      bottomText.setTextPosition(Component.BOTTOM);

      Container buttonBar = new Container(new BoxLayout(BoxLayout.X_AXIS));
      buttonBar.addComponent(new Button("Add"));
      buttonBar.addComponent(new Button("Remove"));
      buttonBar.addComponent(new Button("Edit"));
      buttonBar.addComponent(new Button("Send"));
      buttonBar.addComponent(new Button("Exit"));

      frmSupportMe.addComponent(BorderLayout.CENTER, bottomText);
      frmSupportMe.addComponent(BorderLayout.SOUTH, buttonBar);
      frmSupportMe.addCommand(mBackCommand);
      frmSupportMe.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return frmSupportMe;
  }
  public Form getAboutUs() {
    final Form f = new Form("Event counting");
    if (frmAboutUs == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

      final Button pushButton = new Button("Tap me!");
      final Label countLabel = new Label(" ");
      pushButton.addActionListener(
          new ActionListener() {
            private int c = 0;

            public void actionPerformed(ActionEvent ae) {
              c++;
              countLabel.setText(Integer.toString(c));
              f.layoutContainer();
              pushButton.setText("Tapped " + Integer.toString(c) + " times");
              // System.out.println(Integer.toString(c));
            }
          });
      f.addComponent(pushButton);
      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return f;
  }
Пример #4
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);
  }
Пример #5
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();
  }
Пример #6
0
 public Form getF_welcome() {
   if (f_welcome == null) {
     f_welcome = new Form("NGCalc 2.4.3 \u00A9 Revzin", new Item[] {getImageItem()});
     f_welcome.addCommand(getC_canvas());
     f_welcome.setCommandListener(this);
   }
   return f_welcome;
 }
Пример #7
0
 /**
  * This method returns instance for PrevNotClosedForm component and should be called instead of
  * accessing PrevNotClosedForm field directly.//GEN-BEGIN:MVDGetBegin46
  *
  * @return Instance for PrevNotClosedForm component
  */
 public Form get_PrevNotClosedForm() {
   if (PrevNotClosedForm == null) { // GEN-END:MVDGetBegin46
     // Insert pre-init code here
     PrevNotClosedForm = new Form(null, new Item[] {get_stringItem5()}); // GEN-BEGIN:MVDGetInit46
     PrevNotClosedForm.addCommand(get_okCommand2());
     PrevNotClosedForm.setCommandListener(this); // GEN-END:MVDGetInit46
     // Insert post-init code here
   } // GEN-BEGIN:MVDGetEnd46
   return PrevNotClosedForm;
 } // GEN-END:MVDGetEnd46
Пример #8
0
 /**
  * This method returns instance for BTOffForm component and should be called instead of accessing
  * BTOffForm field directly.//GEN-BEGIN:MVDGetBegin16
  *
  * @return Instance for BTOffForm component
  */
 public Form get_BTOffForm() {
   if (BTOffForm == null) { // GEN-END:MVDGetBegin16
     // Insert pre-init code here
     BTOffForm = new Form(null, new Item[] {get_stringItem2()}); // GEN-BEGIN:MVDGetInit16
     BTOffForm.addCommand(get_okCommand2());
     BTOffForm.setCommandListener(this); // GEN-END:MVDGetInit16
     // Insert post-init code here
   } // GEN-BEGIN:MVDGetEnd16
   return BTOffForm;
 } // GEN-END:MVDGetEnd16
Пример #9
0
 /**
  * This method returns instance for NoBTForm component and should be called instead of accessing
  * NoBTForm field directly.//GEN-BEGIN:MVDGetBegin11
  *
  * @return Instance for NoBTForm component
  */
 public Form get_NoBTForm() {
   if (NoBTForm == null) { // GEN-END:MVDGetBegin11
     // Insert pre-init code here
     NoBTForm = new Form(null, new Item[] {get_stringItem1()}); // GEN-BEGIN:MVDGetInit11
     NoBTForm.addCommand(get_okCommand2());
     NoBTForm.setCommandListener(this); // GEN-END:MVDGetInit11
     // Insert post-init code here
   } // GEN-BEGIN:MVDGetEnd11
   return NoBTForm;
 } // GEN-END:MVDGetEnd11
Пример #10
0
 /**
  * This method returns instance for helpForm component and should be called instead of accessing
  * helpForm field directly.//GEN-BEGIN:MVDGetBegin25
  *
  * @return Instance for helpForm component
  */
 public Form get_helpForm() {
   if (helpForm == null) { // GEN-END:MVDGetBegin25
     // Insert pre-init code here
     helpForm = new Form(null, new Item[] {get_stringItem4()}); // GEN-BEGIN:MVDGetInit25
     helpForm.addCommand(get_okCommand2());
     helpForm.setCommandListener(this); // GEN-END:MVDGetInit25
     // Insert post-init code here
   } // GEN-BEGIN:MVDGetEnd25
   return helpForm;
 } // GEN-END:MVDGetEnd25
Пример #11
0
 /**
  * This method returns instance for StartFailedForm component and should be called instead of
  * accessing StartFailedForm field directly.//GEN-BEGIN:MVDGetBegin19
  *
  * @return Instance for StartFailedForm component
  */
 public Form get_StartFailedForm() {
   if (StartFailedForm == null) { // GEN-END:MVDGetBegin19
     // Insert pre-init code here
     StartFailedForm = new Form(null, new Item[] {get_stringItem3()}); // GEN-BEGIN:MVDGetInit19
     StartFailedForm.addCommand(get_okCommand2());
     StartFailedForm.setCommandListener(this); // GEN-END:MVDGetInit19
     // Insert post-init code here
   } // GEN-BEGIN:MVDGetEnd19
   return StartFailedForm;
 } // GEN-END:MVDGetEnd19
Пример #12
0
 /**
  * This method returns instance for NoBTAPIForm component and should be called instead of
  * accessing NoBTAPIForm field directly.//GEN-BEGIN:MVDGetBegin43
  *
  * @return Instance for NoBTAPIForm component
  */
 public Form get_NoBTAPIForm() {
   if (NoBTAPIForm == null) { // GEN-END:MVDGetBegin43
     // Insert pre-init code here
     NoBTAPIForm = new Form(null, new Item[] {get_stringItem8()}); // GEN-BEGIN:MVDGetInit43
     NoBTAPIForm.addCommand(get_exitCommand());
     NoBTAPIForm.setCommandListener(this); // GEN-END:MVDGetInit43
     // Insert post-init code here
   } // GEN-BEGIN:MVDGetEnd43
   return NoBTAPIForm;
 } // GEN-END:MVDGetEnd43
  public Form getAboutYou() {
    Form f = new Form("...placeholder ...");
    if (frmAboutYou == null) {
      f.addComponent(new Label("Choose Back to return to the home screen."));

      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return f;
  }
Пример #14
0
  public Form getForm() {
    if (form == null) {

      form = new Form("form");
      form.addCommand(getC_tovars());
      form.addCommand(getC_history());
      form.setCommandListener(this);
    }
    return form;
  }
Пример #15
0
  public void commandAction(Command c, Displayable d) {
    if (c == startCmd) {
      form.deleteAll();
      form.removeCommand(startCmd);
      form.addCommand(byeCmd);

      Thread t =
          new Thread() {

            public void run() {
              startSession();
            }
          };
      t.start();

      //	    startSession();
      return;
    } else if (c == exitCmd) {
      destroyApp(true);
      return;
    } else if (c == byeCmd) {
      form.removeCommand(byeCmd);
      form.addCommand(restartCmd);
      sendBYE();
      return;
    } else if (c == restartCmd) {
      stopListener();
      form.removeCommand(restartCmd);
      form.addCommand(startCmd);
      form.deleteAll();
      form.append(address);
      return;
    }
  }
Пример #16
0
 public void addRecordForm() {
   fmAddRecord = new Form("Add Record");
   txfName = new TextField("Name", "", 10, TextField.ANY);
   txfNumber = new TextField("Number", "", 10, TextField.NUMERIC);
   fmAddRecord.append(txfName);
   fmAddRecord.append(txfNumber);
   fmAddRecord.addCommand(cmdAdd);
   fmAddRecord.addCommand(cmdMenu);
   fmAddRecord.setCommandListener(this);
   dsp.setCurrent(fmAddRecord);
 }
Пример #17
0
 public void getNumberRecord() {
   fmNumbers = new Form("Number of Records");
   int number = 0;
   try {
     number = rs.getNumRecords();
   } catch (Exception e) {
   }
   fmNumbers.append("Numbers of Records: " + number);
   dsp.setCurrent(fmNumbers);
   fmNumbers.setCommandListener(this);
   fmNumbers.addCommand(cmdMenu);
 }
Пример #18
0
 public OriginatingINVITE() {
   // <i><b>Initialize MIDlet display</b></i>
   display = Display.getDisplay(this);
   // <i><b>create a Form for progess info printings</b></i>
   form = new Form("Session example");
   address = new TextField("INVITE:", "sip:[email protected]:5070", 40, TextField.LAYOUT_LEFT);
   form.append(address);
   byeCmd = new Command("Bye", Command.ITEM, 1);
   restartCmd = new Command("Restart", Command.ITEM, 1);
   startCmd = new Command("Start", Command.ITEM, 1);
   form.addCommand(startCmd);
   exitCmd = new Command("Exit", Command.EXIT, 1);
   form.addCommand(exitCmd);
   form.setCommandListener(this);
 }
Пример #19
0
 /**
  * Returns an initialized instance of inputForm component.
  *
  * @return the initialized component instance
  */
 public Form getInputForm() {
   if (inputForm == null) {
     // GEN-END:|14-getter|0|14-preInit
     // write pre-init user code here
     inputForm =
         new Form(
             "Guess the number!",
             new Item[] {getStringItem(), getInputNumber()}); // GEN-BEGIN:|14-getter|1|14-postInit
     inputForm.addCommand(getOkCommand());
     inputForm.addCommand(getExitCommand());
     inputForm.setCommandListener(this); // GEN-END:|14-getter|1|14-postInit
     // write post-init user code here
   } // GEN-BEGIN:|14-getter|2|
   return inputForm;
 }
Пример #20
0
 /**
  * Returns an initialized instance of resultForm component.
  *
  * @return the initialized component instance
  */
 public Form getResultForm() {
   if (resultForm == null) {
     // GEN-END:|26-getter|0|26-preInit
     // write pre-init user code here
     resultForm =
         new Form(
             "Result",
             new Item[] {
               getResultText(), getAttemptsText()
             }); // GEN-BEGIN:|26-getter|1|26-postInit
     resultForm.addCommand(getBackCommand());
     resultForm.addCommand(getExitCommand1());
     resultForm.setCommandListener(this); // GEN-END:|26-getter|1|26-postInit
     // write post-init user code here
   } // GEN-BEGIN:|26-getter|2|
   return resultForm;
 }
Пример #21
0
 public void notifyRequest(SipConnectionNotifier sn) {
   try {
     ssc = scn.acceptAndOpen(); // <i><b>blocking</b></i>
     if (ssc.getMethod().equals("BYE")) {
       // <i><b>respond 200 OK to BYE</b></i>
       ssc.initResponse(200);
       ssc.send();
       str = new StringItem("Other side hang-up!", "");
       form.append(str);
     }
     form.append("Closing notifier...");
     form.removeCommand(byeCmd);
     form.addCommand(restartCmd);
     scn.close();
   } catch (IOException ex) {
     // <i><b>handle IOException</b></i>
   }
 }
  public void startApp() {
    Display.init(this);

    installTheme();

    createUI();

    mHomeForm.show();
  }
Пример #23
0
  /** Handle incoming response here */
  public void notifyResponse(SipClientConnection scc) {
    int statusCode = 0;
    boolean received = false;
    try {
      scc.receive(0); // <i><b>fetch resent response</b></i>
      statusCode = scc.getStatusCode();
      str = new StringItem("Response: ", statusCode + " " + scc.getReasonPhrase());
      form.append(str);
      if (statusCode < 200) {
        dialog = scc.getDialog();
        form.append("Early-Dialog state: " + dialog.getState());
      }
      if (statusCode == 200) {
        String contentType = scc.getHeader("Content-Type");
        String contentLength = scc.getHeader("Content-Length");
        int length = Integer.parseInt(contentLength);
        if (contentType.equals("application/sdp")) {
          //
          // <i><b>handle SDP here</b></i>
          //
        }
        dialog = scc.getDialog(); // <i><b>save dialog info</b></i>
        form.append("Dialog state: " + dialog.getState());

        scc.initAck(); // <i><b>initialize and send ACK</b></i>
        scc.send();
        str = new StringItem("Session established: ", scc.getHeader("Call-ID"));
        form.append(str);
        scc.close();
      } else if (statusCode >= 300) {
        str = new StringItem("Session failed: ", scc.getHeader("Call-ID"));
        form.append(str);
        form.removeCommand(byeCmd);
        form.addCommand(restartCmd);
        scc.close();
      }
    } catch (IOException ioe) {
      // <i><b>handle e.g. transaction timeout here</b></i>
      str = new StringItem("No answer: ", ioe.getMessage());
      form.append(str);
      form.removeCommand(byeCmd);
      form.addCommand(restartCmd);
    }
  }
Пример #24
0
  public void showFirstRecord() {
    fmFirstRecord = new Form("First Record");
    String name = "Nenacetl jsem";
    int number = 0;
    try {
      byte[] record = rs.getRecord(1);
      ByteArrayInputStream buffer = new ByteArrayInputStream(record);
      DataInputStream dis = new DataInputStream(buffer);
      name = dis.readUTF();
      number = dis.readInt();
      dis.close();
    } catch (Exception e) {
    }

    fmFirstRecord.append(name + " " + String.valueOf(number));
    // fmFirstRecord.append(String.valueOf(number));
    fmFirstRecord.setCommandListener(this);
    fmFirstRecord.addCommand(cmdMenu);
    dsp.setCurrent(fmFirstRecord);
  }
  public Form getResources() {
    if (frmResources == null) {
      frmResources = new Form("Resources");

      List list = new List();
      list.addItem("uno");
      list.addItem("due");
      list.addItem("tre");
      list.addItem("quattro");
      list.addItem("cinque");
      list.addItem("sei");
      frmResources.addComponent(list);

      ComboBox comboBox = new ComboBox(list.getModel());
      frmResources.addComponent(comboBox);
      frmResources.addCommand(mBackCommand);
      frmResources.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return frmResources;
  }
Пример #26
0
 public void editRecord(int record_num) {
   fmEditRecord = new Form("Edit Record");
   String name = "Nenacetl jsem";
   int number = 0;
   try {
     byte[] record = rs.getRecord(record_num);
     ByteArrayInputStream buffer = new ByteArrayInputStream(record);
     DataInputStream dis = new DataInputStream(buffer);
     name = dis.readUTF();
     number = dis.readInt();
     dis.close();
   } catch (Exception e) {
   }
   txfName = new TextField("Name", name, 10, TextField.ANY);
   txfNumber = new TextField("Number", String.valueOf(number), 10, TextField.NUMERIC);
   fmEditRecord.append(txfName);
   fmEditRecord.append(txfNumber);
   fmEditRecord.addCommand(cmdEdit);
   fmEditRecord.addCommand(cmdMenu);
   fmEditRecord.setCommandListener(this);
   dsp.setCurrent(fmEditRecord);
 }
  public Form getMessages() {
    if (frmMessages == null) {
      // ---------------------------------------------------
      frmMessages = new Form("Messages");
      TextArea area = new TextArea("Peppino");
      frmMessages.addComponent(area);

      TextArea big =
          new TextArea(
              "On February 24, 1815, the lookout at "
                  + "Notre-Dame de la Garde signalled the arrival of the three-master "
                  + "Pharaon, coming from Smyrna, Trieste and Naples.",
              5,
              20);
      frmMessages.addComponent(big);
      frmMessages.addCommand(mBackCommand);
      frmMessages.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      // ---------------------------------------

    }
    return frmMessages;
  }
  public Form getToDoList() {
    Form f = new Form("To Do List");
    if (frmToDoList == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
      Label sLabel = new Label("To Do List appears here");
      f.addComponent(sLabel);

      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      f.setTransitionInAnimator(Transition3D.createCube(300, false));
      f.setTransitionOutAnimator(Transition3D.createCube(300, true));
    }
    return f;
  }
  public Form getCalendar() {
    Form f = new Form("Calendar");

    if (frmCalendar == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

      Calendar cal = new Calendar();
      f.addComponent(cal);
      f.addCommand(mBackCommand);
      f.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
      f.setTransitionInAnimator(Transition3D.createCube(300, false));
      f.setTransitionOutAnimator(Transition3D.createCube(300, true));
    }
    return f;
  }
Пример #30
0
 private void startSession() {
   SipClientConnection scc = null;
   try {
     // <i><b>start a listener for incoming requests</b></i>
     startListener();
     // <i><b>open SIP connection with remote user</b></i>
     scc = (SipClientConnection) Connector.open(address.getString());
     scc.setListener(this);
     // <i><b>initialize INVITE request</b></i>
     scc.initRequest("INVITE", scn);
     scc.setHeader("Content-Length", "" + sdp.length());
     scc.setHeader("Content-Type", "application/sdp");
     OutputStream os = scc.openContentOutputStream();
     os.write(sdp.getBytes());
     os.close(); // <i><b>close and send</b></i>
     str = new StringItem("Inviting... ", scc.getHeader("To"));
     form.append(str);
   } catch (Exception ex) {
     ex.printStackTrace();
     // <i><b>handle IOException</b></i>
   }
 }