KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.eclipse.jface.viewers.ITreeContentProvider;
14 import org.eclipse.pde.core.plugin.IPlugin;
15 import org.eclipse.pde.core.plugin.IPluginBase;
16 import org.eclipse.pde.core.plugin.IPluginImport;
17 import org.eclipse.pde.core.plugin.IPluginModelBase;
18 import org.eclipse.pde.internal.core.PDECore;
19
20 public class CalleesTreeContentProvider extends CalleesContentProvider
21         implements ITreeContentProvider {
22
23     /**
24      * Constructor.
25      */

26     public CalleesTreeContentProvider(DependenciesView view) {
27         super(view);
28     }
29
30     /**
31      * @see ITreeContentProvider#getChildren(Object)
32      */

33     public Object JavaDoc[] getChildren(Object JavaDoc parentElement) {
34         if (parentElement instanceof IPluginBase) {
35             IPluginBase plugin = (IPluginBase) parentElement;
36             return findCallees(plugin);
37         } else if (parentElement instanceof IPluginImport) {
38             IPluginImport pluginImport = (IPluginImport) parentElement;
39             String JavaDoc id = pluginImport.getId();
40             IPlugin importedPlugin = PDECore.getDefault().findPlugin(id);
41             if (importedPlugin != null)
42                 return findCallees(importedPlugin);
43
44         }
45         return new Object JavaDoc[0];
46     }
47
48     /**
49      * @see IStructuredContentProvider#getElements(Object)
50      * @return Object[] of IPluginBase
51      */

52     public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
53         if (inputElement instanceof IPluginModelBase) {
54             return new Object JavaDoc[] { ((IPluginModelBase) inputElement)
55                     .getPluginBase() };
56         }
57         return new Object JavaDoc[0];
58     }
59
60     /**
61      * @see ITreeContentProvider#getParent(Object)
62      */

63     public Object JavaDoc getParent(Object JavaDoc element) {
64         return null;
65     }
66
67     /**
68      * @see ITreeContentProvider#hasChildren(Object)
69      */

70     public boolean hasChildren(Object JavaDoc element) {
71         return getChildren(element).length > 0;
72     }
73
74 }
75
Popular Tags