First commit in a looooooong time. I had connectivity problems.
[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(int numTests, int numTestsRun, int numFailures, int numErrors) {
89                 
90                 //update progress bar
91                 progressBar.setMaximum(numTests);
92                 progressBar.setSelection(numTestsRun);
93         
94         
95                 //update labels
96                 labelRunsVal.setText(numTestsRun + " / " + numTests);
97                 labelFailuresVal.setText("" + numFailures);
98                 labelErrorsVal.setText("" + numErrors);
99                 
100                 //TODO: change Failures label to red if some exist.
101                 
102                 
103                 
104         }
105
106
107         public void updateInfo(TestPool testPool) {
108                 
109                 int numTestsOverall = testPool.getNumTestsOverall();
110                 int numTestsRun = testPool.getNumTestsRun();
111                 
112                 //update progress bar
113                 progressBar.setMaximum(numTestsOverall);
114                 progressBar.setSelection(numTestsRun);
115         
116         
117                 //update labels
118                 labelRunsVal.setText(numTestsRun + " / " + numTestsOverall);
119                 labelFailuresVal.setText("" + testPool.getNumFailures());
120                 labelErrorsVal.setText("" + testPool.getNumErrors());
121                 
122                 //TODO: change Failures label to red if some exist.
123                 
124                 
125                 
126         }
127
128 }