1 11 package org.eclipse.search.internal.core.text; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.IProgressMonitor; 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.core.runtime.MultiStatus; 17 18 import org.eclipse.jface.util.Assert; 19 20 import org.eclipse.search.ui.NewSearchUI; 21 22 import org.eclipse.search.internal.core.SearchScope; 23 import org.eclipse.search.internal.ui.Messages; 24 import org.eclipse.search.internal.ui.SearchMessages; 25 26 public class TextSearchEngine { 27 28 public IStatus search(SearchScope scope, boolean visitDerived, ITextSearchResultCollector collector, MatchLocator matchLocator) { 29 Assert.isNotNull(scope); 30 Assert.isNotNull(collector); 31 Assert.isNotNull(matchLocator); 32 IProgressMonitor monitor= collector.getProgressMonitor(); 33 34 String message= SearchMessages.TextSearchEngine_statusMessage; 35 MultiStatus status= new MultiStatus(NewSearchUI.PLUGIN_ID, IStatus.OK, message, null); 36 37 int amountOfWork= new AmountOfWorkCalculator(scope, status, visitDerived).process(); 38 try { 39 monitor.beginTask("", amountOfWork); if (amountOfWork > 0) { 41 Integer [] args= new Integer [] {new Integer (1), new Integer (amountOfWork)}; 42 monitor.setTaskName(Messages.format(SearchMessages.TextSearchEngine_scanning, args)); 43 } 44 collector.aboutToStart(); 45 TextSearchVisitor visitor= new TextSearchVisitor(matchLocator, scope, visitDerived, collector, status, amountOfWork); 46 visitor.process(); 47 } catch (CoreException ex) { 48 status.add(ex.getStatus()); 49 } finally { 50 monitor.done(); 51 try { 52 collector.done(); 53 } catch (CoreException ex) { 54 status.add(ex.getStatus()); 55 } 56 } 57 return status; 58 } 59 } 60 | Popular Tags |