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