private static boolean isMoveSupported(JTree tree, int dir) {
   final TreePath[] selectionPaths = tree.getSelectionPaths();
   if (selectionPaths != null) {
     DefaultMutableTreeNode parent = null;
     for (TreePath treePath : selectionPaths)
       if (treePath.getLastPathComponent() != null) {
         final DefaultMutableTreeNode node =
             (DefaultMutableTreeNode) treePath.getLastPathComponent();
         if (parent == null) {
           parent = (DefaultMutableTreeNode) node.getParent();
         }
         if (parent != node.getParent()) {
           return false;
         }
         if (dir > 0) {
           if (parent.getIndex(node) == parent.getChildCount() - 1) {
             return false;
           }
         } else {
           if (parent.getIndex(node) == 0) {
             return false;
           }
         }
       }
     return true;
   }
   return false;
 }
  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);
    }
  }
示例#3
0
  // {{{ removeSelectedNode() method
  private void removeSelectedNode() {
    TreePath path = resultTree.getSelectionPath();
    if (path == null) return;

    MutableTreeNode value = (MutableTreeNode) path.getLastPathComponent();

    if (path.getPathCount() > 1) {
      // Adjust selection so that repeating some removals
      // behave naturally.
      TreePath parentPath = path.getParentPath();
      MutableTreeNode parent = (MutableTreeNode) parentPath.getLastPathComponent();
      int removingIndex = parent.getIndex(value);
      int nextIndex = removingIndex + 1;
      if (nextIndex < parent.getChildCount()) {
        TreeNode next = parent.getChildAt(nextIndex);
        resultTree.setSelectionPath(parentPath.pathByAddingChild(next));
      } else {
        resultTree.setSelectionPath(parentPath);
      }

      resultTreeModel.removeNodeFromParent(value);
    }

    HyperSearchOperationNode.removeNodeFromCache(value);
    if (resultTreeRoot.getChildCount() == 0) {
      hideDockable();
    }
  } // }}}
示例#4
0
 public void run() {
   if (getTree().isExpanded(t)) {
     expandedNodes.add(t.getLastPathComponent());
   } else {
     expandedNodes.remove(t.getLastPathComponent());
   }
 }
示例#5
0
文件: TreeUtil.java 项目: jexp/idea2
 private static IndexTreePathState removeLastPathComponent(
     final DefaultTreeModel model, final TreePath pathToBeRemoved) {
   final IndexTreePathState selectionState = new IndexTreePathState(pathToBeRemoved);
   if (((MutableTreeNode) pathToBeRemoved.getLastPathComponent()).getParent() == null)
     return selectionState;
   model.removeNodeFromParent((MutableTreeNode) pathToBeRemoved.getLastPathComponent());
   return selectionState;
 }
 @Nullable
 public Object getSelectedObject() {
   final TreePath selectionPath = myTree.getSelectionPath();
   if (selectionPath != null && selectionPath.getLastPathComponent() instanceof MyNode) {
     MyNode node = (MyNode) selectionPath.getLastPathComponent();
     final NamedConfigurable configurable = node.getConfigurable();
     LOG.assertTrue(configurable != null, "already disposed");
     return configurable.getEditableObject();
   }
   return null;
 }
 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);
 }
示例#8
0
文件: TreeUtil.java 项目: jexp/idea2
 public static List<TreePath> collectExpandedPaths(final JTree tree, TreePath path) {
   final ArrayList<TreePath> result = new ArrayList<TreePath>();
   if (!tree.isExpanded(path)) return result;
   final Object lastPathComponent = path.getLastPathComponent();
   final TreeModel model = tree.getModel();
   if (model.isLeaf(lastPathComponent)) {
     result.add(path);
   } else {
     boolean pathWasAdded = false;
     for (int i = model.getChildCount(lastPathComponent) - 1; i >= 0; i--) {
       final TreePath childPath = path.pathByAddingChild(model.getChild(lastPathComponent, i));
       if (model.isLeaf(lastPathComponent)) {
         if (!pathWasAdded) {
           result.add(path);
           pathWasAdded = true;
         }
       } else if (tree.isExpanded(childPath)) {
         result.addAll(collectExpandedPaths(tree, childPath));
       } else {
         if (!pathWasAdded) {
           result.add(path);
           pathWasAdded = true;
         }
       }
     }
   }
   return result;
 }
