Example #1
0
 // {{{ updateMultiStatus() method
 private void updateMultiStatus() {
   if (multiStatus)
     multi.setIcon(
         GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.multi.multiple.icon")));
   else
     multi.setIcon(
         GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.multi.single.icon")));
 } // }}}
Example #2
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();
 } // }}}
Example #3
0
    @Override
    public void actionPerformed(ActionEvent evt) {
      Object source = evt.getSource();
      if (source == highlight) {
        String prop = jEdit.getProperty(HIGHLIGHT_PROP);
        Font f = (resultTree != null) ? resultTree.getFont() : UIManager.getFont("Tree.font");
        SyntaxStyle style =
            new StyleEditor(
                    jEdit.getActiveView(),
                    HtmlUtilities.parseHighlightStyle(prop, f),
                    "hypersearch")
                .getStyle();
        if (style != null) jEdit.setProperty(HIGHLIGHT_PROP, GUIUtilities.getStyleString(style));
        updateHighlightStatus();
      } else if (source == clear) {
        removeAllNodes();
      } else if (source == multi) {
        multiStatus = !multiStatus;
        updateMultiStatus();

        if (!multiStatus) {
          for (int i = resultTreeRoot.getChildCount() - 2; i >= 0; i--) {
            resultTreeModel.removeNodeFromParent((MutableTreeNode) resultTreeRoot.getChildAt(i));
          }
        }
      } else if (source == stop) {
        jEdit.setTemporaryProperty("hyperSearch-stopButton", "true");
      }
    }
Example #4
0
    // {{{ mousePressed() method
    @Override
    public void mousePressed(MouseEvent evt) {
      if (evt.isConsumed()) return;

      TreePath path1 = resultTree.getPathForLocation(evt.getX(), evt.getY());
      if (path1 == null) return;

      resultTree.setSelectionPath(path1);
      if (GUIUtilities.isPopupTrigger(evt)) showPopupMenu(evt);
      else {
        goToSelectedNode(M_OPEN);
      }
    } // }}}
Example #5
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();
    } // }}}
Example #6
0
  // {{{ HyperSearchResults constructor
  public HyperSearchResults(View view) {
    super(new BorderLayout());

    this.view = view;

    caption = new JLabel();

    Box toolBar = new Box(BoxLayout.X_AXIS);
    toolBar.add(caption);
    toolBar.add(Box.createGlue());

    ActionHandler ah = new ActionHandler();

    highlight = new RolloverButton();
    highlight.setToolTipText(jEdit.getProperty("hypersearch-results.highlight.label"));
    highlight.addActionListener(ah);
    toolBar.add(highlight);

    clear =
        new RolloverButton(
            GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.clear.icon")));
    clear.setToolTipText(jEdit.getProperty("hypersearch-results.clear.label"));
    clear.addActionListener(ah);
    toolBar.add(clear);

    multi = new RolloverButton();
    multi.setToolTipText(jEdit.getProperty("hypersearch-results.multi.label"));
    multi.addActionListener(ah);
    toolBar.add(multi);

    stop =
        new RolloverButton(
            GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.stop.icon")));
    stop.setToolTipText(jEdit.getProperty("hypersearch-results.stop.label"));
    stop.addActionListener(ah);
    toolBar.add(stop);
    stop.setEnabled(false);

    add(BorderLayout.NORTH, toolBar);

    resultTreeRoot = new DefaultMutableTreeNode();
    resultTreeModel = new DefaultTreeModel(resultTreeRoot);
    resultTree = new HighlightingTree(resultTreeModel);
    resultTree.setToolTipText(null);
    resultTree.setCellRenderer(new ResultCellRenderer());
    resultTree.setVisibleRowCount(16);
    resultTree.setRootVisible(false);
    resultTree.setShowsRootHandles(true);
    // the ESCAPE keystroke is assigned to hideTip action by swing
    // it breaks the action usually assigned to close-docking-area by jEdit,
    // so we remove this keystroke binding bug #1955140
    KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    resultTree.getInputMap().remove(keyStroke);
    // looks bad with the OS X L&F, apparently...
    if (!OperatingSystem.isMacOSLF()) resultTree.putClientProperty("JTree.lineStyle", "Angled");

    resultTree.setEditable(false);

    resultTree.addKeyListener(new KeyHandler());
    resultTree.addMouseListener(new MouseHandler());

    JScrollPane scrollPane = new JScrollPane(resultTree);
    Dimension dim = scrollPane.getPreferredSize();
    dim.width = 400;
    scrollPane.setPreferredSize(dim);
    add(BorderLayout.CENTER, scrollPane);
    resultTree.setTransferHandler(new ResultTreeTransferHandler());
  } // }}}