commented out code responsible for exceptions. now showing correct suite names and...
[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 java.net.MalformedURLException;
10 import java.net.URL;
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  * @author Ali Echihabi
21  *
22  * To change the template for this generated type comment go to
23  * Window>Preferences>Java>Code Generation>Code and Comments
24  */
25 public class TestPoolLabelProvider extends LabelProvider {
26
27         //TODO: replace with installDir + path
28         private static String iconsPath = "C:\\Documents and Settings\\Ali Echihabi\\My Documents\\workspace.eclipse2.1\\net.sourceforge.phpeclipse.phpunit\\icons";
29
30         public String getText(Object element) {
31                 
32                 String text = "";
33                 
34                 if(element instanceof TestSuite) 
35                         return ((TestSuite)element).getName();
36                 else if(element instanceof TestCase) {
37                 
38                         text = ((TestCase)element).getTestName();
39                         
40                         //has the form: TESTSUITENAME_TESTNAME
41                         
42                 }
43                 else
44                         text = "UNKNOWN ELEMENT TYPE";
45                 
46                 return text;
47                 
48         }
49
50         public Image getImage(Object element) {
51                 
52                 Image image = null;
53                 
54                 try {
55                         
56                         String icon = "";
57                         if(element instanceof TestSuite) {
58                                 
59                                 TestSuite suite = (TestSuite)element;
60                                 
61                                 //TODO check if there has been an error, a failure...
62                                 
63                                 icon = "tsuite.gif";
64                                 
65                         } else if(element instanceof TestCase) {
66                                 
67                                 TestCase test = (TestCase)element;
68                                 
69                                 if(test.isError())
70                                         icon = "testerr.gif";
71                                 else if(test.isFailure())
72                                         icon = "testfail.gif";
73                                 else if(test.isPass())
74                                         icon = "testok.gif";
75                                 
76                         }
77                         
78                         
79                         ImageDescriptor descriptor = ImageDescriptor.createFromURL(new URL("file://" + iconsPath + "//" + icon));
80                         image = descriptor.createImage();
81                         
82                 } catch (MalformedURLException e) {
83                         
84                         e.printStackTrace();
85                         image = ImageDescriptor.getMissingImageDescriptor().createImage();
86                 }
87                 
88                 
89                 
90                 
91                 
92                 return image;
93                 
94         }
95
96 }