Example usage for com.vaadin.ui FormLayout FormLayout

List of usage examples for com.vaadin.ui FormLayout FormLayout

Introduction

In this page you can find the example usage for com.vaadin.ui FormLayout FormLayout.

Prototype

public FormLayout() 

Source Link

Usage

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.PasswordResetPopup.java

License:Open Source License

@SuppressWarnings("serial")
public PasswordResetPopup(Button.ClickListener listener, String uname) {
    setCaption("Password Reset");
    VerticalLayout vLay = new VerticalLayout();
    vLay.setSpacing(true);/*from   ww w  .  j ava  2 s . c  o  m*/
    vLay.setMargin(true);
    setContent(vLay);

    vLay.addComponent(new HtmlLabel(
            "<center>Please fill in your player name and/or email address<br/>to initiate a password reset.</center>"));
    // Use an actual form widget here for data binding and error display.
    FormLayout formLay = new FormLayout();
    formLay.setSizeUndefined();
    formLay.setSpacing(true);
    formLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield)
    vLay.addComponent(formLay);
    vLay.setComponentAlignment(formLay, Alignment.TOP_CENTER);

    formLay.addComponent(userIDTf = new TextField("Player name:"));
    userIDTf.addStyleName("m-dialog-textfield");
    userIDTf.setWidth("85%");
    userIDTf.setTabIndex(100);

    // Help out a little here
    userIDTf.setValue(uname == null ? "" : uname);
    formLay.addComponent(emailTf = new TextField("Email:"));
    emailTf.addStyleName("m-dialog-textfield");
    emailTf.setWidth("85%");
    emailTf.setTabIndex(101);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    hl.setMargin(false);
    hl.setWidth("100%");
    vLay.addComponent(hl);

    Label lab;
    hl.addComponent(lab = new Label());
    hl.setExpandRatio(lab, 1.0f);
    Button cancelButt = new Button("Cancel");
    hl.addComponent(cancelButt);
    cancelButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getUI().setScrollTop(0);
            getUI().removeWindow(PasswordResetPopup.this);
        }
    });
    cancelButt.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);

    Button continueButt = new Button("Continue");
    hl.addComponent(continueButt);
    continueButt.addClickListener(PasswordResetPopup.this);
    continueButt.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    emailTf.focus();
}

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPagePopupFirst.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
public RegistrationPagePopupFirst(ClickListener listener) {
    super(listener);
    super.initGui();

    setTitleString("We don't need much to get you started.", true); //smaller

    contentVLayout.setSpacing(true);//  ww  w.j ava 2s.com

    Label lab;
    contentVLayout.addComponent(lab = new Label());
    lab.setHeight("10px");

    contentVLayout.addComponent(
            lab = new Label("Game play for this session of mmowgli is restricted to invited users"));
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    contentVLayout.addComponent(
            lab = new Label("with a previously-registered email address or approved email domain."));
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    contentVLayout.addComponent(lab = new HtmlLabel("&nbsp;"));
    ;
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    contentVLayout
            .addComponent(lab = new Label("Please choose a player name (ID) that protects your privacy."));
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    // Use an actual form widget here for data binding and error display.
    formLay = new FormLayout();
    formLay.setSizeUndefined();
    formLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield)
    contentVLayout.addComponent(formLay);
    contentVLayout.setComponentAlignment(formLay, Alignment.TOP_CENTER);

    formLay.addComponent(userIDTf = new TextField("Pick a player name (ID)"));
    userIDTf.setColumns(24);
    // userIDTf.setRequired(true);
    // userIDTf.setRequiredError("We really need an occupation.");

    formLay.addComponent(passwordTf = new PasswordField("Password *"));
    passwordTf.setColumns(24);
    // passwordTf.setRequired(true);
    // passwordTf.setRequiredError("We really need some expertise.");

    formLay.addComponent(confirmTf = new PasswordField("Confirm password *"));
    confirmTf.setColumns(24);
    // confirmTf.setRequired(true);
    // confirmTf.setRequiredError("We really need some expertise.");

    HorizontalLayout hl;
    contentVLayout.addComponent(hl = new HorizontalLayout());
    hl.setMargin(false);

    hl.addComponent(lab = new Label());
    lab.setWidth("50px");
    hl.addComponent(lab = new Label("Choose an avatar image:"));
    lab.addStyleName("m-dialog-text"); //"m-dialog-label");

    chooser = new AvatarPanel(null); // no initselected
    chooser.setWidth("500px"); //"470px"); // doesn't work well w/ relative width 470=min for displaying 4 across of size below
    //  chooser.setHeight("130px"); // 125 enough for mac to show complete image plus bottom scrollbar, IE 7 will ALWAYS show vert scroller
    // todo, check commented-out line on windows...works well on new macs.
    chooser.initGui();
    contentVLayout.addComponent(chooser);
    contentVLayout.setComponentAlignment(chooser, Alignment.TOP_CENTER);
    chooser.setSelectedAvatarIdx(0); // choose the first one just so something is chosen

    contentVLayout.addComponent(lab = new Label());
    lab.setHeight("10px");

    contentVLayout.addComponent(lab = new Label("The following information is not revealed to other players"));
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    formLay = new FormLayout();
    formLay.setSizeUndefined();
    formLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield)
    contentVLayout.addComponent(formLay);
    contentVLayout.setComponentAlignment(formLay, Alignment.TOP_CENTER);

    formLay.addComponent(firstNameTf = new TextField("First name *"));
    firstNameTf.setColumns(27); // sets width
    firstNameTf.setInputPrompt("optional");
    // firstNameTf.setRequired(true);
    // firstNameTf.setRequiredError("We really need a location.");

    formLay.addComponent(lastNameTf = new TextField("Last name *"));
    lastNameTf.setColumns(27); // sets width
    lastNameTf.setInputPrompt("optional");
    // lastNameTf(true);
    // lastNameTf("We really need a location.");

    formLay.addComponent(emailTf = new TextField("Email address *"));
    emailTf.setColumns(27); // sets width
    // emailTf.setRequired(true);
    // emailTf.setRequiredError("We really need a location.");

    contentVLayout.addComponent(lab = new Label("* private information (encrypted in database)"));
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    hl = new HorizontalLayout();
    hl.setWidth("100%");
    contentVLayout.addComponent(hl);

    hl.addComponent(lab = new Label());
    hl.setExpandRatio(lab, 1.0f);

    continueButt = new NativeButton(null);
    continueButt.setStyleName("m-continueButton");
    //NativeButton continueButt = new NativeButton();
    hl.addComponent(continueButt);
    //app.globs().mediaLocator().decorateDialogContinueButton(continueButt);
    continueButt.addClickListener(new MyContinueListener());
    continueButt.setClickShortcut(KeyCode.ENTER);

    hl.addComponent(lab = new Label());
    lab.setWidth("15px");

    // if this is a cac-based registration, initialize the tf's with the cac card.
    // then, if the cac values are require to be used, mark the tf's as read-only
    CACData cData = Mmowgli2UI.getGlobals().getCACInfo();
    if (CACManager.isCacPresent(cData)) {
        Game g = Game.getTL();
        boolean force = g.isEnforceCACdataRegistration();

        String s;
        if ((s = CACManager.getFirstName(cData)) != null) {
            firstNameTf.setValue(s);
            firstNameTf.setReadOnly(force);
        }
        if ((s = CACManager.getLastName(cData)) != null) {
            lastNameTf.setValue(s);
            lastNameTf.setReadOnly(force);
        }
        if ((s = CACManager.getEmail(cData)) != null) {
            emailTf.setValue(s);
            emailTf.setReadOnly(force);
        }
    }

    userIDTf.focus(); // should do it
    FocusHack.focus(userIDTf); // this does
}

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPagePopupFirstA.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
public RegistrationPagePopupFirstA(ClickListener listener) {
    super(listener);
    super.initGui();

    setTitleString("We don't need much to get you started.", true); //smaller

    contentVLayout.setSpacing(true);/*from w ww  .  java  2 s. c  om*/

    Label lab;
    contentVLayout.addComponent(lab = new Label());
    lab.setHeight("10px");

    contentVLayout.addComponent(
            lab = new Label("Game play for this session of mmowgli is restricted to invited users"));
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    contentVLayout.addComponent(
            lab = new Label("with a previously-registered email address or approved email domain."));
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    contentVLayout.addComponent(lab = new HtmlLabel("&nbsp;"));
    ;
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    contentVLayout
            .addComponent(lab = new Label("Please choose a player name (ID) that protects your privacy."));
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    // Use an actual form widget here for data binding and error display.
    formLay = new FormLayout();
    formLay.setSizeUndefined();
    formLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield)
    contentVLayout.addComponent(formLay);
    contentVLayout.setComponentAlignment(formLay, Alignment.TOP_CENTER);

    formLay.addComponent(userIDTf = new TextField("Pick a player name (ID)"));
    userIDTf.setColumns(24);
    // userIDTf.setRequired(true);
    // userIDTf.setRequiredError("We really need an occupation.");

    formLay.addComponent(passwordTf = new PasswordField("Password *"));
    passwordTf.setColumns(24);
    // passwordTf.setRequired(true);
    // passwordTf.setRequiredError("We really need some expertise.");

    formLay.addComponent(confirmTf = new PasswordField("Confirm password *"));
    confirmTf.setColumns(24);
    // confirmTf.setRequired(true);
    // confirmTf.setRequiredError("We really need some expertise.");

    formLay.addComponent(emailTf = new TextField("Email address *"));
    emailTf.setColumns(27); // sets width
    // emailTf.setRequired(true);
    // emailTf.setRequiredError("We really need a location.");

    contentVLayout.addComponent(lab = new Label("* private information (encrypted in database)"));
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth("100%");
    contentVLayout.addComponent(hl);

    hl.addComponent(lab = new Label());
    hl.setExpandRatio(lab, 1.0f);

    continueButt = new NativeButton(null);
    continueButt.setStyleName("m-continueButton");
    //NativeButton continueButt = new NativeButton();
    hl.addComponent(continueButt);
    //app.globs().mediaLocator().decorateDialogContinueButton(continueButt);
    continueButt.addClickListener(new MyContinueListener());
    continueButt.setClickShortcut(KeyCode.ENTER);

    hl.addComponent(lab = new Label());
    lab.setWidth("15px");

    // if this is a cac-based registration, initialize the tf's with the cac card.
    // then, if the cac values are require to be used, mark the tf's as read-only
    CACData cData = Mmowgli2UI.getGlobals().getCACInfo();
    if (CACManager.isCacPresent(cData)) {
        Game g = Game.getTL();
        boolean force = g.isEnforceCACdataRegistration();

        String s;
        /*if((s = CACManager.getFirstName(cData))!=null) {
          firstNameTf.setValue(s);
          firstNameTf.setReadOnly(force);
        }
        if((s = CACManager.getLastName(cData))!=null) {
          lastNameTf.setValue(s);
          lastNameTf.setReadOnly(force);
        }
        */
        if ((s = CACManager.getEmail(cData)) != null) {
            emailTf.setValue(s);
            emailTf.setReadOnly(force);
        }
    }

    userIDTf.focus(); // should do it
    FocusHack.focus(userIDTf); // this does
}

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPagePopupFirstB.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
public RegistrationPagePopupFirstB(ClickListener listener, Long uId) {
    super(listener);
    super.initGui();
    localUserId = uId;// w  w w  .  j  a  v  a 2 s .co  m

    setTitleString("The following is not revealed to other players.", true); //smaller

    contentVLayout.setSpacing(true);

    Label lab;
    contentVLayout.addComponent(lab = new Label());
    lab.setHeight("10px");

    // Use an actual form widget here for data binding and error display.
    formLay = new FormLayout();
    formLay.setSizeUndefined();
    formLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield)
    contentVLayout.addComponent(formLay);
    contentVLayout.setComponentAlignment(formLay, Alignment.TOP_CENTER);

    formLay.addComponent(firstNameTf = new TextField("First name *"));
    firstNameTf.setColumns(27); // sets width
    firstNameTf.setInputPrompt("optional");
    // firstNameTf.setRequired(true);
    // firstNameTf.setRequiredError("We really need a location.");

    formLay.addComponent(lastNameTf = new TextField("Last name *"));
    lastNameTf.setColumns(27); // sets width
    lastNameTf.setInputPrompt("optional");
    // lastNameTf(true);
    // lastNameTf("We really need a location.");

    contentVLayout.addComponent(lab = new Label("* private information (encrypted in database)"));
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    contentVLayout.addComponent(lab = new Label());
    lab.setHeight("5px");

    HorizontalLayout hl;
    contentVLayout.addComponent(hl = new HorizontalLayout());
    hl.setMargin(false);

    hl.addComponent(lab = new Label());
    lab.setWidth("50px");
    hl.addComponent(lab = new Label("Choose an avatar image:"));
    lab.addStyleName("m-dialog-text"); //"m-dialog-label");

    chooser = new AvatarPanel(null); // no initselected
    chooser.setWidth("500px"); //"470px"); // doesn't work well w/ relative width 470=min for displaying 4 across of size below
    //  chooser.setHeight("130px"); // 125 enough for mac to show complete image plus bottom scrollbar, IE 7 will ALWAYS show vert scroller
    // todo, check commented-out line on windows...works well on new macs.
    chooser.initGui();
    contentVLayout.addComponent(chooser);
    contentVLayout.setComponentAlignment(chooser, Alignment.TOP_CENTER);
    chooser.setSelectedAvatarIdx(0); // choose the first one just so something is chosen

    hl = new HorizontalLayout();
    hl.setWidth("100%");
    contentVLayout.addComponent(hl);

    hl.addComponent(lab = new Label());
    hl.setExpandRatio(lab, 1.0f);

    continueButt = new NativeButton(null);
    continueButt.setStyleName("m-continueButton");
    //NativeButton continueButt = new NativeButton();
    hl.addComponent(continueButt);
    //app.globs().mediaLocator().decorateDialogContinueButton(continueButt);
    continueButt.addClickListener(new MyContinueListener());
    continueButt.setClickShortcut(KeyCode.ENTER);

    hl.addComponent(lab = new Label());
    lab.setWidth("15px");

    // if this is a cac-based registration, initialize the tf's with the cac card.
    // then, if the cac values are require to be used, mark the tf's as read-only
    CACData cData = Mmowgli2UI.getGlobals().getCACInfo();
    if (CACManager.isCacPresent(cData)) {
        Game g = Game.getTL();
        boolean force = g.isEnforceCACdataRegistration();

        String s;
        if ((s = CACManager.getFirstName(cData)) != null) {
            firstNameTf.setValue(s);
            firstNameTf.setReadOnly(force);
        }
        if ((s = CACManager.getLastName(cData)) != null) {
            lastNameTf.setValue(s);
            lastNameTf.setReadOnly(force);
        }
        /*
        if((s = CACManager.getEmail(cData))!=null) {
          emailTf.setValue(s);
          emailTf.setReadOnly(force);
        }
        */
    }

    firstNameTf.focus(); // should do it
    FocusHack.focus(firstNameTf); // this does
}

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPagePopupSecond.java