示例#9
0
    @Override
    public void actionPerformed(ActionEvent evt) {
      JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) evt.getSource();
      boolean curState = menuItem.isSelected();

      TreePath path = resultTree.getSelectionPath();
      DefaultMutableTreeNode operNode = (DefaultMutableTreeNode) path.getLastPathComponent();

      HyperSearchOperationNode operNodeObj = (HyperSearchOperationNode) operNode.getUserObject();
      if (curState) operNodeObj.cacheResultNodes(operNode);
      operNode.removeAllChildren();
      if (curState) {
        Exception excp = null;
        try {
          operNodeObj.insertTreeNodes(resultTree, operNode);
        } catch (Exception ex) {
          operNodeObj.restoreFlatNodes(resultTree, operNode);
          menuItem.setSelected(false);
          excp = ex;
        } finally {
          ((DefaultTreeModel) resultTree.getModel()).nodeStructureChanged(operNode);
          expandAllNodes(operNode);
          resultTree.scrollPathToVisible(new TreePath(operNode.getPath()));
        }
        if (excp != null) throw new RuntimeException(excp);
      } else operNodeObj.restoreFlatNodes(resultTree, operNode);

      operNodeObj.setTreeViewDisplayed(menuItem.isSelected());
    }
  @NotNull
  public Change[] getSelectedChanges() {
    Set<Change> changes = new LinkedHashSet<Change>();

    final TreePath[] paths = getSelectionPaths();
    if (paths == null) {
      return new Change[0];
    }

    for (TreePath path : paths) {
      ChangesBrowserNode<?> node = (ChangesBrowserNode) path.getLastPathComponent();
      changes.addAll(node.getAllChangesUnder());
    }

    if (changes.isEmpty()) {
      final List<VirtualFile> selectedModifiedWithoutEditing = getSelectedModifiedWithoutEditing();
      if (selectedModifiedWithoutEditing != null && !selectedModifiedWithoutEditing.isEmpty()) {
        for (VirtualFile file : selectedModifiedWithoutEditing) {
          AbstractVcs vcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(file);
          if (vcs == null) continue;
          final VcsCurrentRevisionProxy before =
              VcsCurrentRevisionProxy.create(file, myProject, vcs.getKeyInstanceMethod());
          if (before != null) {
            ContentRevision afterRevision = new CurrentContentRevision(new FilePathImpl(file));
            changes.add(new Change(before, afterRevision, FileStatus.HIJACKED));
          }
        }
      }
    }

    return changes.toArray(new Change[changes.size()]);
  }
