KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > ui > SootOptionsContentProvider


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 package ca.mcgill.sable.soot.ui;
21
22 import org.eclipse.jface.viewers.ITreeContentProvider;
23 import org.eclipse.jface.viewers.Viewer;
24
25 public class SootOptionsContentProvider implements ITreeContentProvider {
26
27
28     protected static final Object JavaDoc[] EMPTY_ARRAY = new Object JavaDoc[0];
29
30     
31     /**
32      * Constructor for OptionsTreeContentProvider.
33      */

34     public SootOptionsContentProvider() {
35         super();
36     }
37
38     /**
39      * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(Object)
40      */

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

61     public Object JavaDoc getParent(Object JavaDoc element) {
62         return ((SootOption)element).getParent();
63     }
64
65     /**
66      * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(Object)
67      */

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

85     public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
86         return getChildren(inputElement);
87     }
88
89     /**
90      * @see org.eclipse.jface.viewers.IContentProvider#dispose()
91      */

92     public void dispose() {
93     }
94
95     /**
96      * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(Viewer, Object, Object)
97      */

98     public void inputChanged(Viewer viewer, Object JavaDoc oldInput, Object JavaDoc newInput) {
99         
100     }
101
102 }
103
Popular Tags