License:Open Source License

public RegistrationPagePopupSecond(Button.ClickListener listener, Long uId) {
    super(listener);
    super.initGui();
    localUserId = uId;//from   ww w .jav  a  2 s.c om
    setTitleString("Tell us about you");

    contentVLayout.setSpacing(true);
    Label sp;
    contentVLayout.addComponent(sp = new Label());
    sp.setHeight("20px");

    Label header = new HtmlLabel(
            "<center>Affiliation category and location are optional and are displayed to other game players.</center>"); // and help you</center>");
    header.addStyleName("m-dialog-label-noindent");
    contentVLayout.addComponent(header);
    contentVLayout.setComponentAlignment(header, Alignment.TOP_CENTER);

    HorizontalLayout horL = new HorizontalLayout();
    horL.setSpacing(false);
    horL.setWidth("100%");
    contentVLayout.addComponent(horL);

    horL.addComponent(sp = new Label());
    sp.setWidth("20px");

    // Use an actual form widget here for data binding and error display.
    formLay = new FormLayout();
    formLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield)
    formLay.setSizeUndefined();

    horL.addComponent(formLay);
    horL.setExpandRatio(formLay, 1.0f);

    formLay.addComponent(affilCombo = new BoundAffiliationCombo("Affiliation:"));
    affilCombo.setValue(affilCombo.getItemIds().toArray()[0]); // Tried to get this to be editable....needs more work

    formLay.addComponent(locTf = new TextField("Location:"));
    locTf.setColumns(31);
    locTf.setInputPrompt("optional");
    locTf.addStyleName("m-noleftmargin");

    Label lab;
    contentVLayout.addComponent(lab = new HtmlLabel(warning));
    lab.addStyleName(labelStyle);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth("100%");
    contentVLayout.addComponent(hl);

    hl.addComponent(lab = new Label());
    hl.setExpandRatio(lab, 1.0f);

    NativeButton continueButt = new NativeButton(null);
    continueButt.setStyleName("m-continueButton");
    hl.addComponent(continueButt);
    continueButt.addClickListener(new JoinListener());
    continueButt.setClickShortcut(KeyCode.ENTER);

    hl.addComponent(lab = new Label());
    lab.setWidth("20px"); // don't run off the end
}

