KickJava   Java API By Example, From Geeks To Geeks.

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


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.Set JavaDoc;
15
16 import org.eclipse.pde.core.plugin.IFragment;
17 import org.eclipse.pde.core.plugin.IPluginBase;
18 import org.eclipse.pde.core.plugin.IPluginImport;
19 import org.eclipse.pde.core.plugin.IPluginModelBase;
20 import org.eclipse.pde.internal.core.ModelEntry;
21
22 public class CallersContentProvider extends DependenciesViewPageContentProvider {
23     public CallersContentProvider(DependenciesView view) {
24         super(view);
25     }
26
27     /**
28      * @param id
29      * @return Set of IPluginBase
30      */

31     protected Set JavaDoc findReferences(String JavaDoc id) {
32         ModelEntry[] entries = getPluginManager().getEntries();
33         Set JavaDoc l = new HashSet JavaDoc(entries.length);
34         for (int i = 0; i < entries.length; i++) {
35             IPluginModelBase candidate = entries[i].getActiveModel();
36             IPluginBase candidateBase = candidate.getPluginBase(false);
37             if (candidateBase == null) {
38                 continue;
39             }
40             // refs by require
41
IPluginImport[] imports = candidateBase.getImports();
42             for (int m = 0; m < imports.length; m++) {
43                 String JavaDoc candidateId = imports[m].getId();
44                 if (id.equals(candidateId)) {
45                     l.add(candidateBase);
46                 }
47             }
48             // ref of plugin by fragment
49
if (candidateBase instanceof IFragment) {
50                 String JavaDoc candidateId = ((IFragment) candidateBase).getPluginId();
51                 if (id.equals(candidateId)) {
52                     l.add(candidateBase);
53                 }
54             }
55         }
56         return l;
57     }
58
59 }
60
Popular Tags