protected boolean onPersonalinfoDone() {
    TextField t = (TextField) findByName("thispass", perosnl);
    TextField t2 = (TextField) findByName("nowpass", perosnl);
    TextField l = (TextField) findByName("path11", perosnl);
    int indecate = 0;
    Label l2 = (Label) findByName("Label32", perosnl);

    if (!t2.getText().equals("")) {

      if (t.getText().equals(password.getText())) {
        checkpass = t2.getText();
      } else {

        l2.setText("error password miss match");
        indecate = 1;
      }
    }
    if (l.getText() != null) {
      imgpath = l.getText();
    }
    if (indecate == 0) {
      Myprofile.show();
      // showForm("MyProfile", null);
    }

    boolean val = super.onPersonalinfoDone();
    return val;
  }
  protected boolean onLoginGUILogme() {
    try {
      showForm("FirstForm", null);
      String values[] = Splitter.Split(new String(record.getRecord(1)), "-");
      showForm("FirstForm", null);
      if (values[0].equals(username.getText()) && values[1].equals(password.getText())) {
        showForm("FirstForm", null);
      } else {

        showForm("Htmlpasrecover", null);
      }

      values = null;
    } catch (Exception e) {
      System.out.println(e);
    }

    boolean val = super.onLoginGUILogme();
    return val;
  }
  protected void beforeMyProfile(Form f) {
    Myprofile = f;
    Label l1 = (Label) findByName("propic", f);
    name = (TextField) findByName("name", Myprofile);
    index = (TextField) findByName("index", Myprofile);
    tel = (TextField) findByName("tel", Myprofile);
    addr = (TextField) findByName("addr", Myprofile);
    email = (TextField) findByName("email", Myprofile);
    group = (TextField) findByName("group", Myprofile);
    try {

      String userde[] = Splitter.Split(new String(record.getRecord(4)), "-");

      name.setText(userde[0]);
      index.setText(userde[1]);
      tel.setText(userde[2]);
      addr.setText(userde[3]);
      email.setText(userde[4]);
      group.setText(userde[5]);

      if (new String(record.getRecord(2)).equals("no")) {
        l1.setIcon(Image.createImage("/no_user.png").scaledHeight(72));

      } else {
        l1.setIcon(Image.createImage(new String(record.getRecord(2))).scaledHeight(72));
      }

      System.gc();
    } catch (Exception e) {
    }
    super.beforeMyProfile(f);
  }
示例#4
0
  private boolean authentication() throws SaveException, RecordStoreException {

    titleLbl.setText("Authenticating...");
    String username = usernameTxt.getText().trim().toLowerCase();
    String password = passwordTxt.getText().trim().toLowerCase();

    // TODO crytped password + encoding
    HTTPWebAPI api = new HTTPWebAPI();
    String apikey = api.getAPIKey(username, password);
    log.debug("API key: " + apikey);
    if (apikey.length() == 40) {
      titleLbl.setText("Saving API key...");
      midlet.getPreferences().setAPIKey(apikey);
      midlet.getPreferences().setUsername(usernameTxt.getText().trim());
      midlet.getPreferences().save();
      titleLbl.setText("API key saved");
      return true;
    } else {

      return false;
    }
  }
示例#5
0
 /** Similar to getText() but works properly with password fields */
 private String getTextFieldString(TextField ta) {
   String text = (String) ta.getText();
   String displayText = "";
   if ((ta.getConstraint() & TextArea.PASSWORD) != 0) {
     // show the last character in a password field
     if (ta.isPendingCommit()) {
       if (text.length() > 0) {
         for (int j = 0; j < text.length() - 1; j++) {
           displayText += "*";
         }
         displayText += text.charAt(text.length() - 1);
       }
     } else {
       for (int j = 0; j < text.length(); j++) {
         displayText += "*";
       }
     }
   } else {
     displayText = text;
   }
   return displayText;
 }
