Example usage for com.vaadin.ui NativeButton NativeButton

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

Introduction

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

Prototype

public NativeButton(String caption) 

Source Link

Usage

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);/*from   w ww. j ava2s . 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(" "));
    ;
    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);/*w  ww . ja  va  2  s  .  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(" "));
    ;
    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  ww  . j a  v a 2  s .com*/

    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  .  j ava 2 s. c  o  m
    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.registrationlogin.RoleSelectionPage.java

License:Open Source License

public RoleSelectionPage(ClickListener listener, Long uId) {
    super(listener);
    super.initGui();
    this.localUserId = uId;

    setTitleString("Last Step: tell others of your interests"); //"Role Selection");

    contentVLayout.setSpacing(true);//from  w w  w .j  a  v  a2  s . c  o m
    contentVLayout.setMargin(true);
    contentVLayout.addStyleName("m-role-page");

    Label lab;
    contentVLayout.addComponent(lab = new HtmlLabel(
            "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This optional information is revealed to other players."));
    lab.addStyleName(labelStyle);
    contentVLayout.addComponent(lab = new Label());
    lab.setHeight("10px");

    expertiseTf = new TextField();
    expertiseTf.addStyleName("m-noleftmargin");
    expertiseTf.setCaption("Enter a short description of your pertinent expertise.");
    expertiseTf.setColumns(38);
    expertiseTf.setInputPrompt("optional");
    contentVLayout.addComponent(expertiseTf);

    Game game = Game.getTL();
    ques = game.getQuestion();

    ansTf = new TextArea(ques.getQuestion());
    ansTf.setWidth("98%");
    ansTf.setRows(10);
    ansTf.setInputPrompt("(optional, but worth 10 points if you answer)");
    contentVLayout.addComponent(ansTf);

    emailCb = new CheckBox("I agree to receive private email during game play.");
    contentVLayout.addComponent(emailCb);
    emailCb.addStyleName(labelStyle);
    emailCb.addStyleName("m-nopaddingormargin");
    emailCb.setValue(true);

    messagesCb = new CheckBox("I agree to receive private in-game messages during game play.");
    contentVLayout.addComponent(messagesCb);
    messagesCb.addStyleName(labelStyle);
    messagesCb.addStyleName("m-nopaddingormargin");
    messagesCb.setValue(true);

    HorizontalLayout buttPan = new HorizontalLayout();
    buttPan.setWidth("100%");
    buttPan.setSpacing(true);

    buttPan.addComponent(lab = new Label("OK great, thanks for registering!  Let's play."));
    lab.addStyleName(labelStyle);
    lab.addStyleName("m-nopaddingormargin");
    lab.setSizeUndefined();

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

    buttPan.addComponent(continueButt = new NativeButton(null));
    Mmowgli2UI.getGlobals().mediaLocator().decorateGetABriefingButton(continueButt);

    Label sp;
    buttPan.addComponent(sp = new Label());
    sp.setWidth("10px");

    contentVLayout.addComponent(buttPan);

    continueButt.addClickListener(new ContinueListener());
    continueButt.setClickShortcut(KeyCode.ENTER);
    expertiseTf.focus();
}

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  w  ww.java2 s . c  om*/
    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.mmowgli.modules.userprofile.UserProfile3Top.java

License:Open Source License

