Example usage for com.vaadin.ui Alignment MIDDLE_CENTER

List of usage examples for com.vaadin.ui Alignment MIDDLE_CENTER

Introduction

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

Prototype

Alignment MIDDLE_CENTER

To view the source code for com.vaadin.ui Alignment MIDDLE_CENTER.

Click Source Link

Usage

From source file:by.bigvova.LoginUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    getPage().setTitle("Vaadin Shared Security Demo Login");

    FormLayout loginForm = new FormLayout();
    loginForm.setSizeUndefined();/*  w w w. j a  v a 2s .  co  m*/

    userName = new TextField("Username");
    passwordField = new PasswordField("Password");
    rememberMe = new CheckBox("Remember me");
    login = new Button("Login");
    Label label = new Label("Name: User / Password: password");
    loginForm.addComponent(userName);
    loginForm.addComponent(passwordField);
    loginForm.addComponent(rememberMe);
    loginForm.addComponent(login);
    login.addStyleName(ValoTheme.BUTTON_PRIMARY);
    login.setDisableOnClick(true);
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            login();
        }
    });

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setSpacing(true);
    loginLayout.setSizeUndefined();

    if (request.getParameter("logout") != null) {
        loggedOutLabel = new Label("You have been logged out!");
        loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS);
        loggedOutLabel.setSizeUndefined();
        loginLayout.addComponent(loggedOutLabel);
        loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER);
    }

    loginLayout.addComponent(loginFailedLabel = new Label());
    loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER);
    loginFailedLabel.setSizeUndefined();
    loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE);
    loginFailedLabel.setVisible(false);

    loginLayout.addComponent(label);
    loginLayout.addComponent(loginForm);
    loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER);

    VerticalLayout rootLayout = new VerticalLayout(loginLayout);
    rootLayout.setSizeFull();
    rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER);
    setContent(rootLayout);
    setSizeFull();
}

From source file:by.bigvova.ui.LoginUI.java

License:Apache License

private VerticalLayout root() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//from  www . ja  v a2 s.c om

    Component loginForm = buildLoginForm();
    layout.addComponent(loginForm);
    layout.setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER);
    return layout;
}

From source file:ch.bfh.ti.soed.hs16.srs.black.view.loginView.LoginView.java

License:Open Source License

public LoginView() {
    usernameField = new TextField("Username");
    usernameField.setIcon(FontAwesome.USER);
    usernameField.setWidth(12, Unit.EM);
    passwordField = new PasswordField("Password");
    passwordField.setIcon(FontAwesome.KEY);
    passwordField.setWidth(12, Unit.EM);
    loginButton = new Button("Login");
    loginButton.setWidth(5, Unit.EM);//  w w  w.j  a v  a  2 s  .  com
    loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signUpButton = new Button("Sign Up");
    signUpButton.setWidth(6, Unit.EM);

    VerticalLayout layout = new VerticalLayout();
    HorizontalLayout layoutButtons = new HorizontalLayout(loginButton, signUpButton);
    layoutButtons.setSpacing(true);
    Panel panel = new Panel("Login - Smart ReservationEntity System");
    panel.setSizeUndefined();
    layout.addComponent(panel);

    FormLayout content = new FormLayout();
    content.addComponents(usernameField, passwordField, layoutButtons);
    content.setSizeFull();
    content.setMargin(true);
    panel.setContent(content);

    setCompositionRoot(layout);

    layout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
    layout.setMargin(new MarginInfo(true, false, false, false));
}

From source file:ch.bfh.ti.soed.hs16.srs.black.view.signUpView.SignUpView.java

License:Open Source License

