KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > javadocexport > JavadocMemberContentProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.jdt.internal.ui.javadocexport;
12
13 import org.eclipse.jface.viewers.ITreeContentProvider;
14 import org.eclipse.jface.viewers.Viewer;
15
16 import org.eclipse.jdt.core.ICompilationUnit;
17 import org.eclipse.jdt.core.IPackageFragment;
18 import org.eclipse.jdt.core.JavaModelException;
19
20 import org.eclipse.jdt.internal.ui.JavaPlugin;
21
22 public class JavadocMemberContentProvider implements ITreeContentProvider {
23
24     /*
25      * @see ITreeContentProvider#getChildren(Object)
26      */

27     public Object JavaDoc[] getChildren(Object JavaDoc parentElement) {
28         return new Object JavaDoc[0];
29     }
30
31     /*
32      * @see ITreeContentProvider#getParent(Object)
33      */

34     public Object JavaDoc getParent(Object JavaDoc element) {
35         //@test
36
//System.out.println(element.getClass().toString());
37
if (element instanceof IPackageFragment)
38             return ((IPackageFragment) element).getParent();
39         return null;
40     }
41
42     /*
43      * @see ITreeContentProvider#hasChildren(Object)
44      */

45     public boolean hasChildren(Object JavaDoc element) {
46         try {
47             if (element instanceof IPackageFragment) {
48                 IPackageFragment iPackageFragment= (IPackageFragment) element;
49                 return (iPackageFragment.getChildren().length > 0);
50             }
51         } catch (JavaModelException e) {
52         }
53         return false;
54     }
55
56     /*
57      * @see IStructuredContentProvider#getElements(Object)
58      */

59     public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
60         try {
61             if (inputElement instanceof IPackageFragment) {
62                 ICompilationUnit[] cu= ((IPackageFragment) inputElement).getCompilationUnits();
63                 return cu;
64             }
65         } catch (JavaModelException e) {
66             JavaPlugin.log(e);
67         }
68         return new Object JavaDoc[0];
69     }
70
71     /*
72      * @see IContentProvider#dispose()
73      */

74     public void dispose() {
75     }
76
77     /*
78      * @see IContentProvider#inputChanged(Viewer, Object, Object)
79      */

80     public void inputChanged(Viewer viewer, Object JavaDoc oldInput, Object JavaDoc newInput) {
81     }
82
83 }
84
Popular Tags