From source file:edu.nps.moves.mmowgli.modules.userprofile.ChangeEmailDialog.java

License:Open Source License

@SuppressWarnings("serial")
public ChangeEmailDialog(EmailPacket pkt) {
    this.packet = pkt;
    // this.uid=uid;
    //User user = DBGet.getUser(uid);

    setCaption("Change Email");
    setModal(true);/*from  w  w  w  . j a  va 2 s .  co m*/
    setWidth("350px");
    //setHeight("200px");

    VerticalLayout vLay = new VerticalLayout();
    setContent(vLay);
    FormLayout fLay = new FormLayout();
    oldEmail = new TextField("Current Email", pkt.original);//user.getEmailAddresses().toString());
    //oldPw.setColumns(20);
    oldEmail.setWidth("99%");
    fLay.addComponent(oldEmail);
    newEmail = new TextField("New Email");
    newEmail.setWidth("99%");
    fLay.addComponent(newEmail);
    newEmail2 = new TextField("Confirm Email");
    newEmail2.setWidth("99%");
    fLay.addComponent(newEmail2);

    vLay.addComponent(fLay);

    HorizontalLayout buttLay = new HorizontalLayout();
    buttLay.setSpacing(true);
    vLay.addComponent(buttLay);
    vLay.setComponentAlignment(buttLay, Alignment.TOP_RIGHT);
    MediaLocator mLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    NativeButton cancelButt = new NativeButton();
    mLoc.decorateCancelButton(cancelButt);
    buttLay.addComponent(cancelButt);
    buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT);

    //    Label sp;
    //    buttLay.addComponent(sp = new Label());
    //    sp.setWidth("30px");

    saveButt = new NativeButton();
    //app.globs().mediaLocator().decorateSaveButton(saveButt);  //"save"
    mLoc.decorateOkButton(saveButt); //"ok"
    buttLay.addComponent(saveButt);
    buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT);

    //    buttLay.addComponent(sp = new Label());
    //    sp.setWidth("5px");

    cancelButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(ChangeEmailDialog.this);
        }
    });
    saveButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String oldTry = oldEmail.getValue().toString();
            if (!packet.original.equals(oldTry)) {
                Notification.show("Error", "This should never show", Notification.Type.ERROR_MESSAGE);
                return;
            }

            String check = newEmail2.getValue().toString();
            String newStr = newEmail.getValue().toString();
            if (check == null || !newStr.trim().equals(check.trim())) {
                Notification.show("Error", "Emails do not match", Notification.Type.ERROR_MESSAGE);
                return;
            }

            EmailValidator v = new EmailValidator("");
            if (newStr == null || !v.isValid(newStr)) {
                Notification.show("Error", "Please enter a valid email", Notification.Type.ERROR_MESSAGE);
                return;
            }

            packet.updated = newStr.trim();
            if (saveListener != null)
                saveListener.buttonClick(event);
            UI.getCurrent().removeWindow(ChangeEmailDialog.this);
        }
    });
}

