1 11 package org.eclipse.pde.internal.ui.search; 12 13 import org.eclipse.core.runtime.IProgressMonitor; 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.core.runtime.Status; 16 import org.eclipse.pde.core.ISourceObject; 17 import org.eclipse.pde.internal.core.search.PluginSearchInput; 18 import org.eclipse.search.ui.ISearchQuery; 19 import org.eclipse.search.ui.ISearchResult; 20 import org.eclipse.search.ui.text.AbstractTextSearchResult; 21 import org.eclipse.search.ui.text.Match; 22 23 public class PluginSearchQuery implements ISearchQuery { 24 25 private SearchResult fSearchResult; 26 27 private PluginSearchInput fSearchInput; 28 29 public PluginSearchQuery(PluginSearchInput input) { 30 fSearchInput = input; 31 } 32 33 38 public IStatus run(IProgressMonitor monitor) { 39 final AbstractTextSearchResult result = (AbstractTextSearchResult) getSearchResult(); 40 result.removeAll(); 41 ISearchResultCollector collector = new ISearchResultCollector() { 42 public void accept(Object match) { 43 if (match instanceof ISourceObject) { 44 ISourceObject object = (ISourceObject) match; 45 result.addMatch(new Match(match, Match.UNIT_LINE, 46 object.getStartLine() - 1, 1)); 47 } 48 } 49 }; 50 PluginSearchOperation op = new PluginSearchOperation(fSearchInput, collector); 51 op.execute(monitor); 52 monitor.done(); 53 return Status.OK_STATUS; 54 } 55 56 61 public String getLabel() { 62 return fSearchInput.getSearchString(); 63 } 64 65 66 71 public boolean canRerun() { 72 return true; 73 } 74 75 80 public boolean canRunInBackground() { 81 return true; 82 } 83 84 89 public ISearchResult getSearchResult() { 90 if (fSearchResult == null) 91 fSearchResult = new SearchResult(this); 92 return fSearchResult; 93 } 94 95 } 96 | Popular Tags |