1 19 20 25 26 package org.netbeans.modules.javadoc.search; 27 28 import java.util.ArrayList ; 29 import org.openide.ErrorManager; 30 31 import org.openide.filesystems.FileObject; 32 33 38 class JavadocSearchEngineImpl extends JavadocSearchEngine { 39 40 private ArrayList tasks; 41 42 private IndexSearchThread.DocIndexItemConsumer diiConsumer; 43 44 48 public void search(String [] items, final SearchEngineCallback callback) throws NoJavadocException { 49 FileObject docRoots[] = JavadocRegistry.getDefault().getDocRoots(); 50 tasks = new ArrayList ( docRoots.length ); 51 52 diiConsumer = new IndexSearchThread.DocIndexItemConsumer() { 53 public void addDocIndexItem( final DocIndexItem dii ) { 54 callback.addItem(dii); 55 } 56 57 public void indexSearchThreadFinished( IndexSearchThread t ) { 58 tasks.remove( t ); 59 if ( tasks.isEmpty() ) 60 callback.finished(); 61 } 62 }; 63 64 if ( docRoots.length <= 0 ) { 65 callback.finished(); 66 throw new NoJavadocException(); 67 } 68 String toFind = items[0]; 69 70 for( int i = 0; i < docRoots.length; i++ ) { 71 72 JavadocSearchType st = JavadocRegistry.getDefault().findSearchType( docRoots[i] ); 73 if (st == null) { 74 ErrorManager.getDefault().log ("NO Search type for " + docRoots[i]); 75 continue; 76 } 77 FileObject indexFo = st.getDocFileObject( docRoots[i] ); 78 if (indexFo == null) { 79 ErrorManager.getDefault().log ("NO Index files fot " + docRoots[i] ); 80 continue; 81 } 82 83 IndexSearchThread searchThread = st.getSearchThread( toFind, indexFo, diiConsumer ); 84 85 tasks.add( searchThread ); 86 searchThread.go(); 87 } 88 } 90 91 93 public void stop() { 94 for( int i = 0; i < tasks.size(); i++ ) { 95 SearchThreadJdk12 searchThread = (SearchThreadJdk12)tasks.get( i ); 96 searchThread.finish(); 97 } 98 } 99 } 100 | Popular Tags |