Example usage for com.vaadin.ui VerticalLayout setComponentAlignment

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

Introduction

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

Prototype

@Override
    public void setComponentAlignment(Component childComponent, Alignment alignment) 

Source Link

Usage

From source file:com.freebox.engeneering.application.web.layout.FooterController.java

License:Apache License

/**
 * Loads data into the form while entering 'loadData' state.
 *
 * @param stateEvent the state event.//w w  w  .  ja  v  a2s . c  o  m
 */
@OnEnterState(EventConstants.LOAD_DATA)
public void buildFooterView(StateEvent stateEvent) {
    clearView(stateEvent);
    final Label htmlLabel = new Label(
            "© " + Calendar.getInstance().get(Calendar.YEAR) + " Lexaden.com  All rights reserved",
            ContentMode.HTML);
    htmlLabel.setStyleName(Reindeer.LABEL_SMALL);
    htmlLabel.setSizeUndefined();
    final VerticalLayout view = getView();
    view.addComponent(htmlLabel);
    view.setComponentAlignment(htmlLabel, Alignment.MIDDLE_CENTER);
    view.setMargin(new MarginInfo(false, false, true, false));
}

From source file:com.github.tempora.view.MainView.java

License:Apache License

public MainView() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.addStyleName("outlined");
    vlayout.addStyleName("bg");
    vlayout.setSizeFull();//w  w  w .ja v  a2 s  .co m
    vlayout.setMargin(true);
    HorizontalLayout hlayout = new HorizontalLayout();
    hlayout.addStyleName("outlined");
    hlayout.setSizeFull();
    setContent(vlayout);

    // Title
    Label caption = new Label("Tempora");
    caption.setStyleName("logo-label", true);
    caption.setWidth(null);
    vlayout.addComponent(caption);
    vlayout.setExpandRatio(caption, 0.2f);

    vlayout.setComponentAlignment(caption, Alignment.MIDDLE_CENTER);
    vlayout.addComponent(hlayout);
    vlayout.setExpandRatio(hlayout, 0.7f);

    //
    // General information about the User's mailbox
    //
    final Panel generalInfoPanel = new Panel("<center>General Information</center>");
    generalInfoPanel.addStyleName("frame-bg-general-info");
    generalInfoPanel.setSizeFull();

    this.currentHistoryId = new Label("0");
    currentHistoryId.setStyleName("general-info-count", true);
    currentHistoryId.setCaption("History ID");

    this.messagesTotal = new Label("0");
    messagesTotal.setStyleName("general-info-count", true);
    messagesTotal.setCaption("Messages Total");

    this.threadsTotal = new Label("0");
    threadsTotal.setCaption("Threads Total");
    threadsTotal.setStyleName("general-info-count", true);

    FormLayout mailboxInfoLayout = new FormLayout(messagesTotal, currentHistoryId, threadsTotal);
    VerticalLayout mailboxInfoMainLayout = new VerticalLayout(mailboxInfoLayout);
    mailboxInfoMainLayout.setSizeFull();
    mailboxInfoMainLayout.setMargin(true);
    generalInfoPanel.setContent(mailboxInfoMainLayout);

    //
    // Stats
    //
    final Panel statsPanel = new Panel("<center>Statistics</center>");
    statsPanel.addStyleName("frame-bg-stats");
    statsPanel.setSizeFull();

    this.bodyAvgSize = new Label("0");
    bodyAvgSize.setCaption("Body Avg. Size");
    bodyAvgSize.setStyleName("stats-count", true);

    FormLayout statsLayout = new FormLayout(bodyAvgSize);
    VerticalLayout statsMainLayout = new VerticalLayout(statsLayout);
    statsMainLayout.setSizeFull();
    statsMainLayout.setMargin(true);
    statsPanel.setContent(statsMainLayout);

    //
    // Top 5
    //
    Panel top5Panel = new Panel("<center>Top 5</center>");
    top5Panel.addStyleName("frame-bg-top5");

    // Top 5 Senders
    Panel top5SendersPanel = new Panel("<center>Senders</center>");
    top5SendersPanel.addStyleName("frame-bg-top5");
    top5SendersPanel.setSizeFull();
    this.top5Senders = new Label("NO DATA", ContentMode.PREFORMATTED);
    top5Senders.setSizeUndefined();
    top5SendersPanel.setContent(top5Senders);

    // Top 5 Title Tags
    Panel top5TitleTagsPanel = new Panel("<center>Title Tags</center>");
    top5TitleTagsPanel.addStyleName("frame-bg-top5");
    top5TitleTagsPanel.setSizeFull();
    this.top5TitleTags = new Label("NO DATA", ContentMode.PREFORMATTED);
    top5TitleTags.setSizeUndefined();
    top5TitleTagsPanel.setContent(top5TitleTags);

    top5Panel.setSizeFull();

    VerticalLayout top5MainLayout = new VerticalLayout(top5SendersPanel, top5TitleTagsPanel);
    top5MainLayout.setMargin(true);
    top5MainLayout.setSpacing(true);
    top5MainLayout.setSizeFull();
    top5MainLayout.setComponentAlignment(top5SendersPanel, Alignment.MIDDLE_CENTER);
    top5MainLayout.setComponentAlignment(top5TitleTagsPanel, Alignment.MIDDLE_CENTER);
    top5Panel.setContent(top5MainLayout);

    hlayout.setSpacing(true);
    hlayout.addComponent(generalInfoPanel);
    hlayout.addComponent(statsPanel);
    hlayout.addComponent(top5Panel);

    this.currentUserEmail = new Label("-");
    currentUserEmail.setCaption("Email");

    Button reloadButton = new Button("\u27F3 Reload");
    reloadButton.addClickListener(e -> {
        getSession().getSession().invalidate();
        getUI().getPage().reload();
    });

    HorizontalLayout infoHLayout = new HorizontalLayout();
    infoHLayout.addStyleName("outlined");
    infoHLayout.setSizeFull();
    infoHLayout.setSpacing(true);
    infoHLayout.setMargin(true);

    infoHLayout.addComponent(reloadButton);
    reloadButton.setWidth(null);
    infoHLayout.setComponentAlignment(reloadButton, Alignment.BOTTOM_LEFT);

    infoHLayout.addComponent(currentUserEmail);
    currentUserEmail.setWidth(null);
    infoHLayout.setComponentAlignment(currentUserEmail, Alignment.BOTTOM_RIGHT);

    vlayout.addComponent(infoHLayout);
    vlayout.setExpandRatio(infoHLayout, 0.5f);
}

