Example #1
0
 /**
  * Display a window containing the results of the search.
  *
  * @param component the component which start the search. It is prevented that search is done via
  *     a firePropertyChange (SEARCHDONE).
  * @param editor the editor where to open a file
  * @param base the base directory
  * @param recursive, if true then a recursive search is made
  * @param ignoreCR, if true then the read file is considered as one line and regex pattern can
  *     include \n
  * @param filePattern the pattern to use to select the files. * is equivalent to .* and ? to .?
  * @param fileCaseSensitive, if true then the file pattern is case sensitive
  * @param wordPattern the pattern of the word to search
  * @param wordCaseSensitive, if true then the word pattern is case sensitive
  * @param wholeWord, if true only whole word will be matched, e.g. in "foobar foo bar", if the
  *     pattern is "foo", then only the second "foo" will be matched
  * @param regexp, if true the word pattern is considered as a regex
  * @return a key, can be used to stop the search
  */
 public static Object getSearchResultsWindow(
     JComponent component,
     SciNotes editor,
     String base,
     boolean recursive,
     boolean ignoreCR,
     String filePattern,
     boolean fileCaseSensitive,
     String wordPattern,
     boolean wordCaseSensitive,
     boolean wholeWord,
     boolean regexp) {
   MyBackgroundSearch searcher =
       new MyBackgroundSearch(
           component,
           editor,
           base,
           recursive,
           ignoreCR,
           filePattern,
           fileCaseSensitive,
           wordPattern,
           wordCaseSensitive,
           wholeWord,
           regexp);
   searcher.start();
   return searcher;
 }
Example #2
0
 private void saveSearchFile() {
   if (mySearch != null) {
     try {
       FileWriter fwriter =
           new FileWriter(
               ScilabConstants.SCIHOME.toString() + File.separator + getPersistentId() + ".xml");
       BufferedWriter buffer = new BufferedWriter(fwriter);
       buffer.append("<SearchResults editor=\"" + editor.getUUID() + "\"");
       buffer.append(" base=\"" + mySearch.base + "\"");
       buffer.append(" recursive=\"" + mySearch.recursive + "\"");
       buffer.append(" ignoreCR=\"" + mySearch.ignoreCR + "\"");
       buffer.append(
           " filePattern=\"" + ScilabXMLUtilities.getXMLString(mySearch.filePattern) + "\"");
       buffer.append(" fileCaseSensitive=\"" + mySearch.fileCaseSensitive + "\"");
       if (mySearch.wordPattern != null && !mySearch.wordPattern.isEmpty()) {
         buffer.append(
             " wordPattern=\"" + ScilabXMLUtilities.getXMLString(mySearch.wordPattern) + "\"");
       }
       buffer.append(" wordCaseSensitive=\"" + mySearch.wordCaseSensitive + "\"");
       buffer.append(" wholeWord=\"" + mySearch.wholeWord + "\"");
       buffer.append(" regexp=\"" + mySearch.regexp + "\"");
       buffer.append(">\n");
       mySearch.getResults().toXML(buffer, 1);
       buffer.append("</SearchResults>");
       buffer.close();
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
Example #3
0
 /**
  * Stop the current search
  *
  * @param searcher the key returned by getSearchResultsWindow
  */
 public static void stopSearch(Object searcher) {
   if (searcher != null && (searcher instanceof MyBackgroundSearch)) {
     ((MyBackgroundSearch) searcher).stop();
   }
 }