From source file:edu.nps.moves.mmowgli.modules.userprofile.ChangePasswordDialog.java

License:Open Source License

@SuppressWarnings("serial")
public ChangePasswordDialog(PasswordPacket pkt) {
    this.packet = pkt;

    setCaption("Change Password");
    setModal(true);/*  ww  w  .  ja  v  a  2s . c o m*/
    setWidth("350px");

    VerticalLayout vLay = new VerticalLayout();
    setContent(vLay);
    FormLayout fLay = new FormLayout();
    oldPw = new PasswordField("Current");
    //oldPw.setColumns(20);
    oldPw.setWidth("99%");
    fLay.addComponent(oldPw);
    newPw = new PasswordField("New");
    newPw.setWidth("99%");
    fLay.addComponent(newPw);
    newPw2 = new PasswordField("New again");
    newPw2.setWidth("99%");
    fLay.addComponent(newPw2);

    vLay.addComponent(fLay);

    HorizontalLayout buttLay = new HorizontalLayout();
    buttLay.setSpacing(true);
    vLay.addComponent(buttLay);
    vLay.setComponentAlignment(buttLay, Alignment.TOP_RIGHT);

    MediaLocator mLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    NativeButton cancelButt = new NativeButton();
    mLoc.decorateCancelButton(cancelButt);
    buttLay.addComponent(cancelButt);
    buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT);

    //    Label sp;
    //    buttLay.addComponent(sp = new Label());
    //    sp.setWidth("30px");

    saveButt = new NativeButton();
    //app.globs().mediaLocator().decorateSaveButton(saveButt);  //"save"
    mLoc.decorateOkButton(saveButt); //"ok"
    buttLay.addComponent(saveButt);
    buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT);

    //    buttLay.addComponent(sp = new Label());
    //    sp.setWidth("5px");

    cancelButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(ChangePasswordDialog.this);
        }
    });
    saveButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String oldTry = oldPw.getValue().toString();
            StrongPasswordEncryptor spe = new StrongPasswordEncryptor();
            if (!spe.checkPassword(oldTry, packet.original)) {
                Notification.show("Error", "Existing password incorrect", Notification.Type.ERROR_MESSAGE);
                return;
            }

            String newStr = newPw.getValue().toString();
            if (newStr == null || newStr.length() < 6) {
                Notification.show("Error", "Enter a password of at least six characters",
                        Notification.Type.ERROR_MESSAGE);
                return;
            }
            String check = newPw2.getValue().toString();
            if (check == null || !newStr.trim().equals(check.trim())) {
                Notification.show("Error", "Passwords do not match", Notification.Type.ERROR_MESSAGE);
                return;
            }

            packet.updated = newStr.trim();
            if (saveListener != null)
                saveListener.buttonClick(event);
            UI.getCurrent().removeWindow(ChangePasswordDialog.this);
        }
    });
}