public SignUpView() {
    usernameField = new TextField("Username");
    usernameField.setIcon(FontAwesome.USER);
    usernameField.setWidth(12, Unit.EM);
    passwordField = new PasswordField("Password");
    passwordField.setIcon(FontAwesome.KEY);
    passwordField.setWidth(12, Unit.EM);
    passwordFieldRepeat = new PasswordField("Repeat Password");
    passwordFieldRepeat.setIcon(FontAwesome.KEY);
    passwordFieldRepeat.setWidth(12, Unit.EM);
    addUserButton = new Button("Add New User");
    addUserButton.setWidth(12, Unit.EM);
    goBackButton = new Button("Back");

    VerticalLayout layout = new VerticalLayout();
    Panel panel = new Panel("Sign Up - Smart ReservationEntity System");
    panel.setSizeUndefined();// w w  w . j av a  2s. co m
    layout.addComponent(panel);

    FormLayout content = new FormLayout();
    content.addComponents(usernameField, passwordField, passwordFieldRepeat, addUserButton);
    content.setSizeUndefined();
    content.setMargin(true);
    VerticalLayout formAndBack = new VerticalLayout(content, goBackButton);
    formAndBack.setMargin(true);
    panel.setContent(formAndBack);

    setCompositionRoot(layout);

    layout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
    layout.setMargin(new MarginInfo(true, false, false, false));
}

From source file:ch.bfh.ti.soed.hs16.srs.yellow.views.LoginView.java

License:Open Source License

public LoginView() {

    setSizeFull();// ww  w  .j a  v a 2 s .c om

    lUName.setRequired(true);
    lPwd.setRequired(true);

    lUName.setSizeFull();
    lPwd.setSizeFull();
    lLoginBtn.setSizeFull();

    loginFormLayout.addComponents(lUName, lPwd, lLoginBtn);
    loginFormLayout.setMargin(true);
    loginFormLayout.setWidth(500, Sizeable.Unit.PIXELS);

    lHeader.addComponent(lbackBtn);

    lbackBtn.addClickListener(e -> {
        navigationRoot.navigator.navigateTo(NavigationRoot.MAINVIEW);
    });

    lLoginBtn.addClickListener(evt -> {
        Long cID = jpaProxyDataAccessor.authentifyCustomer(lUName.getValue(), lPwd.getValue());
        if (cID != null) {
            Notification.show("Successfully authentified");
            lbackBtn.click();
        } else {
            Notification.show("Sorry, could not authentify. Please check your credentials one more time");
        }
    });

    loginVLayout.addComponents(lHeader, loginFormLayout);
    loginVLayout.setSpacing(true);
    loginVLayout.setComponentAlignment(loginFormLayout, Alignment.MIDDLE_CENTER);
    loginVLayout.setComponentAlignment(lHeader, Alignment.TOP_RIGHT);

    setCompositionRoot(loginVLayout);
}

From source file:ch.bfh.ti.soed.hs16.srs.yellow.views.MainView.java

License:Open Source License

