Example usage for javax.swing.tree AbstractLayoutCache getExpandedState

List of usage examples for javax.swing.tree AbstractLayoutCache getExpandedState

Introduction

In this page you can find the example usage for javax.swing.tree AbstractLayoutCache getExpandedState.

Prototype

public abstract boolean getExpandedState(TreePath path);

Source Link

Document

Returns true if the path is expanded, and visible.

Usage

From source file:ca.uhn.hl7v2.testpanel.ui.v2tree.Hl7V2MessageTree.java

private Set<String> getOpenPaths() {
    Set<String> retVal = new HashSet<String>();

    TableModel model = getModel();
    AbstractLayoutCache layout = ((OutlineModel) model).getLayout();
    int messageIndex = -1;
    for (int i = 0; i < layout.getRowCount(); i++) {
        TreePath path = layout.getPathForRow(i);

        Object baseObj = path.getLastPathComponent();
        if (baseObj instanceof TreeNodeMessage || baseObj instanceof TreeNodeUnknown) {

            messageIndex++;//from  w  ww  .  j a  v a2 s.  c o  m

            if (layout.getExpandedState(path)) {
                retVal.add(Integer.toString(messageIndex));
            }

        } else {

            baseObj = path.getPathComponent(path.getPathCount() - 2);
            if (baseObj instanceof TreeNodeBase) {
                retVal.add(Integer.toString(messageIndex) + ((TreeNodeBase) baseObj).getTerserPath());
            }
        }

    }

    return retVal;
}