KickJava   Java API By Example, From Geeks To Geeks.

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


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.Set JavaDoc;
14
15 import org.eclipse.jface.viewers.ITreeContentProvider;
16 import org.eclipse.pde.core.plugin.IPlugin;
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
21 public class CallersTreeContentProvider extends CallersContentProvider
22         implements ITreeContentProvider {
23
24     /**
25      * Constructor.
26      */

27     public CallersTreeContentProvider(DependenciesView view) {
28         super(view);
29     }
30
31     /**
32      * @see ITreeContentProvider#getChildren(Object) return Object[] of
33      * IPluginBase
34      */

35     public Object JavaDoc[] getChildren(Object JavaDoc parentElement) {
36         String JavaDoc id = null;
37         if (parentElement instanceof IPluginModelBase) {
38             IPluginBase pluginBase = ((IPluginModelBase) parentElement)
39                     .getPluginBase(false);
40             if (pluginBase != null)
41                 id = pluginBase.getId();
42         } else if (parentElement instanceof IPlugin) {
43             id = ((IPlugin) parentElement).getId();
44         } else if (parentElement instanceof IPluginImport) {
45             id = ((IPluginImport) parentElement).getId();
46         }
47         if (id == null) {
48             return new Object JavaDoc[0];
49         }
50         Set JavaDoc l = findReferences(id);
51         return l.toArray();
52     }
53
54     /**
55      * @see IStructuredContentProvider#getElements(Object)
56      * @return Object[] with 0 or 1 IPluginBase
57      */

58     public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
59         if (inputElement instanceof IPluginModelBase) {
60             return new Object JavaDoc[] { ((IPluginModelBase) inputElement)
61                     .getPluginBase() };
62         }
63         return new Object JavaDoc[0];
64     }
65
66     /**
67      * @see ITreeContentProvider#getParent(Object)
68      */

69     public Object JavaDoc getParent(Object JavaDoc element) {
70         return null;
71     }
72
73     /**
74      * @see ITreeContentProvider#hasChildren(Object)
75      */

76     public boolean hasChildren(Object JavaDoc element) {
77         return getChildren(element).length > 0;
78     }
79
80 }
81
Popular Tags