示例#6
0
 private void construirForm() {
   txtPassword.setConstraint(com.sun.lwuit.TextField.PASSWORD);
   this.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
   this.addComponent(this.lblError);
   Container form = new Container(new BoxLayout(BoxLayout.Y_AXIS));
   form.addComponent(new Label(Application.getMessage("auth.login")));
   form.addComponent(txtLogin);
   form.addComponent(new Label(Application.getMessage("auth.password")));
   form.addComponent(txtPassword);
   this.addComponent(form);
   this.addCommand(commandSair);
   this.addCommand(commandEntrar);
   this.setFocused(txtLogin);
 }
  /*
   public PIMBrowser getPimToDo() {
      if (pimToDo == null) {
          // write pre-init user code here
          pimToDo = new PIMBrowser(getDisplay(), PIM.TODO_LIST);
          pimToDo.setTitle("To Do List");
          pimToDo.addCommand(PIMBrowser.SELECT_PIM_ITEM);
          pimToDo.addCommand(getBackCommand5());
          pimToDo.setCommandListener(this);
          // write post-init user code here
      }
      return pimToDo;
  }
  */
  public Form fullgetToDoList() {
    Form f = new Form("To Do List");
    if (frmToDoList == null) {
      f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
      toDoList = new List();
      pim = PIM.getInstance();
      f.addComponent(toDoList);

      final TextArea searchField = TextField.create();
      f.addComponent(searchField);

      Button searchButton = new Button("Search");
      searchButton.setPreferredW(f.getWidth() / 2 - 5);
      searchButton.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
              populateToDoList(searchField.getText());
            }
          });
      Button clearButton = new Button("Clear");
      clearButton.setPreferredW(f.getWidth() / 2 - 5);
      clearButton.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
              searchField.setText("");
              populateToDoList("");
            }
          });
      Container buttonContainer = new Container();
      buttonContainer.setLayout(new BorderLayout());
      buttonContainer.addComponent(BorderLayout.WEST, searchButton);
      buttonContainer.addComponent(BorderLayout.EAST, clearButton);
      f.addComponent(buttonContainer);

      populateToDoList(searchField.getText());

      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;
  }
  protected void beforeLoginGUI(Form f) {
    Login = f;
    username = (TextField) findByName("Username", f);
    password = (TextField) findByName("Password", f);
    password.setConstraint(TextField.PASSWORD);

    try {
      record = RecordStore.openRecordStore("recordpr", true);

    } catch (Exception e) {
    }

    try {

      record.getRecord(1);
    } catch (Exception e) {

      byte[] defaultlogin = "******".getBytes();
      byte image[] = "no".getBytes();
      byte prio[] = "0-0-0".getBytes();
      byte[] userdetail = "n-n-n-n-n-n".getBytes();
      try {
        record.addRecord(defaultlogin, 0, defaultlogin.length); // 1
        record.addRecord(image, 0, image.length); // 2
        record.addRecord(prio, 0, prio.length); // 3
        record.addRecord(userdetail, 0, userdetail.length);

        defaultlogin = null;
        image = null;
        prio = null;
        userdetail = null;
        System.gc();

      } catch (Exception e1) {
        System.out.println(e1);
      }
    }
    super.beforeLoginGUI(f);
  }
  protected boolean onMyProfileSaveAll() {
    String pass = null;
    byte arr[] = null;

    if (checkpass.equals("+")) {
      try {
        pass = new String(record.getRecord(1));
        pass = Splitter.Split(pass, "-")[1];
      } catch (Exception e) {
      }

    } else {
      pass = checkpass;
    }

    if (!imgpath.equals("+")) {
      try {
        record.setRecord(2, imgpath.getBytes(), 0, imgpath.getBytes().length);
      } catch (RecordStoreException ex) {
        ex.printStackTrace();
      }
    }

    try {

      String userpass[] = Splitter.Split(new String(record.getRecord(1)), "-");

      byte userpsss[] = (userpass[0] + "-" + pass).getBytes();
      record.setRecord(1, userpsss, 0, userpsss.length);

      String record4 =
          name.getText()
              + "-"
              + index.getText()
              + "-"
              + tel.getText()
              + "-"
              + addr.getText()
              + "-"
              + email.getText()
              + "-"
              + group.getText();
      byte reco4[] = record4.getBytes();

      record.setRecord(4, reco4, 0, reco4.length);

      String id = (Splitter.Split(new String(record.getRecord(3)), "-")[1]);

      if (id.equals("0")) {

        HttpCon con2 = new HttpCon(record4 + "-" + pass, PropertyClass.ServerUrl + "addaUser");
        con2.SetContype(true, true, true);
        Thread t = new Thread(con2);
        synchronized (t) {
          t.start();
          t.wait();
        }

        String[] newid = Splitter.Split((new String(record.getRecord(3))), "-");
        userpsss = null;
        userpsss = (newid[0] + "-" + con2.getValue().toString() + "-" + newid[2]).getBytes();
        record.setRecord(3, userpsss, 0, userpsss.length);

      } else {
        HttpCon con12 =
            new HttpCon(record4 + ("-" + pass + "-" + id), PropertyClass.ServerUrl + "UpdateUser");

        con12.SetContype(true, true, true);
        Thread t = new Thread(con12);

        synchronized (t) {
          t.start();
          t.wait();
        }
      }
    } catch (Exception e) {
      System.out.println(e);
    }
    pass = null;
    arr = null;
    boolean val = super.onMyProfileSaveAll();
    return val;
  }
