예제 #1
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();
    }
  } // }}}
예제 #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
 // {{{ updateHighlightStatus() method
 private void updateHighlightStatus() {
   String prop = jEdit.getProperty(HIGHLIGHT_PROP);
   if (prop != null && !prop.isEmpty())
     highlight.setIcon(
         GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.match.highlight.icon")));
   else
     highlight.setIcon(
         GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.match.normal.icon")));
   resultTree.repaint();
 } // }}}
예제 #4
0
 // {{{ parseHighlightStyle()
 SyntaxStyle parseHighlightStyle(String style) {
   Font f = (resultTree != null) ? resultTree.getFont() : UIManager.getFont("Tree.font");
   SyntaxStyle s;
   try {
     s = SyntaxUtilities.parseStyle(style, f.getFamily(), f.getSize(), true, null);
   } catch (Exception e) {
     style = "color:#000000";
     s = SyntaxUtilities.parseStyle(style, f.getFamily(), f.getSize(), true);
   }
   return s;
 } // }}}