getting the path to phpunit from a preference page. added icons to progressComposite
[phpeclipse.git] / net.sourceforge.phpeclipse.phpunit / src / net / sourceforge / phpeclipse / phpunit / ProgressInfoComposite.java
1 /*
2  * Created on Jul 31, 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.TestPool;
10
11 import org.eclipse.swt.SWT;
12 import org.eclipse.swt.graphics.Image;
13 import org.eclipse.swt.layout.FillLayout;
14 import org.eclipse.swt.layout.GridData;
15 import org.eclipse.swt.layout.GridLayout;
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.swt.widgets.Label;
18 import org.eclipse.swt.widgets.ProgressBar;
19
20 /**
21  * @author Ali Echihabi
22  *
23  * To change the template for this generated type comment go to
24  * Window>Preferences>Java>Code Generation>Code and Comments
25  */
26 public class ProgressInfoComposite extends Composite {
27
28
29         private Label labelRuns, labelRunsVal; // Runs: 12
30         private Label labelErrors, labelErrorsImage, labelErrorsVal;
31         private Label labelFailures, labelFailuresImage, labelFailuresVal;
32         
33                 
34         private ProgressBar progressBar;
35
36         /**
37          * @param arg0
38          * @param arg1
39          */
40         public ProgressInfoComposite(Composite parent) {
41                 
42                 super(parent, SWT.NONE);
43                 
44                 GridLayout gridLayout = new GridLayout();
45                 gridLayout.numColumns = 1;
46                 
47                 // set title and layout
48                 setLayout(gridLayout);
49                 
50
51                 // set the progress bar
52                 progressBar = new ProgressBar(this, SWT.HORIZONTAL);
53                 progressBar.setLayoutData(
54                         new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL));
55                 progressBar.setMinimum(0);
56                         
57
58                 Composite labelsComposite =
59                         new Composite(this, SWT.NONE);
60                 
61                 labelsComposite.setLayoutData(
62                         new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL));
63
64                 labelsComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
65
66                 labelRuns = new Label(labelsComposite, SWT.NONE);
67                 labelRuns.setText("Runs: ");
68                 labelRunsVal = new Label(labelsComposite, SWT.NONE);
69                 labelRunsVal.setText("0 / 0");
70
71                 labelFailuresImage = new Label(labelsComposite, SWT.NONE);
72                 labelFailuresImage.setImage(PHPUnitImages.DESC_FAILURE.createImage());
73                 labelFailures = new Label(labelsComposite, SWT.NONE);
74                 labelFailures.setText("Failures: ");
75                 labelFailuresVal = new Label(labelsComposite, SWT.NONE);
76                 labelFailuresVal.setText("0");
77
78
79                 labelErrorsImage = new Label(labelsComposite, SWT.NONE);
80                 labelErrorsImage.setImage(PHPUnitImages.DESC_ERROR.createImage());
81                 labelErrors = new Label(labelsComposite, SWT.NONE);
82                 labelErrors.setText("Errors: ");
83                 labelErrorsVal = new Label(labelsComposite, SWT.NONE);
84                 labelErrorsVal.setText("0");            
85         }
86
87         public void resetInfo() {
88         
89                 labelErrorsVal.setText("0");
90                 labelFailuresVal.setText("0");
91                 labelRunsVal.setText("0 / 0");
92                 progressBar.setSelection(0);    
93         
94         }
95
96         public void updateInfo(TestPool testPool) {
97                 
98                 int numTestsOverall = testPool.getNumTestsOverall();
99                 int numTestsRun = testPool.getNumTestsRun();
100                 
101                 //update progress bar
102                 progressBar.setMaximum(numTestsOverall);
103                 progressBar.setSelection(numTestsRun);
104         
105         
106                 //update labels
107                 labelRunsVal.setText(numTestsRun + " / " + numTestsOverall);
108                 labelFailuresVal.setText("" + testPool.getNumFailures());
109                 labelErrorsVal.setText("" + testPool.getNumErrors());
110                 
111                 //TODO: change Failures label to red if some exist.
112                 
113                 
114                 
115         }
116
117 }