Example usage for com.vaadin.ui Tree Tree

List of usage examples for com.vaadin.ui Tree Tree

Introduction

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

Prototype

public Tree() 

Source Link

Document

Constructs a new Tree Component.

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 ww w. ja  v  a 2 s  .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;

}

From source file:com.zklogtool.web.components.SnapshotView.java

License:Apache License

@AutoGenerated
private VerticalLayout buildVerticalLayout_1() {
    // common part: create layout
    verticalLayout_1 = new VerticalLayout();
    verticalLayout_1.setImmediate(false);
    verticalLayout_1.setWidth("100.0%");
    verticalLayout_1.setHeight("-1px");
    verticalLayout_1.setMargin(true);// w ww.j a v  a2s  .c om
    verticalLayout_1.setSpacing(true);

    // label_4
    label_4 = new Label();
    label_4.setImmediate(false);
    label_4.setWidth("-1px");
    label_4.setHeight("-1px");
    label_4.setValue("Data Tree:");
    verticalLayout_1.addComponent(label_4);

    // dataTree
    dataTree = new Tree();
    dataTree.setImmediate(false);
    dataTree.setWidth("-1px");
    dataTree.setHeight("-1px");
    verticalLayout_1.addComponent(dataTree);

    // label_5
    label_5 = new Label();
    label_5.setImmediate(false);
    label_5.setWidth("-1px");
    label_5.setHeight("-1px");
    label_5.setValue("Sessions:");
    verticalLayout_1.addComponent(label_5);

    // sessionTree
    sessionTree = new Tree();
    sessionTree.setImmediate(false);
    sessionTree.setWidth("-1px");
    sessionTree.setHeight("-1px");
    verticalLayout_1.addComponent(sessionTree);

    return verticalLayout_1;
}

From source file:de.catma.ui.analyzer.AnalyzerView.java

License:Open Source License

private Component createDocumentsPanel() {
    Panel documentsPanel = new Panel();

    documentsContainer = new HierarchicalContainer();
    documentsTree = new Tree();
    documentsTree.setContainerDataSource(documentsContainer);
    documentsTree.setCaption("Documents and collections constraining this search");

    if (corpus != null) {
        for (SourceDocument sd : corpus.getSourceDocuments()) {
            addSourceDocument(sd);//from  ww w.  j  a v  a  2 s. com
        }
    } else {
        documentsTree.addItem("All documents");
    }

    documentsPanel.addComponent(documentsTree);
    return documentsPanel;
}

From source file:de.catma.ui.analyzer.querybuilder.TagPanel.java

License:Open Source License

private Component createTagLibraryTreePanel() {

    Panel tagLibraryPanel = new Panel();
    tagLibraryPanel.getContent().setSizeUndefined();
    tagLibraryPanel.setSizeFull();//from   www.  ja  v  a  2  s .  c  om

    tagLibrariesTree = new Tree();
    tagLibrariesTree.setCaption("Tag Libraries");
    tagLibrariesTree.addStyleName("bold-label-caption");
    tagLibrariesTree.setImmediate(true);
    tagLibrariesTree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_ID);

    for (TagLibraryReference tlr : queryOptions.getRepository().getTagLibraryReferences()) {
        addTagLibraryReferenceToTree(tlr);
    }

    tagLibraryPanel.addComponent(tagLibrariesTree);

    return tagLibraryPanel;
}

From source file:de.catma.ui.repository.CorpusPanel.java

License:Open Source License

private Component createCorporaPanel() {
    Panel corporaPanel = new Panel();
    corporaPanel.getContent().setSizeUndefined();
    corporaPanel.setSizeFull();/*from w  w w.j av  a  2  s. c  om*/

    corporaContainer = new HierarchicalContainer();
    corporaTree = new Tree();
    corporaTree.setContainerDataSource(corporaContainer);

    corporaTree.addStyleName("bold-label-caption");
    corporaTree.setCaption("Corpora");
    corporaTree.addItem(allDocuments);
    corporaTree.setChildrenAllowed(allDocuments, false);
    corporaTree.setImmediate(true);

    corporaContainer.addContainerProperty(SORTCAP_PROP, String.class, null);

    for (Corpus c : repository.getCorpora()) {
        addCorpusToTree(c);
    }
    corporaContainer.sort(new Object[] { SORTCAP_PROP }, new boolean[] { true });

    corporaTree.setValue(allDocuments);

    corporaPanel.addComponent(corporaTree);

    return corporaPanel;
}

From source file:de.catma.ui.repository.SourceDocumentPanel.java

License:Open Source License

private Component createDocumentsPanel() {

    Panel documentsPanel = new Panel();

    documentsContainer = new HierarchicalContainer();
    documentsTree = new Tree();
    documentsTree.setContainerDataSource(documentsContainer);
    documentsTree.setCaption("Documents");
    documentsTree.addStyleName("bold-label-caption");
    documentsTree.setImmediate(true);// w ww  .ja  v a 2s. c o m
    documentsTree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_ID);
    documentsTree.setDragMode(TreeDragMode.NODE);

    documentsPanel.addComponent(documentsTree);
    documentsPanel.getContent().setSizeUndefined();
    documentsPanel.setSizeFull();

    documentsContainer.addContainerProperty(SORTCAP_PROP, String.class, null);

    for (SourceDocument sd : repository.getSourceDocuments()) {
        addSourceDocumentToTree(sd);
    }

    documentsContainer.sort(new Object[] { SORTCAP_PROP }, new boolean[] { true });

    return documentsPanel;
}

From source file:de.catma.ui.repository.TagLibraryPanel.java

License:Open Source License

