예제 #1
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());
    }
예제 #2
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);
    }
  } // }}}
예제 #3
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()));
 }
예제 #4
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);
 }
예제 #5
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);
 }
예제 #6
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);
    }
예제 #7
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();
    }
  } // }}}
예제 #8
0
    // {{{ showPopupMenu method
    private void showPopupMenu(MouseEvent evt) {
      TreePath path = resultTree.getSelectionPath();
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();

      popupMenu = new JPopupMenu();
      Object userObj = node.getUserObject();
      if (userObj instanceof HyperSearchFileNode || userObj instanceof HyperSearchResult) {
        popupMenu.add(new GoToNodeAction("hypersearch-results.open", M_OPEN));
        popupMenu.add(new GoToNodeAction("hypersearch-results.open-view", M_OPEN_NEW_VIEW));
        popupMenu.add(
            new GoToNodeAction("hypersearch-results.open-plain-view", M_OPEN_NEW_PLAIN_VIEW));
        popupMenu.add(new GoToNodeAction("hypersearch-results.open-split", M_OPEN_NEW_SPLIT));
      }
      if (!(userObj instanceof HyperSearchFolderNode)) popupMenu.add(new RemoveTreeNodeAction());
      popupMenu.add(new ExpandChildTreeNodesAction());
      if (userObj instanceof HyperSearchFolderNode || userObj instanceof HyperSearchOperationNode) {
        popupMenu.add(new CollapseChildTreeNodesAction());
        if (userObj instanceof HyperSearchFolderNode) popupMenu.add(new NewSearchAction());
      }
      if (userObj instanceof HyperSearchOperationNode) {
        popupMenu.add(new JPopupMenu.Separator());
        HyperSearchOperationNode resultNode = (HyperSearchOperationNode) userObj;
        JCheckBoxMenuItem chkItem =
            new JCheckBoxMenuItem(
                jEdit.getProperty("hypersearch-results.tree-view"),
                resultNode.isTreeViewDisplayed());
        chkItem.addActionListener(new TreeDisplayAction());
        popupMenu.add(chkItem);

        popupMenu.add(new RedoSearchAction((HyperSearchOperationNode) userObj));
      }
      popupMenu.add(new CopyToClipboardAction());

      GUIUtilities.showPopupMenu(popupMenu, evt.getComponent(), evt.getX(), evt.getY());
      evt.consume();
    } // }}}
예제 #9
0
 @Override
 public void actionPerformed(ActionEvent evt) {
   TreePath path = resultTree.getSelectionPath();
   DefaultMutableTreeNode operNode = (DefaultMutableTreeNode) path.getLastPathComponent();
   expandAllNodes(operNode);
 }