Example usage for com.vaadin.ui HorizontalLayout setExpandRatio

List of usage examples for com.vaadin.ui HorizontalLayout setExpandRatio

Introduction

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

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

From source file:com.logicbomb.newschool.pages.masterpages.PrimaryMasterPage.java

public PrimaryMasterPage() {

    //ContextWidget c= new ContextWidget();

    HorizontalLayout iHorizontalLayout = new HorizontalLayout();
    //addComponent(iHorizontalLayout,"top:0px;left:0px");
    iHorizontalLayout.setWidth(String.valueOf(Page.getCurrent().getBrowserWindowWidth()));
    iHorizontalLayout.setHeight(String.valueOf(Page.getCurrent().getBrowserWindowHeight()));
    iHorizontalLayout.setStyleName("backColorBlack");

    //String[] captions1 = {"Logo Here", "My Cool School", "Third"};

    //Layout A and its sub components
    Panel AP = new Panel();
    iHorizontalLayout.addComponent(AP);//w  w w.  ja  v  a  2  s .c  om
    AP.setSizeFull();
    AP.setStyleName("backColorBlack");
    VerticalLayout A1 = new VerticalLayout();
    AP.setContent(A1);
    //A.setSizeFull();
    A1.setSpacing(true);
    iHorizontalLayout.setExpandRatio(AP, 1);

    A1.setStyleName("backColorBlack");
    A1.setMargin(new MarginInfo(true, true, true, true));

    Button logoImage = new Button();
    logoImage.setIcon(FontAwesome.PICTURE_O);
    logoImage.setWidth("80px");
    logoImage.setHeight(logoImage.getWidth(), Unit.PIXELS);
    //logoImage.setWidth("100px");
    A1.addComponent(logoImage);
    A1.setComponentAlignment(logoImage, Alignment.TOP_CENTER);

    Label schoolName = new Label("The School Of Future");
    schoolName.setStyleName("v-label-big");
    A1.addComponent(schoolName);
    //A.setComponentAlignment(schoolName,Alignment.TOP_CENTER);

    Label schoolMinorName = new Label("Random Branch");
    schoolMinorName.setStyleName("v-label-small");
    A1.addComponent(schoolMinorName);

    VerticalLayout A2 = new VerticalLayout();
    A1.addComponent(A2);
    MainMenuWidget iMainMenuWidget = new MainMenuWidget();
    A2.addComponent(iMainMenuWidget);

    //A.setComponentAlignment(schoolName,Alignment.TOP_CENTER);

    //Layout B
    ContextWidgetTop c = new ContextWidgetTop();
    c = ContextWidgetTop.ContextWidgetTransformer(c, new UserDetailsWidget(), SliderMode.TOP,
            SliderPanelStyles.COLOR_RED);
    VerticalLayout B = new VerticalLayout();
    B.setSizeFull();
    //B.setSpacing(true);
    iHorizontalLayout.addComponent(c);
    c.addComponent(B);
    iHorizontalLayout.setExpandRatio(c, 7);

    //Layout B1 and its sub Components
    HorizontalLayout B1 = new HorizontalLayout();
    B.addComponent(B1);
    //B.setExpandRatio(B1, 1);
    //B1.setHeight("70px");
    B1.setSizeFull();
    //B1=ContextWidget.ContextWidgetTransformer(B1, new SliderMasterPage(),SliderMode.RIGHT,SliderPanelStyles.COLOR_RED);

    HorizontalLayout B11 = new HorizontalLayout();
    B1.addComponent(B11);
    B1.setStyleName("backColorBlack");
    B11.setSizeFull();
    B1.setHeight("45px");
    //B1.setStyleName("backColorWhite");
    //B1.setMargin(new MarginInfo(false, true, false, true));

    TextField iTextField = new TextField();
    iTextField.setWidth("200px");
    iTextField.setInputPrompt("Search!");
    iTextField.setStyleName("v-text-type-search");
    iTextField.focus();
    B11.addComponent(iTextField);
    B11.setComponentAlignment(iTextField, Alignment.MIDDLE_LEFT);

    //Layout B2 and its Sub Components
    ContextWidget B2 = new ContextWidget();
    B2.setSizeFull();
    B.addComponent(B2);
    B.setExpandRatio(B2, 10);
    B2 = ContextWidget.ContextWidgetTransformer(B2, new SliderMasterPage(), SliderMode.RIGHT,
            SliderPanelStyles.COLOR_BLUE);
    //B2=ContextWidget.ContextWidgetTransformer(B2, new SliderMasterPage(),SliderMode.TOP,SliderPanelStyles.COLOR_RED);
    VerticalLayout v = new VerticalLayout();
    B2.addComponent(v);

    Button b1111 = new Button(
            "Put all the inner components like this Put all the inner components like this Put all the inner components like this Put all the inner components like this");
    v.addComponent(b1111);
    Button b1112 = new Button("Put all the inner components like this");
    v.addComponent(b1112);

    /*
    Panel p = new Panel();
    VerticalLayout v= new VerticalLayout();
    v.addComponent(new TextField("Name"));
    v.addComponent(new TextField("Street address"));
    v.addComponent(new TextField("Postal code"));
    p.setContent(v);
    B2.addComponent(p);
    v.setWidth(String.valueOf(B2.getWidth()*10)+"px");
    //v.setSizeFull();// <- This will cause issues. Don't do this
    p.setSizeFull();
    */

    //ContextWidget iContextPanel= new ContextWidget(p);
    //B2.addComponent(iContextPanel);
    //setPosition(p, iComponentPositionPanel);

    addComponent(iHorizontalLayout);
}

