KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > view > CallersListContentProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.view;
12
13 import java.util.HashSet JavaDoc;
14 import java.util.Iterator JavaDoc;
15 import java.util.Set JavaDoc;
16
17 import org.eclipse.jface.viewers.IStructuredContentProvider;
18 import org.eclipse.pde.core.plugin.IPluginBase;
19 import org.eclipse.pde.core.plugin.IPluginModelBase;
20
21 public class CallersListContentProvider extends CallersContentProvider
22         implements IStructuredContentProvider {
23
24     public CallersListContentProvider(DependenciesView view) {
25         super(view);
26     }
27
28     /**
29      * @see IStructuredContentProvider#getElements(Object)
30      */

31     public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
32         // input IPluginModelBase
33
if (inputElement instanceof IPluginModelBase) {
34             IPluginBase pluginBase = ((IPluginModelBase) inputElement)
35                     .getPluginBase();
36
37             Set JavaDoc callers = new HashSet JavaDoc();
38             Set JavaDoc candidates = new HashSet JavaDoc();
39             candidates.addAll(findReferences(pluginBase.getId()));
40             while (!candidates.isEmpty()) {
41                 Set JavaDoc newCandidates = new HashSet JavaDoc();
42                 for (Iterator JavaDoc it = candidates.iterator(); it.hasNext();) {
43                     Object JavaDoc o = it.next();
44                     it.remove();
45                     IPluginBase caller = (IPluginBase) o;
46                     if (!callers.contains(caller)) {
47                         callers.add(caller);
48                         newCandidates.addAll(findReferences(caller.getId()));
49                     }
50                 }
51                 candidates = newCandidates;
52
53             }
54
55             return callers.toArray();
56         }
57         return new Object JavaDoc[0];
58     }
59 }
60
Popular Tags