Example usage for com.vaadin.ui HorizontalLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:com.cavisson.gui.dashboard.components.controls.ValoThemeUI.java

License:Apache License

CssLayout buildMenu() {
    // Add items/*from  www . jav a2s.c o m*/
    menuItems.put("common", "Common UI Elements");
    menuItems.put("labels", "Labels");
    menuItems.put("buttons-and-links", "Buttons & Links");
    menuItems.put("textfields", "Text Fields");
    menuItems.put("datefields", "Date Fields");
    menuItems.put("comboboxes", "Combo Boxes");
    menuItems.put("selects", "Selects");
    menuItems.put("checkboxes", "Check Boxes & Option Groups");
    menuItems.put("sliders", "Sliders & Progress Bars");
    menuItems.put("colorpickers", "Color Pickers");
    menuItems.put("menubars", "Menu Bars");
    menuItems.put("trees", "Trees");
    menuItems.put("tables", "Tables");
    menuItems.put("dragging", "Drag and Drop");
    menuItems.put("panels", "Panels");
    menuItems.put("splitpanels", "Split Panels");
    menuItems.put("tabs", "Tabs");
    menuItems.put("accordions", "Accordions");
    menuItems.put("popupviews", "Popup Views");
    // menuItems.put("calendar", "Calendar");
    menuItems.put("forms", "Forms");

    final HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName("valo-menu-title");
    menu.addComponent(top);
    menu.addComponent(createThemeSelect());

    final Button showMenu = new Button("Menu", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menu.getStyleName().contains("valo-menu-visible")) {
                menu.removeStyleName("valo-menu-visible");
            } else {
                menu.addStyleName("valo-menu-visible");
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName("valo-menu-toggle");
    showMenu.setIcon(FontAwesome.LIST);
    menu.addComponent(showMenu);

    final Label title = new Label("<h3>Vaadin <strong>Valo Theme</strong></h3>", ContentMode.HTML);
    title.setSizeUndefined();
    top.addComponent(title);
    top.setExpandRatio(title, 1);

    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");
    final StringGenerator sg = new StringGenerator();
    final MenuItem settingsItem = settings.addItem(
            sg.nextString(true) + " " + sg.nextString(true) + sg.nextString(false),
            new ThemeResource("../tests-valo/img/profile-pic-300px.jpg"), null);
    settingsItem.addItem("Edit Profile", null);
    settingsItem.addItem("Preferences", null);
    settingsItem.addSeparator();
    settingsItem.addItem("Sign Out", null);
    menu.addComponent(settings);

    menuItemsLayout.setPrimaryStyleName("valo-menuitems");
    menu.addComponent(menuItemsLayout);

    Label label = null;
    int count = -1;
    for (final Entry<String, String> item : menuItems.entrySet()) {
        if (item.getKey().equals("labels")) {
            label = new Label("Components", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        if (item.getKey().equals("panels")) {
            label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");
            count = 0;
            label = new Label("Containers", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        if (item.getKey().equals("forms")) {
            label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");
            count = 0;
            label = new Label("Other", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        final Button b = new Button(item.getValue(), new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                navigator.navigateTo(item.getKey());
            }
        });
        if (count == 2) {
            b.setCaption(b.getCaption() + " <span class=\"valo-menu-badge\">123</span>");
        }
        b.setHtmlContentAllowed(true);
        b.setPrimaryStyleName("valo-menu-item");
        b.setIcon(testIcon.get());
        menuItemsLayout.addComponent(b);
        count++;
    }
    label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");

    return menu;
}

From source file:com.cerebro.provevaadin.ChatOffGame.java

public ChatOffGame() {
    Panel messagesPanel = new Panel();
    messagesPanel.setSizeFull();/*from   w w w .ja v  a 2 s .  c o  m*/
    messagesPanel.setContent(messages);
    this.addComponent(messagesPanel);
    this.setExpandRatio(messagesPanel, 1.0f);

    HorizontalLayout sendBar = new HorizontalLayout();
    sendBar.setWidth("100%");
    final TextField input = new TextField();
    input.setWidth("100%");
    sendBar.addComponent(input);
    sendBar.setExpandRatio(input, 1.0f);

    Button send = new Button("Send");
    send.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    send.addClickListener((Button.ClickEvent event) -> {
        BroadcasterOffGame.broadcast(input.getValue(), FROM);
        input.setValue("");
    });
    sendBar.addComponent(send);
    this.addComponent(sendBar);

    BroadcasterOffGame.register(this);
}

From source file:com.cerebro.provevaadin.ChatOnGame.java

public ChatOnGame(User user) {
    if (user.getUltimoLuogoPG() != null) {
        logger.info("Luogo: " + user.getUltimoLuogoPG());
    } else {/*from w  w w. j a  va 2  s. c o m*/
        logger.info("Nessun luogo selezionato");
    }
    Panel messagesPanel = new Panel();
    messagesPanel.setSizeFull();
    messagesPanel.setContent(messages);
    this.addComponent(messagesPanel);
    this.setExpandRatio(messagesPanel, 1.0f);

    HorizontalLayout sendBar = new HorizontalLayout();
    sendBar.setWidth("100%");
    final TextField input = new TextField();
    input.setWidth("100%");
    sendBar.addComponent(input);
    sendBar.setExpandRatio(input, 1.0f);

    Button send = new Button("Send");
    send.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    send.addClickListener((Button.ClickEvent event) -> {
        logger.info("Invio del messaggio al server");
        BroadcasterOnGame.broadcast(input.getValue(), FROM);
        input.setValue("");
    });
    sendBar.addComponent(send);
    this.addComponent(sendBar);

    BroadcasterOnGame.register(this);
}

From source file:com.cerebro.provevaadin.Secure.java

public Secure() {

    HorizontalLayout top = new HorizontalLayout();
    this.addComponent(top);
    top.addComponent(new Label("Area sicura"));

    VerticalLayout content = new VerticalLayout();
    this.addComponent(content);

    Navigator nav = new Navigator(UI.getCurrent(), content);
    nav.setErrorView(new ErrorView());
    nav.addView("", new HomeView());
    nav.navigateTo("");

    Button logout = new Button("Logout");
    logout.addClickListener((Button.ClickEvent event) -> {
        System.out.println("Esco dalla sessione");
        SecurityUtils.getSubject().logout();
        UI.getCurrent().getSession().close();
        UI.getCurrent().getPage().setLocation("");
    });/*w  ww. j  a  va2  s.co m*/
    top.addComponent(logout);
}

From source file:com.cerebro.provevaadin.Start.java

public Start() {

    InputStream iniFile = VaadinServlet.getCurrent().getServletContext()
            .getResourceAsStream("/WEB-INF/shiro.ini");
    if (iniFile == null) {
        logger.error("Il file Shiro.ini non esiste");
        return;/*from   w w  w . jav a  2 s .  c  om*/
    } else {
        logger.info("File presente");
    }
    Ini ini = new Ini();
    ini.load(iniFile);
    Factory<SecurityManager> factory = new IniSecurityManagerFactory(ini);
    SecurityManager securityManager = factory.getInstance();
    SecurityUtils.setSecurityManager(securityManager);

    HorizontalLayout root = new HorizontalLayout();
    root.setWidth("800px");
    root.setHeight("600px");
    this.addComponent(root);
    this.setComponentAlignment(root, Alignment.MIDDLE_CENTER);

    FormLayout loginDiv = new FormLayout();
    root.addComponent(loginDiv);
    username.focus();
    errorMessage.setVisible(false);
    loginDiv.addComponents(username, password, rememberMe, login, errorMessage);

    login.addClickListener((Button.ClickEvent e) -> {
        logger.info("Pulsante: " + e.toString());
        Subject currentUser = SecurityUtils.getSubject();
        UsernamePasswordToken token = new UsernamePasswordToken(username.getValue(), password.getValue());
        token.setRememberMe(rememberMe.getValue());
        try {
            currentUser.login(token);
            if (currentUser.hasRole("firsttime")) {
                logger.info("Configurazione parametri del primo avvio");
                getUI().setContent(new FirstTime());
            } else {
                logger.info("Classe di gioco principale");
                getUI().setContent(new Game());
                VaadinService.reinitializeSession(VaadinService.getCurrentRequest());
            }
        } catch (Exception ex) {
            logger.error("Errore nel login: " + ex.getMessage());
            username.setValue("");
            password.setValue("");
            errorMessage.setVisible(true);
        }
    });

    FormLayout signInForm = new FormLayout();
    root.addComponent(signInForm);
    usernameSignIn.focus();
    sesso.addItems("Maschio", "Femmina");
    signInForm.addComponents(usernameSignIn, passwordSignIn, passwordConf, nome, cognome, sesso, eta, signIn);
    signIn.addClickListener((Button.ClickEvent event) -> {
        logger.info("Iscrizione al sito");
        User utente = new User();
        utente.setEmail(usernameSignIn.getValue());
        utente.setPassword(passwordSignIn.getValue());
        utente.setNomeUtente(nome.getValue());
        utente.setCognomeUtente(cognome.getValue());
        utente.setSessoUtente(sesso.getValue().toString());
        utente.setDataNascitaUtente(eta.getValue());
        SignIn signInWindow = new SignIn(utente);
        signInWindow.center();
        UI.getCurrent().addWindow(signInWindow);
    });

}

From source file:com.cms.component.CustomPageTable.java

public HorizontalLayout createControls(String pageSizeDefault) {
    this.pageSizeDefault = pageSizeDefault;
    separatorTotal.setImmediate(true);/*www  .  j  a v  a 2 s.  c  o  m*/
    Label itemsPerPageLabel = new Label(BundleUtils.getString("common.table.numberRecord"));

    for (String numberSize : Constants.PAGE_SIZE_LIST) {
        itemsPerPageSelect.addItem(numberSize);
    }
    itemsPerPageSelect.setImmediate(true);
    itemsPerPageSelect.setNullSelectionAllowed(false);
    itemsPerPageSelect.setWidth("50px");
    itemsPerPageSelect.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -2255853716069800092L;

        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            setPageLength(Integer.valueOf(String.valueOf(event.getProperty().getValue())));
            firePagedChangedEvent();
        }
    });
    itemsPerPageSelect.select(pageSizeDefault);
    Label pageLabel = new Label(BundleUtils.getString("common.table.page"), ContentMode.HTML);
    final TextField currentPageTextField = new TextField();
    currentPageTextField.setValue(String.valueOf(getCurrentPage()));
    currentPageTextField.setConverter(Integer.class);
    currentPageTextField
            .addValidator(new IntegerRangeValidator("Wrong page number", 1, getTotalAmountOfPages()));
    Label separatorLabel = new Label("&nbsp;/&nbsp;", ContentMode.HTML);
    final Label totalPagesLabel = new Label(String.valueOf(getTotalAmountOfPages()), ContentMode.HTML);
    currentPageTextField.setStyleName(Reindeer.TEXTFIELD_SMALL);
    currentPageTextField.setImmediate(true);
    currentPageTextField.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -2255853716069800092L;

        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            currentPageTextField.removeAllValidators();
            currentPageTextField
                    .addValidator(new IntegerRangeValidator("Wrong page number", 1, getTotalAmountOfPages()));
            if (Integer.valueOf(String.valueOf(currentPageTextField.getValue())) <= getTotalAmountOfPages()) {
                int page = Integer.valueOf(String.valueOf(currentPageTextField.getValue()));
                setCurrentPage(page);
            }
        }
    });
    pageLabel.setWidth(null);
    currentPageTextField.setWidth("30px");
    separatorLabel.setWidth(null);
    totalPagesLabel.setWidth(null);

    HorizontalLayout controlBar = new HorizontalLayout();
    HorizontalLayout pageSize = new HorizontalLayout();
    HorizontalLayout pageManagement = new HorizontalLayout();
    final Button first = new Button("<<", new Button.ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            setCurrentPage(0);
        }
    });
    previous = new Button("<", new Button.ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            previousPage();
        }
    });
    final Button next = new Button(">", new Button.ClickListener() {
        private static final long serialVersionUID = -1927138212640638452L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            nextPage();
        }
    });
    final Button last = new Button(">>", new Button.ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            setCurrentPage(getTotalAmountOfPages());
        }
    });
    first.setStyleName(Reindeer.BUTTON_LINK);
    previous.setStyleName(Reindeer.BUTTON_LINK);
    next.setStyleName(Reindeer.BUTTON_LINK);
    last.setStyleName(Reindeer.BUTTON_LINK);

    itemsPerPageLabel.addStyleName("pagedtable-itemsperpagecaption");
    itemsPerPageSelect.addStyleName("pagedtable-itemsperpagecombobox");
    pageLabel.addStyleName("pagedtable-pagecaption");
    currentPageTextField.addStyleName("pagedtable-pagefield");
    separatorLabel.addStyleName("pagedtable-separator");
    separatorTotal.addStyleName("pagedtable-separator");
    totalPagesLabel.addStyleName("pagedtable-total");
    first.addStyleName("pagedtable-first");
    previous.addStyleName("pagedtable-previous");
    next.addStyleName("pagedtable-next");
    last.addStyleName("pagedtable-last");

    itemsPerPageLabel.addStyleName("pagedtable-label");
    itemsPerPageSelect.addStyleName("pagedtable-combobox");
    pageLabel.addStyleName("pagedtable-label");
    currentPageTextField.addStyleName("pagedtable-label");
    separatorLabel.addStyleName("pagedtable-label");
    separatorTotal.addStyleName("pagedtable-label");
    totalPagesLabel.addStyleName("pagedtable-label");
    first.addStyleName("pagedtable-button");
    previous.addStyleName("pagedtable-button");
    next.addStyleName("pagedtable-button");
    last.addStyleName("pagedtable-button");

    pageSize.addComponent(itemsPerPageLabel);
    pageSize.addComponent(itemsPerPageSelect);
    Label separator = new Label("&nbsp;/&nbsp;", ContentMode.HTML);
    pageSize.addComponent(separator);
    pageSize.addComponent(separatorTotal);
    pageSize.setComponentAlignment(itemsPerPageLabel, Alignment.MIDDLE_LEFT);
    pageSize.setComponentAlignment(itemsPerPageSelect, Alignment.MIDDLE_LEFT);
    pageSize.setComponentAlignment(separator, Alignment.MIDDLE_LEFT);
    pageSize.setComponentAlignment(separatorTotal, Alignment.MIDDLE_LEFT);
    pageSize.setSpacing(true);
    pageManagement.addComponent(first);
    pageManagement.addComponent(previous);
    pageManagement.addComponent(pageLabel);
    pageManagement.addComponent(currentPageTextField);
    pageManagement.addComponent(separatorLabel);
    pageManagement.addComponent(totalPagesLabel);
    pageManagement.addComponent(next);
    pageManagement.addComponent(last);
    pageManagement.setComponentAlignment(first, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(previous, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(pageLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(currentPageTextField, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(separatorLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(totalPagesLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(next, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(last, Alignment.MIDDLE_LEFT);
    pageManagement.setWidth(null);
    pageManagement.setSpacing(true);
    controlBar.addComponent(pageSize);
    controlBar.addComponent(pageManagement);
    controlBar.setComponentAlignment(pageManagement, Alignment.MIDDLE_CENTER);
    controlBar.setWidth("100%");
    controlBar.setExpandRatio(pageSize, 1);
    addListener(new PageChangeListener() {
        @Override
        public void pageChanged(PagedTableChangeEvent event) {
            int abc = event.getCurrentPage();
            first.setEnabled(container.getStartIndex() > 0);
            previous.setEnabled(container.getStartIndex() > 0);
            next.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength());
            last.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength());
            currentPageTextField.setValue(String.valueOf(getCurrentPage()));
            totalPagesLabel.setValue(String.valueOf(getTotalAmountOfPages()));
            if (resizePage) {
                int lenght = getPageLength();
                int a = lenght % 5;
                int b = lenght / 5;
                if (a != 0) {
                    int pageLenght = 5 * (b + 1);
                    itemsPerPageSelect.setValue(pageLenght);
                }
            }
            separatorTotal.setValue(String.valueOf(container.getRealSize()));
        }
    });
    return controlBar;
}

From source file:com.cms.component.WindowProgress.java

public WindowProgress(String caption) {
    setClosable(false);//from  w w  w.j a  v a 2 s  .com
    setReadOnly(true);
    setResizable(false);
    setWidth("-1px");
    setHeight("-1px");
    setModal(true);
    //        setStyleName("loading-window");
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setWidth("-1px");
    horizontalLayout.setHeight("-1px");
    horizontalLayout.setSpacing(true);
    horizontalLayout.setMargin(true);

    pb = new ProgressBar();
    pb.setIndeterminate(true);
    lb = new Label();
    lb.setValue(BundleUtils.getString("Running"));
    horizontalLayout.addComponent(pb);
    horizontalLayout.addComponent(lb);

    setContent(horizontalLayout);
}

From source file:com.cms.component.WindowProgress.java

public WindowProgress() {
    setClosable(false);/*from  www.  j a  va2  s . c  o  m*/
    setReadOnly(true);
    setResizable(false);
    setWidth("-1px");
    setHeight("-1px");
    setModal(true);
    //        setStyleName("loading-window");
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setWidth("-1px");
    horizontalLayout.setHeight("-1px");
    horizontalLayout.setSpacing(true);
    horizontalLayout.setMargin(true);

    pb = new ProgressBar();
    pb.setIndeterminate(true);
    lb = new Label();
    lb.setValue(BundleUtils.getString("Running"));
    horizontalLayout.addComponent(pb);
    horizontalLayout.addComponent(lb);

    setContent(horizontalLayout);
}

From source file:com.coatl.pruebas.datastore.DataStoreUI.java

@Override
protected void init(VaadinRequest vaadinRequest) {
    this.principal = new VerticalLayout();
    {/*from  w w w.  j ava2  s.c  o m*/
        principal.addComponent(new Label("Pruebas de DataStore"));
        HorizontalLayout superior = new HorizontalLayout();
        principal.addComponent(superior);

        this.forma = new FormLayout();
        superior.addComponent(forma);
        {
            this.tabla = new TextField("Tabla");
            tabla.setValue("iq3_usuarios");
            forma.addComponents(tabla);

            this.nombre = new TextField("Nombre");
            forma.addComponents(nombre);
            this.ap1 = new TextField("Apellido Paterno");
            forma.addComponents(ap1);
            this.ap2 = new TextField("Apellido Materno");
            forma.addComponents(ap2);
            this.renglones = new Label("Renglones");
            forma.addComponents(renglones);

        }

        FormLayout botones = new FormLayout();
        /*
        botones.addComponent(new Label(" "));
        botones.addComponent(new Label("Acciones:"));
         */
        superior.addComponent(botones);

        Button recargar = new Button("Recargar");
        botones.addComponent(recargar);
        recargar.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                listarObjetos();
            }
        });

        Button guardar = new Button("Guardar");
        botones.addComponent(guardar);
        guardar.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                Map m = new HashMap();
                m.put("nombre", nombre.getValue());
                m.put("ap1", ap1.getValue());
                m.put("ap2", ap2.getValue());
                m.put("id", nombre.getValue());

                IU7.ds.guardar(tabla.getValue(), m);
                System.out.println("Objeto guardado");
                listarObjetos();
            }
        });

        Button borrar = new Button("Borrar");
        botones.addComponent(borrar);
        borrar.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                borrar();
            }
        });

        Button mil = new Button("Hacer 1,000");
        botones.addComponent(mil);
        mil.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                for (int i = 0; i < 1000; i++) {
                    Map m = new HashMap();
                    String id = "ID_" + i + "_" + Math.random();
                    m.put("id", id);
                    m.put("nombre", "Nombre_" + id + "_" + Math.random());
                    m.put("ap1", "Ap1_" + id + "_" + Math.random());
                    m.put("ap2", "Ap2_" + id + "_" + Math.random());
                    IU7.ds.guardar(tabla.getValue(), m);
                    System.out.println(" >" + id);
                }
            }
        });

    }

    VerticalSplitPanel vsl = new VerticalSplitPanel();
    setContent(vsl);
    vsl.setFirstComponent(principal);

    grid.setSizeFull();
    grid.setComponenteSuperior(new Label("primer panel"));
    //grid.setComponenteMedio(new Label("segundo panel"));
    //grid.setComponenteInferior(new Label("tercer panel"));
    grid.setNombreTabla(tabla.getValue());
    grid.setColumnas("id,nombre,ap1,ap2");
    grid.setColumnasVisibles("nombre,ap1,ap2");

    vsl.setSecondComponent(grid);
    //grid.setComponenteMedio(grid);
    this.listarObjetos();
}

