Package com.vaadin.ui

Examples of com.vaadin.ui.Tree$TreeTargetDetails


    Layout buildTrees() {
        final GridLayout l = new GridLayout(1, 1);
        l.setMargin(true);
        l.setCaption("Trees");

        Tree tree = new Tree();
        l.addComponent(tree);
        tree.addItem("Item 1");
        tree.setItemIcon("Item 1", ICON_GLOBE);
        tree.addItem("Child 1");
        tree.setItemIcon("Child 1", ICON_GLOBE);
        tree.setParent("Child 1", "Item 1");
        tree.addItem("Child 2");
        tree.setParent("Child 2", "Item 1");
        tree.addItem("Child 3");
        tree.setChildrenAllowed("Child 3", false);
        tree.setItemIcon("Child 3", ICON_GLOBE);
        tree.setParent("Child 3", "Item 1");
        tree.addItem("Child 4");
        tree.setChildrenAllowed("Child 4", false);
        tree.setParent("Child 4", "Item 1");
        tree.addItem("Item 2");
        tree.addItem("Item 3");
        tree.setItemIcon("Item 3", ICON_GLOBE);
        tree.setChildrenAllowed("Item 3", false);
        tree.addItem("Item 4");
        tree.setChildrenAllowed("Item 4", false);

        tree.addActionHandler(handler);

        return l;
    }
View Full Code Here


    protected void setup() {

        String itemId1 = "Item 1";
        String itemId2 = "Item 2";

        Tree tree = new Tree();

        tree.addItem(itemId1);
        tree.addItem(itemId2);

        // Removing this line causes the tree to show normally in Firefox
        tree.select(itemId1);
        addComponent(tree);

    }
View Full Code Here

    @Override
    protected void setup() {
        styles = new CustomLayout(css);
        addComponent(styles);

        Tree tree = new Tree();

        tree.setItemStyleGenerator(new Tree.ItemStyleGenerator() {
            @Override
            public String getStyle(Tree source, Object itemId) {
                // simple return itemId as css style name
                return itemId.toString();
            }
        });

        tree.addItem("red");
        tree.setChildrenAllowed("red", false);
        tree.addItem("green");
        tree.addItem("green children");
        tree.setParent("green children", "green");
        tree.addItem("blue");
        tree.addItem("non-blue-childnode");
        tree.setParent("non-blue-childnode", "blue");

        addComponent(tree);
    }
View Full Code Here

        table.addItem("Row 6");
        table.addItem("Row 7");

        h.addComponent(table);

        final Tree tree = new Tree();
        tree.setDropHandler(new DropHandler() {

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return TargetItemAllowsChildren.get();
            }

            @Override
            public void drop(DragAndDropEvent dropEvent) {
                // criteria verify that this is safe
                DataBoundTransferable t = (DataBoundTransferable) dropEvent
                        .getTransferable();
                Container sourceContainer = t.getSourceContainer();
                Object sourceItemId = t.getItemId();
                System.out.println(sourceItemId);

                AbstractSelectTargetDetails dropData = ((AbstractSelectTargetDetails) dropEvent
                        .getTargetDetails());
                Object targetItemId = dropData.getItemIdOver();

                // move item from table to category'
                tree.addItem(sourceItemId);
                tree.setParent(sourceItemId, targetItemId);
                tree.setChildrenAllowed(sourceItemId, false);
                sourceContainer.removeItem(sourceItemId);

            }
        });

        tree.addItem("Item 1");
        tree.addItem("Item 11");
        tree.setChildrenAllowed("Item 11", false);
        tree.setParent("Item 11", "Item 1");
        tree.addItem("Item 12");
        tree.setChildrenAllowed("Item 12", false);
        tree.setParent("Item 12", "Item 1");
        tree.addItem("Item 13");
        tree.setChildrenAllowed("Item 13", false);
        tree.setParent("Item 13", "Item 1");

        tree.addItem("Item 2");
        tree.addItem("Item 21");
        tree.setChildrenAllowed("Item 21", false);
        tree.setParent("Item 21", "Item 2");
        tree.addItem("Item 22");
        tree.setChildrenAllowed("Item 22", false);
        tree.setParent("Item 22", "Item 2");
        tree.addItem("Item 23");
        tree.setChildrenAllowed("Item 23", false);
        tree.setParent("Item 23", "Item 2");

        tree.addItem("Item 3");
        tree.addItem("Item 31");
        tree.setChildrenAllowed("Item 31", false);
        tree.setParent("Item 31", "Item 3");
        tree.addItem("Item 32");
        tree.setChildrenAllowed("Item 32", false);
        tree.setParent("Item 32", "Item 3");
        tree.addItem("Item 33");
        tree.setChildrenAllowed("Item 33", false);
        tree.setParent("Item 33", "Item 3");

        tree.expandItemsRecursively("Item 1");
        tree.expandItemsRecursively("Item 2");
        tree.expandItemsRecursively("Item 3");

        h.addComponent(tree);
    }
