Ejemplo n.º 1
0
 /** Creates a new html tag handler */
 public HtmlTagHandler() {
   // #ifdef polish.i18n.useDynamicTranslations
   if (Locale.get("polish.command.followlink") != CMD_LINK.getLabel()) {
     CMD_LINK = new Command(Locale.get("polish.command.followlink"), Command.OK, 2);
     CMD_SUBMIT = new Command(Locale.get("polish.command.submit"), Command.ITEM, 2);
     CMD_BACK = new Command(Locale.get("polish.command.back"), Command.BACK, 10);
   }
   // #endif
   STYLE_LINE_BREAK.layout = Item.LAYOUT_NEWLINE_AFTER;
 }
  public EditWebAccountForm(
      Model model, Controller controller, ExternalNetwork nw, Identity iden, Style style) {
    super(model, controller, null, style);

    this.network = nw;
    this.iden = iden;

    // #style webaccount_edit_headline
    Container info = new Container(false);
    info.setAppearanceMode(Item.PLAIN);

    // constructs network icon and sets default style to focused/'white'
    IconItem networkIcon =
        UiFactory.createNetworkIcon(
            (null != this.network ? this.network.getNetworkId() : ""), false);
    networkIcon.setStyle(networkIcon.getFocusedStyle());
    networkIcon.setAppearanceMode(Item.PLAIN);

    info.add(networkIcon);
    info.add(
        // #style webaccount_edit_headline_text
        new StringItem(
            null,
            (null != this.network ? this.network.getName() : "")
                + " "
                + Locale.get("nowplus.client.java.webaccounts.edit.info.suffix")));
    this.append(info);

    String credentialsLabel = null;
    if (nw.getCredentialsType() == ExternalNetwork.CREDENTIALS_USERNAME) {
      credentialsLabel = Locale.get("nowplus.client.java.webaccounts.edit.username");
    } else if (nw.getCredentialsType() == ExternalNetwork.CREDENTIALS_USERNAME_OR_EMAIL) {
      credentialsLabel = Locale.get("nowplus.client.java.webaccounts.edit.username_email");
    }

    // add username textfield
    this.usernameTextField =
        UiFactory.createTextField(
            null, null, 128, TextField.ANY | TextField.INITIAL_CAPS_NEVER, this);
    // fix for PBLA-816 Touch device: predictive text while disabling the surepress
    // #if polish.blackberry
    this.usernameTextField.setNoComplexInput(true);
    // #endif

    // #if using.native.textfield:defined
    this.usernameTextField.setTitle(credentialsLabel);
    // #if (${lowercase(polish.vendor)}==samsung)
    UiFactory.fixSamsungNativeTextField(this.usernameTextField);
    // #endif
    // #endif

    // check for existing username
    if (null == this.iden) {
      this.usernameTextField.setHelpText(credentialsLabel);

      // #if polish.blackberry
      // #style ui_factory_textfield_helpfont
      usernameTextField.setHelpStyle();
      // #endif
    } else {
      this.usernameTextField.setString(this.iden.getName());

      // username uneditable in 'edit mode'
      //			this.usernameTextField.setAppearanceMode(Item.PLAIN);
    }

    // add password textfield
    this.passwordTextField =
        UiFactory.createTextField(
            null,
            null,
            128,
            TextField.NON_PREDICTIVE | TextField.INITIAL_CAPS_NEVER | TextField.PASSWORD,
            this);
    // #if using.native.textfield:defined
    this.passwordTextField.setTitle(Locale.get("nowplus.client.java.webaccounts.edit.password"));
    // #if (${lowercase(polish.vendor)}==samsung)
    UiFactory.fixSamsungNativeTextField(this.passwordTextField);
    // #elif polish.device.textField.requires.initialCapsNeverFix
    UiFactory.fixS40NativeTextField(this.passwordTextField);
    // #endif
    // #endif

    // check for existing password
    this.passwordTextField.setHelpText(Locale.get("nowplus.client.java.webaccounts.edit.password"));

    // #if polish.blackberry
    // #style ui_factory_textfield_helpfont
    this.passwordTextField.setHelpStyle();
    // #endif

    // #if polish.blackberry
    removeCommand(cmdBack);

    // #style ui_factory_button_item
    StringItem loginButton =
        UiFactory.createButtonItem(
            null, cmdLogin.getLabel(), (de.enough.polish.ui.Command) cmdLogin, null, null);

    append(loginButton);

    // #endif

    // adding disclaimer for given network
    if (null != this.network) {
      String[] disclaimer = this.network.getDisclaimer();

      if (disclaimer[0] != null) {
        // #style .webaccount_edit_disclaimer_header
        this.append(disclaimer[0]);
      }

      for (int i = 1; i < disclaimer.length; i++) {
        // #style .webaccount_edit_disclaimer_text
        this.append(disclaimer[i]);
      }
    }

    // #if !polish.blackberry
    this.addCommand(cmdLogin);
    this.addCommand(cmdBack);
    // #endif
  }