public MainView() {

    setSizeFull();/*w  w  w  .  j a  va2  s .co  m*/

    headerLayout = new HorizontalLayout();
    date = new Date();
    limitDate = Calendar.getInstance();
    limitDate.setTime(date);
    limitDate.add(Calendar.YEAR, 1);
    lastDate = limitDate.getTime();

    fromDate.setValue(date);
    fromDate.setRangeStart(date);
    fromDate.setRangeEnd(lastDate);
    fromDate.setImmediate(true);
    fromDate.setResolution(Resolution.MINUTE);

    toDate.setRangeStart(date);
    toDate.setRangeEnd(lastDate);
    toDate.setImmediate(true);
    toDate.setResolution(Resolution.MINUTE);

    objSelect.setSizeFull();
    equipSelect.setSizeFull();
    fromDate.setSizeFull();
    toDate.setSizeFull();
    searchBtn.setSizeFull();

    signupBtn.addClickListener(e -> {
        navigationRoot.navigator.navigateTo(NavigationRoot.SIGNUPVIEW);
    });

    loginBtn.addClickListener(e -> {
        navigationRoot.navigator.navigateTo(NavigationRoot.LOGINVIEW);
    });

    searchBtn.addClickListener(evt -> {
        Notification.show("Sorry, search will be made later with Vaadin Grid.");
    });

    loginLayout.addComponents(signupBtn, loginBtn);

    headerLayout.addComponent(titleLbl);
    leftVLayout.addComponents(fromDate, objSelect);
    leftVLayout.setSpacing(true);
    leftVLayout.setSizeFull();
    rightVLayout.addComponents(toDate, equipSelect);
    rightVLayout.setSpacing(true);
    rightVLayout.setSizeFull();
    inputLayout.addComponents(leftVLayout, rightVLayout);
    inputLayout.setSpacing(true);
    inputLayout.setSizeFull();

    searchLayout.addComponents(headerLayout, inputLayout, searchBtn);
    searchLayout.setComponentAlignment(headerLayout, Alignment.TOP_CENTER);
    searchLayout.setMargin(true);
    searchLayout.setSpacing(true);
    searchLayout.setWidth(500, Sizeable.Unit.PIXELS);

    panelContent.addComponents(loginLayout, searchLayout);
    panelContent.setComponentAlignment(searchLayout, Alignment.MIDDLE_CENTER);
    panelContent.setComponentAlignment(loginLayout, Alignment.TOP_RIGHT);
    panel.setContent(panelContent);
    setCompositionRoot(panelContent);
}

From source file:ch.bfh.ti.soed.hs16.srs.yellow.views.SignUpView.java

License:Open Source License

public SignUpView() {

    sUName.setRequired(true);//from   w w w  . j av  a  2 s.  co m
    sPwd.setRequired(true);
    fName.setRequired(true);
    lName.setRequired(true);
    emailField.setRequired(true);

    sUName.setSizeFull();
    sPwd.setSizeFull();
    fName.setSizeFull();
    lName.setSizeFull();
    emailField.setSizeFull();
    sSignUpBtn.setSizeFull();

    backBtn.addClickListener(e -> {
        navigationRoot.navigator.navigateTo(NavigationRoot.MAINVIEW);
    });

    sSignUpBtn.addClickListener(e -> {
        String result = checkIfAllFieldsAreValid();
        if (!(result == "")) {
            Notification.show(result);
        } else if (checkIfAllTextEntryNonEmpty()) {
            jpaProxyDataAccessor.makeCustomer(this.sUName.getValue(), this.sPwd.getValue());
            Notification.show("User created successfully");
            backBtn.click();
        } else {
            Notification.show("Please fill all required fields to create an user!");
        }
    });

    signFormLayout.addComponents(sUName, sPwd, fName, lName, emailField, sSignUpBtn);
    signFormLayout.setMargin(true);
    signFormLayout.setWidth(500, Sizeable.Unit.PIXELS);

    sHeader.addComponent(backBtn);

    signVLayout.addComponents(sHeader, signFormLayout);
    signVLayout.setSpacing(true);
    signVLayout.setComponentAlignment(signFormLayout, Alignment.MIDDLE_CENTER);
    signVLayout.setComponentAlignment(sHeader, Alignment.TOP_RIGHT);

    setCompositionRoot(signVLayout);
}

From source file:com.aaron.mbpet.views.users.UserEditor.java

License:Apache License