@Override
public void initGui() {
    User u = User.getTL(uid);//from   w ww.  jav  a 2s .c o  m
    Game g = Game.getTL();

    setWidth("945px");
    setHeight("579px");

    addStyleName("m-userprofile3top");

    if (iCanEdit() && itsSomebodyElse) {
        coverUpChangePW.setWidth(buildPxString(COVERUPCHANGEPW_W));
        coverUpChangePW.setHeight(buildPxString(COVERUPCHANGEPW_H));
        coverUpChangePW.addStyleName("m-coverUpChangePW");
        addComponent(coverUpChangePW, buildLocString(CHANGE_PW_TOP, CHANGE_PW_LEFT));
    }
    setAvatarIconFromDb();
    avatarButt.setHeight("151px");
    avatarButt.setWidth("151px");
    avatarButt.addStyleName("m-userprofile3-avatar");

    avatarButt.setDescription("Choose your avatar image");

    addComponent(avatarButt, buildLocString(AVATAR_TOP, AVATAR_LEFT));

    if (iCanEdit() && !itsSomebodyElse) {
        String changeEmail = "Change email";
        changeEmailButt = new NativeButton(changeEmail);
        changeEmailButt.addStyleName("m-userprofile3-changeemailbutt");
        addComponent(changeEmailButt, buildLocString(CHANGEEMAIL_TOP, CHANGEEMAIL_LEFT));
        changePWButt.addStyleName("m-userprofile3-changepasswordbutt");
        addComponent(changePWButt, buildLocString(CHANGE_PW_TOP, CHANGE_PW_LEFT));
    }

    String prompt = itsSomebodyElse ? "Send " + u.getUserName() + " private mail" : "Send yourself test mail";
    sendEmailButt = new NativeButton(prompt);
    sendEmailButt.addStyleName("m-userprofile3-sendemailbutt");

    if (iCanEdit() && ((itsSomebodyElse && (u.isOkEmail() || u.isOkGameMessages())) || !itsSomebodyElse)) {
        addComponent(sendEmailButt, buildLocString(SENDEMAIL_TOP, SENDEMAIL_LEFT));
        sendEmailButt.addClickListener(new SendEmailListener());
    }

    if (iCanEdit() && itsSomebodyElse) {
        String followTxt = "Follow " + u.getUserName();
        followCB.setCaption(followTxt);
        followCB.setWidth(buildPxString(FOLLOW_W));
        followCB.setHeight(buildPxString(FOLLOW_H));
        followCB.addStyleName("m-userProfile3-follow-button");
        followCB.setImmediate(true);
        addComponent(followCB, buildLocString(FOLLOW_TOP, FOLLOW_LEFT));
    }
    scoresLab.setWidth(buildPxString(SCORES_LAB_W));
    scoresLab.setHeight(buildPxString(SCORES_LAB_H));
    addComponent(scoresLab, buildLocString(SCORES_LAB_TOP, SCORES_LAB_LEFT));

    if (g.isActionPlansEnabled()) {
        exploreScoreLab.setWidth(buildPxString(EXPLORE_SCORE_LAB_WIDTH));
        exploreScoreLab.setHeight(buildPxString(EXPLORE_SCORE_LAB_HEIGHT));
        addComponent(exploreScoreLab, buildLocString(EXPLORE_SCORE_LAB_TOP, EXPLORE_SCORE_LAB_LEFT));

        innovateScoreLab.setWidth(buildPxString(INNOVATION_SCORE_LAB_WIDTH));
        innovateScoreLab.setHeight(buildPxString(INNOVATION_SCORE_LAB_HEIGHT));
        addComponent(innovateScoreLab, buildLocString(INNOVATION_SCORE_LAB_TOP, INNOVATION_SCORE_LAB_LEFT));
    } else {
        exploreScoreLab.setWidth(buildPxString(EXPLORE_SCORE_LAB_WIDTH));
        exploreScoreLab.setHeight("25px"); //buildPxString(EXPLORE_SCORE_LAB_HEIGHT));
        addComponent(exploreScoreLab, buildLocString(EXPLORE_SCORE_LAB_TOP + 10, EXPLORE_SCORE_LAB_LEFT - 50));
    }
    learnLab.setWidth(buildPxString(LEARN_LAB_W));
    learnLab.setHeight(buildPxString(LEARN_LAB_H));
    learnLab.setStyleName("m-userProfile3-learn-label");
    addComponent(learnLab, buildLocString(LEARN_LAB_TOP, LEARN_LAB_LEFT));

    locationLab.setWidth(buildPxString(LEARN_LAB_W));
    locationLab.setHeight(buildPxString(LEARN_LAB_H_ORIG));
    addComponent(locationLab, buildLocString(LOCATION_TOP, LOCATION_LAB_LEFT));

    expertiseLab.setWidth(buildPxString(LEARN_LAB_W));
    expertiseLab.setHeight(buildPxString(LEARN_LAB_H_ORIG));
    addComponent(expertiseLab, buildLocString(EXPERTISE_TOP, EXPERTISE_LAB_LEFT));

    expertiseTA.setWidth(buildPxString(EXPERTISE_W));
    expertiseTA.setHeight(buildPxString(EXPERTISE_H));
    expertiseTA.addStyleName("m-overflow-hidden"); // don't want scroll bar
    expertiseTA.addStyleName("m-transparent");
    expertiseTA.addStyleName("m-noresize");
    expertiseTA.addStyleName("m-userprofile3-text-border");
    addComponent(expertiseTA, buildLocString(EXPERTISE_TOP, EXPERTISE_LEFT));

    affiliationLab.setWidth(buildPxString(LEARN_LAB_W));
    affiliationLab.setHeight(buildPxString(LEARN_LAB_H_ORIG));
    addComponent(affiliationLab, buildLocString(AFFILIATION_TOP, AFFILIATION_LAB_LEFT));

    affiliationCombo.addStyleName("m-transparent");
    //affiliationCombo.addStyleName("m-userprofile3-affiliation-border");  to be tested
    addComponent(affiliationCombo, buildLocString(AFFILIATION_TOP, AFFILIATION_LEFT));

    affiliationTA.setWidth(buildPxString(AFFILIATION_W));
    affiliationTA.setHeight(buildPxString(AFFILIATION_H - 23));
    affiliationTA.addStyleName("m-overflow-hidden"); // don't want scroll bar
    affiliationTA.addStyleName("m-transparent");
    affiliationTA.addStyleName("m-noresize");
    affiliationTA.addStyleName("m-userprofile3-text-border");
    addComponent(affiliationTA, buildLocString(AFFILIATION_TOP + 23, AFFILIATION_LEFT));

    locationTF.setWidth(buildPxString(LOCATION_W));
    locationTF.setHeight(buildPxString(LOCATION_H));
    locationTF.addStyleName("m-noresize");
    locationTF.addStyleName("m-overflow-hidden"); // don't want scroll bar on safari
    locationTF.addStyleName("m-userprofile3-text-border");
    locationTF.addStyleName("m-transparent");
    addComponent(locationTF, buildLocString(LOCATION_TOP, LOCATION_LEFT));

    if (imAdmin)
        addComponent(manageAwardsButt, buildLocString(142, 770));

    badgeLayout.setMargin(false);
    badgeLayout.setWidth(buildPxString(BADGES_W));
    badgeLayout.setHeight(buildPxString(BADGES_H));
    badgeLayout.setSpacing(false);
    addComponent(badgeLayout, buildLocString(BADGES_TOP, BADGES_LEFT));

    learnTA.setWidth(buildPxString(LEARN_W));
    learnTA.setHeight(buildPxString(LEARN_H));
    learnTA.addStyleName("m-noresize");
    learnTA.addStyleName("m-overflow-hidden"); // no scroll bar
    learnTA.addStyleName("m-transparent");
    learnTA.addStyleName("m-userprofile3-text-border");
    addComponent(learnTA, buildLocString(LEARN_TOP, LEARN_LEFT));

    nameLab.setWidth(buildPxString(NAME_W));
    nameLab.setHeight(buildPxString(NAME_H));
    nameLab.addStyleName("m-userprofile3name");
    addComponent(nameLab, buildLocString(NAME_TOP, NAME_LEFT));

    Component titleComp = Mmowgli2UI.getGlobals().getMediaLocator().getUserProfileTitle();
    addComponent(titleComp, buildLocString(TITLE_TOP, TITLE_LEFT));

    levelLab.setWidth(buildPxString(LEVEL_W));
    levelLab.setHeight(buildPxString(LEVEL_H));
    levelLab.addStyleName("m-userprofile3name");
    addComponent(levelLab, buildLocString(LEVEL_TOP, LEVEL_LEFT));

    addComponent(externMailCB, buildLocString(EXTERN_MAIL_TOP, EXTERN_MAIL_LEFT));
    addComponent(ingameMailCB, buildLocString(INGAME_MAIL_TOP, INGAME_MAIL_LEFT));

    displayBadgesAndAwardsTL(uid);

    if (!itsSomebodyElse)
        avatarButt.addClickListener(new ClickListener() {
            private static final long serialVersionUID = 1L;

            @MmowgliCodeEntry
            @HibernateOpened
            @HibernateClosed
            @Override
            public void buttonClick(ClickEvent event) {
                HSess.init();
                User u = User.getTL(uid);
                Avatar av = u.getAvatar();
                AvatarChooser chooser = new AvatarChooser(av == null ? null : av.getId());
                chooser.initGui();
                chooser.addCloseListener(new ChooserClosed());
                UI.getCurrent().addWindow(chooser);
                chooser.center();
                HSess.close();
            }
        });

    learnTA.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateUpdate
        @HibernateClosed
        @HibernateUserUpdate
        @Override
        public void valueChange(ValueChangeEvent event) {
            if (listenersDisabled)
                return;
            HSess.init();
            String s = learnTA.getValue().toString().trim();
            User u = User.getTL(uid);
            u.setAnswer(clampToVarchar255(s)); // Db field is 255 varchar
            User.updateTL(u);
            Notification.show("Answer changed", Notification.Type.HUMANIZED_MESSAGE);
            HSess.close();
        }
    });

    expertiseTA.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateUpdate
        @HibernateClosed
        @HibernateUserUpdate
        @Override
        public void valueChange(ValueChangeEvent event) {
            if (listenersDisabled)
                return;

            HSess.init();
            String s = expertiseTA.getValue().toString().trim();
            User u = User.getTL(uid);
            u.setExpertise(clampToVarchar255(s));
            User.updateTL(u);
            Notification.show("Expertised changed", Notification.Type.HUMANIZED_MESSAGE);
            HSess.close();
        }
    });

    ValueChangeListener affiliationListener = new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateUpdate
        @HibernateClosed
        @HibernateUserUpdate
        @Override
        public void valueChange(ValueChangeEvent event) {
            if (listenersDisabled)
                return;

            HSess.init();
            String s = buildAffiliation();
            User u = User.getTL(uid);
            u.setAffiliation(clampToVarchar255(s));
            User.updateTL(u);
            Notification.show("Affiliation changed", Notification.Type.HUMANIZED_MESSAGE);
            HSess.close();
        }
    };
    affiliationTA.addValueChangeListener(affiliationListener);
    affiliationCombo.addValueChangeListener(affiliationListener);

    locationTF.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateUpdate
        @HibernateClosed
        @HibernateUserUpdate
        @Override
        public void valueChange(ValueChangeEvent event) {
            if (listenersDisabled)
                return;

            HSess.init();
            String s = locationTF.getValue().toString().trim();
            User u = User.getTL(uid);
            u.setLocation(clampToVarchar255(s));
            User.updateTL(u);
            Notification.show("Location changed", Notification.Type.HUMANIZED_MESSAGE);
            HSess.close();
        }
    });

    externMailCB.addValueChangeListener(new EmailListener(externMailCB));
    ingameMailCB.addValueChangeListener(new EmailListener(ingameMailCB));

    if (!itsSomebodyElse && iCanEdit()) {
        changeEmailButt.addClickListener(new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            @MmowgliCodeEntry
            public void buttonClick(ClickEvent event) {
                emailPacket = new ChangeEmailDialog.EmailPacket();
                EmailPii emailAddr = VHibPii.getUserPiiEmail((Long) uid);
                if (emailAddr != null)
                    emailPacket.original = emailAddr.getAddress();
                else
                    emailPacket.original = "";

                ChangeEmailDialog email = new ChangeEmailDialog(emailPacket);
                UI.getCurrent().addWindow(email);
                email.center();

                email.setSaveListener(new ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        VHibPii.newUserPiiEmail((Long) uid, emailPacket.updated);
                        /*
                         * MailManager mmgr = app.globs().applicationMaster().mailManager(); User me = DBGet.getUser(app.getUser()); for(User u : authors) {
                         * mmgr.mailToUser(me.getId(), u.getId(), subj.toString(), msg.toString()); } try { if(!u.isOkEmail()) return;
                         *
                         * List<Email> elis= u.getEmailAddresses();
                         * if(elis == null || elis.size()<=0) {
                         *   System.err.println("No email address found for user "+u.getUserName()); return;
                         * }
                         *
                         * String toAddr = elis.get(0).getAddress();
                         * String from = "mmowgli<mmowgli@nps.navy.mil>";
                         * String subj = "MMOWGLI: Email Updated";
                         *
                         * StringBuilder sb = new StringBuilder();
                         *
                         * sb.append("<p>Greetings, <b>");
                         * sb.append(u.getUserName());
                         * sb.append("</b>, from <i>mmowgli</i>, the \"Massively Multiplayer Online War Game Leveraging the Internet\".</p><p>At ");
                         * sb.append(new SimpleDateFormat("MM/dd HH:mm z").format(new Date()));
                         * sb.append(", you changed your email. This is a confirmation of this new email address. <br/>");
                         * sb.append("</p><p>");
                         * sb.append("If you believe you received this email by mistake, please disregard this. If you did not request a change of email or have any other questions, ");
                         * sb.append("you may report such concerns on the <a href='http://mmowgli.nps.edu/trouble'>MMOWGLI Trouble Report</a> page at <a href='http://mmowgli.nps.edu/trouble'>mmowgli.nps.edu/trouble</a>.");
                         * sb.append("</p><p>Thanks for playing mmowgli.</p>");
                         *
                         * String body = sb.toString();
                         * mailer.send(toAddr, from, subj, body, true);
                         * changeEmailButt.getWindow().showNotification("Test email sent to "+emailPacket.updated,null);//Password Changed DEREK }
                         * catch (Throwable t) {
                         *   System.err.println("Error sending action plan invitation email: " + t.getClass().getSimpleName() + ": " + t.getLocalizedMessage());
                         *  }
                         */
                    }
                });
            }
        });

        changePWButt.addClickListener(new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                packet = new ChangePasswordDialog.PasswordPacket();
                final UserPii uPii = VHibPii.getUserPii((Long) uid);
                packet.original = uPii.getPassword();

                ChangePasswordDialog dial = new ChangePasswordDialog(packet);
                UI.getCurrent().addWindow(dial);
                dial.center();

                dial.setSaveListener(new ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    @MmowgliCodeEntry
                    @HibernateOpened
                    @HibernateClosed
                    public void buttonClick(ClickEvent event) {
                        HSess.init();
                        uPii.setPassword(new StrongPasswordEncryptor().encryptPassword(packet.updated));
                        VHibPii.update(uPii);
                        Notification.show("Password Changed", Notification.Type.HUMANIZED_MESSAGE);

                        GameEventLogger.logUserPasswordChangedTL(User.getTL(uid));

                        // Clean up for security
                        packet.original = null;
                        packet.updated = null;
                        HSess.close();
                    }
                });
            }
        });
    }

    if (!itsSomebodyElse && iCanEdit())
        ;
    else {
        changePWButt.setEnabled(false);
        locationTF.setReadOnly(true);
        externMailCB.setEnabled(false);
        ingameMailCB.setEnabled(false);
        expertiseTA.setReadOnly(true);
        avatarButt.setReadOnly(true);
        learnTA.setReadOnly(true);
    }
}

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

