Example usage for com.vaadin.ui Tree isExpanded

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

Introduction

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

Prototype

public boolean isExpanded(T item) 

Source Link

Document

Returns whether a given item is expanded or collapsed.

Usage

From source file:org.lucidj.containertree.ContainerTreeRenderer.java

License:Apache License

@Override // ItemClickEvent.ItemClickListener
public void itemClick(ItemClickEvent itemClickEvent) {
    // There's no need to bubble-up the event since the foreign
    // listeners are already attached directly to this component
    // via bypass. We only need to do local housekeeping.

    if (itemClickEvent.isDoubleClick() && itemClickEvent.getSource() instanceof Tree) {
        // Handles directory expand/contract automatically
        Tree tree = (Tree) itemClickEvent.getSource();
        Object item_id = itemClickEvent.getItemId();

        if (tree.isExpanded(item_id)) {
            tree.collapseItem(item_id);/*from w  w w.ja  v a2  s.  c  o  m*/
        } else {
            tree.expandItem(item_id);
        }
    }
}

From source file:org.lucidj.explorer.ExplorerView.java

License:Apache License

@Override // ItemClickEvent.ItemClickListener
public void itemClick(ItemClickEvent itemClickEvent) {
    // FilesystemContainer uses File as item id
    File item_id = ((File) itemClickEvent.getItemId());
    String item_path = userdir.relativize(item_id.toPath()).toString();

    if (item_id.getName().toLowerCase().endsWith(".leap")) {
        log.info("OPEN item_path={}", item_id.toPath().toString());

        try {//from   w  w w.  ja v  a  2 s  . co m
            String view_name = OpenView.NAVID + '/' + item_path;

            Map<String, Object> properties = new HashMap<>();
            properties.put(OpenView.ARTIFACT_URL, item_id.toURI().toString());

            navigatorManager.navigateTo(view_name, properties);
        } catch (Exception e) {
            log.error("Exception deploying artifact", e);
            //show message
        }
    } else if (item_id.isDirectory()) {
        // Open/close directory
        if (itemClickEvent.getSource() instanceof Tree) {
            Tree tree = (Tree) itemClickEvent.getSource();

            if (tree.isExpanded(item_id)) {
                tree.collapseItem(item_id);
            } else {
                tree.expandItem(item_id);
            }
        }
    } else {
        // Get item relative path
        log.info("CLICK item_path={}", item_path);
    }
}

From source file:org.lucidj.pathrenderer.PathRenderer.java

License:Apache License

@Override // ItemClickEvent.ItemClickListener
public void itemClick(ItemClickEvent itemClickEvent) {
    // There's no need to bubble-up the event since the foreign
    // listeners are already attached directly to this component
    // via bypass. We only need to do local housekeeping.

    if (itemClickEvent.isDoubleClick() && itemClickEvent.getSource() instanceof Tree) {
        // Handles directory expand/contract automatically
        Tree tree = (Tree) itemClickEvent.getSource();
        File item_id = ((File) itemClickEvent.getItemId());

        if (tree.isExpanded(item_id)) {
            tree.collapseItem(item_id);//from w  w  w.  ja  v a 2 s  .c o m
        } else {
            tree.expandItem(item_id);
        }
    }
}

From source file:org.ripla.web.demo.widgets.views.TreeWidgetsView.java

License:Open Source License

/**
 * @param inCountryContainer/*from www.  ja  va2  s  .c o m*/
 */
public TreeWidgetsView(final CountryTree inCountries) {
    super();

    final IMessages lMessages = Activator.getMessages();
    final VerticalLayout lLayout = initLayout(lMessages, "widgets.title.page.tree"); //$NON-NLS-1$

    final Tree lTree = new Tree(lMessages.getMessage("widgets.view.tree.title")); //$NON-NLS-1$
    lTree.setContainerDataSource(inCountries);
    lTree.setImmediate(true);
    lTree.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(final ItemClickEvent inEvent) {
            final Object lItem = inEvent.getItemId();
            if (lItem instanceof CountryBean) {
                Popup.displayPopup(lMessages.getMessage("widgets.view.tree.popup"), //$NON-NLS-1$
                        createCountryPopup((CountryBean) lItem), 260, 685);
            } else {
                if (lTree.isExpanded(lItem)) {
                    lTree.collapseItem(lItem);
                } else {
                    lTree.expandItem(lItem);
                }
            }
        }
    });

    lLayout.addComponent(lTree);
}