1 11 package org.eclipse.pde.internal.ui.search.dependencies; 12 13 import java.util.ArrayList ; 14 15 import org.eclipse.core.resources.IProject; 16 import org.eclipse.core.runtime.IProgressMonitor; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.core.runtime.Status; 19 import org.eclipse.jdt.core.IPackageFragmentRoot; 20 import org.eclipse.jdt.core.JavaCore; 21 import org.eclipse.jdt.core.JavaModelException; 22 import org.eclipse.pde.internal.ui.PDEUIMessages; 23 import org.eclipse.search.ui.ISearchQuery; 24 import org.eclipse.search.ui.ISearchResult; 25 import org.eclipse.search.ui.text.AbstractTextSearchResult; 26 27 28 public class DependencyExtentQuery implements ISearchQuery { 29 30 private ISearchResult fSearchResult; 31 private IProject fProject; 32 private String fImportID; 33 34 public DependencyExtentQuery(IProject project, String importID) { 35 fProject = project; 36 fImportID = importID; 37 } 38 39 42 public IStatus run(IProgressMonitor monitor) { 43 final AbstractTextSearchResult result = (AbstractTextSearchResult) getSearchResult(); 44 result.removeAll(); 45 DependencyExtentOperation op = new DependencyExtentOperation(fProject, fImportID, result); 46 op.execute(monitor); 47 return Status.OK_STATUS; 48 } 49 50 53 public String getLabel() { 54 return PDEUIMessages.DependencyExtentQuery_label + " " + fImportID; } 56 57 60 public boolean canRerun() { 61 return true; 62 } 63 64 67 public boolean canRunInBackground() { 68 return true; 69 } 70 71 74 public ISearchResult getSearchResult() { 75 if (fSearchResult == null) 76 fSearchResult = new DependencyExtentSearchResult(this); 77 return fSearchResult; 78 } 79 80 public IPackageFragmentRoot[] getDirectRoots() { 81 ArrayList result = new ArrayList (); 82 try { 83 IPackageFragmentRoot[] roots = JavaCore.create(fProject).getPackageFragmentRoots(); 84 for (int i = 0; i < roots.length; i++) { 85 if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE 86 || (roots[i].isArchive() && !roots[i].isExternal())) { 87 result.add(roots[i]); 88 } 89 } 90 } catch (JavaModelException e) { 91 } 92 return (IPackageFragmentRoot[]) result 93 .toArray(new IPackageFragmentRoot[result.size()]); 94 } 95 96 } 97 | Popular Tags |