Search in sources :

Example 1 with Group

use of com.intellij.ide.util.treeView.smartTree.Group in project intellij-community by JetBrains.

the class StructureTreeBuilder method isAutoExpandNode.

@Override
protected final boolean isAutoExpandNode(NodeDescriptor nodeDescriptor) {
    StructureViewModel model = myStructureModel;
    if (model instanceof TreeModelWrapper) {
        model = ((TreeModelWrapper) model).getModel();
    }
    if (model instanceof StructureViewModel.ExpandInfoProvider) {
        StructureViewModel.ExpandInfoProvider provider = (StructureViewModel.ExpandInfoProvider) model;
        Object element = nodeDescriptor.getElement();
        if (element instanceof StructureViewComponent.StructureViewTreeElementWrapper) {
            StructureViewComponent.StructureViewTreeElementWrapper wrapper = (StructureViewComponent.StructureViewTreeElementWrapper) element;
            if (wrapper.getValue() instanceof StructureViewTreeElement) {
                final StructureViewTreeElement value = (StructureViewTreeElement) wrapper.getValue();
                if (value != null) {
                    return provider.isAutoExpand(value);
                }
            }
        } else if (element instanceof GroupWrapper) {
            final Group group = ((GroupWrapper) element).getValue();
            for (TreeElement treeElement : group.getChildren()) {
                if (treeElement instanceof StructureViewTreeElement && !provider.isAutoExpand((StructureViewTreeElement) treeElement)) {
                    return false;
                }
            }
        }
    }
    // expand root node & its immediate children
    final NodeDescriptor parent = nodeDescriptor.getParentDescriptor();
    return super.isAutoExpandNode(parent == null ? nodeDescriptor : parent);
}
Also used : Group(com.intellij.ide.util.treeView.smartTree.Group) GroupWrapper(com.intellij.ide.util.treeView.smartTree.GroupWrapper) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) NodeDescriptor(com.intellij.ide.util.treeView.NodeDescriptor) TreeElement(com.intellij.ide.util.treeView.smartTree.TreeElement) StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement) StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement)

Aggregations

StructureViewModel (com.intellij.ide.structureView.StructureViewModel)1 StructureViewTreeElement (com.intellij.ide.structureView.StructureViewTreeElement)1 NodeDescriptor (com.intellij.ide.util.treeView.NodeDescriptor)1 Group (com.intellij.ide.util.treeView.smartTree.Group)1 GroupWrapper (com.intellij.ide.util.treeView.smartTree.GroupWrapper)1 TreeElement (com.intellij.ide.util.treeView.smartTree.TreeElement)1