License:Open Source License

Button makeButt(String s) {
    NativeButton b = new NativeButton(s);
    b.setStyleName(BaseTheme.BUTTON_LINK);
    b.addStyleName("m-link-button");
    b.addStyleName("borderless");
    b.addClickListener(this);
    return b;//from  w  w  w .j  a v  a 2  s  . c o m
}

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

License:Open Source License

@Override
public void initGui() {
    super.initGui();

    String left = "Players can choose to receive messages in-game or externally (or both or neither).<br/><br/>Player messages are private and"
            + " actual email identities are hidden.<br/><br/>You can find another player's profile by clicking on their name or using the search"
            + " feature. Then you may send a message to that player by clicking on the "
            + "<i>Send player private email</i> link.<br/><br/>If this link is not present or is disabled, then the player has opted "
            + "to receive neither email nor in-game messages.<br/><br/>";
    getLeftLabel().setValue(left);/*  w w w  . j ava2 s  .c om*/

    if (!userIsMe) {
        User u = User.getTL(uid);
        if (u.isOkEmail() || u.isOkGameMessages()) {
            final NativeButton sendEmailButt = new NativeButton("Send private mail to this user");
            sendEmailButt.addStyleName(BaseTheme.BUTTON_LINK);
            sendEmailButt.addStyleName("m-userProfile3-sendmail-button");
            Label sp;
            VerticalLayout vl = getRightLayout();

            vl.setSizeUndefined();
            vl.setWidth("100%");
            vl.addComponent(sp = new Label());
            sp.setHeight("50px");
            vl.addComponent(sendEmailButt);
            vl.setComponentAlignment(sendEmailButt, Alignment.MIDDLE_CENTER);
            vl.addComponent(sp = new Label());
            sp.setHeight("1px");
            vl.setExpandRatio(sp, 1.0f);

            sendEmailButt.addClickListener(new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                @MmowgliCodeEntry
                @HibernateOpened
                @HibernateClosed
                public void buttonClick(ClickEvent event) {
                    HSess.init();

                    User u = User.getTL(uid);
                    if (u.isOkEmail() || u.isOkGameMessages()) // redundant here
                        new SendMessageWindow(u, imAdminOrGameMaster);
                    else
                        Notification.show("Sorry", "Player " + u.getUserName() + " does not receive mail.",
                                Notification.Type.WARNING_MESSAGE);

                    HSess.close();
                }
            });
        }
        return;
    }
    VerticalLayout rightVL = getRightLayout();
    rightVL.setSizeUndefined();
    rightVL.setWidth("100%");

    getLeftAddedVerticalLayout()
            .addComponent(showButt = new ToggleLinkButton("View all", "View unhidden only", null)); //,ttArray));
    showButt.addOnListener(new ViewAllListener());
    showButt.addOffListener(new ViewUnhiddenOnlyListener());
    showButt.setToolTips("Temporarily show all messages, including those marked \"hidden\"",
            "Temporarily hide messages marked \"hidden\"");
    Label sp;
    rightVL.addComponent(sp = new Label());
    sp.setHeight("10px");
    rightVL.addComponent(mailPanel);

    User me = Mmowgli2UI.getGlobals().getUserTL();
    Set<Message> msgs = me.getGameMessages();
    if (msgs.size() > 0) {
        Message[] msgsAr = new Message[msgs.size()];
        msgsAr = msgs.toArray(msgsAr); // avoid concurrent mod
        int num = msgsAr.length;// .size();
        int n = num;
        for (Message m : msgsAr) {
            addOneMessage(m, n--, num, null);
        }
    }
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

