Example usage for com.vaadin.ui CssLayout getComponentCount

List of usage examples for com.vaadin.ui CssLayout getComponentCount

Introduction

In this page you can find the example usage for com.vaadin.ui CssLayout getComponentCount.

Prototype

@Override
public int getComponentCount() 

Source Link

Document

Gets the number of contained components.

Usage

From source file:com.wintindustries.pfserver.interfaces.view.dashboard.DashboardMenu.java

private Component buildFolderTree() {

    CssLayout treeLayout = new CssLayout();
    treeLayout.setWidth("100%");
    if (treeLayout.getComponentCount() > 0) {
        treeLayout.removeAllComponents();
    }//from   w w w. jav  a  2s. com

    System.out.println("Init Dataasource");

    for (PFDataSource source : PFCore.core.getDataSources()) {
        System.out.println("NEW TREE");

        Label label = new Label(source.getName(), ContentMode.HTML);
        label.setPrimaryStyleName("valo-menu-subtitle");
        label.addStyleName("h4");

        label.setSizeUndefined();
        treeLayout.addComponent(label);
        //      label.setIcon(FontAwesome.LAPTOP);
        treeLayout.addStyleName("valo-menuitems");

        Tree tree = new Tree();
        //tree.setIcon(FontAwesome.LAPTOP);
        // tree.setWidth("100%");

        // container.setItemSorter(new l);

        source.Session().OpenSession();
        source.Session().getSession().beginTransaction();
        source.Session().getSession().getTransaction().setTimeout(4);

        System.out.println(": " + source.getDatabase().getSessionManager());

        Set<PFFolder> rootFolders = PFLocation.getRootDirectoriesFromDatabase(source.getDatabase());

        System.out.println(": " + source.getDatabase().getSessionManager());

        final PFFolderProxyContainer container = new PFFolderProxyContainer(rootFolders, source);

        container.setSortAlphabetic(true);
        tree.setContainerDataSource(container);
        tree.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
        tree.setItemCaptionPropertyId("Name");
        tree.setItemIconPropertyId("Icon");

        ItemClickListener treeclick;
        treeclick = new ItemClickListener() {

            @Override
            public void itemClick(final ItemClickEvent event) {

                //  Notification note = new Notification("Notificaton", event.getItemId().toString(), Notification.Type.ERROR_MESSAGE);
                // note.show(Page.getCurrent());
                PFFolderProxy proxyFolder = (PFFolderProxy) event.getItemId();
                MyUI.getPFNavigator().navigateTo(MyUI.PAGE_FOLDERVIEW + "/" + proxyFolder.getIdentifier());
            }
        };

        tree.addItemClickListener(treeclick);

        // Allow all nodes to have children
        //   .dashboard-menu-folder-wrapper
        // all these wrappers are a hacky workaround to a Vaadin CSS glitch
        CssLayout treeWrapper = new CssLayout();
        treeWrapper.setStyleName(".dashboard-menu-folder-wrapper");
        treeWrapper.addComponent(tree);
        treeWrapper.setWidth("40px");
        tree.setWidth("800px");
        tree.setStyleName(".dashboard-menu-folder-tree");

        treeLayout.addComponent(treeWrapper);
        source.Session().getSession().getTransaction().commit();
        source.getDatabase().getSessionManager().CloseSession();
    }

    return treeLayout;

}