Example usage for javax.swing JTree isCollapsed

List of usage examples for javax.swing JTree isCollapsed

Introduction

In this page you can find the example usage for javax.swing JTree isCollapsed.

Prototype

public boolean isCollapsed(int row) 

Source Link

Document

Returns true if the node at the specified display row is collapsed.

Usage

From source file:org.eclipse.jubula.rc.swing.tester.util.TreeOperationContext.java

/**
 * {@inheritDoc}/*ww w  .jav  a  2 s.com*/
 */
public void collapseNode(Object node) {
    final JTree tree = (JTree) getTree();
    final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(tree.getClass().getClassLoader());
        final int row = getRowForTreeNode(node);
        final Rectangle nodeBounds = getNodeBounds(node);
        final boolean collapsed = tree.isCollapsed(row);
        boolean doAction = isExpanded(node);
        final IEventThreadQueuer queuer = new EventThreadQueuerAwtImpl();

        queuer.invokeAndWait("scrollRowToVisible", new IRunnable() { //$NON-NLS-1$
            public Object run() {
                tree.scrollRowToVisible(row);

                return null;
            }
        });

        Rectangle visibleNodeBounds = getVisibleRowBounds(nodeBounds);
        getRobot().move(tree, visibleNodeBounds);
        if (doAction) {
            if (log.isDebugEnabled()) {
                log.debug((collapsed ? "Expanding" : "Collapsing") + " node: " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                        + node);
                log.debug("Row           : " + row); //$NON-NLS-1$
                log.debug("Node bounds   : " + visibleNodeBounds); //$NON-NLS-1$
            }
            queuer.invokeAndWait("collapseRow", new IRunnable() { //$NON-NLS-1$
                public Object run() {
                    tree.collapseRow(row);

                    return null;
                }
            });
        }
    } finally {
        Thread.currentThread().setContextClassLoader(oldCl);
    }

}

From source file:org.eclipse.jubula.rc.swing.tester.util.TreeOperationContext.java

/**
 * {@inheritDoc}/*from   w  ww . j  av  a2  s  .  c  om*/
 */
public void expandNode(Object node) {
    final JTree tree = (JTree) getTree();
    final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(tree.getClass().getClassLoader());
        final int row = getRowForTreeNode(node);
        final Rectangle nodeBounds = getNodeBounds(node);
        final boolean collapsed = tree.isCollapsed(row);
        boolean doAction = !isExpanded(node);
        final IEventThreadQueuer queuer = new EventThreadQueuerAwtImpl();

        queuer.invokeAndWait("scrollRowToVisible", new IRunnable() { //$NON-NLS-1$
            public Object run() {
                tree.scrollRowToVisible(row);

                return null;
            }
        });

        Rectangle visibleNodeBounds = getVisibleRowBounds(nodeBounds);
        getRobot().move(tree, visibleNodeBounds);
        if (doAction) {
            if (log.isDebugEnabled()) {
                log.debug((collapsed ? "Expanding" : "Collapsing") + " node: " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                        + node);
                log.debug("Row           : " + row); //$NON-NLS-1$
                log.debug("Node bounds   : " + visibleNodeBounds); //$NON-NLS-1$
            }
            queuer.invokeAndWait("expandRow", new IRunnable() { //$NON-NLS-1$
                public Object run() {
                    tree.expandRow(row);

                    return null;
                }
            });
        }
    } finally {
        Thread.currentThread().setContextClassLoader(oldCl);
    }

}