A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse.phpunit / src / net / sourceforge / phpeclipse / phpunit / TestPoolLabelProvider.java
index 6977a6d..40614c3 100644 (file)
@@ -1,13 +1,12 @@
-/*
- * Created on Aug 8, 2004
+/*************************************************************************
+ * @author Ali Echihabi (ali_echihabi@ieee.org, ali.echihabi@souss.ca)
  *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package net.sourceforge.phpeclipse.phpunit;
+ * Plugin for PHP unit Testing.
+ * www.phpeclipse.de
+ * 
+ *************************************************************************/
 
-import java.net.MalformedURLException;
-import java.net.URL;
+package net.sourceforge.phpeclipse.phpunit;
 
 import net.sourceforge.phpeclipse.phpunit.testpool.TestCase;
 import net.sourceforge.phpeclipse.phpunit.testpool.TestSuite;
@@ -16,74 +15,63 @@ import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.graphics.Image;
 
-/**
- * @author Ali Echihabi
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
 public class TestPoolLabelProvider extends LabelProvider {
 
-       //TODO: replace with installDir + path
-       private static String iconsPath = "C:\\Documents and Settings\\Ali Echihabi\\My Documents\\workspace.eclipse2.1\\net.sourceforge.phpeclipse.phpunit\\icons";
-
        public String getText(Object element) {
-               
-               if(element instanceof TestSuite) 
-                       return ((TestSuite)element).getName();
-               else if(element instanceof TestCase)
-                       return ((TestCase)element).getTestName();
-               else
-                       return "UNKNOWN ELEMENT TYPE";
-               
-               
-               
+
+               String text = "";
+
+               if (element instanceof TestSuite)
+                       return ((TestSuite) element).getName();
+               else if (element instanceof TestCase) {
+
+                       text = ((TestCase) element).getTestName();
+
+                       // has the form: TESTSUITENAME_TESTNAME
+
+               } else
+                       text = "UNKNOWN ELEMENT TYPE";
+
+               return text;
+
        }
 
        public Image getImage(Object element) {
-               
+
                Image image = null;
-               
-               try {
-                       
-                       String icon = "";
-                       if(element instanceof TestSuite) {
-                               
-                               TestSuite suite = (TestSuite)element;
-                               
-                               //TODO check if there has been an error, a failure...
-                               
-                               icon = "tsuite.gif";
-                               
-                       } else if(element instanceof TestCase) {
-                               
-                               TestCase test = (TestCase)element;
-                               
-                               if(test.isError())
-                                       icon = "testerr.gif";
-                               else if(test.isFailure())
-                                       icon = "testfail.gif";
-                               else if(test.isPass())
-                                       icon = "testok.gif";
-                               
-                       }
-                       
-                       
-                       ImageDescriptor descriptor = ImageDescriptor.createFromURL(new URL("file://" + iconsPath + "//" + icon));
-                       image = descriptor.createImage();
-                       
-               } catch (MalformedURLException e) {
-                       
-                       e.printStackTrace();
-                       image = ImageDescriptor.getMissingImageDescriptor().createImage();
+               ImageDescriptor descriptor = null;
+
+               if (element instanceof TestSuite) {
+
+                       TestSuite suite = (TestSuite) element;
+                       descriptor = PHPUnitImages.DESC_TEST_SUITE_PASS;
+
+                       if (suite.hasError())
+                               descriptor = PHPUnitImages.DESC_TEST_SUITE_ERROR;
+                       else if (suite.hasFailure())
+                               descriptor = PHPUnitImages.DESC_TEST_SUITE_FAILURE;
+                       else if (suite.isAllPass())
+                               descriptor = PHPUnitImages.DESC_TEST_SUITE_PASS;
+
+               } else if (element instanceof TestCase) {
+
+                       TestCase test = (TestCase) element;
+
+                       descriptor = PHPUnitImages.DESC_TEST_PASS;
+
+                       if (test.isError())
+                               descriptor = PHPUnitImages.DESC_TEST_ERROR;
+                       else if (test.isFailure())
+                               descriptor = PHPUnitImages.DESC_TEST_FAILURE;
+                       else if (test.isPass())
+                               descriptor = PHPUnitImages.DESC_TEST_PASS;
+
                }
-               
-               
-               
-               
-               
+
+               image = descriptor.createImage();
+
                return image;
-               
+
        }
 
 }