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