Example usage for com.vaadin.ui VerticalLayout getComponentIndex

List of usage examples for com.vaadin.ui VerticalLayout getComponentIndex

Introduction

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

Prototype

public int getComponentIndex(Component component) 

Source Link

Document

Returns the index of the given component.

Usage

From source file:com.snowy.Login.java

@PostConstruct
void init() {/*www . j a v  a 2 s.c  om*/
    d = ((MyVaadinUI) UI.getCurrent()).getDataObject();
    //Logger.getLogger(Login.class.getName()).info(d);
    this.setSizeFull();
    this.setSpacing(false);
    this.setMargin(true);
    Label MainL = new Label("<h1>Connect 4</h1?>", ContentMode.HTML);
    //layout.addComponent(MainL);
    MainL.setSizeUndefined();
    VerticalLayout lay = new VerticalLayout();
    lay.setMargin(false);
    lay.addComponent(MainL);
    lay.setComponentAlignment(MainL, Alignment.TOP_CENTER);
    HorizontalLayout hz = new HorizontalLayout();
    hz.setMargin(false);
    hz.setSpacing(false);
    LoginForm lf = new LoginForm();
    lf.addLoginListener((e) -> {
        String token = d.genToken(e.getLoginParameter("username"), e.getLoginParameter("password"));
        //String token="true";
        if (!token.equals("false")) {

            Cookie c = new Cookie("token", token);
            VaadinService.getCurrentResponse().addCookie(c);
            //https://vaadin.com/wiki/-/wiki/Main/Setting+and+reading+Cookies
            //Notification.show(VaadinService.getCurrentRequest().getCookies()[1].getValue(),Notification.Type.ERROR_MESSAGE);
            //this.getNavigator().navigateTo("main");
            //this.getUI().get
            this.getUI().getNavigator().navigateTo("main");
        } else {
            Label l = new Label("<h4 style=\"color:red\">Invalid Username or Password</h4>", ContentMode.HTML);
            l.setId("created");

            if (lay.getComponent(lay.getComponentIndex(lf) + 1).getId() == null) {
                //lay.addComponent(new Label(String.valueOf(lay.getComponentIndex(l))));
                lay.addComponent(l, lay.getComponentIndex(lf) + 1);
                l.setSizeUndefined();
                lay.setComponentAlignment(l, Alignment.TOP_CENTER);
            }

        }

    });

    lay.addComponent(lf);
    Button newUser = new Button("New User");
    newUser.addClickListener((e) -> {

        this.getUI().addWindow(new NewUserSubWindow(d));
    });
    //newUser.setWidth((float)5.5, Unit.EM);
    Button forgotPass = new Button("Forgot Password");
    //temp
    forgotPass.addClickListener((e) -> {
        //Notification.show(, Notification.Type.ERROR_MESSAGE);
    });
    forgotPass.setEnabled(false);
    forgotPass.setDescription("Feature Disabled, Contact Administrator for Assistance");
    //forgotPass.setWidth((float) 8.5,Unit.EM);
    forgotPass.setStyleName(ValoTheme.BUTTON_LINK);
    newUser.setStyleName(ValoTheme.BUTTON_LINK);

    hz.addComponent(newUser);
    hz.addComponent(forgotPass);
    lay.addComponent(hz);
    lay.setComponentAlignment(lf, Alignment.TOP_CENTER);
    lay.setComponentAlignment(hz, Alignment.MIDDLE_CENTER);
    this.addComponent(lay);
    this.setComponentAlignment(lay, Alignment.MIDDLE_CENTER);
}

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

License:Open Source License

@Override
public void initGui() {
    super.initGui();
    VerticalLayout leftLayout = getLeftLayout();
    leftLayout.setSpacing(true);/*from w ww . j  a  va 2s .  c om*/
    getLeftLabel().setValue(""); //"Click on the links below to display lists of cards in play.");
    int i = leftLayout.getComponentIndex(getLeftLabel()) + 1;
    // start adding from here
    Label sp;

    String possessive = "my";
    String capPossessive = "My";
    if (!userIsMe)
        possessive = capPossessive = userName + "'s";

    leftLayout.addComponent(allRow = makeCheckRow(allButt = makeButt("All " + possessive + " ideas")), i++);
    setCheck(allRow, true);
    leftLayout.setComponentAlignment(allRow, Alignment.MIDDLE_LEFT);
    leftLayout.addComponent(
            buildsRow = makeCheckRow(buildsButt = makeButt("Builds on " + possessive + " ideas")), i++);
    setCheck(buildsRow, false);
    leftLayout.addComponent(favsRow = makeCheckRow(favsButt = makeButt(capPossessive + " favorite ideas")),
            i++);
    setCheck(favsRow, false);
    leftLayout.addComponent(profileRow = makeCheckRow(profileButt = makeButt(capPossessive + " idea profile")),
            i++);
    setCheck(profileRow, false);

    getRightLayout().addComponent(sp = new Label());
    sp.setHeight("20px");

    showAllMyIdeas();
}