intial source from ttp://www.sf.net/projects/wdte
[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 org.eclipse.swt.SWT;
10 import org.eclipse.swt.layout.FillLayout;
11 import org.eclipse.swt.layout.GridData;
12 import org.eclipse.swt.layout.GridLayout;
13 import org.eclipse.swt.widgets.Composite;
14 import org.eclipse.swt.widgets.Label;
15 import org.eclipse.swt.widgets.ProgressBar;
16
17 /**
18  * @author Ali Echihabi
19  *
20  * To change the template for this generated type comment go to
21  * Window>Preferences>Java>Code Generation>Code and Comments
22  */
23 public class ProgressInfoComposite extends Composite {
24
25
26         private Label labelRuns, labelRunsVal; // Runs: 12
27         private Label labelErrors, labelErrorsVal;
28         private Label labelFailures, labelFailuresVal;
29         
30         private ProgressBar progressBar;
31
32         /**
33          * @param arg0
34          * @param arg1
35          */
36         public ProgressInfoComposite(Composite parent) {
37                 
38                 super(parent, SWT.NONE);
39                 
40                 GridLayout gridLayout = new GridLayout();
41                 gridLayout.numColumns = 1;
42                 
43                 // set title and layout
44                 setLayout(gridLayout);
45                 
46
47                 // set the progress bar
48                 progressBar = new ProgressBar(this, SWT.HORIZONTAL);
49                 progressBar.setLayoutData(
50                         new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL));
51                 progressBar.setMinimum(0);
52                         
53
54                 Composite labelsComposite =
55                         new Composite(this, SWT.NONE);
56                 labelsComposite.setLayoutData(
57                         new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL));
58
59                 labelsComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
60
61                 labelRuns = new Label(labelsComposite, SWT.NONE);
62                 labelRuns.setText("Runs: ");
63                 labelRunsVal = new Label(labelsComposite, SWT.NONE);
64                 labelRunsVal.setText("0 / 0");
65
66                 labelFailures = new Label(labelsComposite, SWT.NONE);
67                 labelFailures.setText("Failures: ");
68                 labelFailuresVal = new Label(labelsComposite, SWT.NONE);
69                 labelFailuresVal.setText("0");
70
71                 labelErrors = new Label(labelsComposite, SWT.NONE);
72                 labelErrors.setText("Errors: ");
73                 labelErrorsVal = new Label(labelsComposite, SWT.NONE);
74                 labelErrorsVal.setText("0");            
75         }
76
77         public void updateInfo(int numTests, int numTestsRun, int numFailures, int numErrors) {
78                 
79                 //update progress bar
80                 progressBar.setMaximum(numTests);
81                 progressBar.setSelection(numTestsRun);
82                 
83                 System.out.println("numTestsRun: " + numTestsRun);
84         
85                 //update labels
86                 labelRunsVal.setText(numTestsRun + " / " + numTests);
87                 labelFailuresVal.setText("" + numFailures);
88                 labelErrorsVal.setText("" + numErrors);
89                 
90                 //TODO: change Failures label to red if some exist.
91                 
92                 
93                 
94         }
95
96 }