1 11 package org.eclipse.jdt.internal.ui; 12 13 import org.eclipse.core.resources.mapping.ResourceMapping; 14 15 import org.eclipse.core.runtime.IAdapterFactory; 16 17 18 import org.eclipse.search.ui.ISearchPageScoreComputer; 19 20 import org.eclipse.jdt.internal.corext.util.JavaElementResourceMapping; 21 22 import org.eclipse.jdt.internal.ui.browsing.LogicalPackage; 23 import org.eclipse.jdt.internal.ui.search.JavaSearchPageScoreComputer; 24 import org.eclipse.jdt.internal.ui.search.SearchUtil; 25 26 29 public class LogicalPackageAdapterFactory implements IAdapterFactory { 30 31 private static Class [] PROPERTIES= new Class [] { 32 ResourceMapping.class 33 }; 34 35 private Object fSearchPageScoreComputer; 37 38 public Class [] getAdapterList() { 39 updateLazyLoadedAdapters(); 40 return PROPERTIES; 41 } 42 43 public Object getAdapter(Object element, Class key) { 44 updateLazyLoadedAdapters(); 45 46 if (fSearchPageScoreComputer != null && ISearchPageScoreComputer.class.equals(key)) { 47 return fSearchPageScoreComputer; 48 } else if (ResourceMapping.class.equals(key)) { 49 if (!(element instanceof LogicalPackage)) 50 return null; 51 return JavaElementResourceMapping.create((LogicalPackage)element); 52 } 53 return null; 54 } 55 56 private void updateLazyLoadedAdapters() { 57 if (fSearchPageScoreComputer == null && SearchUtil.isSearchPlugInActivated()) 58 createSearchPageScoreComputer(); 59 } 60 61 private void createSearchPageScoreComputer() { 62 fSearchPageScoreComputer= new JavaSearchPageScoreComputer(); 63 PROPERTIES= new Class [] { 64 ISearchPageScoreComputer.class, 65 ResourceMapping.class 66 }; 67 } 68 } 69 | Popular Tags |