1 11 package org.eclipse.pde.internal.ui.search; 12 13 import org.eclipse.core.resources.IFile; 14 import org.eclipse.jface.action.IAction; 15 import org.eclipse.jface.viewers.ISelection; 16 import org.eclipse.jface.viewers.IStructuredSelection; 17 import org.eclipse.pde.core.plugin.IPluginModelBase; 18 import org.eclipse.pde.core.plugin.PluginRegistry; 19 import org.eclipse.pde.internal.core.search.PluginSearchInput; 20 import org.eclipse.pde.internal.core.search.PluginSearchScope; 21 import org.eclipse.search.ui.ISearchQuery; 22 import org.eclipse.search.ui.NewSearchUI; 23 import org.eclipse.ui.IObjectActionDelegate; 24 import org.eclipse.ui.IWorkbenchPart; 25 26 public class FindPluginReferencesAction implements IObjectActionDelegate { 27 private String fSearchString = null; 28 29 33 public void setActivePart(IAction action, IWorkbenchPart targetPart) { 34 } 35 36 40 public void run(IAction action) { 41 if (fSearchString != null) { 42 NewSearchUI.activateSearchResultView(); 43 NewSearchUI.runQueryInBackground(createSearchQuery()); 44 } 45 } 46 47 private ISearchQuery createSearchQuery() { 48 PluginSearchInput input = new PluginSearchInput(); 49 input.setSearchElement(PluginSearchInput.ELEMENT_PLUGIN); 50 input.setSearchLimit(PluginSearchInput.LIMIT_REFERENCES); 51 input.setSearchString(fSearchString); 52 input.setSearchScope(new PluginSearchScope()); 53 return new PluginSearchQuery(input); 54 } 55 56 60 public void selectionChanged(IAction action, ISelection selection) { 61 fSearchString = null; 62 if (selection instanceof IStructuredSelection) { 63 IStructuredSelection sSelection = (IStructuredSelection) selection; 64 if (sSelection.size() == 1) { 65 IFile file = (IFile) sSelection.getFirstElement(); 66 IPluginModelBase model = PluginRegistry.findModel(file.getProject()); 67 if (model != null) 68 fSearchString = model.getPluginBase().getId(); 69 } 70 } 71 } 72 73 } 74 | Popular Tags |