/** * If the user hits ENTER key or double-click on a node, the corresponding file is open in * SciNotes. * * @param editor the editor where to open the file * @param the word pattern used * @param path the path of the node */ private static void validNode(SciNotes editor, final Pattern pat, TreePath path) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object userObj = node.getUserObject(); int lineNumber = -1; String fileName = null; boolean line = false; if (userObj instanceof SearchManager.MatchingPositions) { SearchManager.MatchingPositions pos = (SearchManager.MatchingPositions) userObj; lineNumber = 0; if (!pos.isDirectory()) { fileName = pos.getFileName(); } } else if (userObj instanceof SearchManager.Line) { SearchManager.Line l = (SearchManager.Line) userObj; lineNumber = l.getNumber(); fileName = ((SearchManager.MatchingPositions) ((DefaultMutableTreeNode) node.getParent()).getUserObject()) .getFileName(); line = true; } if (fileName != null) { final boolean fline = !line; final int ln = lineNumber; if (lineNumber != -1) { editor.openFile(fileName, 0, null); final ScilabEditorPane sep = editor.getTextPane(); if (sep.getName().equals(fileName)) { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { sep.highlightWords(pat, fline); if (ln != 0) { sep.scrollTextToLineNumber(ln, false, false, true); } } }); } } } }