KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > views > dependencies > CallersTreeContentProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.views.dependencies;
12
13 import org.eclipse.jface.viewers.ITreeContentProvider;
14 import org.eclipse.osgi.service.resolver.BundleDescription;
15 import org.eclipse.pde.core.plugin.IPluginBase;
16 import org.eclipse.pde.core.plugin.IPluginModelBase;
17
18 public class CallersTreeContentProvider extends CallersContentProvider
19         implements ITreeContentProvider {
20
21     /**
22      * Constructor.
23      */

24     public CallersTreeContentProvider(DependenciesView view) {
25         super(view);
26     }
27
28     public Object JavaDoc[] getChildren(Object JavaDoc parentElement) {
29         if (parentElement instanceof IPluginBase) {
30             parentElement = ((IPluginBase)parentElement).getModel();
31         }
32         if (parentElement instanceof IPluginModelBase ) {
33             parentElement = ((IPluginModelBase)parentElement).getBundleDescription();
34         }
35         if (parentElement instanceof BundleDescription) {
36             return findReferences((BundleDescription)parentElement).toArray();
37         }
38         return new Object JavaDoc[0];
39     }
40
41     /**
42      * @see IStructuredContentProvider#getElements(Object)
43      * @return Object[] with 0 or 1 IPluginBase
44      */

45     public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
46         if (inputElement instanceof IPluginModelBase) {
47             return new Object JavaDoc[] { ((IPluginModelBase) inputElement)
48                     .getPluginBase() };
49         }
50         return new Object JavaDoc[0];
51     }
52
53     /**
54      * @see ITreeContentProvider#getParent(Object)
55      */

56     public Object JavaDoc getParent(Object JavaDoc element) {
57         return null;
58     }
59
60     /**
61      * @see ITreeContentProvider#hasChildren(Object)
62      */

63     public boolean hasChildren(Object JavaDoc element) {
64         return getChildren(element).length > 0;
65     }
66
67 }
68
Popular Tags