Пример #1
0
  private void resetTree() {
    _tree.getSelectionModel().removeTreeSelectionListener(_treeSelectionListener);

    Enumeration expandedDescendants = null;
    TreePath path = null;
    if (_model.getRoot() != null) {
      expandedDescendants = _tree.getExpandedDescendants(new TreePath(_model.getRoot()));
      path = _tree.getSelectionModel().getSelectionPath();
    }

    _model = new PsiViewerTreeModel(_projectComponent);
    _model.setRoot(getRootElement());
    _tree.setModel(_model);
    if (expandedDescendants != null)
      while (expandedDescendants.hasMoreElements()) {
        TreePath treePath = (TreePath) expandedDescendants.nextElement();
        _tree.expandPath(treePath);
      }
    _tree.setSelectionPath(path);
    _tree.scrollPathToVisible(path);

    _tree.getSelectionModel().addTreeSelectionListener(_treeSelectionListener);
  }