KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > markers > internal > MarkerTreeContentProvider


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.ui.views.markers.internal;
12
13
14 import org.eclipse.jface.viewers.ITreeContentProvider;
15 import org.eclipse.jface.viewers.TreeViewer;
16 import org.eclipse.jface.viewers.Viewer;
17
18 /**
19  * The MarkerTreeContentProvider is the content provider for the marker trees.
20  *
21  * @since 3.2
22  *
23  */

24 public class MarkerTreeContentProvider implements ITreeContentProvider {
25
26     TreeViewer viewer;
27
28     boolean hierarchalMode = true;
29
30     private MarkerAdapter adapter;
31
32     /**
33      * Create a new content provider for the view.
34      */

35     MarkerTreeContentProvider() {
36     }
37
38     /*
39      * (non-Javadoc)
40      *
41      * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
42      */

43     public Object JavaDoc[] getChildren(Object JavaDoc parentElement) {
44         if (parentElement instanceof MarkerNode) {
45             return ((MarkerNode) parentElement).getChildren();
46         }
47         return Util.EMPTY_MARKER_ARRAY;
48     }
49
50     /*
51      * (non-Javadoc)
52      *
53      * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
54      */

55     public Object JavaDoc getParent(Object JavaDoc element) {
56         if (element instanceof MarkerNode) {
57             return ((MarkerNode) element).getParent();
58         }
59         return null;
60     }
61
62     /*
63      * (non-Javadoc)
64      *
65      * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
66      */

67     public boolean hasChildren(Object JavaDoc element) {
68         if (element instanceof MarkerNode) {
69             return ((MarkerNode) element).getChildren().length > 0;
70         }
71         return false;
72     }
73
74     /*
75      * (non-Javadoc)
76      *
77      * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
78      */

79     public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
80         return adapter.getElements();
81     }
82
83     /*
84      * (non-Javadoc)
85      *
86      * @see org.eclipse.jface.viewers.IContentProvider#dispose()
87      */

88     public void dispose() {
89         // Nothing to do here.
90
}
91
92     /*
93      * (non-Javadoc)
94      *
95      * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
96      * java.lang.Object, java.lang.Object)
97      */

98     public void inputChanged(Viewer viewer, Object JavaDoc oldInput, Object JavaDoc newInput) {
99         this.viewer = (TreeViewer) viewer;
100         adapter = (MarkerAdapter) newInput;
101
102     }
103 }
104
Popular Tags