Example #1
0
 private void popupInvoked(Component component, int x, int y) {
   final TreePath path = myTree.getLeadSelectionPath();
   if (path == null) return;
   if (!(path.getLastPathComponent() instanceof MessageNode)) return;
   if (getData(DataConstants.NAVIGATABLE_ARRAY) == null) return;
   DefaultActionGroup group = new DefaultActionGroup();
   group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE));
   ActionPopupMenu menu =
       ActionManager.getInstance().createActionPopupMenu(ActionPlaces.ANT_MESSAGES_POPUP, group);
   menu.getComponent().show(component, x, y);
 }
 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);
 }
Example #3
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);
    }
  }