public UserEditor(Item personItem, String lableText, boolean mode) {
    this.editMode = mode;
    //       this.setModal(true);
    center();/*from   w  ww.  j  ava 2 s . c  om*/
    setResizable(true);
    setClosable(true);
    setModal(true);
    //      setSizeUndefined();
    setWidth(25, Unit.EM);

    this.currsessionuser = ((MbpetUI) UI.getCurrent()).getSessionUser();

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);

    this.personItem = personItem;
    editorForm = new Form();
    editorForm.setFormFieldFactory(this);
    editorForm.setBuffered(true);
    editorForm.setImmediate(true);
    editorForm.setItemDataSource(personItem,
            Arrays.asList("firstname", "lastname", "email", "username", "password", "organization"));

    //buttons        
    saveButton = new Button("Save", this);
    saveButton.setClickShortcut(KeyCode.ENTER);
    cancelButton = new Button("Cancel", this);
    saveButton.addStyleName(ValoTheme.BUTTON_PRIMARY);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setWidth("100%");
    buttons.addComponents(saveButton, cancelButton);
    buttons.setComponentAlignment(saveButton, Alignment.BOTTOM_LEFT);
    buttons.setComponentAlignment(cancelButton, Alignment.BOTTOM_RIGHT);

    //        editorForm.getFooter().addComponent(buttons);
    //        editorForm.getFooter().addComponent(cancelButton);

    layout.addComponent(new Label("<h3>" + lableText + "</h3>", ContentMode.HTML));
    layout.addComponent(editorForm);
    layout.setComponentAlignment(editorForm, Alignment.MIDDLE_CENTER);
    layout.addComponent(buttons);

    setContent(layout); //editorForm
    setCaption(buildCaption());
}

From source file:com.adonis.ui.vehicles.VehiclesCrudView.java

public VehiclesCrudView(VehicleService vehicleService, FotoAlbumService fotoAlbumService) {
    setSizeFull();// w ww. jav  a 2 s  .c  o  m
    setStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    addStyleName("backImage");
    setVehiclesCrudProperties(vehicleService, fotoAlbumService);
    addComponent(vehiclesCrud);
    objects = vehicleService.findAll();

    objects.forEach(vehicle -> {
        container.addBean(vehicle);
    });

    setComponentAlignment(vehiclesCrud, Alignment.MIDDLE_CENTER);

}

From source file:com.anphat.customer.ui.ImportCustomerUploadForm.java

private void buildGridTermInfo() {
    gridTermInfo = new GridLayout(4, 3);
    CommonUtils.setBasicAttributeLayout(gridTermInfo, GRID_UPLOAD_CAPTION, true);
    gridTermInfo.setImmediate(true);/*from ww w.  j a  v  a2s .  com*/
    gridTermInfo.setWidth("100%");
    gridTermInfo.setHeight("-1px");

    cboService = CommonUtils.buildComboBox("term.information.service");
    cboService.setRequired(true);
    cboService.setRequiredError(CommonMessages.messageRequire("customerStatusForm.service"));
    cboMineName = CommonUtils.buildComboBox("term.information.mineName");
    cboMineName.setRequired(true);
    tfMineName = CommonUtils.buildTextField(BundleUtils.getString("term.information.mineName"), 100);
    tfMineName.setRequired(true);
    gridTermInfo.addComponent(cboService, 2, 1);
    gridTermInfo.addComponent(cboMineName, 3, 1);
    btnAddMineName = new Button(BundleUtils.getString("button.add.mineName"));
    btnAddMineName.setIcon(new ThemeResource(Constants.ICON.ADD));
    btnAddMineName.setDisableOnClick(true);
    btnAddMineName.addStyleName("v-button-link");
    gridTermInfo.addComponent(btnAddMineName, 3, 2);

    uFileCommonInfo = new Upload();
    uFileCommonInfo.setCaption(Constants.NULL);
    uFileTermInfo = new Upload();
    uFileTermInfo.setCaption(Constants.NULL);
    uFileCommonInfo.setWidth("100%");
    uFileTermInfo.setWidth("100%");

    gridTermInfo.addComponent(uFileTermInfo, 0, 1, 1, 1);

    gridTermInfo.addComponent(uFileCommonInfo, 0, 0, 1, 0);
    gridTermInfo.setComponentAlignment(uFileCommonInfo, Alignment.MIDDLE_CENTER);
    gridTermInfo.setComponentAlignment(uFileTermInfo, Alignment.MIDDLE_CENTER);
}