KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > editors > JimpleOutlineContentProvider


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20
21
22 package ca.mcgill.sable.soot.editors;
23
24 import org.eclipse.jface.viewers.ITreeContentProvider;
25 import org.eclipse.jface.viewers.Viewer;
26
27
28
29 public class JimpleOutlineContentProvider implements ITreeContentProvider {
30
31
32     protected static final Object JavaDoc[] EMPTY_ARRAY = new Object JavaDoc[0];
33
34     
35     /**
36      * Constructor for OptionsTreeContentProvider.
37      */

38     public JimpleOutlineContentProvider() {
39         super();
40     }
41
42     /**
43      * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(Object)
44      */

45     public Object JavaDoc[] getChildren(Object JavaDoc parentElement) {
46         if (parentElement instanceof JimpleOutlineObject) {
47             JimpleOutlineObject opt = (JimpleOutlineObject)parentElement;
48             if (opt.getChildren() != null) {
49                 return opt.getChildren().toArray();
50             }
51             else {
52                 return EMPTY_ARRAY;
53             }
54         }
55         else {
56             return EMPTY_ARRAY;
57         }
58         
59     }
60     
61
62     /**
63      * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(Object)
64      */

65     public Object JavaDoc getParent(Object JavaDoc element) {
66         return ((JimpleOutlineObject)element).getParent();
67     }
68
69     /**
70      * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(Object)
71      */

72     public boolean hasChildren(Object JavaDoc element) {
73         if (element instanceof JimpleOutlineObject) {
74             if (((JimpleOutlineObject)element).getChildren() != null) {
75                 return true;
76             }
77             else {
78                 return false;
79             }
80         }
81         else {
82             return false;
83         }
84     }
85
86     /**
87      * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(Object)
88      */

89     public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
90         return getChildren(inputElement);
91     }
92
93     /**
94      * @see org.eclipse.jface.viewers.IContentProvider#dispose()
95      */

96     public void dispose() {
97     }
98
99     /**
100      * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(Viewer, Object, Object)
101      */

102     public void inputChanged(Viewer viewer, Object JavaDoc oldInput, Object JavaDoc newInput) {
103     }
104
105 }
106
Popular Tags