1 /*************************************************************************
2 * @author Ali Echihabi (ali_echihabi@ieee.org, ali.echihabi@souss.ca)
4 * Plugin for PHP unit Testing.
7 *************************************************************************/
9 package net.sourceforge.phpeclipse.phpunit;
11 import net.sourceforge.phpeclipse.phpunit.testpool.TestPool;
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.layout.FillLayout;
15 import org.eclipse.swt.layout.GridData;
16 import org.eclipse.swt.layout.GridLayout;
17 import org.eclipse.swt.widgets.Composite;
18 import org.eclipse.swt.widgets.Label;
19 import org.eclipse.swt.widgets.ProgressBar;
21 public class ProgressInfoComposite extends Composite {
23 private Label labelRuns, labelRunsVal; // Runs: 12
25 private Label labelErrors, labelErrorsImage, labelErrorsVal;
27 private Label labelFailures, labelFailuresImage, labelFailuresVal;
29 private ProgressBar progressBar;
35 public ProgressInfoComposite(Composite parent) {
37 super(parent, SWT.NONE);
39 GridLayout gridLayout = new GridLayout();
40 gridLayout.numColumns = 1;
42 // set title and layout
43 setLayout(gridLayout);
45 // set the progress bar
46 progressBar = new ProgressBar(this, SWT.HORIZONTAL);
47 progressBar.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
48 | GridData.FILL_HORIZONTAL));
49 progressBar.setMinimum(0);
51 Composite labelsComposite = new Composite(this, SWT.NONE);
53 labelsComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
54 | GridData.FILL_HORIZONTAL));
56 labelsComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
58 labelRuns = new Label(labelsComposite, SWT.NONE);
59 labelRuns.setText("Runs: ");
60 labelRunsVal = new Label(labelsComposite, SWT.NONE);
61 labelRunsVal.setText("0 / 0");
63 labelFailuresImage = new Label(labelsComposite, SWT.NONE);
64 labelFailuresImage.setImage(PHPUnitImages.DESC_FAILURE.createImage());
65 labelFailures = new Label(labelsComposite, SWT.NONE);
66 labelFailures.setText("Failures: ");
67 labelFailuresVal = new Label(labelsComposite, SWT.NONE);
68 labelFailuresVal.setText("0");
70 labelErrorsImage = new Label(labelsComposite, SWT.NONE);
71 labelErrorsImage.setImage(PHPUnitImages.DESC_ERROR.createImage());
72 labelErrors = new Label(labelsComposite, SWT.NONE);
73 labelErrors.setText("Errors: ");
74 labelErrorsVal = new Label(labelsComposite, SWT.NONE);
75 labelErrorsVal.setText("0");
78 public void resetInfo() {
80 labelErrorsVal.setText("0");
81 labelFailuresVal.setText("0");
82 labelRunsVal.setText("0 / 0");
83 progressBar.setSelection(0);
87 public void updateInfo(TestPool testPool) {
89 int numTestsOverall = testPool.getNumTestsOverall();
90 int numTestsRun = testPool.getNumTestsRun();
92 // update progress bar
93 progressBar.setMaximum(numTestsOverall);
94 progressBar.setSelection(numTestsRun);
97 labelRunsVal.setText(numTestsRun + " / " + numTestsOverall);
98 labelFailuresVal.setText("" + testPool.getNumFailures());
99 labelErrorsVal.setText("" + testPool.getNumErrors());
101 // TODO: change Failures label to red if some exist.