示例#10
0
  public Form getForm() {

    if (loginForm != null) {
      titleLbl.setText("Login:"******"NoiseTube Account");
    loginPanel = new Container();
    loginPanel.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    titleLbl = new Label(" ");

    usernameLbl = new Label();
    usernameTxt = new TextField();
    usernameLbl.setText("Username:"******"Password:"******"Skip");
    loginCmd = new Command("Login");

    // buttonPanel = new Container();
    // buttonPanel.addComponent(loginBtn);
    // buttonPanel.getStyle().setMargin(2, 2, 2, 2);

    titleLbl.setText("Login:"******"Connexion error");
                titleLbl.setText("Connexion error");
              } catch (RecordStoreException e1) {
                titleLbl.setText("Error saving APIkey");
                log.error(e1, "Error saving APIkey");
              }
            } else if (skipCmd.equals(arg0.getCommand())) {
              MainMidlet.getInstance()
                  .getPreferences()
                  .setSavingMode(
                      Device.supportsSavingToFile() ? Preferences.SAVE_FILE : Preferences.SAVE_NO);
              midlet.showMeasureForm();
            } else midlet.notifyDestroyed();
          }
        });
    return loginForm;
  }
示例#11
0
 protected TextField createTextField(String text, boolean editable) {
   TextField textField = new TextField(text);
   textField.setEditable(editable);
   return textField;
 }
示例#12
0
 protected TextField createTextField(String text, int constraint) {
   TextField textField = new TextField(text);
   textField.setConstraint(constraint);
   return textField;
 }
示例#13
0
  /** @inheritDoc */
  public void drawTextField(Graphics g, TextField ta) {
    if (ta instanceof DateField) {
      drawDateField(g, (DateField) ta);
      return;
    }
    setFG(g, ta);

    // display ******** if it is a password field
    String displayText = getTextFieldString(ta);

    Style style = ta.getStyle();
    int x = 0;
    int cursorCharPosition = ta.getCursorPosition();
    Font f = ta.getStyle().getFont();
    int cursorX = 0;
    int xPos = 0;
    if (cursorCharPosition > 0) {
      xPos = f.stringWidth(displayText.substring(0, cursorCharPosition));
      cursorX = ta.getX() + style.getPadding(Component.LEFT) + xPos;
      if (ta.getWidth() > (f.getHeight() * 2)
          && cursorX >= ta.getWidth() - style.getPadding(Component.LEFT)) {
        while (x + xPos >= ta.getWidth() - style.getPadding(Component.LEFT) * 2) {
          x--;
        }
      }
    }

    g.drawString(
        displayText,
        ta.getX() + x + style.getPadding(Component.LEFT),
        ta.getY() + style.getPadding(Component.TOP));

    // show always
    if (ta.getInputModeOrder() != null && ta.getInputModeOrder().length > 0) {
      String inputMode = ta.getInputMode();
      int inputModeWidth = f.stringWidth(inputMode);
      if (ta.handlesInput() && ta.getWidth() / 2 > inputModeWidth) {
        int drawXPos = ta.getX() + style.getPadding(Component.LEFT) - 1;
        if (xPos < ta.getWidth() / 2) {
          // draw on the right side
          drawXPos =
              drawXPos
                  + ta.getWidth()
                  - inputModeWidth
                  - style.getPadding(Component.RIGHT)
                  - style.getPadding(Component.LEFT);
        }
        g.setColor(style.getFgSelectionColor());
        // unfurtanally g.fillroundrect does not suppport alpha
        // g.fillRoundRect(drawXPos, ta.getY() + style.getPadding(Component.TOP)-1, inputModeWidth,
        // ta.getHeight()-4, 4, 4);
        // so a work around is required
        byte alphaLevel = (byte) 140;
        g.fillRect(
            drawXPos,
            ta.getY() + style.getPadding(Component.TOP) - 1,
            inputModeWidth + 2,
            ta.getHeight() - 4,
            alphaLevel);
        // g.setColor(0xFF0000);

        g.setColor(style.getBgSelectionColor());

        g.fillRect(drawXPos, ta.getY() + style.getPadding(Component.TOP) - 1, 1, 1, alphaLevel);
        g.fillRect(
            drawXPos + inputModeWidth + 1,
            ta.getY() + style.getPadding(Component.TOP) - 1,
            1,
            1,
            alphaLevel);
        g.fillRect(
            drawXPos + inputModeWidth + 1,
            ta.getY() + style.getPadding(Component.TOP) - 1 + ta.getHeight() - 4 - 1,
            1,
            1,
            alphaLevel);
        g.fillRect(
            drawXPos,
            ta.getY() + style.getPadding(Component.TOP) - 1 + ta.getHeight() - 4 - 1,
            1,
            1,
            alphaLevel);

        g.drawString(inputMode, drawXPos + 1, ta.getY() + style.getPadding(Component.TOP));
      }
    }
  }
