Example usage for javafx.scene.control TreeItem setExpanded

List of usage examples for javafx.scene.control TreeItem setExpanded

Introduction

In this page you can find the example usage for javafx.scene.control TreeItem setExpanded.

Prototype

public final void setExpanded(boolean value) 

Source Link

Document

Sets the expanded state of this TreeItem.

Usage

From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeTableOperationContext.java

@Override
public void expandNode(final Object node) {
    scrollNodeToVisible(node);// ww w. j av  a 2 s. c  o  m
    Object result = EventThreadQueuerJavaFXImpl.invokeAndWait("expandNode", //$NON-NLS-1$
            new Callable<Object>() {

                @Override
                public Object call() throws Exception {
                    TreeItem<?> item = (TreeItem<?>) node;
                    TreeTableView<?> treeTable = getTree();
                    List<TreeTableCell> cells = new NodeTraverseHelper<TreeTableCell>()
                            .getInstancesOf(treeTable, TreeTableCell.class);
                    for (TreeTableCell<?, ?> treeTableCell : cells) {
                        // Nullchecks because of the virtual flow cells
                        // are created which might not be associated
                        // with a row or an item
                        TreeTableRow<?> ttRow = treeTableCell.getTreeTableRow();
                        if (ttRow == null) {
                            continue;
                        }
                        TreeItem<?> checkItem = ttRow.getTreeItem();
                        if (checkItem == null) {
                            continue;
                        }
                        if (item != null && checkItem.equals(item) && !item.isExpanded()) {
                            return treeTableCell.getTreeTableRow().getDisclosureNode();
                        }
                    }
                    return null;
                }

            });
    if (result != null) {
        getRobot().click(result, null, ClickOptions.create().setClickCount(1).setMouseButton(1));
    }
    EventThreadQueuerJavaFXImpl.invokeAndWait("expandNodeCheckIfExpanded", //$NON-NLS-1$
            new Callable<Void>() {

                @Override
                public Void call() throws Exception {
                    TreeItem<?> item = (TreeItem<?>) node;
                    if (!getTree().isDisabled() && !item.isExpanded()) {
                        log.warn("Expand node fallback used for: " //$NON-NLS-1$
                                + item.getValue());
                        item.setExpanded(true);
                    }
                    return null;
                }
            });
}

From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeTableOperationContext.java

@Override
public void collapseNode(final Object node) {
    scrollNodeToVisible(node);/* w w w  .ja  v a 2  s.  c  om*/
    Object result = EventThreadQueuerJavaFXImpl.invokeAndWait("collapseNode", //$NON-NLS-1$
            new Callable<Object>() {

                @Override
                public Object call() throws Exception {
                    TreeItem<?> item = (TreeItem<?>) node;
                    TreeTableView<?> treeTable = getTree();
                    List<TreeTableCell> cells = new NodeTraverseHelper<TreeTableCell>()
                            .getInstancesOf(treeTable, TreeTableCell.class);
                    for (TreeTableCell<?, ?> treeTableCell : cells) {
                        // Nullchecks because of the virtual flow cells
                        // are created which might not be associated
                        // with a row or an item
                        TreeTableRow<?> ttRow = treeTableCell.getTreeTableRow();
                        if (ttRow == null) {
                            continue;
                        }
                        TreeItem<?> checkItem = ttRow.getTreeItem();
                        if (checkItem == null) {
                            continue;
                        }
                        if (item != null && checkItem.equals(item) && item.isExpanded()) {
                            return treeTableCell.getTreeTableRow().getDisclosureNode();
                        }
                    }
                    return null;
                }

            });
    if (result != null) {
        getRobot().click(result, null, ClickOptions.create().setClickCount(1).setMouseButton(1));
    }
    EventThreadQueuerJavaFXImpl.invokeAndWait("collapseNodeCheckIfExpanded", //$NON-NLS-1$
            new Callable<Void>() {

                @Override
                public Void call() throws Exception {
                    TreeItem<?> item = (TreeItem<?>) node;
                    if (!getTree().isDisabled() && item.isExpanded()) {
                        log.warn("Expand node fallback used for: " //$NON-NLS-1$
                                + item.getValue());

                        item.setExpanded(true);
                    }
                    return null;
                }
            });
}