From source file:com.lst.deploymentautomation.vaadin.page.SettingsView.java

License:Open Source License

private void createView() {
    LspsUI ui = (LspsUI) getUI();/*from ww  w .  j av a  2 s  . com*/
    Person user = ui.getUser().getPerson();
    userRights = user.getRights();

    setTitle(ui.getMessage(TITLE));

    Panel panel = new Panel();
    panel.addStyleName("l-border-none");
    setContent(panel);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    panel.setContent(layout);

    //user data and settings will be laid out next to each other
    HorizontalLayout topSection = new HorizontalLayout();
    topSection.setSpacing(true);
    topSection.setWidth("100%");
    layout.addComponent(topSection);

    VerticalLayout userData = createUserDataSection(ui, user);
    topSection.addComponent(userData);
    topSection.setExpandRatio(userData, 1);

    Label spacer = new Label();
    spacer.setWidth("20px");
    topSection.addComponent(spacer);

    VerticalLayout settings = createSettingsSection(ui);
    topSection.addComponent(settings);
    topSection.setExpandRatio(settings, 1);

    //substitution section
    VerticalLayout substitution = createSubstitutionSection(ui, user);
    layout.addComponent(substitution);

    Label spacer2 = new Label();
    spacer2.setHeight("10px");
    layout.addComponent(spacer2);

    //buttons
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    Button saveButton = new Button(ui.getMessage("action.save"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (save()) {
                if (requestReload) {
                    JavaScript.getCurrent().execute("window.location.reload()");
                } else {
                    close();
                }
            }
        }
    });
    saveButton.setData(BUTTON_TYPE_SAVE);
    buttons.addComponent(saveButton);
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
    layout.addComponent(buttons);
}

From source file:com.lst.deploymentautomation.vaadin.page.TodoView.java

License:Open Source License

@SuppressWarnings("serial")
@Override/*from   w  w  w .ja  v a2  s  . c o  m*/
protected Component createHeader(Component titleComponent) {
    LspsUI ui = (LspsUI) getUI();

    MenuBar menu = new MenuBar();
    menu.addStyleName("menu-button-action");
    MenuItem actions = menu.addItem("", new ThemeResource("../icons/popup-menu.png"), null);

    final ViewAction closeView = new ViewAction() {

        @Override
        public void invoke() {
            close(); //maybe close only if the to-do is not allocated to the user anymore
        }
    };
    final ViewAction refreshAnnotations = new ViewAction() {

        @Override
        public void invoke() {
            Todo todo = todoService.getTodo(todoHolder.getTodo().getId());
            refreshAnnotations(todo);
        }
    };

    actions.addItem(ui.getMessage("action.info"), new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            //get fresh info
            Todo todo = todoService.getTodo(todoHolder.getTodo().getId());
            getUI().addWindow(new TodoDetails(todo));
        }
    });
    actions.addSeparator();
    actions.addItem(ui.getMessage("action.annotate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            //get fresh info
            Todo todo = todoService.getTodo(todoHolder.getTodo().getId());
            getUI().addWindow(new TodoAnnotation(todo, refreshAnnotations));
        }
    });
    actions.addSeparator();
    actions.addItem(ui.getMessage("action.unlock"), new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            unlock();
        }
    });
    actions.addItem(ui.getMessage("action.reject") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoRejection(todoHolder.getTodo().getId(), closeView));
        }
    });
    actions.addItem(ui.getMessage("action.delegate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoDelegation(todoHolder.getTodo().getId(), closeView));
        }
    });
    actions.addItem(ui.getMessage("action.escalate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoEscalation(todoHolder.getTodo().getId(), closeView));
        }
    });

    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth("100%");
    layout.addComponent(titleComponent);
    layout.setExpandRatio(titleComponent, 1);
    layout.addComponent(menu);
    layout.setComponentAlignment(menu, Alignment.MIDDLE_RIGHT);
    return layout;
}