From source file:com.gmail.volodymyrdotsenko.cms.fe.vaadin.LoginUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    langRepo.findAll().forEach(e -> {
        langSet.add(e.getCode());//from w  w w . j  av  a 2  s. c  o m
    });

    lang = new ComboBox("Language", langSet);

    getPage().setTitle("CMS");

    FormLayout loginForm = new FormLayout();
    loginForm.setSizeUndefined();

    loginForm.addComponent(userName = new TextField("Username"));
    userName.setRequired(true);
    loginForm.addComponent(passwordField = new PasswordField("Password"));
    passwordField.setRequired(true);
    loginForm.addComponent(rememberMe = new CheckBox("Remember me"));
    loginForm.addComponent(lang);
    lang.setRequired(true);
    lang.setNullSelectionAllowed(false);
    loginForm.addComponent(login = new Button("Login"));
    login.addStyleName(ValoTheme.BUTTON_PRIMARY);
    login.setDisableOnClick(true);
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addClickListener(e -> {
        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(loginForm);
    loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER);

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

    String currentLang = getLocale().getLanguage();
    if (langSet.contains(currentLang))
        lang.select(currentLang);
    else
        lang.select("en");
}

From source file:com.gnts.pem.txn.sbi.SBIBuilding.java

String showSubWindow() {
    tfCaption.setValue("");
    VerticalLayout subwindow = new VerticalLayout();
    mywindow.setHeight("130px");
    mywindow.setWidth("230px");
    tfCaption.setWidth("200px");
    mywindow.center();/*from  w w w  .ja v a2 s .c  o m*/
    mywindow.setModal(true);
    tfCaption.focus();
    subwindow.addComponent(tfCaption);
    subwindow.addComponent(myButton);
    subwindow.setComponentAlignment(myButton, Alignment.MIDDLE_CENTER);
    subwindow.setSpacing(true);
    subwindow.setMargin(true);
    mywindow.setContent(subwindow);

    mywindow.setResizable(false);
    myButton.setStyleName("default");
    mywindow.setContent(subwindow);
    UI.getCurrent().addWindow(mywindow);
    return null;
}

From source file:com.gnts.pem.txn.sbi.SBIConstruction.java

String showSubWindow() {
    tfCaption.setValue("");
    VerticalLayout subwindow = new VerticalLayout();
    mywindow.setHeight("130px");
    mywindow.setWidth("230px");
    tfCaption.setWidth("200px");
    mywindow.center();//from   w  w w  .  j av  a 2  s  .c o  m
    mywindow.setModal(true);
    tfCaption.focus();
    subwindow.addComponent(tfCaption);
    subwindow.addComponent(myButton);
    subwindow.setComponentAlignment(myButton, Alignment.MIDDLE_CENTER);
    subwindow.setMargin(true);
    subwindow.setSpacing(true);
    mywindow.setContent(subwindow);

    mywindow.setResizable(false);
    myButton.setStyleName("default");
    mywindow.setContent(subwindow);
    UI.getCurrent().addWindow(mywindow);
    return null;
}

