corrected the number of tests expected in progress view. Added toolbar actions to...
[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.layout.FillLayout;
13 import org.eclipse.swt.layout.GridData;
14 import org.eclipse.swt.layout.GridLayout;
15 import org.eclipse.swt.widgets.Composite;
16 import org.eclipse.swt.widgets.Label;
17 import org.eclipse.swt.widgets.ProgressBar;
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 ProgressInfoComposite extends Composite {
26
27
28         private Label labelRuns, labelRunsVal; // Runs: 12
29         private Label labelErrors, labelErrorsVal;
30         private Label labelFailures, labelFailuresVal;
31         
32         private ProgressBar progressBar;
33
34         /**
35          * @param arg0
36          * @param arg1
37          */
38         public ProgressInfoComposite(Composite parent) {
39                 
40                 super(parent, SWT.NONE);
41                 
42                 GridLayout gridLayout = new GridLayout();
43                 gridLayout.numColumns = 1;
44                 
45                 // set title and layout
46                 setLayout(gridLayout);
47                 
48
49                 // set the progress bar
50                 progressBar = new ProgressBar(this, SWT.HORIZONTAL);
51                 progressBar.setLayoutData(
52                         new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL));
53                 progressBar.setMinimum(0);
54                         
55
56                 Composite labelsComposite =
57                         new Composite(this, SWT.NONE);
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                 labelFailures = new Label(labelsComposite, SWT.NONE);
69                 labelFailures.setText("Failures: ");
70                 labelFailuresVal = new Label(labelsComposite, SWT.NONE);
71                 labelFailuresVal.setText("0");
72
73                 labelErrors = new Label(labelsComposite, SWT.NONE);
74                 labelErrors.setText("Errors: ");
75                 labelErrorsVal = new Label(labelsComposite, SWT.NONE);
76                 labelErrorsVal.setText("0");            
77         }
78
79         public void resetInfo() {
80         
81                 labelErrorsVal.setText("0");
82                 labelFailuresVal.setText("0");
83                 labelRunsVal.setText("0 / 0");
84                 progressBar.setSelection(0);    
85         
86         }
87
88         public void updateInfo(TestPool testPool) {
89                 
90                 int numTestsOverall = testPool.getNumTestsOverall();
91                 int numTestsRun = testPool.getNumTestsRun();
92                 
93                 //update progress bar
94                 progressBar.setMaximum(numTestsOverall);
95                 progressBar.setSelection(numTestsRun);
96         
97         
98                 //update labels
99                 labelRunsVal.setText(numTestsRun + " / " + numTestsOverall);
100                 labelFailuresVal.setText("" + testPool.getNumFailures());
101                 labelErrorsVal.setText("" + testPool.getNumErrors());
102                 
103                 //TODO: change Failures label to red if some exist.
104                 
105                 
106                 
107         }
108
109 }