From source file:edu.nps.moves.mmowgli.modules.userprofile.EditAwardTypeDialog.java

License:Open Source License

@SuppressWarnings("serial")
private EditAwardTypeDialog(AwardType awt, EditAwardResultListener lis) {
    Object sessKey = HSess.checkInit();
    listener = lis;/*from ww w .j a  va 2  s.  c  o  m*/
    awardType = awt;

    setCaption("Edit Award Type");
    setModal(true);
    setWidth("450px");

    VerticalLayout vLay = new VerticalLayout();
    setContent(vLay);
    vLay.setMargin(true);
    vLay.setSpacing(true);
    vLay.addStyleName("m-greybackground");

    FormLayout formLay;
    vLay.addComponent(formLay = new FormLayout());
    formLay.setSizeFull();

    formLay.addComponent(
            nameTF = new MTextField("Award Title").withFullWidth().withNullRepresentation("required field"));
    nameTF.setRequired(true);
    nameTF.setRequiredError("Required field");
    nameTF.setSizeFull();

    formLay.addComponent(
            descTF = new MTextField("Description").withFullWidth().withNullRepresentation("required field"));
    descTF.setRequired(true);
    descTF.setRequiredError("Required field");

    Label sp;

    formLay.addComponent(hLay55 = new HorizontalLayout());
    hLay55.setWidth("100%");
    hLay55.setCaption("55x55 pixel icon");
    hLay55.setSpacing(true);
    hLay55.addComponent(lab55 = new HtmlLabel("<i>image name</i>"));
    hLay55.setComponentAlignment(lab55, Alignment.MIDDLE_CENTER);
    hLay55.addComponent(butt55 = new NativeButton("Choose 55x55 image"));
    hLay55.setComponentAlignment(butt55, Alignment.MIDDLE_CENTER);
    hLay55.addComponent(sp = new Label());
    hLay55.setExpandRatio(sp, 1.0f);
    hLay55.addComponent(image55 = new Image(null));
    image55.setWidth("55px");
    image55.setHeight("55px");
    image55.addStyleName("m-greyborder3");

    formLay.addComponent(hLay300 = new HorizontalLayout());
    hLay300.setWidth("100%");
    hLay300.setCaption("300x300 pixel icon");
    hLay300.setSpacing(true);
    hLay300.addComponent(lab300 = new HtmlLabel("<i>image name</i>"));
    hLay300.setComponentAlignment(lab300, Alignment.MIDDLE_CENTER);
    hLay300.addComponent(butt300 = new NativeButton("Choose 300x300 image"));
    hLay300.setComponentAlignment(butt300, Alignment.MIDDLE_CENTER);
    hLay300.addComponent(sp = new Label());
    hLay300.setExpandRatio(sp, 1.0f);
    hLay300.addComponent(image300 = new Image(null));
    image300.setWidth("55px");
    image300.setHeight("55px");
    image300.addStyleName("m-greyborder3");

    ClickListener chooseIconListener = new ClickListener() {
        boolean is55 = false;

        @Override
        public void buttonClick(ClickEvent event) {
            is55 = (event.getButton() == butt55);
            String txt = (is55 ? pix55text : pix300text);
            InstallImageResultListener lis = new InstallImageResultListener() {
                @Override
                public void doneTL(MediaImage mimg) {
                    Media m = null;
                    if (mimg != null)
                        m = mimg.media;

                    if (m != null) {
                        MediaLocator mediaLoc = Mmowgli2UI.getGlobals().getMediaLocator();
                        String handle = m.getHandle();
                        if (handle != null && handle.trim().length() <= 0)
                            handle = null;
                        if (is55) {
                            media55 = m;
                            if (handle == null) {
                                m.setHandle("55x55");
                                Media.updateTL(m);
                            }
                            lab55.setValue(m.getUrl());
                            image55.setSource(mediaLoc.locate(m));
                        } else {
                            media300 = m;
                            if (handle == null) {
                                m.setHandle("300x300");
                                Media.updateTL(m);
                            }
                            lab300.setValue(m.getUrl());
                            image300.setSource(mediaLoc.locate(m));
                        }
                    }
                }
            };
            InstallImageDialog.show(txt, lis, is55 ? pix55filter : pix300filter);
        }
    };

    butt55.addClickListener(chooseIconListener);
    butt300.addClickListener(chooseIconListener);

    HorizontalLayout buttHL = new HorizontalLayout();
    vLay.addComponent(buttHL);
    buttHL.setWidth("100%");

    buttHL.addComponent(sp = new Label());
    sp.setWidth("1px");
    buttHL.setExpandRatio(sp, 1.0f);

    buttHL.addComponent(new NativeButton("Cancel", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            awardType = null;
            doneHereTL();
        }
    }));

    buttHL.addComponent(new NativeButton("Close", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String title = nameTF.getValue().trim();
            String description = descTF.getValue().trim();
            if (title.length() <= 0 || description.length() <= 0 || media300 == null || media55 == null) {
                Notification.show("All fields must be completed", Notification.Type.ERROR_MESSAGE);
                return;
            }

            HSess.init();

            boolean save = false;
            if (awardType == null) {
                awardType = new AwardType();
                save = true;
            }

            awardType.setName(nameTF.getValue().trim());
            awardType.setDescription(descTF.getValue().trim());
            awardType.setIcon300x300(media300);
            awardType.setIcon55x55(media55);

            if (save)
                HSess.get().save(awardType);
            else
                HSess.get().update(awardType);

            doneHereTL();
            HSess.close();
        }
    }));

    HSess.checkClose(sessKey);
}

