01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.ui.javadocexport;
11:
12: import org.eclipse.jface.viewers.ITreeContentProvider;
13: import org.eclipse.jface.viewers.Viewer;
14:
15: import org.eclipse.jdt.core.ICompilationUnit;
16: import org.eclipse.jdt.core.IPackageFragment;
17: import org.eclipse.jdt.core.JavaModelException;
18:
19: import org.eclipse.jdt.internal.ui.JavaPlugin;
20:
21: public class JavadocMemberContentProvider implements
22: ITreeContentProvider {
23:
24: /*
25: * @see ITreeContentProvider#getChildren(Object)
26: */
27: public Object[] getChildren(Object parentElement) {
28: return new Object[0];
29: }
30:
31: /*
32: * @see ITreeContentProvider#getParent(Object)
33: */
34: public Object getParent(Object 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 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[] getElements(Object inputElement) {
60: try {
61: if (inputElement instanceof IPackageFragment) {
62: ICompilationUnit[] cu = ((IPackageFragment) inputElement)
63: .getCompilationUnits();
64: return cu;
65: }
66: } catch (JavaModelException e) {
67: JavaPlugin.log(e);
68: }
69: return new Object[0];
70: }
71:
72: /*
73: * @see IContentProvider#dispose()
74: */
75: public void dispose() {
76: }
77:
78: /*
79: * @see IContentProvider#inputChanged(Viewer, Object, Object)
80: */
81: public void inputChanged(Viewer viewer, Object oldInput,
82: Object newInput) {
83: }
84:
85: }
|