示例#11
0
  private void goToSelectedNode(int mode) {
    TreePath path = resultTree.getSelectionPath();
    if (path == null) return;

    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
    Object value = node.getUserObject();

    // do nothing if clicked "foo (showing n occurrences in m files)"
    if (node.getParent() != resultTreeRoot && value instanceof HyperSearchNode) {
      HyperSearchNode n = (HyperSearchNode) value;
      Buffer buffer = n.getBuffer(view);
      if (buffer == null) return;

      EditPane pane;

      switch (mode) {
        case M_OPEN:
          pane = view.goToBuffer(buffer);
          break;
        case M_OPEN_NEW_VIEW:
          pane = jEdit.newView(view, buffer, false).getEditPane();
          break;
        case M_OPEN_NEW_PLAIN_VIEW:
          pane = jEdit.newView(view, buffer, true).getEditPane();
          break;
        case M_OPEN_NEW_SPLIT:
          pane = view.splitHorizontally();
          break;
        default:
          throw new IllegalArgumentException("Bad mode: " + mode);
      }

      n.goTo(pane);
    }
  } // }}}
 @Override
 public void keyPressed(KeyEvent e) {
   TreePath path = myTree.getLeadSelectionPath();
   if (path == null) return;
   final Object lastComponent = path.getLastPathComponent();
   if (e.getKeyCode() == KeyEvent.VK_ENTER) {
     if (lastComponent instanceof ParentNode) return;
     doOKAction();
     e.consume();
   } else if (e.getKeyCode() == KeyEvent.VK_INSERT) {
     if (lastComponent instanceof ElementNode) {
       final DefaultMutableTreeNode node = (DefaultMutableTreeNode) lastComponent;
       if (!mySelectedNodes.contains(node)) {
         if (node.getNextNode() != null) {
           myTree.setSelectionPath(new TreePath(node.getNextNode().getPath()));
         }
       } else {
         if (node.getNextNode() != null) {
           myTree.removeSelectionPath(new TreePath(node.getPath()));
           myTree.setSelectionPath(new TreePath(node.getNextNode().getPath()));
           myTree.repaint();
         }
       }
       e.consume();
     }
   }
 }
    public static Image createImage(final JTree tree) {
      final TreeSelectionModel model = tree.getSelectionModel();
      final TreePath[] paths = model.getSelectionPaths();

      int count = 0;
      final List<ChangesBrowserNode> nodes = new ArrayList<ChangesBrowserNode>();
      for (final TreePath path : paths) {
        final ChangesBrowserNode node = (ChangesBrowserNode) path.getLastPathComponent();
        if (!node.isLeaf()) {
          nodes.add(node);
          count += node.getCount();
        }
      }

      for (TreePath path : paths) {
        final ChangesBrowserNode element = (ChangesBrowserNode) path.getLastPathComponent();
        boolean child = false;
        for (final ChangesBrowserNode node : nodes) {
          if (node.isNodeChild(element)) {
            child = true;
            break;
          }
        }

        if (!child) {
          if (element.isLeaf()) count++;
        } else if (!element.isLeaf()) {
          count -= element.getCount();
        }
      }

      final JLabel label = new JLabel(VcsBundle.message("changes.view.dnd.label", count));
      label.setOpaque(true);
      label.setForeground(tree.getForeground());
      label.setBackground(tree.getBackground());
      label.setFont(tree.getFont());
      label.setSize(label.getPreferredSize());
      final BufferedImage image =
          new BufferedImage(label.getWidth(), label.getHeight(), BufferedImage.TYPE_INT_ARGB);

      Graphics2D g2 = (Graphics2D) image.getGraphics();
      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
      label.paint(g2);
      g2.dispose();

      return image;
    }
 @Override
 public void calcData(DataKey key, DataSink sink) {
   if (key == VcsDataKeys.CHANGES) {
     sink.put(VcsDataKeys.CHANGES, getSelectedChanges());
   } else if (key == VcsDataKeys.CHANGE_LEAD_SELECTION) {
     sink.put(VcsDataKeys.CHANGE_LEAD_SELECTION, getLeadSelection());
   } else if (key == VcsDataKeys.CHANGE_LISTS) {
     sink.put(VcsDataKeys.CHANGE_LISTS, getSelectedChangeLists());
   } else if (key == PlatformDataKeys.VIRTUAL_FILE_ARRAY) {
     sink.put(PlatformDataKeys.VIRTUAL_FILE_ARRAY, getSelectedFiles());
   } else if (key == PlatformDataKeys.NAVIGATABLE) {
     final VirtualFile[] files = getSelectedFiles();
     if (files.length == 1 && !files[0].isDirectory()) {
       sink.put(PlatformDataKeys.NAVIGATABLE, new OpenFileDescriptor(myProject, files[0], 0));
     }
   } else if (key == PlatformDataKeys.NAVIGATABLE_ARRAY) {
     sink.put(
         PlatformDataKeys.NAVIGATABLE_ARRAY,
         ChangesUtil.getNavigatableArray(myProject, getSelectedFiles()));
   } else if (key == PlatformDataKeys.DELETE_ELEMENT_PROVIDER) {
     final TreePath[] paths = getSelectionPaths();
     if (paths != null) {
       for (TreePath path : paths) {
         ChangesBrowserNode node = (ChangesBrowserNode) path.getLastPathComponent();
         if (!(node.getUserObject() instanceof ChangeList)) {
           sink.put(PlatformDataKeys.DELETE_ELEMENT_PROVIDER, new VirtualFileDeleteProvider());
           break;
         }
       }
     }
   } else if (key == PlatformDataKeys.COPY_PROVIDER) {
     sink.put(PlatformDataKeys.COPY_PROVIDER, myCopyProvider);
   } else if (key == UNVERSIONED_FILES_DATA_KEY) {
     sink.put(UNVERSIONED_FILES_DATA_KEY, getSelectedUnversionedFiles());
   } else if (key == VcsDataKeys.MODIFIED_WITHOUT_EDITING_DATA_KEY) {
     sink.put(VcsDataKeys.MODIFIED_WITHOUT_EDITING_DATA_KEY, getSelectedModifiedWithoutEditing());
   } else if (key == LOCALLY_DELETED_CHANGES) {
     sink.put(LOCALLY_DELETED_CHANGES, getSelectedLocallyDeletedChanges());
   } else if (key == MISSING_FILES_DATA_KEY) {
     sink.put(MISSING_FILES_DATA_KEY, getSelectedMissingFiles());
   } else if (VcsDataKeys.HAVE_LOCALLY_DELETED == key) {
     sink.put(VcsDataKeys.HAVE_LOCALLY_DELETED, haveLocallyDeleted());
   } else if (VcsDataKeys.HAVE_MODIFIED_WITHOUT_EDITING == key) {
     sink.put(VcsDataKeys.HAVE_MODIFIED_WITHOUT_EDITING, haveLocallyModified());
   } else if (VcsDataKeys.HAVE_SELECTED_CHANGES == key) {
     sink.put(VcsDataKeys.HAVE_SELECTED_CHANGES, haveSelectedChanges());
   } else if (key == HELP_ID_DATA_KEY) {
     sink.put(HELP_ID_DATA_KEY, ourHelpId);
   } else if (key == VcsDataKeys.CHANGES_IN_LIST_KEY) {
     final TreePath selectionPath = getSelectionPath();
     if (selectionPath != null && selectionPath.getPathCount() > 1) {
       ChangesBrowserNode<?> firstNode = (ChangesBrowserNode) selectionPath.getPathComponent(1);
       if (firstNode instanceof ChangesBrowserChangeListNode) {
         final List<Change> list = firstNode.getAllChangesUnder();
         sink.put(VcsDataKeys.CHANGES_IN_LIST_KEY, list);
       }
     }
   }
 }
  @Nullable
  private Node getSelectedNode() {
    TreePath leadSelectionPath = myTree.getLeadSelectionPath();
    if (leadSelectionPath == null) return null;

    DefaultMutableTreeNode node = (DefaultMutableTreeNode) leadSelectionPath.getLastPathComponent();
    return node instanceof Node ? (Node) node : null;
  }
