/** Creates a new instance of PrivacyForm */
  public PrivacyForm(Display display, PrivacyItem item, PrivacyList plist) {
    this.display = display;
    parentView = display.getCurrent();
    this.item = item;
    targetList = plist;

    textValue = new TextField(null, item.value, 64, ConstMIDP.TEXTFIELD_URL);
    TextFieldCombo.setLowerCaseLatin(textValue);

    form.append(choiceAction);
    choiceAction.setSelectedIndex(item.action, true);

    form.append(choiseType);

    form.append(textValue);
    choiseType.setSelectedIndex(item.type, true);
    switchType();

    form.append(choiseStanzas);
    choiseStanzas.setSelectedFlags(item.stanzasSet);

    // form.append("Order: "+item.order);

    form.setItemStateListener(this);
    form.setCommandListener(this);
    form.addCommand(cmdOk);
    form.addCommand(cmdCancel);
    display.setCurrent(form);
  }
  private void createForm(
      final Display display, String room, String server, String nick, final String password) {
    this.display = display;
    parentView = display.getCurrent();

    Form formJoin = new Form(SR.MS_JOIN_CONFERENCE);

    roomField = new TextField(SR.MS_ROOM, room, 64, ConstMIDP.TEXTFIELD_URL);
    TextFieldCombo.setLowerCaseLatin(roomField);
    formJoin.append(roomField);

    hostField = new TextField(SR.MS_AT_HOST, server, 64, ConstMIDP.TEXTFIELD_URL);
    TextFieldCombo.setLowerCaseLatin(hostField);
    formJoin.append(hostField);

    if (nick == null) nick = sd.account.getNickName();
    nickField = new TextFieldCombo(SR.MS_NICKNAME, nick, 32, TextField.ANY, "roomnick", display);
    formJoin.append(nickField);

    passField =
        new TextField(SR.MS_PASSWORD, password, 32, TextField.ANY | ConstMIDP.TEXTFIELD_SENSITIVE);
    formJoin.append(passField);

    msgLimitField = new NumberField(SR.MS_MSG_LIMIT, 20, 0, 20);
    formJoin.append(msgLimitField);

    formJoin.addCommand(cmdJoin);
    // formJoin.addCommand(cmdBookmarks);
    formJoin.addCommand(cmdAdd);

    formJoin.addCommand(cmdCancel);
    formJoin.setCommandListener(this);
    display.setCurrent(formJoin);
  }
  public void commandAction(Command c, Displayable d) {
    if (c == cmdCancel) {
      destroyView();
    }
    // if (c==cmdBookmarks) { new Bookmarks(display, null); }
    if (c == cmdJoin || c == cmdAdd) {
      String nick = nickField.getString().trim();
      String host = hostField.getString().trim();
      String room = roomField.getString().trim();
      String pass = passField.getString();
      int msgLimit = msgLimitField.getValue();

      if (nick.length() == 0) return;
      if (room.length() == 0) return;
      if (host.length() == 0) return;
      StringBuffer gchat = new StringBuffer(room.trim());
      gchat.append('@');
      gchat.append(host.trim());
      // sd.roster.mucContact(gchat.toString(), Contact.ORIGIN_GROUPCHAT);
      if (c == cmdAdd) new Bookmarks(display, new BookmarkItem(gchat.toString(), nick, pass));
      else {
        try {
          gchat.append('/');
          gchat.append(nick);
          join(gchat.toString(), pass, msgLimit);

          display.setCurrent(sd.roster);
        } catch (Exception e) {
          e.printStackTrace();
          // display.setCurrent(new Alert("Exception", e.toString(), null, AlertType.ERROR),
          // sd.roster);
        }
      }
    }
  }
 public void destroyView() {
   if (display != null) display.setCurrent(parentView);
 }