Package com.vaadin.ui

Examples of com.vaadin.ui.Tree$ExpandListener


public class TreeFiltering extends TestBase {

    @Override
    public void setup() {

        final Tree ccTree = new Tree();
        addComponent(ccTree);
        final HierarchicalContainer cont = new HierarchicalContainer();
        cont.addContainerProperty("caption", String.class, "");

        Item item;
        for (int i = 0; i < 5; i++) {
            item = cont.addItem(i);
            item.getItemProperty("caption").setValue("Number " + i);
            cont.setParent(i, i - 1);
        }

        for (int i = 0; i < 5; i++) {
            Object id = cont.addItem();
            item = cont.getItem(id);
            item.getItemProperty("caption").setValue("0-" + i);
            cont.setParent(id, 0);
        }

        ccTree.setContainerDataSource(cont);
        ccTree.setItemCaptionPropertyId("caption");

        for (final Object o : ccTree.getItemIds()) {
            ccTree.expandItem(o);
        }

        final CheckBox filterType = new CheckBox(
                "Include parent when filtering", true);
        filterType.setImmediate(true);
        filterType.addListener(new ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                cont.setIncludeParentsWhenFiltering(((CheckBox) event
                        .getProperty()).getValue());
                ccTree.markAsDirty();
            }
        });
        addComponent(filterType);

        final Button b = new Button("Add filter 'foo'", new ClickListener() {
View Full Code Here


        }

        HorizontalLayout hl = new HorizontalLayout();
        hl.setWidth("100%");

        tree = new Tree();
        tree.setImmediate(true);
        hl.addComponent(tree);
        HorizontalLayout state = new HorizontalLayout();
        state.setSpacing(true);
        hl.addComponent(state);
View Full Code Here

        Panel treePanel = new Panel(treeLayout);
        treePanel.setHeight("500px");
        treePanel.setWidth(null);
        addComponent(treePanel);

        Tree tree = new Tree();
        tree.setContainerDataSource(getHardwareContainer());
        tree.setItemCaptionPropertyId(hw_PROPERTY_NAME);
        for (Iterator<?> it = tree.rootItemIds().iterator(); it.hasNext();) {
            tree.expandItemsRecursively(it.next());
        }
        treeLayout.addComponent(tree);
    }
View Full Code Here

    protected static final String MENU_ITEM_TEMPLATE = "Menu Item %d";

    @Override
    protected void setup(VaadinRequest request) {
        Tree tree = new Tree("With ItemClickListener not Immediate");
        tree.setId(TREE_ID);
        tree.setImmediate(false);

        for (int i = 1; i <= 4; i++) {
            tree.addItem(String.format(MENU_ITEM_TEMPLATE, i));
        }

        tree.addItemClickListener(new ItemClickEvent.ItemClickListener() {

            @Override
            public void itemClick(ItemClickEvent event) {
                log("ItemClickEvent = " + event.getItemId());
            }
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

            public void valueChange(ValueChangeEvent event) {
                log.log("TF value now:" + event.getProperty().getValue());
            }
        });

        Tree tree = new Tree("Simple selectable tree (immediate)");
        tree.addItem("Item1");
        addComponent(tree);
        tree.addListener(new Property.ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                log.log("Tree value now:" + event.getProperty().getValue());
            }
        });
        tree.setImmediate(true);

        tree = new Tree("Simple tree with itemm click listener");
        tree.addItem("Item1");
        tree.addListener(new ItemClickEvent.ItemClickListener() {
            @Override
            public void itemClick(ItemClickEvent event) {
                log.log("Item click event");
            }
        });
View Full Code Here

public class TreeToolTips extends TestBase {

    @Override
    protected void setup() {
        final Tree tree = new Tree(null, createContainer());
        tree.setItemDescriptionGenerator(new AbstractSelect.ItemDescriptionGenerator() {
            @Override
            public String generateDescription(Component source, Object itemId,
                    Object propertyId) {
                return "This is a tooltip for item id '" + itemId + "'";
            }
        });

        for (Object rootItems : tree.rootItemIds()) {
            tree.expandItemsRecursively(rootItems);
        }

        addComponent(tree);
    }
View Full Code Here

        addComponent(cb);
        addComponent(tree);
    }

    private Tree createTree() {
        final Tree tree = new Tree(null, createContainer());
        tree.setWidth("300px");
        for (Object rootItems : tree.rootItemIds()) {
            tree.expandItemsRecursively(rootItems);
        }
        tree.setChildrenAllowed("Item 73", false);

        tree.setDragMode(TreeDragMode.NODE);
        tree.setDropHandler(new DropHandler() {

            @Override
            public void drop(DragAndDropEvent event) {
                // TODO Auto-generated method stub

            }

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

        });

        tree.setItemIcon("Item 1", new ThemeResource(
                "../runo/icons/32/folder.png"));
        tree.setItemIcon("Item 3", new ThemeResource(
                "../runo/icons/32/document.png"));
        tree.setItemIcon("Item 13", new ThemeResource(
                "../runo/icons/64/user.png"));
        tree.setItemIcon("Item 72", new ThemeResource(
                "../runo/icons/64/users.png"));
        tree.setItemIcon("Item 17", new ThemeResource(
                "../runo/icons/16/document-pdf.png"));

        return tree;
    }
View Full Code Here

public class TreeItemDoubleClick extends AbstractTestUIWithLog {

    @Override
    protected void setup(VaadinRequest request) {
        final Tree tree = new Tree("Immediate With ItemClickListener");
        tree.setImmediate(true);
        tree.setNullSelectionAllowed(false);

        for (int i = 1; i < 6; i++) {
            tree.addItem("Tree Item " + i);
        }

        ItemClickEvent.ItemClickListener listener = new ItemClickEvent.ItemClickListener() {
            @Override
            public void itemClick(ItemClickEvent event) {
                if (event.isDoubleClick()) {
                    log.log("Double Click " + event.getItemId());
                }
            }
        };

        tree.addItemClickListener(listener);

        addComponent(tree);

        addButton("Change immediate flag", new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                // this wouldn't work if tree had a value change listener
                tree.setImmediate(!tree.isImmediate());
                log.log("tree.isImmediate() is now " + tree.isImmediate());
            }

        });

    }
View Full Code Here

        LegacyWindow w = new LegacyWindow("", layout);
        setMainWindow(w);

        TextField filler1 = new TextField();
        RichTextArea filler2 = new RichTextArea();
        Tree tree = new Tree();
        for (int i = 0; i < 20; i++) {
            String parentId = "Item " + i;
            // Item parentItem =
            tree.addItem(parentId);
            for (int j = 0; j < 20; j++) {
                String subId = "Item " + i + " - " + j;
                // Item subItem =
                tree.addItem(subId);
                tree.setParent(subId, parentId);
            }

        }

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

        layout.addComponent(filler1);
        layout.addComponent(filler2);
        layout.addComponent(tree);
View Full Code Here

TOP

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

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.