Пример #1
0
  private void updateSelectionFromTree() {
    TreePath[] treePaths = myTree.getSelectionPaths();
    if (treePaths != null) {
      List<NamedConfigurable> selectedConfigurables = new ArrayList<NamedConfigurable>();
      for (TreePath path : treePaths) {
        Object lastPathComponent = path.getLastPathComponent();
        if (lastPathComponent instanceof MyNode) {
          selectedConfigurables.add(((MyNode) lastPathComponent).getConfigurable());
        }
      }
      if (selectedConfigurables.size() > 1 && updateMultiSelection(selectedConfigurables)) {
        return;
      }
    }

    final TreePath path = myTree.getSelectionPath();
    if (path != null) {
      final Object lastPathComp = path.getLastPathComponent();
      if (!(lastPathComp instanceof MyNode)) return;
      final MyNode node = (MyNode) lastPathComp;
      setSelectedNode(node);
    } else {
      setSelectedNode(null);
    }
  }
 private Set<PsiFile> getSelectedScope(final Tree tree) {
   TreePath[] paths = tree.getSelectionPaths();
   if (paths == null) return EMPTY_FILE_SET;
   Set<PsiFile> result = new HashSet<PsiFile>();
   for (TreePath path : paths) {
     PackageDependenciesNode node = (PackageDependenciesNode) path.getLastPathComponent();
     node.fillFiles(result, !mySettings.UI_FLATTEN_PACKAGES);
   }
   return result;
 }
 private VirtualFile[] getVirtualFileArray() {
   ArrayList<VirtualFile> result = new ArrayList<VirtualFile>();
   TreePath[] selectionPaths = myTree.getSelectionPaths();
   if (selectionPaths != null) {
     for (TreePath selectionPath : selectionPaths) {
       AbstractTreeNode treeNode = (AbstractTreeNode) selectionPath.getLastPathComponent();
       result.addAll(treeNode.getVirtualFiles());
     }
   }
   return VfsUtil.toVirtualFileArray(result);
 }
 private Pair<ElementNode, List<ElementNode>> storeSelection() {
   List<ElementNode> selectedNodes = new ArrayList<ElementNode>();
   TreePath[] paths = myTree.getSelectionPaths();
   if (paths != null) {
     for (TreePath path : paths) {
       selectedNodes.add((ElementNode) path.getLastPathComponent());
     }
   }
   TreePath leadSelectionPath = myTree.getLeadSelectionPath();
   return Pair.create(
       leadSelectionPath != null ? (ElementNode) leadSelectionPath.getLastPathComponent() : null,
       selectedNodes);
 }
 @Nullable
 private File[] getFileArray() {
   ArrayList<File> result = new ArrayList<File>();
   TreePath[] selectionPaths = myTree.getSelectionPaths();
   if (selectionPaths != null) {
     for (TreePath selectionPath : selectionPaths) {
       AbstractTreeNode treeNode = (AbstractTreeNode) selectionPath.getLastPathComponent();
       result.addAll(treeNode.getFiles());
     }
   }
   if (result.isEmpty()) return null;
   return result.toArray(new File[result.size()]);
 }
 boolean isButtonEnabled(boolean rec) {
   final TreePath[] paths = myPackageTree.getSelectionPaths();
   if (paths != null) {
     for (TreePath path : paths) {
       final PackageDependenciesNode node = (PackageDependenciesNode) path.getLastPathComponent();
       if (PatternDialectProvider.getInstance(DependencyUISettings.getInstance().SCOPE_TYPE)
               .createPackageSet(node, rec)
           != null) {
         return true;
       }
     }
   }
   return false;
 }
Пример #7
0
  public void expandAll() {
    TreePath[] selectionPaths = myTree.getSelectionPaths();
    TreePath leadSelectionPath = myTree.getLeadSelectionPath();
    int row = 0;
    while (row < myTree.getRowCount()) {
      myTree.expandRow(row);
      row++;
    }

    if (selectionPaths != null) {
      // restore selection
      myTree.setSelectionPaths(selectionPaths);
    }
    if (leadSelectionPath != null) {
      // scroll to lead selection path
      myTree.scrollPathToVisible(leadSelectionPath);
    }
  }