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.lst.deploymentautomation.vaadin.core.AppFormConnector.java

License:Open Source License

@Override
public void setContent(Component content) {
    if (content == null) {
        //rendering failed; show a sad face to show how sorry we are
        VerticalLayout layout = new VerticalLayout();
        Label fail = new Label(":-(");
        fail.addStyleName("screen-failed-to-render");
        layout.addComponent(fail);//  ww w.ja v a 2 s.  c o m
        layout.setExpandRatio(fail, 1);
        layout.setComponentAlignment(fail, Alignment.MIDDLE_LEFT);
        layout.setSizeFull();

        view.setContent(layout);

    } else {
        //if the component has either natural or absolute size, wrap it
        //in a scrollable panel with full size and nice margin
        if (content.getHeightUnits() != Unit.PERCENTAGE) {
            final Panel panel = new Panel();
            panel.addStyleName("l-border-none");
            panel.setContent(content);
            panel.setSizeFull();
            content = panel;
        }

        view.setContent(content);
    }
}

From source file:com.m4gik.views.MainView.java

/**
 * @param root// w  w  w.ja va 2 s.co  m
 */
private void addSlogan(VerticalLayout root) {
    Label slogan = new Label("All music now without limits");
    slogan.addStyleName(Runo.LABEL_SMALL);
    slogan.setSizeUndefined();
    root.addComponent(slogan);
    root.setComponentAlignment(slogan, Alignment.TOP_CENTER);
}

From source file:com.m4gik.views.MainView.java

/**
 * @param root//from  w  ww.  j a  v  a 2 s  . c  o m
 */
private void addTitle(VerticalLayout root) {
    Label title = new Label("Music Player");
    title.addStyleName(Runo.LABEL_H1);
    title.setSizeUndefined();
    root.addComponent(title);
    root.setComponentAlignment(title, Alignment.TOP_CENTER);

    addSlogan(root);
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.authentication.LoginScreen.java

License:Apache License

private void buildUI() {
    addStyleName("login-screen");

    // login form, centered in the available part of the screen
    Component loginForm = buildLoginForm();

    // layout to center login form when there is sufficient screen space
    // - see the theme for how this is made responsive for various screen
    // sizes//www .  j  a v  a  2s  .co m
    VerticalLayout centeringLayout = new VerticalLayout();
    centeringLayout.setStyleName("centering-layout");
    centeringLayout.addComponent(loginForm);
    centeringLayout.setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER);

    // information text about logging in
    CssLayout loginInformation = buildLoginInformation();

    addComponent(centeringLayout);
    addComponent(loginInformation);
}

From source file:com.mechanicshop.components.MaintenanceLayout.java

private void buildLayout() {
    HorizontalLayout layoutTitle = new HorizontalLayout();
    layoutTitle.setSizeUndefined();/*from  ww  w .java  2  s .  c o m*/
    layoutTitle.setWidth("100%");
    layoutTitle.setSpacing(false);
    layoutTitle.setMargin(false);
    titleLabel.addStyleName(ValoTheme.LABEL_H2);
    titleLabel.addStyleName(ValoTheme.LABEL_COLORED);
    titleLabel.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    titleLabel.addStyleName(ValoTheme.LABEL_BOLD);
    titleLabel.setSizeUndefined();

    layoutTitle.addComponent(titleLabel);
    layoutTitle.setComponentAlignment(titleLabel, Alignment.MIDDLE_CENTER);

    VerticalLayout layoutTable = new VerticalLayout();

    layoutTable.setSizeFull();

    layoutTable.setSpacing(true);
    HorizontalLayout layoutButtons = new HorizontalLayout();
    layoutButtons.setMargin(false);
    layoutButtons.setSpacing(true);
    layoutButtons.setSizeUndefined();
    Button passwordBtn = new Button("Edit Password");
    passwordBtn.addClickListener(passwordListener);
    passwordBtn.setImmediate(true);
    passwordBtn.setIcon(FontAwesome.EDIT);
    passwordBtn.setStyleName(ValoTheme.BUTTON_TINY);
    Button media1Btn = new Button("Media 1 Default Text");
    media1Btn.setStyleName(ValoTheme.BUTTON_TINY);
    media1Btn.setImmediate(true);
    media1Btn.setIcon(FontAwesome.EDIT);
    media1Btn.addClickListener(media1Listener);
    Button media2Btn = new Button("Media 2 Default Text");
    media2Btn.setStyleName(ValoTheme.BUTTON_TINY);
    media2Btn.setImmediate(true);
    media2Btn.setIcon(FontAwesome.EDIT);
    media2Btn.addClickListener(media2Listener);
    layoutButtons.addComponents(passwordBtn, media1Btn, media2Btn);

    layoutButtons.setComponentAlignment(passwordBtn, Alignment.MIDDLE_LEFT);
    layoutButtons.setComponentAlignment(media1Btn, Alignment.MIDDLE_LEFT);
    layoutButtons.setComponentAlignment(media2Btn, Alignment.MIDDLE_LEFT);

    addComponent(layoutTitle);
    addComponent(layoutTable);
    layoutTable.addComponent(layoutButtons);
    layoutTable.addComponent(table);
    layoutTable.setComponentAlignment(table, Alignment.TOP_CENTER);
    layoutTable.setExpandRatio(table, 3);
    setComponentAlignment(layoutTitle, Alignment.TOP_CENTER);
    setComponentAlignment(layoutTable, Alignment.TOP_CENTER);
    setExpandRatio(layoutTable, 3);
    setSpacing(true);
    setMargin(true);

}

