Example #1
0
  /**
   * @see
   *     org.eclipse.search.internal.ui.text.FileSearchQuery#run(org.eclipse.core.runtime.IProgressMonitor)
   */
  public IStatus run(final IProgressMonitor monitor) {
    AbstractTextSearchResult textResult = (AbstractTextSearchResult) this.getSearchResult();
    textResult.removeAll();

    Pattern searchPattern = this.getSearchPattern();
    boolean isFileSearchOnly = searchPattern.pattern().length() == 0;
    boolean searchInBinaries = !this.isScopeAllFileTypes();

    if (this.directory != null || this.isOpenEditorsOnly) {
      boolean onlyFilesEditorInput = isAllOpenEditorsOnWorkspace();
      if (!onlyFilesEditorInput || !isOpenEditorsOnly) {
        FileTextSearchResultCollector fcollector =
            new FileTextSearchResultCollector(textResult, isFileSearchOnly, searchInBinaries);
        String fs = directory == null ? "." : directory; // $NON-NLS-1$
        FileSystemTextSearchScope newSearchScope =
            FileNamePatternSearchScope.newSearchScope(
                new File[] {new File(fs)}, this.fScope.getFileNamePatterns());
        newSearchScope.setOpenEditors(this.isOpenEditorsOnly);
        return FileTextSearchEngine.createDefault()
            .search(newSearchScope, fcollector, searchPattern, monitor);
      }
    }
    TextSearchResultCollector collector =
        new TextSearchResultCollector(textResult, isFileSearchOnly, searchInBinaries);
    AptanaTextEngine aptanaTextEngine = new AptanaTextEngine();
    aptanaTextEngine.setOpenEditorsOnly(this.isOpenEditorsOnly);
    aptanaTextEngine.needsRefresh(this.refresh);
    return aptanaTextEngine.search(this.fScope, collector, searchPattern, monitor);
  }
Example #2
0
 /**
  * @param result
  * @param monitor
  * @param entry
  * @return
  */
 public IStatus searchInFile(
     AbstractTextSearchResult result, IProgressMonitor monitor, File entry) {
   FileSystemTextSearchScope scope =
       FileSystemTextSearchScope.newSearchScope(
           new File[] {entry}, new String[] {"*"}, true); // $NON-NLS-1$
   Pattern searchPattern = this.getSearchPattern();
   boolean isFileSearchOnly = searchPattern.pattern().length() == 0;
   FileTextSearchResultCollector collector =
       new FileTextSearchResultCollector(result, isFileSearchOnly, true);
   return FileTextSearchEngine.createDefault().search(scope, collector, searchPattern, monitor);
 }