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(String caption, HierarchicalDataProvider<T, ?> dataProvider) 

Source Link

Document

Constructs a new Tree Component with given caption and HierarchicalDataProvider .

Usage

From source file:com.cavisson.gui.dashboard.components.charts.model.CreateTree.java

public CreateTree() {
    setSpacing(true);//from  w w w  .  ja v a2 s .c om
    tree = new Tree("Hardware Inventory", new HierarchicalContainer());
    tree.setMultiSelect(true);
    tree.setImmediate(true);
    tree.addListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            Tree t = (Tree) event.getProperty();
            deleteButton.setEnabled(t.getValue() != null && ((Set<?>) t.getValue()).size() > 0);
        }
    });

    // Add Actionhandler
    tree.addActionHandler(this);

    // Set tree to show the 'name' property as caption for items
    tree.setItemCaptionPropertyId("");
    tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);

    // Expand whole tree
    for (Iterator<?> it = tree.rootItemIds().iterator(); it.hasNext();) {
        tree.expandItemsRecursively(it.next());
    }

    // Create the 'delete button', inline click-listener
    deleteButton = new Button("Delete", new Button.ClickListener() {
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            // Delete all the selected objects
            Object[] toDelete = ((Set<Object>) tree.getValue()).toArray();
            for (int i = 0; i < toDelete.length; i++) {
                handleAction(ACTION_DELETE, tree, toDelete[i]);
            }
        }
    });
    deleteButton.setEnabled(false);

    addComponent(deleteButton);
    addComponent(tree);

}

From source file:com.parship.roperty.ui.WorkBenchSplitViewUI.java

License:Apache License

@AutoGenerated
private AbsoluteLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new AbsoluteLayout();
    mainLayout.setImmediate(false);//from  w w w.  j  ava 2 s .  c  om
    mainLayout.setWidth("100%");
    mainLayout.setHeight("100%");

    // top-level component properties
    setWidth("100.0%");
    setHeight("100.0%");

    // splitPanel
    splitPanel = new HorizontalSplitPanel();
    splitPanel.setImmediate(false);
    splitPanel.setWidth("100.0%");
    splitPanel.setHeight("100.0%");
    mainLayout.addComponent(splitPanel, "top:0.0px;right:0.0px;bottom:0.0px;left:0.0px;");

    Roperty r = new Roperty();
    r.set("/key1", "value_1", "desc");
    r.set("/key1/subkey1", "value_1_1", "desc");
    r.set("/key1/subkey2", "value_1_2", "desc");
    r.set("/key1/subkey2/subsub1", "value_1_2_1", "desc");
    r.set("/key1/subkey2/subsub2", "value_1_2_2", "desc");
    r.set("/key1/subkey2/subsub2/subsubsub1", "value_1_2_2_1", "desc");
    r.set("/key2", "value_2", "desc");
    r.set("/key2/subkey1", "value_1_1", "desc");
    r.set("/key2/subkey2", "value_1_2", "desc");
    r.set("plain", "plainValue", "desc");
    r.set("plain/plainsub1", "plainValue_1", "desc");
    r.set("plain/plainsub2", "plainValue_2", "desc");
    r.set("plain/plainsub3", "plainValue_3", "desc");
    Tree tree = new Tree("Properties", new RopertyPropertyTreeContainer(r));
    splitPanel.setFirstComponent(tree);

    return mainLayout;
}

From source file:org.lunifera.example.vaadin.osgi.jpacontainer.AddressBookMainView.java

License:Apache License

@SuppressWarnings("deprecation")
private void buildTree() {
    groupTree = new Tree(null, departments);
    groupTree.setItemCaptionPropertyId("name");

    groupTree.setImmediate(true);//from  w ww  . java  2  s . com
    groupTree.setSelectable(true);
    groupTree.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            Object id = event.getProperty().getValue();
            if (id != null) {
                Department entity = departments.getItem(id).getEntity();
                departmentFilter = entity;
            } else if (departmentFilter != null) {
                departmentFilter = null;
            }
            updateFilters();
        }

    });
    setFirstComponent(groupTree);
}

From source file:pl.alburnus.testcaseapp.AddressBookMainView.java

License:Apache License