Ejemplo n.º 3
0
  private void initForm(boolean firstLogin) {
    // #if !polish.blackberry
    this.addCommand(cmdSave);

    if (firstLogin) this.addCommand(cmdCancel);
    else this.addCommand(cmdExit);
    // #endif

    StringItem headLine;
    // #if polish.blackberry
    // #if polish.blackberry.isTouchBuild == false
    // #style .login_headline
    headLine = new StringItem(null, Locale.get("nowplus.client.java.loginform.headline"));
    this.append(headLine);
    // #endif
    // #else
    // #style .login_headline
    headLine = new StringItem(null, Locale.get("nowplus.client.java.loginform.headline"));
    this.append(headLine);

    // #endif

    // #if polish.blackberry && polish.blackberry.isTouchBuild == false
    headLine.setAppearanceMode(Item.PLAIN);
    // #endif

    String usernameString = model.getUserName();
    String passwordString = "";

    // #if username:defined
    // #message Username is set
    // #= usernameString = "${username}";
    // #endif

    // #if password:defined
    // #message Password is set
    // #= passwordString = "${password}";
    // #endif

    if (usernameString == null) usernameString = "";
    if (passwordString == null) passwordString = "";

    // username textfield

    // #if polish.blackberry
    userName =
        UiFactory.createTextField(
            Locale.get("nowplus.client.java.loginform.username.hint"),
            usernameString,
            255,
            TextField.NON_PREDICTIVE,
            this);
    // fix for PBLA-816 Touch device: predictive text while disabling the surepress
    userName.setNoComplexInput(true);
    // #else
    userName = UiFactory.createTextField(null, usernameString, 255, TextField.NON_PREDICTIVE, this);
    // #endif

    UiAccess.setTextfieldHelp(userName, Locale.get("nowplus.client.java.loginform.username.hint"));
    // #if using.native.textfield:defined
    userName.setTitle(Locale.get("nowplus.client.java.loginform.username.hint"));
    // #if (${lowercase(polish.vendor)}==samsung)
    UiFactory.fixSamsungNativeTextField(userName);
    // #endif
    // #endif

    if (userName.getText().length() > 0) {
      // Change username textfield into uneditable field once authenticated once to keep users from
      // switching username
      userName.setConstraints(TextField.NON_PREDICTIVE | TextField.UNEDITABLE);

      usernameReadonly = true;

      // #if not polish.blackberry
      // #style .login_textfield_readonly
      // #= userName.setStyle();
      // #endif
    }

    // password textfield

    // #if polish.blackberry
    passWord =
        UiFactory.createTextField(
            Locale.get("nowplus.client.java.loginform.password.hint"),
            passwordString,
            255,
            TextField.NON_PREDICTIVE | TextField.INITIAL_CAPS_NEVER | TextField.PASSWORD,
            this);
    // #else
    passWord =
        UiFactory.createTextField(
            null, passwordString, 255, TextField.INITIAL_CAPS_NEVER | TextField.PASSWORD, this);
    // #endif

    UiAccess.setTextfieldHelp(passWord, Locale.get("nowplus.client.java.loginform.password.hint"));
    // #if using.native.textfield:defined
    passWord.setTitle(Locale.get("nowplus.client.java.loginform.password.hint"));
    // #if (${lowercase(polish.vendor)}==samsung)
    UiFactory.fixSamsungNativeTextField(passWord);
    // #elif polish.device.textField.requires.initialCapsNeverFix:defined
    UiFactory.fixS40NativeTextField(passWord);
    // #endif
    // #endif

    rememberMeItem =
        UiFactory.createChoiceCheckBoxItem(
            Locale.get("nowplus.client.java.loginform.rememberme.label"), Choice.MULTIPLE);
    rememberMeItem.select(model.stayLoggedIn());
    UiFactory.createChoiceGroup(
        null,
        ChoiceGroup.MULTIPLE,
        new ChoiceItem[] {rememberMeItem},
        0,
        rememberMeItem.isSelected,
        null,
        this);

    // #if !polish.blackberry
    if (usernameReadonly) {
      this.focus(passWord);
    }
    // #endif

    // #if polish.blackberry
    // #style ui_factory_button_item
    StringItem loginButton =
        UiFactory.createButtonItem(
            null, cmdSave.getLabel(), (de.enough.polish.ui.Command) cmdSave, null, null);
    append(loginButton);

    if (firstLogin) {
      cmdQuit = cmdCancel;
    } else {
      cmdQuit = cmdExit;
    }
    // #endif
  }