Example usage for javafx.scene.control TreeCell getDisclosureNode

List of usage examples for javafx.scene.control TreeCell getDisclosureNode

Introduction

In this page you can find the example usage for javafx.scene.control TreeCell getDisclosureNode.

Prototype

public final Node getDisclosureNode() 

Source Link

Document

Returns the current disclosure node set in this TreeCell.

Usage

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

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

                @Override
                public Object call() throws Exception {
                    List<? extends TreeCell> tCells = ComponentHandler.getAssignableFrom(TreeCell.class);
                    for (TreeCell<?> cell : tCells) {
                        TreeItem<?> item = cell.getTreeItem();
                        if (item != null && item.equals(node) && !item.isExpanded()) {
                            TreeView<?> tree = ((TreeView<?>) getTree());
                            // Update the layout coordinates otherwise
                            // we would get old position values
                            tree.layout();
                            return cell.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 (!((TreeView<?>) 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.TreeOperationContext.java

@Override
public void collapseNode(final Object node) {
    scrollNodeToVisible(node);//from   w  ww.j  a  v a2 s.co  m
    Object result = EventThreadQueuerJavaFXImpl.invokeAndWait("collapseNode", new Callable<Object>() { //$NON-NLS-1$

        @Override
        public Object call() throws Exception {
            List<? extends TreeCell> tCells = ComponentHandler.getAssignableFrom(TreeCell.class);
            for (TreeCell<?> cell : tCells) {
                TreeItem<?> item = cell.getTreeItem();
                if (item != null && item.equals(node) && item.isExpanded()) {
                    TreeView<?> tree = ((TreeView<?>) getTree());
                    // Update the layout coordinates otherwise
                    // we would get old position values
                    tree.layout();
                    return cell.getDisclosureNode();
                }
            }
            return null;
        }
    });
    if (result != null) {
        getRobot().click(result, null, ClickOptions.create().setClickCount(1).setMouseButton(1));
    }
    EventThreadQueuerJavaFXImpl.invokeAndWait("collapseNodeCheckIfCollapsed", new Callable<Void>() { //$NON-NLS-1$

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

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