示例#14
0
  protected void executeView(final Container f) {
    reportId = "";
    f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    Image helpIcon = HILMain.getInstance().res.getImage("GeneralReportData_sel.png");

    final Label title = new Label(getName());
    title.getStyle().setFont(HILMain.getInstance().theme.getFont("titleFont"));
    title.setIcon(helpIcon);
    title.setAlignment(Label.LEFT);
    title.setHeight(14);
    title.setWidth(240);
    title.getStyle().setBgColor(0x7799bb);
    title.getStyle().setFgColor(0xFFFFFF);
    title.getStyle().setPadding(5, 5, 15, 0);
    title.getStyle().setBgTransparency(250);

    setTitle(title, f);
    f.setScrollable(true);
    FocusListener textFocus =
        new FocusListener() {
          public void focusGained(Component arg0) {
            arg0.getStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
            arg0.getStyle().setBorder(Border.createEmpty());
          }

          public void focusLost(Component arg0) {}
        };

    TextArea shortHelpLabel = new TextArea(2, 10);
    shortHelpLabel.getStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    shortHelpLabel.getStyle().setBorder(Border.createEmpty(), true);
    shortHelpLabel.getStyle().setBgTransparency(0);
    shortHelpLabel.getStyle().setFgColor(0x000000);
    shortHelpLabel.setFocus(false);
    shortHelpLabel.setFocusable(false);
    shortHelpLabel.setText(
        (String) HILMain.getInstance().locale.get("short_help_general_report_data"));
    f.addComponent(shortHelpLabel);

    date = new Date();
    final Button dateLabel = new Button();
    dateLabel.getStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    dateLabel.getStyle().setBorder(Border.createEmpty());
    dateLabel.getStyle().setBgColor(0xCECECE);
    dateLabel.getStyle().setFgColor(0x81746B);
    dateLabel.setTextPosition(Label.LEFT);
    dateLabel.setText("");
    dateLabel.getSelectedStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    dateLabel.getSelectedStyle().setBorder(Border.createEmpty());
    dateLabel.getSelectedStyle().setBgColor(0xCECECE);
    dateLabel.getSelectedStyle().setFgColor(0x81746B);
    dateLabel.getSelectedStyle().setBgTransparency(100);
    dateLabel.getPressedStyle().setBorder(Border.createEmpty());
    dateLabel.getPressedStyle().setBgColor(0xCECECE);
    dateLabel.getPressedStyle().setFgColor(0x81746B);
    dateLabel.getPressedStyle().setBgTransparency(100);
    dateLabel.setText(DateUtil.getMonthYear(date, "/"));
    f.addComponent(createPair((String) HILMain.getInstance().locale.get("time"), dateLabel, 54));

    Container buttonContainer = new Container(new BoxLayout(BoxLayout.X_AXIS));
    buttonContainer.setWidth(Display.getInstance().getDisplayWidth());
    Button submit = new Button();
    submit.setText((String) HILMain.getInstance().locale.get("get_data"));
    submit.getStyle().setBgTransparency(255);
    submit.getStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    submit.getStyle().setBorder(Border.createRoundBorder(0, 0, 0xcadaf1));
    submit.getStyle().setBgColor(0xFAAC58, true);
    submit.getStyle().setAlignment(Label.CENTER);
    submit.getStyle().setFgColor(0xFFFFFF);
    submit.getSelectedStyle().setBgTransparency(255);
    submit.getSelectedStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    submit.getSelectedStyle().setBorder(Border.createRoundBorder(0, 0, 0xcadaf1));
    submit.getSelectedStyle().setBgColor(0xFAAC58);
    submit.getSelectedStyle().setAlignment(Label.CENTER);
    submit.getSelectedStyle().setFgColor(0x000000);
    submit.getPressedStyle().setBgTransparency(255);
    submit.getPressedStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    submit.getPressedStyle().setBorder(Border.createRoundBorder(0, 0, 0xcadaf1));
    submit.getPressedStyle().setBgColor(0xFAAC58);
    submit.getPressedStyle().setAlignment(Label.CENTER);
    submit.getPressedStyle().setFgColor(0x000000);

    final Button buttonEdit = new Button();
    buttonEdit.setText((String) HILMain.getInstance().locale.get("edit"));
    buttonEdit.getStyle().setBgTransparency(255);
    buttonEdit.getStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    buttonEdit.getStyle().setBorder(Border.createRoundBorder(0, 0, 0xcadaf1));
    buttonEdit.getStyle().setBgColor(0xFAAC58, true);
    buttonEdit.getStyle().setAlignment(Label.CENTER);
    buttonEdit.getStyle().setFgColor(0xFFFFFF);
    buttonEdit.getDisabledStyle().setBgTransparency(255);
    buttonEdit.getDisabledStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    buttonEdit.getDisabledStyle().setBorder(Border.createRoundBorder(0, 0, 0xcadaf1));
    buttonEdit.getDisabledStyle().setBgColor(0xBDBDBD);
    buttonEdit.getDisabledStyle().setAlignment(Label.CENTER);
    buttonEdit.getDisabledStyle().setFgColor(0xFFFFFF);
    buttonEdit.getSelectedStyle().setBgTransparency(255);
    buttonEdit.getSelectedStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    buttonEdit.getSelectedStyle().setBorder(Border.createRoundBorder(0, 0, 0xcadaf1));
    buttonEdit.getSelectedStyle().setBgColor(0xFAAC58);
    buttonEdit.getSelectedStyle().setAlignment(Label.CENTER);
    buttonEdit.getSelectedStyle().setFgColor(0x000000);
    buttonEdit.getPressedStyle().setBgTransparency(255);
    buttonEdit.getPressedStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    buttonEdit.getPressedStyle().setBorder(Border.createRoundBorder(0, 0, 0xcadaf1));
    buttonEdit.getPressedStyle().setBgColor(0xFAAC58);
    buttonEdit.getPressedStyle().setAlignment(Label.CENTER);
    buttonEdit.getPressedStyle().setFgColor(0x000000);
    buttonEdit.setEnabled(false);
    buttonContainer.addComponent(submit);
    buttonContainer.addComponent(buttonEdit);
    f.addComponent(buttonContainer);

    Label normalLabel = new Label((String) HILMain.getInstance().locale.get("normal_reaction"));
    normalLabel.getStyle().setBgTransparency(250);
    normalLabel.setWidth(240);
    normalLabel.getStyle().setBgColor(0xBFD6FF);
    f.addComponent(normalLabel);

    final TextField normalReaction = new TextField(10);
    normalReaction.getStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    normalReaction.setText("");
    normalReaction.getStyle().setBorder(Border.createEmpty(), true);
    normalReaction.addFocusListener(textFocus);
    normalReaction.getStyle().setBgColor(0xCECECE);
    normalReaction.getStyle().setBgTransparency(150);
    normalReaction.getStyle().setFgColor(0x81746B);
    normalReaction.getSelectedStyle().setBgColor(0xCECECE);
    normalReaction.getSelectedStyle().setBgTransparency(100);
    normalReaction.getSelectedStyle().setFgColor(0x81746B);
    normalReaction.setConstraint(TextField.NUMERIC);
    normalReaction.setInputModeOrder(new String[] {"123"});
    normalReaction.setEditable(false);
    f.addComponent(normalReaction);

    Label seriousLabel = new Label((String) HILMain.getInstance().locale.get("serious_reaction"));
    seriousLabel.getStyle().setBgTransparency(250);
    seriousLabel.setWidth(240);
    seriousLabel.getStyle().setBgColor(0xBFD6FF);
    f.addComponent(seriousLabel);

    final TextField seriousReaction = new TextField(10);
    seriousReaction.getStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    seriousReaction.setText("");
    seriousReaction.getStyle().setBorder(Border.createEmpty(), true);
    seriousReaction.addFocusListener(textFocus);
    seriousReaction.getStyle().setBgColor(0xCECECE);
    seriousReaction.getStyle().setBgTransparency(150);
    seriousReaction.getStyle().setFgColor(0x81746B);
    seriousReaction.getSelectedStyle().setBgColor(0xCECECE);
    seriousReaction.getSelectedStyle().setBgTransparency(100);
    seriousReaction.getSelectedStyle().setFgColor(0x81746B);
    seriousReaction.setConstraint(TextField.NUMERIC);
    seriousReaction.setInputModeOrder(new String[] {"123"});
    seriousReaction.setEditable(false);
    f.addComponent(seriousReaction);

    Label tetanusLabel = new Label((String) HILMain.getInstance().locale.get("tetanus_protection"));
    tetanusLabel.getStyle().setBgTransparency(250);
    tetanusLabel.setWidth(240);
    tetanusLabel.getStyle().setBgColor(0xBFD6FF);
    f.addComponent(tetanusLabel);

    final TextField tetanus = new TextField(10);
    tetanus.getStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    tetanus.setText("");
    tetanus.getStyle().setBorder(Border.createEmpty(), true);
    tetanus.addFocusListener(textFocus);
    tetanus.getStyle().setBgColor(0xCECECE);
    tetanus.getStyle().setBgTransparency(150);
    tetanus.getStyle().setFgColor(0x81746B);
    tetanus.getSelectedStyle().setBgColor(0xCECECE);
    tetanus.getSelectedStyle().setBgTransparency(100);
    tetanus.getSelectedStyle().setFgColor(0x81746B);
    tetanus.setConstraint(TextField.NUMERIC);
    tetanus.setInputModeOrder(new String[] {"123"});
    tetanus.setEditable(false);
    f.addComponent(tetanus);

    final Button buttonSave = new Button();
    buttonSave.setText((String) HILMain.getInstance().locale.get("save"));

    buttonSave.getStyle().setBgTransparency(255);
    buttonSave.getStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    buttonSave.getStyle().setBorder(Border.createRoundBorder(0, 0, 0xcadaf1));
    buttonSave.getStyle().setBgColor(0xFAAC58, true);
    buttonSave.getStyle().setAlignment(Label.CENTER);
    buttonSave.getStyle().setFgColor(0xFFFFFF);
    buttonSave.setWidth(100);
    buttonSave.getDisabledStyle().setBgTransparency(255);
    buttonSave.getDisabledStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    buttonSave.getDisabledStyle().setBorder(Border.createRoundBorder(0, 0, 0xcadaf1));
    buttonSave.getDisabledStyle().setBgColor(0xBDBDBD);
    buttonSave.getDisabledStyle().setAlignment(Label.CENTER);
    buttonSave.getDisabledStyle().setFgColor(0xFFFFFF);
    buttonSave.getSelectedStyle().setBgTransparency(255);
    buttonSave.getSelectedStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    buttonSave.getSelectedStyle().setBorder(Border.createRoundBorder(0, 0, 0xcadaf1));
    buttonSave.getSelectedStyle().setBgColor(0xFAAC58);
    buttonSave.getSelectedStyle().setAlignment(Label.CENTER);
    buttonSave.getSelectedStyle().setFgColor(0x000000);
    buttonSave.getPressedStyle().setBgTransparency(255);
    buttonSave.getPressedStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
    buttonSave.getPressedStyle().setBorder(Border.createRoundBorder(0, 0, 0xcadaf1));
    buttonSave.getPressedStyle().setBgColor(0xFAAC58);
    buttonSave.getPressedStyle().setAlignment(Label.CENTER);
    buttonSave.getPressedStyle().setFgColor(0x000000);
    buttonSave.setEnabled(false);
    f.addComponent(buttonSave);

    buttonEdit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            normalReaction.setEditable(true);
            seriousReaction.setEditable(true);
            tetanus.setEditable(true);
            buttonSave.setEnabled(true);
          }
        });

    buttonSave.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            if (normalReaction.getText().trim().length() == 0
                && seriousReaction.getText().trim().length() == 0
                && tetanus.getText().trim().length() == 0) return;

            ConnectionRequest req =
                new ConnectionRequest() {
                  protected void readResponse(InputStream input) throws IOException {
                    JSONParser p = new JSONParser();

                    Hashtable result = p.parse(new InputStreamReader(input, "UTF-8"));
                    result = (Hashtable) result.get("ResultSet");

                    int total = ((Double) result.get("totalResultsReturned")).intValue();

                    if (total == 0) {
                      Dialog.show(
                          (String) HILMain.getInstance().locale.get("notice"),
                          (String) HILMain.getInstance().locale.get("upload_unsuccessful"),
                          (String) HILMain.getInstance().locale.get("ok"),
                          null);
                    } else {
                      Vector entries = (Vector) result.get("Result");
                      for (int iter = 0; iter < entries.size(); iter++) {
                        result = (Hashtable) entries.elementAt(iter);
                        reportId = (String) result.get("reportId");
                        normalReaction.setText((String) result.get("normal"));
                        seriousReaction.setText((String) result.get("serious"));
                        tetanus.setText((String) result.get("tetanus"));
                        normalReaction.setEditable(false);
                        seriousReaction.setEditable(false);
                        tetanus.setEditable(false);
                        buttonSave.setEnabled(false);
                      }
                      if (Dialog.show(
                          (String) HILMain.getInstance().locale.get("notice"),
                          (String) HILMain.getInstance().locale.get("upload_successful"),
                          (String) HILMain.getInstance().locale.get("ok"),
                          null)) {
                        buttonSave.setEnabled(false);
                        HILMain.getInstance().showMainMenu();
                      }
                    }
                  }
                };
            req.setPost(true);
            req.setUrl(HILMain.getInstance().SERVER_ADDRESS + "saveGeneralReportData");

            req.setContentType("text/plain");

            req.addArgumentNoEncoding(
                "sessionAuth", HILMain.getInstance().currentUser.getSessionAuth());
            req.addArgumentNoEncoding(
                "username", HILMain.getInstance().currentUser.getAccountName());
            req.addArgumentNoEncoding("password", HILMain.getInstance().currentUser.getPassword());
            req.addArgumentNoEncoding("reportId", reportId);
            req.addArgumentNoEncoding("cId", HILMain.getInstance().currentUser.getcId());
            req.addArgumentNoEncoding("timeData", DateUtil.getMonthYear(date, "/"));
            req.addArgumentNoEncoding("normal", normalReaction.getText().trim());
            req.addArgumentNoEncoding("serious", seriousReaction.getText().trim());
            req.addArgumentNoEncoding("tatanus", tetanus.getText().trim());

            NetworkManager.getInstance().addToQueue(req);
          }
        });

    dateLabel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            TextArea noteLabel = new TextArea(2, 10);
            noteLabel.getStyle().setFont(HILMain.getInstance().theme.getFont("defaultFont"));
            noteLabel.getStyle().setBorder(Border.createEmpty(), true);
            noteLabel.getStyle().setBgTransparency(0);
            noteLabel.getStyle().setFgColor(0x000000);
            noteLabel.setFocus(false);
            noteLabel.setFocusable(false);
            noteLabel.setText((String) HILMain.getInstance().locale.get("help_select_date"));

            Form calendarForm = new Form();
            calendarForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
            final Calendar aCalendar = new Calendar();

            Command okCommand =
                new Command((String) HILMain.getInstance().locale.get("ok")) {
                  public void actionPerformed(ActionEvent evt) {
                    showForm(f);
                  }
                };

            aCalendar.addActionListener(
                new ActionListener() {
                  public void actionPerformed(ActionEvent evt) {
                    date = aCalendar.getDate();
                    if (!DateUtil.getMonthYear(date, "/").equalsIgnoreCase(dateLabel.getText())) {
                      dateLabel.setText(DateUtil.getMonthYear(date, "/"));
                      reportId = "";
                      normalReaction.setText("");
                      seriousReaction.setText("");
                      tetanus.setText("");
                      normalReaction.setEditable(true);
                      seriousReaction.setEditable(true);
                      tetanus.setEditable(true);
                      buttonEdit.setEnabled(false);
                      buttonSave.setEnabled(false);
                    }
                  }
                });
            calendarForm.addComponent(noteLabel);
            Container tContainer = new Container();
            tContainer.setLayout(new BorderLayout());
            tContainer.addComponent(BorderLayout.CENTER, aCalendar);
            calendarForm.addComponent(tContainer);
            calendarForm.addCommand(okCommand);
            calendarForm.show();
          }
        });

    submit.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent ae) {
            ConnectionRequest req =
                new ConnectionRequest() {
                  protected void readResponse(InputStream input) throws IOException {
                    JSONParser p = new JSONParser();

                    Hashtable result = p.parse(new InputStreamReader(input, "UTF-8"));
                    result = (Hashtable) result.get("ResultSet");

                    int total = ((Double) result.get("totalResultsReturned")).intValue();

                    if (total == 0) {
                      Dialog.show(
                          (String) HILMain.getInstance().locale.get("notice"),
                          (String) HILMain.getInstance().locale.get("there_is_no_data"),
                          (String) HILMain.getInstance().locale.get("ok"),
                          null);
                      reportId = "";
                      normalReaction.setText("");
                      normalReaction.setEditable(true);
                      seriousReaction.setText("");
                      seriousReaction.setEditable(true);
                      tetanus.setText("");
                      tetanus.setEditable(true);
                      normalReaction.setEditable(true);
                      seriousReaction.setEditable(true);
                      tetanus.setEditable(true);
                      buttonEdit.setEnabled(false);
                      buttonSave.setEnabled(true);
                    } else {
                      Vector entries = (Vector) result.get("Result");
                      for (int iter = 0; iter < entries.size(); iter++) {
                        result = (Hashtable) entries.elementAt(iter);
                        reportId = (String) result.get("reportId");
                        normalReaction.setText((String) result.get("normal"));
                        normalReaction.setEditable(false);
                        seriousReaction.setText((String) result.get("serious"));
                        seriousReaction.setEditable(false);
                        tetanus.setText((String) result.get("tetanus"));
                        tetanus.setEditable(false);
                        normalReaction.setEditable(false);
                        seriousReaction.setEditable(false);
                        tetanus.setEditable(false);
                        buttonEdit.setEnabled(true);
                        buttonSave.setEnabled(false);
                      }
                      if (normalReaction.getText().length() == 0
                          && seriousReaction.getText().length() == 0
                          && tetanus.getText().length() == 0) {
                        Dialog.show(
                            (String) HILMain.getInstance().locale.get("notice"),
                            (String) HILMain.getInstance().locale.get("there_is_no_data"),
                            (String) HILMain.getInstance().locale.get("ok"),
                            null);
                        normalReaction.setEditable(true);
                        seriousReaction.setEditable(true);
                        tetanus.setEditable(true);
                        buttonEdit.setEnabled(false);
                        buttonSave.setEnabled(true);
                      }
                    }
                  }
                };
            req.setPost(true);
            req.setUrl(HILMain.getInstance().SERVER_ADDRESS + "generalReportData");

            req.setContentType("text/plain");
            req.addArgumentNoEncoding(
                "sessionAuth", HILMain.getInstance().currentUser.getSessionAuth());
            req.addArgumentNoEncoding(
                "username", HILMain.getInstance().currentUser.getAccountName());
            req.addArgumentNoEncoding("password", HILMain.getInstance().currentUser.getPassword());
            req.addArgumentNoEncoding("cId", HILMain.getInstance().currentUser.getcId());
            req.addArgumentNoEncoding("timeData", DateUtil.getMonthYear(date, "/"));
            NetworkManager.getInstance().addToQueue(req);
          }
        });
  }