1 11 package org.eclipse.pde.internal.ui.search; 12 13 import org.eclipse.pde.core.plugin.IPlugin; 14 import org.eclipse.pde.core.plugin.IPluginExtensionPoint; 15 import org.eclipse.pde.core.plugin.IPluginImport; 16 import org.eclipse.pde.core.plugin.IPluginModelBase; 17 import org.eclipse.pde.internal.core.search.PluginSearchInput; 18 import org.eclipse.pde.internal.core.search.PluginSearchScope; 19 import org.eclipse.pde.internal.ui.PDEPluginImages; 20 import org.eclipse.pde.internal.ui.PDEUIMessages; 21 import org.eclipse.search.ui.ISearchQuery; 22 23 24 public class FindReferencesAction extends BaseSearchAction { 25 26 private Object fSelectedObject; 27 private String fPluginID; 28 29 public FindReferencesAction(Object object) { 30 this(object, null); 31 } 32 33 public FindReferencesAction(Object object, String pluginID) { 34 super(PDEUIMessages.SearchAction_references); 35 fSelectedObject = object; 36 fPluginID = pluginID; 37 initialize(); 38 } 39 40 private void initialize() { 41 setImageDescriptor(PDEPluginImages.DESC_PSEARCH_OBJ); 42 } 43 44 protected ISearchQuery createSearchQuery() { 45 PluginSearchInput input = new PluginSearchInput(); 46 if (fSelectedObject instanceof IPlugin) { 47 input.setSearchElement(PluginSearchInput.ELEMENT_PLUGIN); 48 input.setSearchString(((IPlugin) fSelectedObject).getId()); 49 } else if (fSelectedObject instanceof IPluginExtensionPoint) { 50 input.setSearchElement(PluginSearchInput.ELEMENT_EXTENSION_POINT); 51 IPluginModelBase model = ((IPluginExtensionPoint) fSelectedObject).getPluginModel(); 52 String id = model.getPluginBase().getId(); 53 if (id == null || id.trim().length() == 0) 54 id = fPluginID; 55 if (id == null || id.trim().length() == 0) 56 id = "*"; input.setSearchString( 58 id 59 + "." + ((IPluginExtensionPoint) fSelectedObject).getId()); 61 } else if (fSelectedObject instanceof IPluginImport) { 62 input.setSearchElement(PluginSearchInput.ELEMENT_PLUGIN); 63 input.setSearchString(((IPluginImport) fSelectedObject).getId()); 64 } 65 input.setSearchLimit(PluginSearchInput.LIMIT_REFERENCES); 66 input.setSearchScope(new PluginSearchScope()); 67 return new PluginSearchQuery(input); 68 } 69 70 } 71 | Popular Tags |