コード例 #1
0
ファイル: TreeUtil.java プロジェクト: jexp/idea2
 public static void unselect(JTree tree, final DefaultMutableTreeNode node) {
   final TreePath rootPath = new TreePath(node.getPath());
   final TreePath[] selectionPaths = tree.getSelectionPaths();
   if (selectionPaths != null) {
     for (TreePath selectionPath : selectionPaths) {
       if (selectionPath.getPathCount() > rootPath.getPathCount()
           && rootPath.isDescendant(selectionPath)) {
         tree.removeSelectionPath(selectionPath);
       }
     }
   }
 }
コード例 #2
0
ファイル: TreeUtil.java プロジェクト: jexp/idea2
 public static List<TreePath> collectSelectedPaths(final JTree tree, final TreePath treePath) {
   final ArrayList<TreePath> result = new ArrayList<TreePath>();
   final TreePath[] selections = tree.getSelectionPaths();
   if (selections != null) {
     for (TreePath selection : selections) {
       if (treePath.isDescendant(selection)) {
         result.add(selection);
       }
     }
   }
   return result;
 }