initial version
[phpeclipse.git] / net.sourceforge.phpeclipse.phpunit / src / net / sourceforge / phpeclipse / phpunit / TestPoolContentProvider.java
1 /*************************************************************************
2  * @author Ali Echihabi (ali_echihabi@ieee.org, ali.echihabi@souss.ca)
3  *
4  * Plugin for PHP unit Testing.
5  * www.phpeclipse.de
6  * 
7  *************************************************************************/
8
9
10 package net.sourceforge.phpeclipse.phpunit;
11
12 import java.util.Vector;
13
14 import net.sourceforge.phpeclipse.phpunit.testpool.*;
15
16 import org.eclipse.jface.viewers.ITreeContentProvider;
17 import org.eclipse.jface.viewers.Viewer;
18
19
20
21 public class TestPoolContentProvider implements ITreeContentProvider {
22
23
24
25         /* (non-Javadoc)
26          * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
27          */
28         public Object[] getChildren(Object parentElement) {
29
30                 if(parentElement instanceof TestSuite) {
31
32                         Vector allChildren = new Vector();
33                         allChildren.addAll(((TestSuite)parentElement).getTestCases());
34                         allChildren.addAll(((TestSuite)parentElement).getTestSuites());
35                         
36                         return allChildren.toArray();
37                         
38                 } else {
39                         return new Object[0];
40                 }
41                 
42                 
43         }
44
45         /* (non-Javadoc)
46          * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
47          */
48         public Object getParent(Object element) {
49                 
50                 if(element instanceof TestSuite)
51                         return ((TestSuite)element).getParent();
52                 else if (element instanceof TestCase) 
53                         return ((TestCase)element).getParentSuite();
54                 else
55                         return null;
56         }
57
58         /* (non-Javadoc)
59          * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
60          */
61         public boolean hasChildren(Object element) {
62
63                 return getChildren(element).length > 0;
64         }
65
66         /* (non-Javadoc)
67          * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
68          */
69         public Object[] getElements(Object inputElement) {
70                 
71                 return getChildren(inputElement);
72                 
73         }
74
75         /* (non-Javadoc)
76          * @see org.eclipse.jface.viewers.IContentProvider#dispose()
77          */
78         public void dispose() {
79                 
80         }
81
82         /* (non-Javadoc)
83          * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
84          */
85         public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
86                 // TODO Auto-generated method stub
87
88         }
89
90 }