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