From source file:com.m1kah.ui.TodoComponent.java

License:Open Source License

private void initFooter() {
    itemsLeftLabel = new Label("0 items left");
    filterOptionGroup = new OptionGroup();
    filterOptionGroup.setId("filter-radio");
    for (TodoFilter todoFilter : TodoFilter.values()) {
        filterOptionGroup.addItem(todoFilter);
    }//  ww w. jav a2s. co m
    filterOptionGroup.setValue(filter);
    clearCompletedButton = new Button("Clear completed");

    HorizontalLayout footerLayout = new HorizontalLayout(itemsLeftLabel, filterOptionGroup,
            clearCompletedButton);
    footerLayout.setWidth(100.0f, Unit.PERCENTAGE);
    footerLayout.setComponentAlignment(itemsLeftLabel, Alignment.MIDDLE_LEFT);
    footerLayout.setComponentAlignment(filterOptionGroup, Alignment.MIDDLE_CENTER);
    footerLayout.setComponentAlignment(clearCompletedButton, Alignment.MIDDLE_RIGHT);
    footerLayout.setExpandRatio(itemsLeftLabel, 0.25f);
    footerLayout.setExpandRatio(filterOptionGroup, 0.5f);
    footerLayout.setExpandRatio(clearCompletedButton, 0.25f);
    addComponent(footerLayout);
}

From source file:com.m4gik.views.component.LicenseScreen.java

/**
 * Method adds Text to the layout./*from   w  w w .ja va  2  s. c  om*/
 * 
 * @param texts
 *            The layout to add texts.
 * @param string
 *            The text to add to the layout.
 */
private void addText(HorizontalLayout texts, String string, String style) {
    addSpacer(texts);

    Label text = new Label(string, Label.CONTENT_XHTML);

    if (style != null) {
        text.setStyleName(style);
    }

    texts.addComponent(text);
    texts.setExpandRatio(text, 1);
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.crud.SampleCrudView.java

License:Apache License

public HorizontalLayout createTopBar() {
    TextField filter = new TextField();
    filter.setStyleName("filter-textfield");
    filter.setInputPrompt("Filter");
    ResetButtonForTextField.extend(filter);
    filter.setImmediate(true);// w  w w.j a  v  a2s.co  m
    filter.addTextChangeListener(new FieldEvents.TextChangeListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            table.setFilter(event.getText());
        }
    });

    newProduct = new Button("New product");
    newProduct.addStyleName(ValoTheme.BUTTON_PRIMARY);
    newProduct.setIcon(FontAwesome.PLUS_CIRCLE);
    newProduct.addClickListener(new ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            viewLogic.newProduct();
        }
    });

    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setSpacing(true);
    topLayout.setWidth("100%");
    topLayout.addComponent(filter);
    topLayout.addComponent(newProduct);
    topLayout.setComponentAlignment(filter, Alignment.MIDDLE_LEFT);
    topLayout.setExpandRatio(filter, 1);
    topLayout.setStyleName("top-bar");
    return topLayout;
}

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