From source file:com.gnts.pem.txn.sbi.SBIConstructionBuilding.java

String showSubWindow() {
    tfCaption.setValue("");
    VerticalLayout subwindow = new VerticalLayout();

    tfCaption.setWidth("200px");
    mywindow.center();/*from  ww w .ja  va  2 s.  c  o m*/

    mywindow.setModal(true);
    tfCaption.focus();
    mywindow.setHeight("120");
    mywindow.setWidth("220");

    subwindow.addComponent(tfCaption);
    subwindow.addComponent(myButton);
    subwindow.setComponentAlignment(myButton, Alignment.MIDDLE_CENTER);

    subwindow.setMargin(true);
    subwindow.setSpacing(true);

    myButton.setStyleName("default");

    mywindow.setContent(subwindow);

    mywindow.setResizable(false);
    //mywindow.setResizable(false);
    //      subwindow.setWidth("200");
    //      subwindow.setHeight("400");

    UI.getCurrent().addWindow(mywindow);
    return null;
}

From source file:com.gnts.pem.txn.sbi.SBIFlat.java

String showSubWindow() {
    tfCaption.setValue("");
    VerticalLayout subwindow = new VerticalLayout();
    mywindow.setHeight("130px");
    mywindow.setWidth("230px");
    tfCaption.setWidth("210px");
    mywindow.center();//ww w  .j a v  a  2 s. com
    mywindow.setModal(true);
    tfCaption.focus();
    subwindow.addComponent(tfCaption);
    subwindow.setComponentAlignment(tfCaption, Alignment.MIDDLE_CENTER);
    subwindow.addComponent(myButton);
    subwindow.setComponentAlignment(myButton, Alignment.MIDDLE_CENTER);
    subwindow.setMargin(true);
    subwindow.setSpacing(true);
    mywindow.setContent(subwindow);

    mywindow.setResizable(false);
    myButton.setStyleName("default");
    mywindow.setContent(subwindow);
    UI.getCurrent().addWindow(mywindow);
    return null;
}

From source file:com.gnts.pem.txn.sbi.SBILand.java

String showSubWindow() {
    tfCaption.setValue("");
    VerticalLayout subwindow = new VerticalLayout();
    mywindow.setHeight("130px");
    mywindow.setWidth("230px");
    tfCaption.setWidth("200px");
    mywindow.center();/*from w  w w  .  jav  a2s . co m*/
    mywindow.setModal(true);

    tfCaption.focus();
    subwindow.addComponent(tfCaption);
    subwindow.addComponent(myButton);

    subwindow.setComponentAlignment(myButton, Alignment.MIDDLE_CENTER);
    subwindow.setMargin(true);
    subwindow.setSpacing(true);
    myButton.setStyleName("default");
    mywindow.setContent(subwindow);

    mywindow.setResizable(false);
    mywindow.setContent(subwindow);
    UI.getCurrent().addWindow(mywindow);
    return null;
}

From source file:com.gnts.pem.txn.synd.SyndConstructionBuilding.java

String showSubWindow() {
    tfCaption.setValue("");
    VerticalLayout subwindow = new VerticalLayout();
    mywindow.setHeight("130px");
    mywindow.setWidth("230px");
    tfCaption.setWidth("200px");
    mywindow.center();//from  w  ww .  jav a 2  s  . c o m
    mywindow.setModal(true);
    tfCaption.focus();
    subwindow.addComponent(tfCaption);
    subwindow.addComponent(myButton);
    subwindow.setComponentAlignment(myButton, Alignment.MIDDLE_CENTER);

    subwindow.setSpacing(true);
    subwindow.setMargin(true);

    mywindow.setResizable(false);
    myButton.setStyleName("default");

    mywindow.setContent(subwindow);

    UI.getCurrent().addWindow(mywindow);
    return null;
}

From source file:com.hack23.cia.web.impl.ui.application.views.common.AbstractView.java

License:Apache License

/**
 * Creates the basic layout with panel and footer.
 *
 * @param panelName/*ww w  .  j a  v  a 2  s.  co  m*/
 *            the panel name
 */