From source file:edu.nps.moves.security.PasswordResetUI.java

License:Open Source License

private void handleChangeTL(User user) {
    this.user = user;
    Game g = Game.getTL();/*from   w  w  w.j  a  va2 s  .  c  o m*/

    String brand = g.getCurrentMove().getTitle();
    Page.getCurrent().setTitle("Password reset for " + brand + " mmowgli");

    HorizontalLayout hLay = new HorizontalLayout();
    hLay.setMargin(true);
    hLay.setWidth("100%");
    setContent(hLay);

    GameLinks gl = GameLinks.getTL();
    String blog = gl.getBlogLink();
    Label lab;
    hLay.addComponent(lab = new Label());
    hLay.setExpandRatio(lab, 0.5f);

    VerticalLayout vl = new VerticalLayout();
    hLay.addComponent(vl);
    vl.setWidth(bannerWidthPx);

    hLay.addComponent(lab = new Label());
    hLay.setExpandRatio(lab, 0.5f);

    vl.addStyleName("m-greyborder");
    vl.setMargin(true);
    vl.setSpacing(true);

    vl.addComponent(lab = new HtmlLabel(""));
    lab.addStyleName("m-font-21-bold");
    lab.setSizeUndefined();
    vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);
    StringBuilder sb = new StringBuilder();
    sb.append(thanksHdr1);
    sb.append(blog);
    sb.append(thanksHdr2);
    sb.append(brand);
    sb.append(thanksHdr3);
    lab.setValue(sb.toString());

    vl.addComponent(lab = new HtmlLabel(""));
    lab.setHeight("15px");
    vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    FormLayout fLay = new FormLayout();
    fLay.setSizeUndefined();
    fLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield)
    vl.addComponent(fLay);
    vl.setComponentAlignment(fLay, Alignment.MIDDLE_CENTER);

    newPw = new PasswordField("New Password");
    newPw.setWidth("99%");
    fLay.addComponent(newPw);

    newPw2 = new PasswordField("Again, please");
    newPw2.setWidth("99%");
    fLay.addComponent(newPw2);

    HorizontalLayout buttLay = new HorizontalLayout();
    buttLay.setSpacing(true);
    vl.addComponent(buttLay);
    vl.setComponentAlignment(buttLay, Alignment.TOP_CENTER);

    NativeButton cancelButt = new NativeButton();
    cancelButt.setStyleName("m-cancelButton");
    buttLay.addComponent(cancelButt);
    buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT);

    saveButt = new NativeButton();
    saveButt.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    saveButt.setStyleName("m-continueButton"); //m-saveChangesButton");
    buttLay.addComponent(saveButt);
    buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT);

    cancelButt.addClickListener(this);
    saveButt.addClickListener(this);
}

