1 11 package org.eclipse.update.internal.search; 12 13 import java.net.*; 14 import java.util.ArrayList ; 15 16 import org.eclipse.core.runtime.*; 17 import org.eclipse.update.core.*; 18 import org.eclipse.update.search.*; 19 20 23 public class OptionalFeatureSearchCategory extends BaseSearchCategory { 24 private IUpdateSearchQuery[] queries; 25 private ArrayList vids; 26 private static final String CATEGORY_ID = 27 "org.eclipse.update.core.unified-search"; 29 private class OptionalQuery implements IUpdateSearchQuery { 30 public void run( 31 ISite site, 32 String [] categoriesToSkip, 33 IUpdateSearchFilter filter, 34 IUpdateSearchResultCollector collector, 35 IProgressMonitor monitor) { 36 37 monitor.beginTask("", vids.size()); for (int i = 0; i < vids.size(); i++) { 39 VersionedIdentifier vid = (VersionedIdentifier) vids.get(i); 40 monitor.subTask(vid.toString()); 41 IFeature feature = 42 createFeature( 43 site, 44 vid, 45 new SubProgressMonitor(monitor, 1)); 46 if (feature!=null && filter.accept(feature)) 47 collector.accept(feature); 48 } 49 } 50 51 private IFeature createFeature( 52 ISite site, 53 VersionedIdentifier vid, 54 IProgressMonitor monitor) { 55 try { 56 URL siteURL = site.getURL(); 57 String relative = vid.toString(); 63 URL featureURL = new URL(siteURL, "features/" + relative+".jar"); return site.createFeature( 65 "org.eclipse.update.core.packaged", featureURL, 67 monitor); 68 } catch (Exception e) { 69 return null; 70 } 71 } 72 73 76 public IQueryUpdateSiteAdapter getQuerySearchSite() { 77 return null; 78 } 79 } 80 81 public void addVersionedIdentifier(VersionedIdentifier vid) { 82 vids.add(vid); 83 } 84 85 public void clear() { 86 vids.clear(); 87 } 88 89 public OptionalFeatureSearchCategory() { 90 super(CATEGORY_ID); 91 vids = new ArrayList (); 92 queries = new IUpdateSearchQuery[] { new OptionalQuery()}; 93 } 94 95 public IUpdateSearchQuery[] getQueries() { 96 return queries; 97 } 98 } 99 | Popular Tags |