private void buildTree() {
    groupTree = new Tree(null, departments);
    groupTree.setItemCaptionPropertyId("name");

    groupTree.setImmediate(true);//from   w  w  w .j  a  v a2s.  c  o  m
    groupTree.setSelectable(true);
    groupTree.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            Object id = event.getProperty().getValue();
            if (id != null) {
                Department entity = departments.getItem(id).getEntity();
                departmentFilter = entity;
            } else if (departmentFilter != null) {
                departmentFilter = null;
            }
            updateFilters();
        }

    });
    setFirstComponent(groupTree);
}

From source file:pl.exsio.frameset.vaadin.module.management.frames.FramesTree.java

License:Open Source License

private JPAContainer<Frame> initTree() {
    final JPAContainer<Frame> frames = this.createContainer();

    frames.setParentProperty("parent");
    this.tree = new Tree("", frames);

    this.tree.setItemCaptionMode(Tree.ItemCaptionMode.EXPLICIT);
    this.tree.setStyleName("frameset-frames-tree");
    for (Object itemId : frames.getItemIds()) {
        this.tree.setItemCaption(itemId, t(frames.getItem(itemId).getEntity().getTitle()));
        this.tree.setItemIcon(itemId, FontAwesome.TABLET);

    }// www.j  av  a2  s  .  c  om
    if (this.security.canAdminister()) {
        this.tree.setDragMode(Tree.TreeDragMode.NODE);
        this.setTreeDropHandler(frames);
    }
    for (Object rootId : frames.rootItemIds()) {
        this.tree.expandItemsRecursively(rootId);
    }
    return frames;
}

From source file:uk.co.onehp.trickle.ui.BetView.java

License:Open Source License

private void buildView() {
    this.mainLayout = new HorizontalLayout();
    this.mainLayout.setSpacing(true);
    this.mainLayout.setMargin(true);

    this.formSection = new VerticalLayout();
    this.formSection.setSpacing(true);

    this.incompleteBetsSection = new VerticalLayout();
    this.incompleteBetsSection.setSpacing(true);

    this.completeBetsSection = new VerticalLayout();
    this.completeBetsSection.setSpacing(true);

    this.meetingsTreePanel = new Panel();
    this.meetingsTreePanel.setHeight("350px");

    this.completeBetsTreePanel = new Panel();
    this.completeBetsTreePanel.setHeight("350px");

    this.meetingsTree = new Tree("Races", createTreeContainerFromMeetings());

    this.completeBetsTree = new Tree("Complete Bets", createTreeContainerFromCompleteBets());

    this.strategy = new ComboBox("Strategy", createDropdownContainerFromStrategies());

    this.incompleteBetsTable = new Table("Bets", createTableContainerFromIncompleteBets());
    this.incompleteBetsTable.setSelectable(true);
    this.incompleteBetsTable.setVisibleColumns(INCOMPLETE_BETS_COLUMNS);
    this.incompleteBetsTable.setWidth("100%");
    this.incompleteBetsTable.setHeight("350px");

    this.saveBetButton = new Button("Save Bet", this.saveBetListener);
    this.saveBetButton.setStyleName(BaseTheme.BUTTON_LINK);

    this.deleteBetButton = new Button("Delete Bet", this.deleteBetListener);
    this.deleteBetButton.setStyleName(BaseTheme.BUTTON_LINK);

    this.clearAllBetsButton = new Button("Clear All Bets", this.clearAllBetsListener);
    this.clearAllBetsButton.setStyleName(BaseTheme.BUTTON_LINK);

    this.meetingsTreePanel.addComponent(this.meetingsTree);

    this.completeBetsTreePanel.addComponent(this.completeBetsTree);

    setupFormFields();/*  w  ww. j  ava2  s .c  om*/

    this.formSection.addComponent(this.formTitle);
    this.formSection.addComponent(this.meetingsTreePanel);
    this.formSection.addComponent(this.strategy);
    this.formSection.addComponent(this.saveBetButton);

    this.incompleteBetsSection.addComponent(this.incompleteBetsTable);
    this.incompleteBetsSection.addComponent(this.deleteBetButton);
    this.incompleteBetsSection.addComponent(this.clearAllBetsButton);

    this.completeBetsSection.addComponent(this.completeBetsTreePanel);

    this.mainLayout.addComponent(this.incompleteBetsSection);
    this.mainLayout.addComponent(this.formSection);
    this.mainLayout.addComponent(this.completeBetsSection);

}