1 11 package org.eclipse.pde.internal.ui.search; 12 13 import java.util.HashSet ; 14 15 import org.eclipse.core.resources.*; 16 import org.eclipse.core.resources.IProject; 17 import org.eclipse.core.resources.IResource; 18 import org.eclipse.core.runtime.*; 19 import org.eclipse.jdt.core.IJavaElement; 20 import org.eclipse.jface.action.Action; 21 import org.eclipse.pde.core.plugin.IPluginExtensionPoint; 22 import org.eclipse.pde.internal.core.search.PluginSearchInput; 23 import org.eclipse.pde.internal.core.search.PluginSearchScope; 24 import org.eclipse.pde.internal.ui.PDEPlugin; 25 import org.eclipse.search.ui.ISearchResultViewEntry; 26 import org.eclipse.search.ui.SearchUI; 27 28 36 public class ReferencesInPluginAction extends Action { 37 38 private static final String KEY_REFERENCES = "DependencyExtent.references"; 40 ISearchResultViewEntry entry; 41 42 43 public ReferencesInPluginAction(ISearchResultViewEntry entry) { 44 this.entry = entry; 45 setText(PDEPlugin.getResourceString(KEY_REFERENCES) + " " + entry.getResource().getName()); } 47 48 public void run() { 49 try { 50 SearchUI.activateSearchResultView(); 51 IWorkspaceRunnable operation = null; 52 Object object = entry.getGroupByKey(); 53 if (object instanceof IJavaElement) { 54 operation = new JavaSearchOperation((IJavaElement)object, (IProject)entry.getResource()); 55 } else { 56 operation = 57 new PluginSearchUIOperation( 58 getPluginSearchInput((IPluginExtensionPoint) object), 59 new PluginSearchResultCollector()); 60 } 61 PDEPlugin.getWorkspace().run(operation, null, IWorkspace.AVOID_UPDATE, new NullProgressMonitor()); 62 } catch (CoreException e) { 63 } 64 } 65 66 private PluginSearchInput getPluginSearchInput(IPluginExtensionPoint object) { 67 PluginSearchInput input = new PluginSearchInput(); 68 input.setSearchElement(PluginSearchInput.ELEMENT_EXTENSION_POINT); 69 input.setSearchString( 70 ((IPluginExtensionPoint) object).getPluginBase().getId() 71 + "." + ((IPluginExtensionPoint) object).getId()); 73 input.setSearchLimit(PluginSearchInput.LIMIT_REFERENCES); 74 HashSet set = new HashSet (); 75 IResource resource = ((IProject)entry.getResource()).getFile("plugin.xml"); if (!resource.exists()) 77 resource = ((IProject)entry.getResource()).getFile("fragment.xml"); 79 set.add(resource); 80 input.setSearchScope( 81 new PluginSearchScope( 82 PluginSearchScope.SCOPE_SELECTION, 83 PluginSearchScope.EXTERNAL_SCOPE_NONE, 84 set)); 85 return input; 86 } 87 88 89 } 90 | Popular Tags |