First commit in a looooooong time. I had connectivity problems.
[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                 if(element instanceof TestSuite) 
33                         return ((TestSuite)element).getName();
34                 else if(element instanceof TestCase)
35                         return ((TestCase)element).getTestName();
36                 else
37                         return "UNKNOWN ELEMENT TYPE";
38                 
39                 
40                 
41         }
42
43         public Image getImage(Object element) {
44                 
45                 Image image = null;
46                 
47                 try {
48                         
49                         String icon = "";
50                         if(element instanceof TestSuite) {
51                                 
52                                 TestSuite suite = (TestSuite)element;
53                                 
54                                 //TODO check if there has been an error, a failure...
55                                 
56                                 icon = "tsuite.gif";
57                                 
58                         } else if(element instanceof TestCase) {
59                                 
60                                 TestCase test = (TestCase)element;
61                                 
62                                 if(test.isError())
63                                         icon = "testerr.gif";
64                                 else if(test.isFailure())
65                                         icon = "testfail.gif";
66                                 else if(test.isPass())
67                                         icon = "testok.gif";
68                                 
69                         }
70                         
71                         
72                         ImageDescriptor descriptor = ImageDescriptor.createFromURL(new URL("file://" + iconsPath + "//" + icon));
73                         image = descriptor.createImage();
74                         
75                 } catch (MalformedURLException e) {
76                         
77                         e.printStackTrace();
78                         image = ImageDescriptor.getMissingImageDescriptor().createImage();
79                 }
80                 
81                 
82                 
83                 
84                 
85                 return image;
86                 
87         }
88
89 }