private void buildLayout() {
    HorizontalLayout layoutTitle = new HorizontalLayout();
    layoutTitle.setSizeUndefined();//from  w w w. j  a v a2  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.mycollab.mobile.module.project.view.message.MessageAttachmentField.java

License:Open Source License

@Override
protected void constructUI() {
    content = new VerticalLayout();
    content.setStyleName("attachment-field");

    rowWrap = new VerticalLayout();
    rowWrap.setWidth("100%");
    rowWrap.setStyleName("attachment-row-wrap");

    HorizontalLayout compHeader = new HorizontalLayout();
    compHeader.setWidth("100%");
    compHeader.setStyleName("attachment-field-header");

    Label headerLbl = new Label(UserUIContext.getMessage(GenericI18Enum.FORM_ATTACHMENTS));
    headerLbl.setStyleName("field-caption");

    compHeader.addComponent(headerLbl);//from   w w w  . j a v a2  s . co  m
    compHeader.setExpandRatio(headerLbl, 1.0f);
    compHeader.addComponent(attachmentBtn);

    content.addComponent(compHeader);
    content.addComponent(rowWrap);
}

From source file:com.mycollab.module.project.view.settings.ProjectMemberListViewImpl.java

License:Open Source License

private Component generateMemberBlock(final SimpleProjectMember member) {
    HorizontalLayout blockContent = new HorizontalLayout();
    blockContent.setStyleName("member-block");
    if (ProjectMemberStatusConstants.NOT_ACCESS_YET.equals(member.getStatus())) {
        blockContent.addStyleName("inactive");
    }//from   w  w w.  j  av a2 s.  c  om
    blockContent.setWidth("350px");

    Image memberAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getMemberAvatarId(),
            100);
    memberAvatar.addStyleName(UIConstants.CIRCLE_BOX);
    memberAvatar.setWidthUndefined();
    blockContent.addComponent(memberAvatar);

    MVerticalLayout blockTop = new MVerticalLayout().withMargin(new MarginInfo(false, false, false, true))
            .withFullWidth();

    MButton editBtn = new MButton("",
            clickEvent -> EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoEdit(this, member)))
                    .withIcon(FontAwesome.EDIT).withStyleName(WebThemes.BUTTON_LINK)
                    .withVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS));
    editBtn.setDescription("Edit user '" + member.getDisplayName() + "' information");

    MButton deleteBtn = new MButton("", clickEvent -> {
        ConfirmDialogExt.show(UI.getCurrent(),
                UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()),
                UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> {
                    if (confirmDialog.isConfirmed()) {
                        ProjectMemberService prjMemberService = AppContextUtil
                                .getSpringBean(ProjectMemberService.class);
                        prjMemberService.removeWithSession(member, UserUIContext.getUsername(),
                                MyCollabUI.getAccountId());
                        EventBusFactory.getInstance()
                                .post(new ProjectMemberEvent.GotoList(ProjectMemberListViewImpl.this, null));
                    }
                });
    }).withIcon(FontAwesome.TRASH_O).withStyleName(WebThemes.BUTTON_LINK)
            .withVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS));
    deleteBtn.setDescription("Remove user '" + member.getDisplayName() + "' out of this project");

    MHorizontalLayout buttonControls = new MHorizontalLayout(editBtn, deleteBtn);
    blockTop.addComponent(buttonControls);
    blockTop.setComponentAlignment(buttonControls, Alignment.TOP_RIGHT);

    A memberLink = new A(
            ProjectLinkBuilder.generateProjectMemberFullLink(member.getProjectid(), member.getUsername()))
                    .appendText(member.getMemberFullName()).setTitle(member.getMemberFullName());
    ELabel memberNameLbl = ELabel.h3(memberLink.write()).withStyleName(UIConstants.TEXT_ELLIPSIS)
            .withFullWidth();

    blockTop.with(memberNameLbl, ELabel.hr());

    String roleLink = String.format("<a href=\"%s%s%s\"", MyCollabUI.getSiteUrl(),
            GenericLinkUtils.URL_PREFIX_PARAM,
            ProjectLinkGenerator.generateRolePreviewLink(member.getProjectid(), member.getProjectroleid()));
    ELabel memberRole = new ELabel("", ContentMode.HTML).withFullWidth()
            .withStyleName(UIConstants.TEXT_ELLIPSIS);
    if (member.isProjectOwner()) {
        memberRole.setValue(String.format("%sstyle=\"color: #B00000;\">%s</a>", roleLink,
                UserUIContext.getMessage(ProjectRoleI18nEnum.OPT_ADMIN_ROLE_DISPLAY)));
    } else {
        memberRole.setValue(
                String.format("%sstyle=\"color:gray;font-size:12px;\">%s</a>", roleLink, member.getRoleName()));
    }
    blockTop.addComponent(memberRole);

    if (Boolean.TRUE.equals(MyCollabUI.showEmailPublicly())) {
        Label memberEmailLabel = ELabel
                .html(String.format("<a href='mailto:%s'>%s</a>", member.getUsername(), member.getUsername()))
                .withStyleName(UIConstants.META_INFO).withFullWidth();
        blockTop.addComponent(memberEmailLabel);
    }

    ELabel memberSinceLabel = ELabel
            .html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_SINCE,
                    UserUIContext.formatPrettyTime(member.getJoindate())))
            .withDescription(UserUIContext.formatDateTime(member.getJoindate())).withFullWidth();
    blockTop.addComponent(memberSinceLabel);

    if (ProjectMemberStatusConstants.ACTIVE.equals(member.getStatus())) {
        ELabel lastAccessTimeLbl = ELabel
                .html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_LOGGED_IN,
                        UserUIContext.formatPrettyTime(member.getLastAccessTime())))
                .withDescription(UserUIContext.formatDateTime(member.getLastAccessTime()));
        blockTop.addComponent(lastAccessTimeLbl);
    }

    String memberWorksInfo = ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK).getHtml() + " "
            + new Span().appendText("" + member.getNumOpenTasks())
                    .setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_TASKS))
            + "  " + ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG).getHtml() + " "
            + new Span().appendText("" + member.getNumOpenBugs())
                    .setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_BUGS))
            + " " + FontAwesome.MONEY.getHtml() + " "
            + new Span().appendText("" + NumberUtils.roundDouble(2, member.getTotalBillableLogTime()))
                    .setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS))
            + "  " + FontAwesome.GIFT.getHtml() + " "
            + new Span().appendText("" + NumberUtils.roundDouble(2, member.getTotalNonBillableLogTime()))
                    .setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS));

    blockTop.addComponent(ELabel.html(memberWorksInfo).withStyleName(UIConstants.META_INFO));

    blockContent.addComponent(blockTop);
    blockContent.setExpandRatio(blockTop, 1.0f);
    return blockContent;
}

