Refactoringaction: net.sourceforge.phpdt.ltk.ui.actions.RenameLocalVariable
[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.TestCase;
15 import net.sourceforge.phpeclipse.phpunit.testpool.TestSuite;
16
17 import org.eclipse.jface.viewers.ITreeContentProvider;
18 import org.eclipse.jface.viewers.Viewer;
19
20
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 }