01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.search.dependencies;
11:
12: import java.util.Map;
13: import java.util.Set;
14:
15: import org.eclipse.core.resources.IProject;
16: import org.eclipse.core.runtime.IProgressMonitor;
17: import org.eclipse.core.runtime.SubProgressMonitor;
18: import org.eclipse.jdt.core.IClassFile;
19: import org.eclipse.osgi.service.resolver.ExportPackageDescription;
20: import org.eclipse.pde.core.plugin.IPluginModelBase;
21: import org.eclipse.pde.internal.core.PDECore;
22: import org.eclipse.pde.internal.core.PluginModelManager;
23: import org.eclipse.pde.internal.core.ibundle.IBundle;
24: import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase;
25: import org.eclipse.pde.internal.ui.PDEUIMessages;
26:
27: public class AddNewBinaryDependenciesOperation extends
28: AddNewDependenciesOperation {
29: protected IClassFile[] fClassFiles;
30:
31: public AddNewBinaryDependenciesOperation(IProject project,
32: IBundlePluginModelBase base) {
33: this (project, base, PackageFinder.getClassFiles(project, base));
34: }
35:
36: public AddNewBinaryDependenciesOperation(IProject project,
37: IBundlePluginModelBase base, IClassFile[] classFiles) {
38: super (project, base);
39: fClassFiles = classFiles;
40: }
41:
42: protected void findSecondaryDependencies(String[] secDeps,
43: Set ignorePkgs, Map additionalDeps, IBundle bundle,
44: boolean useRequireBundle, IProgressMonitor monitor) {
45: monitor
46: .beginTask(
47: PDEUIMessages.AddNewDependenciesOperation_searchProject,
48: 100);
49: Set projectPkgs = PackageFinder.findPackagesInClassFiles(
50: fClassFiles, new SubProgressMonitor(monitor, 75));
51: PluginModelManager manager = PDECore.getDefault()
52: .getModelManager();
53: IProgressMonitor searchMonitor = new SubProgressMonitor(
54: monitor, 25);
55: searchMonitor.beginTask("", secDeps.length); //$NON-NLS-1$
56: for (int i = 0; i < secDeps.length; i++) {
57: IPluginModelBase base = manager.findModel(secDeps[i]);
58: if (base != null) {
59: ExportPackageDescription pkgs[] = findExportedPackages(base
60: .getBundleDescription());
61: for (int j = 0; j < pkgs.length; j++) {
62: String pkgName = pkgs[j].getName();
63: if (!ignorePkgs.contains(pkgName)
64: && projectPkgs.contains(pkgName)) {
65: additionalDeps.put(pkgs[j], secDeps[i]);
66: ignorePkgs.add(pkgName);
67: if (useRequireBundle) {
68: while (j < pkgs.length) {
69: ignorePkgs.add(pkgs[j].getName());
70: j++;
71: }
72: }
73: }
74: }
75: }
76: searchMonitor.worked(1);
77: }
78: }
79:
80: }
|