From source file:com.mechanicshop.components.TableLayout.java

private void buildLayout() {
    HorizontalLayout layoutTitle = new HorizontalLayout();
    layoutTitle.setSizeUndefined();/*from w ww  .j  a va 2  s . c  o m*/
    layoutTitle.setWidth("100%");
    layoutTitle.setSpacing(false);
    layoutTitle.setMargin(false);
    titleLabel.addStyleName(ValoTheme.LABEL_H2);
    titleLabel.addStyleName(ValoTheme.LABEL_COLORED);
    titleLabel.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    titleLabel.addStyleName(ValoTheme.LABEL_BOLD);
    titleLabel.setSizeUndefined();

    layoutTitle.addComponent(titleLabel);
    layoutTitle.setComponentAlignment(titleLabel, Alignment.MIDDLE_CENTER);

    VerticalLayout layoutTable = new VerticalLayout();

    layoutTable.addComponent(table);
    layoutTable.setComponentAlignment(table, Alignment.TOP_CENTER);
    layoutTable.setSizeFull();

    layoutTable.setSpacing(true);
    HorizontalLayout layoutButtons = new HorizontalLayout();
    layoutButtons.setMargin(false);
    layoutButtons.setSpacing(true);
    layoutButtons.setSizeUndefined();
    layoutButtons.setWidth("100%");
    Button addBtn = new Button("Add new Car");
    addBtn.addClickListener(addBtnListener);
    addBtn.setImmediate(true);
    addBtn.setStyleName(ValoTheme.BUTTON_TINY);
    addBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    Button deleteBtn = new Button("Delete Selected");
    deleteBtn.setStyleName(ValoTheme.BUTTON_TINY);
    deleteBtn.addStyleName(ValoTheme.BUTTON_DANGER);
    deleteBtn.setImmediate(true);
    deleteBtn.addClickListener(removeListener);

    btnSendSMS.setStyleName(ValoTheme.BUTTON_TINY);
    btnSendSMS.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    btnSendSMS.setImmediate(true);
    btnSendSMS.addClickListener(sendSMSBtnListener);

    searchTextField.setImmediate(true);
    searchTextField.addStyleName(ValoTheme.TEXTFIELD_TINY);
    searchTextField.addTextChangeListener(filterChangeListener);
    Label lbSearch = new Label("Search");
    lbSearch.addStyleName(ValoTheme.LABEL_TINY);
    lbSearch.setSizeUndefined();
    layoutButtons.addComponents(lbSearch, searchTextField, addBtn, deleteBtn, btnSendSMS);

    layoutButtons.setComponentAlignment(lbSearch, Alignment.MIDDLE_LEFT);
    layoutButtons.setComponentAlignment(searchTextField, Alignment.BOTTOM_LEFT);
    layoutButtons.setComponentAlignment(addBtn, Alignment.BOTTOM_RIGHT);
    layoutButtons.setComponentAlignment(deleteBtn, Alignment.BOTTOM_RIGHT);
    layoutButtons.setComponentAlignment(btnSendSMS, Alignment.BOTTOM_RIGHT);
    layoutButtons.setExpandRatio(addBtn, 3);
    addComponent(layoutTitle);
    addComponent(layoutTable);
    layoutTable.addComponent(layoutButtons);
    layoutTable.setExpandRatio(table, 3);
    setComponentAlignment(layoutTitle, Alignment.TOP_CENTER);
    setComponentAlignment(layoutTable, Alignment.TOP_CENTER);
    setExpandRatio(layoutTable, 3);
    setSpacing(true);
    setMargin(true);

}

From source file:com.mechanicshop.components.TableLayout.java