View Full Code Here

        // Actions for the context menu
        final Action ACTION_ADD = new Action("Add child item");
        final Action ACTION_DELETE = new Action("Delete");
        final Action[] ACTIONS = new Action[] { ACTION_ADD, ACTION_DELETE };

        final Tree tree = new Tree();
        tree.setId("tree" + debugIdCounter++);

        HierarchicalContainer hc = createHierarchicalContainer();

        tree.setContainerDataSource(hc);

        tree.addActionHandler(new Action.Handler() {

            @Override
            public void handleAction(Action action, Object sender, Object target) {
                // We don't care about functionality, we just want the UI for
                // testing..

            }

            @Override
            public Action[] getActions(Object target, Object sender) {
                // TODO Auto-generated method stub
                return ACTIONS;
            }
        });

        // Expand whole tree
        for (Object id : tree.rootItemIds()) {
            tree.expandItemsRecursively(id);
        }

        parent.addComponent(tree);
    }
View Full Code Here

        sort(indexedContainer);
        sort(hierarchicalContainer);

        HorizontalLayout hl = new HorizontalLayout();

        Tree tree1 = new Tree("Tree with IndexedContainer");
        tree1.setContainerDataSource(indexedContainer);
        tree1.setItemCaptionPropertyId("name");
        hl.addComponent(tree1);

        Tree tree2 = new Tree("Tree with HierarchicalContainer");
        tree2.setContainerDataSource(hierarchicalContainer);
        tree2.setItemCaptionPropertyId("name");
        for (Object id : tree2.rootItemIds()) {
            tree2.expandItemsRecursively(id);
        }
        hl.addComponent(tree2);

        addComponent(hl);
    }
View Full Code Here

public class TreeKeyboardNavigationScrolls extends TestBase {

    @Override
    protected void setup() {
        Tree tree = new Tree();
        tree.setContainerDataSource(generateHierarchicalContainer());
        tree.setImmediate(true);
        tree.addValidator(new AlwaysFailValidator("failed"));
        addComponent(tree);
    }
View Full Code Here

            super("Tree here");

            String itemId1 = "Item 1";
            String itemId2 = "Item 2";

            Tree tree = new Tree();

            tree.addItem(itemId1);
            tree.addItem(itemId2);

            // todo error here
            tree.select(itemId1);

            addComponent(tree);
        }
View Full Code Here

        Panel panel1 = new Panel("This should not be seen");
        panel1.setSizeFull();
        VerticalLayout verticalLayout1 = new VerticalLayout();
        verticalLayout1.setSizeFull();
        Tree tree = new Tree();
        tree.setSizeFull();
        tree.setContainerDataSource(new BeanItemContainer<String>(String.class));
        String a = "aaaaaaaaaaaaaaaaaaaaaaaa";
        String b = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
        String c = "ccccccccccccccccccccccccccccccccccccccccccccccccc";
        tree.addItem(a);
        tree.addItem(b);
        tree.addItem(c);
        tree.setChildrenAllowed(a, true);
        tree.setChildrenAllowed(b, true);
        tree.setParent(b, a);
        tree.setParent(c, b);
        verticalLayout1.addComponent(tree);
        panel1.setContent(verticalLayout1);
        layout.addComponent(panel1);

        final Panel panel2 = new Panel("This should use all space");
View Full Code Here

                layout.addComponent(newlayout);
            }
            layout = newlayout;
        }

        Tree tree = new Tree();

        for (int i = 0; i < getItemCount(); i++) {
            String text = "ITEM " + i;
            tree.addItem(text);
            for (int j = 0; j < getSubItemCount(); j++) {
                String subtext = " SUBITEM " + j + " for " + text;
                tree.addItem(subtext);
                tree.setParent(subtext, text);
            }
            tree.expandItemsRecursively(text);
        }

        // One can test that the slugginesh is actually verticallayout issue
        // Table testTable = TestForTablesInitialColumnWidthLogicRendering
        // .getTestTable(12, 60);
View Full Code Here

TOP

Related Classes of com.vaadin.ui.Tree$TreeTargetDetails

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.