protected final void createBasicLayoutWithPanelAndFooter(final String panelName) {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setHeight(100, Unit.PERCENTAGE);

    final VerticalLayout pageModeContent = new VerticalLayout();
    pageModeContent.setMargin(true);
    pageModeContent.setSpacing(true);
    pageModeContent.setWidth(100, Unit.PERCENTAGE);
    pageModeContent.setHeight(100, Unit.PERCENTAGE);

    layout.addComponent(pageModeContent);

    final ThemeResource ciaLogoResource = new ThemeResource("cia-logo.png");

    final Image ciaLogoImage = new Image(null, ciaLogoResource);

    final HorizontalLayout topHeader = new HorizontalLayout();

    topHeader.addComponent(ciaLogoImage);
    ciaLogoImage.setWidth("75px");
    ciaLogoImage.setHeight("75px");
    topHeader.setComponentAlignment(ciaLogoImage, Alignment.MIDDLE_LEFT);
    topHeader.setExpandRatio(ciaLogoImage, ContentRatio.SMALL);

    final HorizontalLayout topTitleHeadertPanel = new HorizontalLayout();

    final Label titleLabel = new Label("Citizen Intelligence Agency");
    titleLabel.setStyleName("Header");
    topTitleHeadertPanel.addComponent(titleLabel);
    topTitleHeadertPanel.setComponentAlignment(titleLabel, Alignment.MIDDLE_LEFT);

    final Label sloganLabel = new Label("// Tracking politicians like bugs!");
    sloganLabel.setStyleName("HeaderSlogan");
    topTitleHeadertPanel.addComponent(sloganLabel);
    topTitleHeadertPanel.setComponentAlignment(sloganLabel, Alignment.MIDDLE_RIGHT);

    topHeader.addComponent(topTitleHeadertPanel);
    topHeader.setComponentAlignment(topTitleHeadertPanel, Alignment.MIDDLE_LEFT);
    topHeader.setExpandRatio(topTitleHeadertPanel, ContentRatio.GRID);

    topHeaderRightPanel.removeAllComponents();
    topHeader.addComponent(topHeaderRightPanel);
    topHeader.setComponentAlignment(topHeaderRightPanel, Alignment.MIDDLE_RIGHT);
    topHeader.setExpandRatio(topHeaderRightPanel, ContentRatio.LARGE);

    if (UserContextUtil.allowRoleInSecurityContext(ROLE_ADMIN)
            || UserContextUtil.allowRoleInSecurityContext(ROLE_USER)) {

        final Link userHomePageLink = pageLinkFactory.createUserHomeViewPageLink();
        topHeaderRightPanel.addComponent(userHomePageLink);
        topHeaderRightPanel.setComponentAlignment(userHomePageLink, Alignment.MIDDLE_RIGHT);

        final Button logoutButton = new Button(LOGOUT, FontAwesome.SIGN_OUT);

        final LogoutRequest logoutRequest = new LogoutRequest();
        logoutRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
        logoutButton.addClickListener(new LogoutClickListener(logoutRequest, applicationManager));

        topHeaderRightPanel.addComponent(logoutButton);
        topHeaderRightPanel.setComponentAlignment(logoutButton, Alignment.MIDDLE_RIGHT);

    } else {
        final Link createRegisterPageLink = pageLinkFactory.createRegisterPageLink();
        topHeaderRightPanel.addComponent(createRegisterPageLink);
        topHeaderRightPanel.setComponentAlignment(createRegisterPageLink, Alignment.MIDDLE_RIGHT);

        final Link createLoginPageLink = pageLinkFactory.createLoginPageLink();
        topHeaderRightPanel.addComponent(createLoginPageLink);
        topHeaderRightPanel.setComponentAlignment(createLoginPageLink, Alignment.MIDDLE_RIGHT);
    }

    topHeaderRightPanel.setWidth("100%");
    topHeaderRightPanel.setHeight("60px");

    topHeader.setWidth("100%");
    topHeader.setHeight("60px");

    pageModeContent.addComponent(topHeader);
    pageModeContent.setComponentAlignment(topHeader, Alignment.TOP_CENTER);

    pageModeContent.addComponent(getBarmenu());
    pageModeContent.setComponentAlignment(getBarmenu(), Alignment.TOP_CENTER);

    panel = new Panel(panelName);

    panel.setSizeFull();
    pageModeContent.addComponent(panel);
    pageModeContent.setExpandRatio(panel, ContentRatio.FULL_SIZE);

    pageModeContent.addComponent(pageLinkFactory.createMainViewPageLink());
    setContent(layout);

    setWidth(100, Unit.PERCENTAGE);
    setHeight(100, Unit.PERCENTAGE);
    setSizeFull();

}