示例#16
0
 protected Transferable createTransferable(JComponent c) {
   JTree tree = (JTree) c;
   TreePath[] paths = tree.getSelectionPaths();
   if (paths == null || paths.length != 1) return null;
   TreePath path = tree.getSelectionPath();
   GroovyTreeNode groovyTreeNode = (GroovyTreeNode) path.getLastPathComponent();
   return new StringTransferable((String) (groovyTreeNode.node.getNodeValue()));
 }
示例#17
0
文件: TreeUtil.java 项目: jexp/idea2
 private static void expand(JTree tree, TreePath path, int levels) {
   if (levels == 0) return;
   tree.expandPath(path);
   TreeNode node = (TreeNode) path.getLastPathComponent();
   Enumeration children = node.children();
   while (children.hasMoreElements()) {
     expand(tree, path.pathByAddingChild(children.nextElement()), levels - 1);
   }
 }
示例#18
0
 public void actionPerformed(ActionEvent event) {
   JTree tree = getTree();
   TreePath path = tree.getSelectionPath();
   if (path == null) {
     sheet.getLogger().warning("Warning: User must select a node to attach a new config to");
     // XXX add a message telling users to select a node
   } else {
     createAttrConfigForNode((Node) path.getLastPathComponent());
   }
 }
示例#19
0
 @Override
 public void actionPerformed(ActionEvent evt) {
   TreePath path = resultTree.getSelectionPath();
   DefaultMutableTreeNode operNode = (DefaultMutableTreeNode) path.getLastPathComponent();
   ToStringNodes toStringNodes = new ToStringNodes();
   traverseNodes(operNode, toStringNodes);
   StringSelection selection = new StringSelection(toStringNodes.nodesString.toString());
   Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
   clipboard.setContents(selection, null);
 }