From source file:eu.hurion.hello.vaadin.shiro.application.HelloScreen.java

License:Apache License

public HelloScreen(final HerokuShiroApplication app) {
    setSizeFull();//from w  w w .ja  va 2  s.  c om
    final Subject currentUser = SecurityUtils.getSubject();

    final Panel welcomePanel = new Panel();
    final FormLayout content = new FormLayout();
    final Label label = new Label("Logged in as " + currentUser.getPrincipal().toString());
    logout = new Button("logout");
    logout.addClickListener(new HerokuShiroApplication.LogoutListener(app));

    content.addComponent(label);
    content.addComponent(logout);
    welcomePanel.setContent(content);
    welcomePanel.setWidth("400px");
    welcomePanel.setHeight("200px");
    addComponent(welcomePanel);
    setComponentAlignment(welcomePanel, Alignment.MIDDLE_CENTER);

    final HorizontalLayout footer = new HorizontalLayout();
    footer.setHeight("50px");
    addComponent(footer);

    final Button adminButton = new Button("For admin only");
    adminButton.setEnabled(currentUser.hasRole("admin"));
    adminButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            Notification.show("you're an admin");
        }
    });
    content.addComponent(adminButton);

    final Button userButton = new Button("For users with permission 1");
    userButton.setEnabled(currentUser.isPermitted("permission_1"));
    userButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            Notification.show("you've got permission 1");
        }
    });
    content.addComponent(userButton);

}