Layout getCompoundMenus() {
    Layout grid = getPreviewLayout("Compound Menus");

    Label title = new Label("Sidebar Menu");
    title.setStyleName("h1");
    grid.addComponent(title);// w  w w  .j  a va 2 s.c  om
    ((GridLayout) grid).newLine();

    Label menus = new Label(
            "<strong>The sidebar menu</strong> control is just a set of labels and buttons inside a CssLayout or a VerticalLayout. Use the structure shown on the right, <strong>and remember that you need to implement all logic yourself</strong>. This theme just provides suitable stylenames for you to use.<br><br>You can also use the <a href=\"http://vaadin.com/forum/-/message_boards/message/119172\">DetachedTabs add-on</a> inside the sidebar-menu, it will style automatically.<br><br><strong>Note: only NativeButtons are styled inside the menu, normal buttons are left untouched.</strong>",
            Label.CONTENT_XHTML);
    grid.addComponent(menus);
    menus = new Label(
            "CssLayout.setStyleName(\"sidebar-menu\")\n  +  Label\n  +  NativeButton\n  +  NativeButton\n\t...\n  +  Label\n  +  DetachedTabs\n\t...",
            Label.CONTENT_PREFORMATTED);
    grid.addComponent(menus);

    SidebarMenu sidebar = new SidebarMenu();
    sidebar.setWidth("200px");
    sidebar.addComponent(new Label("Fruits"));
    NativeButton b = new NativeButton("Apples");
    b.setIcon(new ThemeResource("../runo/icons/16/note.png"));
    sidebar.addButton(b);
    sidebar.setSelected(b);
    sidebar.addButton(new NativeButton("Oranges"));
    sidebar.addButton(new NativeButton("Bananas"));
    sidebar.addButton(new NativeButton("Grapes"));
    sidebar.addComponent(new Label("Vegetables"));
    sidebar.addButton(new NativeButton("Tomatoes"));
    sidebar.addButton(new NativeButton("Cabbages"));
    sidebar.addButton(new NativeButton("Potatoes"));
    sidebar.addButton(new NativeButton("Carrots"));
    grid.addComponent(sidebar);
    ((GridLayout) grid).setColumnExpandRatio(0, 1);
    ((GridLayout) grid).setColumnExpandRatio(1, 1);

    title = new Label("Toolbar");
    title.setStyleName("h1");
    grid.addComponent(title);
    ((GridLayout) grid).newLine();

    CssLayout toolbars = new CssLayout();

    menus = new Label(
            "<strong>Toolbar</strong> is a simple CssLayout with a stylename. It provides the background and a little padding for its contents. Normally you will want to put buttons inside it, but segment controls fit in nicely as well.",
            Label.CONTENT_XHTML);
    grid.addComponent(menus);
    menus = new Label("CssLayout.setStyleName(\"toolbar\")", Label.CONTENT_PREFORMATTED);
    grid.addComponent(menus);

    CssLayout toolbar = new CssLayout();
    toolbar.setStyleName("toolbar");
    toolbar.setWidth("300px");

    Button b2 = new Button("Action");
    b2.setStyleName("small");
    toolbar.addComponent(b2);

    Segment segment = new Segment();
    segment.addStyleName("segment-alternate");
    b2 = new Button("Apples");
    b2.setStyleName("small");
    b2.addStyleName("down");
    segment.addButton(b2);
    b2 = new Button("Oranges");
    b2.setStyleName("small");
    segment.addButton(b2);
    toolbar.addComponent(segment);

    b2 = new Button("Notes");
    b2.setStyleName("small borderless");
    b2.setIcon(new ThemeResource("../runo/icons/16/note.png"));
    toolbar.addComponent(b2);
    toolbars.addComponent(toolbar);

    toolbar = new CssLayout();
    toolbar.setStyleName("toolbar");
    toolbar.setWidth("300px");

    b2 = new Button("Action");
    b2.setIcon(new ThemeResource("../runo/icons/32/document.png"));
    b2.setStyleName("borderless");
    toolbar.addComponent(b2);

    b2 = new Button("Action 2");
    b2.setStyleName("borderless");
    b2.setIcon(new ThemeResource("../runo/icons/32/user.png"));
    toolbar.addComponent(b2);

    b2 = new Button("Action 3");
    b2.setStyleName("borderless");
    b2.setIcon(new ThemeResource("../runo/icons/32/note.png"));
    toolbar.addComponent(b2);
    toolbars.addComponent(toolbar);

    grid.addComponent(toolbars);

    return grid;
}