From source file:com.mycompany.project.views.ContactsView.java

public ContactsView() {

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);//from ww  w.j  a  va 2 s  .com
    mainVLayout.setSpacing(true);

    setContent(mainVLayout);

    // view header
    Label header = new Label("<div align=\"center\" style=\"font-size:12pt;\">Contactos</div>");
    header.setContentMode(ContentMode.HTML);

    mainVLayout.addComponent(header);

    // set window properties
    window.setWidth("400px");
    window.setCaption("Nuevo Contacto");
    window.setModal(true);
    window.setContent(newContactForm);

    // add new cotact button
    Button btnNew = new Button("Agregar Nuevo Contacto");
    mainVLayout.addComponent(btnNew);

    // clicking the button should display the NewContactForm
    btnNew.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (window.getParent() == null) {
                getUI().addWindow(window);
            }

        }
    });

    //add a horozontal layout - left has a table, right has a ContactDetail component
    HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setSizeFull();
    hLayout.setSpacing(true);

    mainVLayout.addComponent(hLayout);

    //add a table

    table.setWidth("600px");
    table.setImmediate(true);
    hLayout.addComponent(table);

    // how does table get its data
    beanContainer.setBeanIdProperty("id");
    table.setContainerDataSource(beanContainer);

    //set columns
    final Object[] NATURAL_COL_ORDER = new Object[] { "name", "phone", "email" };
    final String[] COL_HEADERS_ENGLISH = new String[] { "Name", "Phone", "Email" };

    table.setSelectable(true);
    table.setColumnCollapsingAllowed(true);
    table.setRowHeaderMode(RowHeaderMode.INDEX);
    table.setVisibleColumns(NATURAL_COL_ORDER);
    table.setColumnHeaders(COL_HEADERS_ENGLISH);

    // selecting a table row should enable/disale the ContactDetails component
    table.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            String contactId = (String) table.getValue();
            contactDetails.setContactId(contactId);
        }
    });

    //add a ContactDetails component

    //        contactDetails.setWidth("500px");
    hLayout.addComponent(contactDetails);

    // let the table fill the entire remaining width
    hLayout.setExpandRatio(contactDetails, 1);

}