getting the path to phpunit from a preference page. added icons to progressComposite
[phpeclipse.git] / net.sourceforge.phpeclipse.phpunit / src / net / sourceforge / phpeclipse / phpunit / TestPoolLabelProvider.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 net.sourceforge.phpeclipse.phpunit.testpool.TestCase;
10 import net.sourceforge.phpeclipse.phpunit.testpool.TestSuite;
11
12 import org.eclipse.jface.resource.ImageDescriptor;
13 import org.eclipse.jface.viewers.LabelProvider;
14 import org.eclipse.swt.graphics.Image;
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 TestPoolLabelProvider extends LabelProvider {
23
24         public String getText(Object element) {
25                 
26                 String text = "";
27                 
28                 if(element instanceof TestSuite) 
29                         return ((TestSuite)element).getName();
30                 else if(element instanceof TestCase) {
31                 
32                         text = ((TestCase)element).getTestName();
33                         
34                         //has the form: TESTSUITENAME_TESTNAME
35                         
36                 }
37                 else
38                         text = "UNKNOWN ELEMENT TYPE";
39                 
40                 return text;
41                 
42         }
43
44         public Image getImage(Object element) {
45                 
46                 Image image = null;
47                 ImageDescriptor descriptor = null;
48                         
49                 if(element instanceof TestSuite) {
50                         
51                         TestSuite suite = (TestSuite)element;
52                         descriptor = PHPUnitImages.DESC_TEST_SUITE_PASS;
53
54
55                         if(suite.hasError())
56                                 descriptor = PHPUnitImages.DESC_TEST_SUITE_ERROR;
57                         else if(suite.hasFailure())
58                                 descriptor = PHPUnitImages.DESC_TEST_SUITE_FAILURE;
59                         else if(suite.isAllPass())
60                                 descriptor = PHPUnitImages.DESC_TEST_SUITE_PASS;
61                                         
62                                                                 
63                 } else if(element instanceof TestCase) {
64                         
65                         TestCase test = (TestCase)element;
66                         
67                         descriptor = PHPUnitImages.DESC_TEST_PASS;
68                         
69                         if(test.isError())
70                                 descriptor = PHPUnitImages.DESC_TEST_ERROR;
71                         else if(test.isFailure())
72                                 descriptor = PHPUnitImages.DESC_TEST_FAILURE;
73                         else if(test.isPass())
74                                 descriptor = PHPUnitImages.DESC_TEST_PASS;
75                                         
76                 }
77                 
78                 image = descriptor.createImage();
79         
80                 
81                 return image;
82                 
83         }
84
85 }