示例#20
0
 @Override
 public void actionPerformed(ActionEvent evt) {
   TreePath path = resultTree.getSelectionPath();
   DefaultMutableTreeNode operNode = (DefaultMutableTreeNode) path.getLastPathComponent();
   for (Enumeration e = operNode.children(); e.hasMoreElements(); ) {
     DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
     resultTree.collapsePath(new TreePath(node.getPath()));
   }
   resultTree.scrollPathToVisible(new TreePath(operNode.getPath()));
 }
示例#21
0
 public void editSelected() {
   TreePath selected = tree.getSelectionPath();
   if (selected != null) {
     DefaultMutableTreeNode node = (DefaultMutableTreeNode) selected.getLastPathComponent();
     Object obj = node.getUserObject();
     if (obj instanceof CavityDBObject) {
       CavityDBObject dbObj = (CavityDBObject) obj;
       new ObjectEditingFrame(new ObjectEditingPanel(dbObj));
     }
   }
 }
示例#22
0
文件: TreeUtil.java 项目: jexp/idea2
 public static void moveSelectedRow(final JTree tree, final int direction) {
   final TreePath selectionPath = tree.getSelectionPath();
   final DefaultMutableTreeNode treeNode =
       (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
   final DefaultMutableTreeNode parent = (DefaultMutableTreeNode) treeNode.getParent();
   final int idx = parent.getIndex(treeNode);
   parent.remove(treeNode);
   parent.insert(treeNode, idx + direction);
   ((DefaultTreeModel) tree.getModel()).reload(parent);
   selectNode(tree, treeNode);
 }
示例#23
0
    @Override
    public void actionPerformed(ActionEvent evt) {
      TreePath path = resultTree.getSelectionPath();
      DefaultMutableTreeNode operNode = (DefaultMutableTreeNode) path.getLastPathComponent();
      HyperSearchFolderNode nodeObj = (HyperSearchFolderNode) operNode.getUserObject();

      String glob = "*";
      SearchFileSet dirList = SearchAndReplace.getSearchFileSet();
      if (dirList instanceof DirectoryListSet) glob = ((DirectoryListSet) dirList).getFileFilter();
      SearchAndReplace.setSearchFileSet(
          new DirectoryListSet(nodeObj.getNodeFile().getAbsolutePath(), glob, true));
      SearchDialog.showSearchDialog(view, null, SearchDialog.DIRECTORY);
    }
示例#24
0
 @Override
 public void exportToClipboard(JComponent comp, Clipboard clip, int action)
     throws IllegalStateException {
   TreePath[] paths = resultTree.getSelectionPaths();
   ToStringNodes toStringNodes = new ToStringNodes();
   for (TreePath path : paths) {
     DefaultMutableTreeNode operNode = (DefaultMutableTreeNode) path.getLastPathComponent();
     toStringNodes.processNode(operNode);
   }
   StringSelection selection = new StringSelection(toStringNodes.nodesString.toString());
   Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
   clipboard.setContents(selection, null);
 }
示例#25
0
 // Called at the end of a cell edition, to process the edition result.
 public final void valueForPathChanged(TreePath path, Object newValue) {
   DynamicNode node = (DynamicNode) path.getLastPathComponent();
   Object obj = node.getRealObject();
   if (obj instanceof DbObject) {
     boolean editable = false;
     try {
       Db db = ((DbObject) obj).getDb();
       if (db.isValid()) {
         db.beginReadTrans();
         MetaField editableMetaField = getEditableMetaField((DbObject) obj);
         if (editableMetaField == null)
           editable =
               ApplicationContext.getSemanticalModel()
                   .isNameEditable((DbObject) obj, Explorer.class);
         else
           editable =
               ApplicationContext.getSemanticalModel()
                   .isEditable(editableMetaField, (DbObject) obj, Explorer.class);
         db.commitTrans();
       }
     } catch (DbException ex) {
       org.modelsphere.jack.util.ExceptionHandler.processUncatchedException(
           ApplicationContext.getDefaultMainFrame(), ex);
       editable = false;
     }
     if (!editable) return;
   } else {
     return;
   }
   DbObject semObj = (DbObject) obj;
   try {
     MetaField editableMetaField = getEditableMetaField(semObj);
     String transName =
         (editableMetaField == null
             ? LocaleMgr.action.getString("rename")
             : MessageFormat.format(kUpdate0, new Object[] {editableMetaField.getGUIName()}));
     semObj.getDb().beginTrans(Db.WRITE_TRANS, transName);
     if (editableMetaField == null) {
       if (semObj.getTransStatus() == Db.OBJ_REMOVED) return;
       semObj.setName((String) newValue);
     } else semObj.set(editableMetaField, (String) newValue);
     semObj.getDb().commitTrans();
     nodeChanged(node); // in case it is a secondary node (only the
     // primary node is updated by the refresh
     // listener).
   } catch (Exception ex) {
     org.modelsphere.jack.util.ExceptionHandler.processUncatchedException(
         ApplicationContext.getDefaultMainFrame(), ex);
   }
 }
  private Change[] getLeadSelection() {
    final Set<Change> changes = new LinkedHashSet<Change>();

    final TreePath[] paths = getSelectionPaths();
    if (paths == null) return new Change[0];

    for (TreePath path : paths) {
      ChangesBrowserNode node = (ChangesBrowserNode) path.getLastPathComponent();
      if (node instanceof ChangesBrowserChangeNode) {
        changes.add(((ChangesBrowserChangeNode) node).getUserObject());
      }
    }

    return changes.toArray(new Change[changes.size()]);
  }
  @Nullable
  private Node[] getSelectedNodes() {
    TreePath[] leadSelectionPath = myTree.getSelectionPaths();
    if (leadSelectionPath == null || leadSelectionPath.length == 0) return null;

    final List<Node> result = new ArrayList<Node>();
    for (TreePath comp : leadSelectionPath) {
      final Object lastPathComponent = comp.getLastPathComponent();
      if (lastPathComponent instanceof Node) {
        final Node node = (Node) lastPathComponent;
        result.add(node);
      }
    }
    return result.isEmpty() ? null : result.toArray(new Node[result.size()]);
  }
  @Override
  @Nullable
  public Set<Usage> getSelectedUsages() {
    TreePath[] selectionPaths = myTree.getSelectionPaths();
    if (selectionPaths == null) {
      return null;
    }

    Set<Usage> usages = new THashSet<Usage>();
    for (TreePath selectionPath : selectionPaths) {
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
      collectUsages(node, usages);
    }

    return usages;
  }
 private List<FilePath> getSelectedFilePaths(final Object tag) {
   Set<FilePath> files = new HashSet<FilePath>();
   final TreePath[] paths = getSelectionPaths();
   if (paths != null) {
     for (TreePath path : paths) {
       if (path.getPathCount() > 1) {
         ChangesBrowserNode firstNode = (ChangesBrowserNode) path.getPathComponent(1);
         if (tag == null || firstNode.getUserObject() == tag) {
           ChangesBrowserNode<?> node = (ChangesBrowserNode) path.getLastPathComponent();
           files.addAll(node.getAllFilePathsUnder());
         }
       }
     }
   }
   return new ArrayList<FilePath>(files);
 }
    @Nullable
    public Set<Object> getTreeSelectedActionIds() {
      TreePath[] paths = myTree.getSelectionPaths();
      if (paths == null) return null;

      Set<Object> actions = new HashSet<Object>();
      for (TreePath path : paths) {
        Object node = path.getLastPathComponent();
        if (node instanceof DefaultMutableTreeNode) {
          DefaultMutableTreeNode defNode = (DefaultMutableTreeNode) node;
          Object userObject = defNode.getUserObject();
          actions.add(userObject);
        }
      }
      return actions;
    }