public void createCustomMessage() {
    final TextArea textArea = new TextArea();
    textArea.setImmediate(true);//w w w  .  ja  v a 2s. c  o m
    textArea.setColumns(30);
    textArea.setRows(10);
    textArea.addStyleName(ValoTheme.TEXTAREA_SMALL);
    textArea.setRequired(true);
    final Window subWindow = new Window();
    subWindow.setModal(true);
    subWindow.setHeight("350px");
    subWindow.setWidth("500px");
    subWindow.setCaption("Insert Message");
    subWindow.setStyleName(ValoTheme.WINDOW_TOP_TOOLBAR);
    subWindow.setClosable(false);
    subWindow.setResizable(false);

    HorizontalLayout layoutButtons = new HorizontalLayout();
    layoutButtons.setMargin(false);
    Button sendBtn = new Button("Send");
    sendBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                textArea.validate();
                String message = textArea.getValue();
                smsSenderService.sendMessageMassive(message);
                subWindow.close();
                Notification.show("Message Sent");
            } catch (Exception e) {

            }
        }
    });
    sendBtn.setImmediate(true);
    sendBtn.setStyleName(ValoTheme.BUTTON_TINY);
    sendBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    Button cancelBtn = new Button("Cancel");
    cancelBtn.setStyleName(ValoTheme.BUTTON_TINY);
    cancelBtn.addStyleName(ValoTheme.BUTTON_DANGER);
    cancelBtn.setImmediate(true);
    cancelBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            subWindow.close();

        }
    });

    layoutButtons.setSizeUndefined();
    layoutButtons.setSpacing(true);
    layoutButtons.addComponents(cancelBtn, sendBtn);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.addComponent(textArea);
    layout.addComponent(layoutButtons);
    layout.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(layoutButtons, Alignment.MIDDLE_RIGHT);
    layout.setExpandRatio(textArea, 3);

    layout.setSizeFull();

    subWindow.setContent(layout);
    subWindow.center();

    getUI().addWindow(subWindow);
}

From source file:com.mycollab.mobile.module.project.view.bug.BugFormLayoutFactory.java

License:Open Source License

@Override
public ComponentContainer getLayout() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(false);//from  w  w  w  .j  a  va  2s  .  c om
    layout.setWidth("100%");
    layout.addComponent(FormSectionBuilder.build(AppContext.getMessage(BugI18nEnum.SINGLE)));

    informationLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 14);
    layout.addComponent(informationLayout.getLayout());
    layout.setComponentAlignment(informationLayout.getLayout(), Alignment.BOTTOM_CENTER);
    layout.setExpandRatio(informationLayout.getLayout(), 1.0f);
    return layout;
}

From source file:com.mycollab.mobile.module.project.view.task.TaskFormLayoutFactory.java

License:Open Source License

@Override
public ComponentContainer getLayout() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(false);// ww  w .  jav a2  s . co m
    layout.addComponent(FormSectionBuilder.build(AppContext.getMessage(TaskI18nEnum.M_FORM_READ_TITLE)));

    informationLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 9);
    layout.addComponent(informationLayout.getLayout());
    layout.setComponentAlignment(informationLayout.getLayout(), Alignment.BOTTOM_CENTER);
    return layout;
}

From source file:com.mycollab.module.crm.view.account.AccountContactListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");

    if (UserUIContext.canWrite(RolePermissionCollections.CRM_CONTACT)) {
        final SplitButton controlsBtn = new SplitButton();
        controlsBtn.addStyleName(WebThemes.BUTTON_ACTION);
        controlsBtn.setCaption(UserUIContext.getMessage(ContactI18nEnum.NEW));
        controlsBtn.setIcon(FontAwesome.PLUS);
        controlsBtn.addClickListener(event -> fireNewRelatedItem(""));
        final MButton selectBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SELECT),
                clickEvent -> {//from  w ww. j av a 2s .co  m
                    final AccountContactSelectionWindow contactsWindow = new AccountContactSelectionWindow(
                            AccountContactListComp.this);
                    final ContactSearchCriteria criteria = new ContactSearchCriteria();
                    criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
                    UI.getCurrent().addWindow(contactsWindow);
                    contactsWindow.setSearchCriteria(criteria);
                    controlsBtn.setPopupVisible(false);
                }).withIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT));

        OptionPopupContent buttonControlLayout = new OptionPopupContent();
        buttonControlLayout.addOption(selectBtn);
        controlsBtn.setContent(buttonControlLayout);

        controlsBtnWrap.addComponent(controlsBtn);
        controlsBtnWrap.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT);
    }

    return controlsBtnWrap;
}