1 /*************************************************************************
2 * @author Ali Echihabi (ali_echihabi@ieee.org, ali.echihabi@souss.ca)
4 * Plugin for PHP unit Testing.
7 *************************************************************************/
10 package net.sourceforge.phpeclipse.phpunit;
12 import net.sourceforge.phpeclipse.phpunit.testpool.TestPool;
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;
23 public class ProgressInfoComposite extends Composite {
26 private Label labelRuns, labelRunsVal; // Runs: 12
27 private Label labelErrors, labelErrorsImage, labelErrorsVal;
28 private Label labelFailures, labelFailuresImage, labelFailuresVal;
31 private ProgressBar progressBar;
37 public ProgressInfoComposite(Composite parent) {
39 super(parent, SWT.NONE);
41 GridLayout gridLayout = new GridLayout();
42 gridLayout.numColumns = 1;
44 // set title and layout
45 setLayout(gridLayout);
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);
55 Composite labelsComposite =
56 new Composite(this, SWT.NONE);
58 labelsComposite.setLayoutData(
59 new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL));
61 labelsComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
63 labelRuns = new Label(labelsComposite, SWT.NONE);
64 labelRuns.setText("Runs: ");
65 labelRunsVal = new Label(labelsComposite, SWT.NONE);
66 labelRunsVal.setText("0 / 0");
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");
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");
84 public void resetInfo() {
86 labelErrorsVal.setText("0");
87 labelFailuresVal.setText("0");
88 labelRunsVal.setText("0 / 0");
89 progressBar.setSelection(0);
93 public void updateInfo(TestPool testPool) {
95 int numTestsOverall = testPool.getNumTestsOverall();
96 int numTestsRun = testPool.getNumTestsRun();
99 progressBar.setMaximum(numTestsOverall);
100 progressBar.setSelection(numTestsRun);
104 labelRunsVal.setText(numTestsRun + " / " + numTestsOverall);
105 labelFailuresVal.setText("" + testPool.getNumFailures());
106 labelErrorsVal.setText("" + testPool.getNumErrors());
108 //TODO: change Failures label to red if some exist.