1 11 package org.eclipse.pde.internal.ui.search.dependencies; 12 13 import java.util.Map ; 14 import java.util.Set ; 15 16 import org.eclipse.core.resources.IProject; 17 import org.eclipse.core.runtime.IProgressMonitor; 18 import org.eclipse.core.runtime.SubProgressMonitor; 19 import org.eclipse.jdt.core.IClassFile; 20 import org.eclipse.osgi.service.resolver.ExportPackageDescription; 21 import org.eclipse.pde.core.plugin.IPluginModelBase; 22 import org.eclipse.pde.internal.core.PDECore; 23 import org.eclipse.pde.internal.core.PluginModelManager; 24 import org.eclipse.pde.internal.core.ibundle.IBundle; 25 import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase; 26 import org.eclipse.pde.internal.ui.PDEUIMessages; 27 28 public class AddNewBinaryDependenciesOperation extends AddNewDependenciesOperation { 29 protected IClassFile [] fClassFiles; 30 31 public AddNewBinaryDependenciesOperation(IProject project, IBundlePluginModelBase base) { 32 this(project, base, PackageFinder.getClassFiles(project, base)); 33 } 34 35 public AddNewBinaryDependenciesOperation(IProject project, IBundlePluginModelBase base, IClassFile[] classFiles) { 36 super(project, base); 37 fClassFiles = classFiles; 38 } 39 40 protected void findSecondaryDependencies(String [] secDeps, Set ignorePkgs, Map additionalDeps, IBundle bundle, boolean useRequireBundle, 41 IProgressMonitor monitor) { 42 monitor.beginTask(PDEUIMessages.AddNewDependenciesOperation_searchProject, 100); 43 Set projectPkgs = PackageFinder.findPackagesInClassFiles(fClassFiles, new SubProgressMonitor(monitor, 75)); 44 PluginModelManager manager = PDECore.getDefault().getModelManager(); 45 IProgressMonitor searchMonitor = new SubProgressMonitor(monitor, 25); 46 searchMonitor.beginTask("", secDeps.length); for (int i = 0; i < secDeps.length; i++) { 48 IPluginModelBase base = manager.findModel(secDeps[i]); 49 if (base != null) { 50 ExportPackageDescription pkgs[] = findExportedPackages(base.getBundleDescription()); 51 for (int j = 0; j < pkgs.length; j++) { 52 String pkgName = pkgs[j].getName(); 53 if (!ignorePkgs.contains(pkgName) && projectPkgs.contains(pkgName)) { 54 additionalDeps.put(pkgs[j], secDeps[i]); 55 ignorePkgs.add(pkgName); 56 if (useRequireBundle) { 57 while (j < pkgs.length) { 58 ignorePkgs.add(pkgs[j].getName()); 59 j++; 60 } 61 } 62 } 63 } 64 } 65 searchMonitor.worked(1); 66 } 67 } 68 69 } 70 | Popular Tags |