01: /*******************************************************************************
02: * Copyright (c) 2000, 2007 IBM Corporation and others.
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.views.dependencies;
11:
12: import java.util.HashSet;
13: import java.util.Iterator;
14: import java.util.Set;
15:
16: import org.eclipse.jface.viewers.IStructuredContentProvider;
17: import org.eclipse.osgi.service.resolver.BundleDescription;
18: import org.eclipse.pde.core.plugin.IPluginModelBase;
19:
20: public class CallersListContentProvider extends CallersContentProvider
21: implements IStructuredContentProvider {
22:
23: public CallersListContentProvider(DependenciesView view) {
24: super (view);
25: }
26:
27: /**
28: * @see IStructuredContentProvider#getElements(Object)
29: */
30: public Object[] getElements(Object inputElement) {
31: // input IPluginModelBase
32: BundleDescription desc = null;
33: if (inputElement instanceof IPluginModelBase) {
34: desc = ((IPluginModelBase) inputElement)
35: .getBundleDescription();
36: } else if (inputElement instanceof BundleDescription) {
37: desc = (BundleDescription) inputElement;
38: }
39: if (desc != null) {
40: Set callers = new HashSet();
41: Set candidates = new HashSet();
42: candidates.addAll(findReferences(desc));
43: while (!candidates.isEmpty()) {
44: Set newCandidates = new HashSet();
45: for (Iterator it = candidates.iterator(); it.hasNext();) {
46: Object o = it.next();
47: it.remove();
48: BundleDescription caller = (BundleDescription) o;
49: if (!callers.contains(caller)) {
50: callers.add(caller);
51: newCandidates.addAll(findReferences(caller));
52: }
53: }
54: candidates = newCandidates;
55:
56: }
57:
58: return callers.toArray();
59: }
60: return new Object[0];
61: }
62: }
|