From source file:com.dungnv.streetfood.ui.ArticleItemUI.java

private void init() {
    this.addStyleName("item-interator");
    this.setSpacing(true);
    this.setWidth("100%");

    CssLayout horizontal = new CssLayout();
    horizontal.setStyleName("padding-5");
    horizontal.setWidth("100%");
    Responsive.makeResponsive(horizontal);
    this.addComponent(horizontal);

    Image imag = new Image();
    if (!StringUtils.isNullOrEmpty(item.getImageUrl())) {
        imag.setSource(new ExternalResource(item.getImageUrl()));
    }/*from   w  w  w  .j a v  a 2s.  c om*/
    horizontal.addComponent(imag);

    VerticalLayout vlInfo = new VerticalLayout();
    vlInfo.setStyleName("padding-5");
    vlInfo.setWidth("70%");

    horizontal.addComponent(vlInfo);

    lbTitle = new Label(item.getTitle());
    lbTitle.addStyleName("lb-title");
    vlInfo.addComponent(lbTitle);

    lbIntroduce = new Label(item.getShortContent());
    lbIntroduce.setStyleName("lb-description");
    vlInfo.addComponent(lbIntroduce);

    HorizontalLayout htInfo = new HorizontalLayout();
    vlInfo.addComponent(htInfo);

    lbInfo = new Label();
    lbInfo.setCaptionAsHtml(true);
    htInfo.addComponent(lbInfo);

    HorizontalLayout htToolBar = new HorizontalLayout();
    htToolBar.setStyleName("lb-toolbar");
    horizontal.addComponent(htToolBar);

    btnLink = new Button();
    btnLink.setIcon(FontAwesome.LINK);
    btnLink.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    btnLink.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
    btnLink.setWidth("25px");
    btnLink.setHeight("25px");
    htToolBar.addComponent(btnLink);
    htToolBar.setComponentAlignment(btnLink, Alignment.BOTTOM_RIGHT);

    btnEdit = new Button();
    btnEdit.setIcon(FontAwesome.EDIT);
    btnEdit.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    btnEdit.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
    btnEdit.setWidth("25px");
    btnEdit.setHeight("25px");
    htToolBar.addComponent(btnEdit);
    htToolBar.setComponentAlignment(btnEdit, Alignment.BOTTOM_RIGHT);

    btnDelete = new Button();
    btnDelete.setIcon(FontAwesome.TIMES);
    btnDelete.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    btnDelete.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
    btnDelete.setWidth("25px");
    btnDelete.setHeight("25px");
    htToolBar.addComponent(btnDelete);
    htToolBar.setComponentAlignment(btnDelete, Alignment.BOTTOM_RIGHT);
}