private Component createTagLibraryTreePanel() {

    Panel tagLibraryPanel = new Panel();
    tagLibraryPanel.getContent().setSizeUndefined();
    tagLibraryPanel.setSizeFull();//from ww w .  j  a v a 2  s.c  o  m

    tagLibraryContainer = new HierarchicalContainer();

    tagLibrariesTree = new Tree();
    tagLibrariesTree.setContainerDataSource(tagLibraryContainer);

    tagLibrariesTree.setCaption("Tag Libraries");
    tagLibrariesTree.addStyleName("bold-label-caption");
    tagLibrariesTree.setImmediate(true);
    tagLibrariesTree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_ID);

    tagLibraryContainer.addContainerProperty(SORTCAP_PROP, String.class, null);

    for (TagLibraryReference tlr : repository.getTagLibraryReferences()) {
        addTagLibraryReferenceToTree(tlr);
    }
    tagLibraryContainer.sort(new Object[] { SORTCAP_PROP }, new boolean[] { true });

    tagLibraryPanel.addComponent(tagLibrariesTree);

    return tagLibraryPanel;
}

From source file:de.fzi.fhemapi.view.vaadin.ui.HWindow.java

License:Apache License

private void fillTree() {

    initDevicesContainer();/*from  w  w  w .  j  ava2s  .  c o m*/
    devicesTree.setContainerDataSource(devicesContainer);
    for (Object id : devicesTree.rootItemIds()) {
        devicesTree.expandItemsRecursively(id);
    }

    devicesTree.setImmediate(true);
    devicesTree.addListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.getButton() == ItemClickEvent.BUTTON_LEFT) {
                if (!server.getStructureManager().structureExists((String) event.getItemId())) {
                    fillRightSideForDevice((String) event.getItemId());
                } else {
                    mainSplitPanel.setSecondComponent(new Tree());
                }
            }
        }
    });
    devicesTree.setDragMode(TreeDragMode.NODE);
    devicesTree.setDropHandler(new DropHandler() {

        @Override
        public AcceptCriterion getAcceptCriterion() {
            //            AcceptCriterion crit = new ClientSideCriterion() {
            //               
            //               @Override
            //               public boolean accept(DragAndDropEvent dragEvent) {
            //                    Transferable t = dragEvent.getTransferable();
            //                  TreeTargetDetails target = (TreeTargetDetails) dragEvent.getTargetDetails();
            //                  Object sourceItemId = t.getData("itemId");
            //                    Object targetItemId = target.getItemIdOver();
            //                    if(devicesContainer.getParent(sourceItemId) == null)
            //                       return false;
            //                    return true;
            //               }
            //            };
            //            return crit;
            return AcceptAll.get();
        }

        @Override
        public void drop(DragAndDropEvent event) {
            Transferable t = event.getTransferable();
            if (t.getSourceComponent() != devicesTree)
                return;
            TreeTargetDetails target = (TreeTargetDetails) event.getTargetDetails();
            Object sourceItemId = t.getData("itemId");
            Object targetItemId = target.getItemIdOver();
            VerticalDropLocation location = target.getDropLocation();
            HierarchicalContainer container = (HierarchicalContainer) devicesTree.getContainerDataSource();

            // Drop right on an item -> make it a child
            if (location == VerticalDropLocation.MIDDLE) {
                if (container.getParent(targetItemId) == null) {
                    server.getStructureManager().addDeviceToStructure((String) targetItemId,
                            (String) sourceItemId);
                } else {
                    server.getStructureManager().addDeviceToStructure(
                            (String) container.getParent(targetItemId), (String) sourceItemId);
                }
                server.getStructureManager().rereadFromFHEM();
                reloadTree();
            }
        }
    });

}

From source file:de.fzi.fhemapi.view.vaadin.ui.HWindow.java

License:Apache License

@AutoGenerated
private HorizontalSplitPanel buildHorizontalSplitPanel_2() {
    // common part: create layout
    mainSplitPanel = new HorizontalSplitPanel();
    mainSplitPanel.setImmediate(false);/*from  w  w  w.  j  a  va2s. c  om*/
    mainSplitPanel.setWidth("100.0%");
    mainSplitPanel.setHeight("100.0%");
    mainSplitPanel.setMargin(false);

    VerticalLayout leftPanelLayout = new VerticalLayout();
    leftPanelLayout.setWidth("100%");
    leftPanelLayout.setHeight("-1");
    leftPanelLayout.setImmediate(false);
    mainSplitPanel.addComponent(leftPanelLayout);

    leftPanelLayout.addComponent(buildMenuBar());

    // devicesTree
    devicesTree = new Tree();
    devicesTree.setImmediate(false);
    devicesTree.setWidth("-1px");
    devicesTree.setHeight("-1px");
    leftPanelLayout.addComponent(devicesTree);

    // verticalLayout_1
    mainSplitPanel.addComponent(new HorizontalLayout());

    return mainSplitPanel;
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

Layout getTreePreviews() {
    Layout grid = getPreviewLayout("Trees");
    tree = new Tree();
    tree.setImmediate(true);//from   w  ww.  j a va 2 s  .  c  o  m
    // we'll use a property for caption instead of the item id ("value"),
    // so that multiple items can have the same caption
    tree.addContainerProperty("caption", String.class, "");
    tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
    tree.setItemCaptionPropertyId("caption");
    for (int i = 1; i <= 3; i++) {
        final Object id = addCaptionedItem("Division " + i, null);
        tree.expandItem(id);
        addCaptionedItem("Team A", id);
        addCaptionedItem("Team B", id);
        tree.setItemIcon(id, new ThemeResource("../runo/icons/16/folder.png"));
    }
    grid.addComponent(tree);
    return grid;
}