First commit in a looooooong time. I had connectivity problems.
[phpeclipse.git] / net.sourceforge.phpeclipse.phpunit / src / net / sourceforge / phpeclipse / phpunit / TestPoolContentProvider.java
1 /*
2  * Created on Aug 8, 2004
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */
7 package net.sourceforge.phpeclipse.phpunit;
8
9 import java.util.Vector;
10
11 import net.sourceforge.phpeclipse.phpunit.testpool.*;
12
13 import org.eclipse.jface.viewers.ITreeContentProvider;
14 import org.eclipse.jface.viewers.Viewer;
15
16 /**
17  * @author Ali Echihabi
18  *
19  * To change the template for this generated type comment go to
20  * Window>Preferences>Java>Code Generation>Code and Comments
21  */
22 public class TestPoolContentProvider implements ITreeContentProvider {
23
24
25
26         /* (non-Javadoc)
27          * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
28          */
29         public Object[] getChildren(Object parentElement) {
30
31                 if(parentElement instanceof TestSuite) {
32
33                         Vector allChildren = new Vector();
34                         allChildren.addAll(((TestSuite)parentElement).getTestCases());
35                         allChildren.addAll(((TestSuite)parentElement).getTestSuites());
36                         
37                         return allChildren.toArray();
38                         
39                 } else {
40                         return new Object[0];
41                 }
42                 
43                 
44         }
45
46         /* (non-Javadoc)
47          * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
48          */
49         public Object getParent(Object element) {
50                 
51                 if(element instanceof TestSuite)
52                         return ((TestSuite)element).getParent();
53                 else if (element instanceof TestCase) 
54                         return ((TestCase)element).getParentSuite();
55                 else
56                         return null;
57         }
58
59         /* (non-Javadoc)
60          * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
61          */
62         public boolean hasChildren(Object element) {
63
64                 return getChildren(element).length > 0;
65         }
66
67         /* (non-Javadoc)
68          * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
69          */
70         public Object[] getElements(Object inputElement) {
71                 
72                 return getChildren(inputElement);
73                 
74         }
75
76         /* (non-Javadoc)
77          * @see org.eclipse.jface.viewers.IContentProvider#dispose()
78          */
79         public void dispose() {
80                 
81         }
82
83         /* (non-Javadoc)
84          * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
85          */
86         public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
87                 // TODO Auto-generated method stub
88
89         }
90
91 }