package junit.swingui;

import java.awt.*;
import java.awt.GridLayout;

import javax.swing.*;

/**
 * A panel with test run counters
 */
public class CounterPanel extends JPanel {
	private JTextField fNumberOfErrors;
	private JTextField fNumberOfFailures;
	private JTextField fNumberOfRuns;
	private Icon fFailureIcon= TestRunner.getIconResource(getClass(), "icons/failure.gif");
	private Icon fErrorIcon= TestRunner.getIconResource(getClass(), "icons/error.gif");

	private int fTotal;
	
	public CounterPanel() {
		super(new GridBagLayout()); 	
		fNumberOfErrors= createOutputField(5);
		fNumberOfFailures= createOutputField(5);
		fNumberOfRuns= createOutputField(9); 
		
      addToGrid(new JLabel("Runs:", JLabel.CENTER),
          0, 0, 1, 1, 0.0, 0.0,
          GridBagConstraints.CENTER, GridBagConstraints.NONE,
          new Insets(0, 0, 0, 0));
     addToGrid(fNumberOfRuns,
          1, 0, 1, 1, 0.33, 0.0,
          GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
          new Insets(0, 8, 0, 0));
          
     addToGrid(new JLabel("Errors:", fErrorIcon, SwingConstants.LEFT),
          2, 0, 1, 1, 0.0, 0.0,
          GridBagConstraints.CENTER, GridBagConstraints.NONE,
          new Insets(0, 8, 0, 0));
      addToGrid(fNumberOfErrors,
          3, 0, 1, 1, 0.33, 0.0,
          GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
          new Insets(0, 8, 0, 0));
          
      addToGrid(new JLabel("Failures:", fFailureIcon, SwingConstants.LEFT),
          4, 0, 1, 1, 0.0, 0.0,
          GridBagConstraints.CENTER, GridBagConstraints.NONE,
          new Insets(0, 8, 0, 0));
      addToGrid(fNumberOfFailures,
          5, 0, 1, 1, 0.33, 0.0,
          GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
          new Insets(0, 8, 0, 0));
	} 
	
	private JTextField createOutputField(int width) {
		JTextField field= new JTextField("0", width);
		field.setHorizontalAlignment(JTextField.LEFT);
		field.setFont(StatusLine.BOLD_FONT);
		field.setEditable(false);
		field.setBorder(BorderFactory.createEmptyBorder());
		return field;
	}

	public void addToGrid(Component comp,
	    	int gridx, int gridy, int gridwidth, int gridheight,
			double weightx, double weighty,
			int anchor, int fill,
			Insets insets) {
		
		GridBagConstraints constraints= new GridBagConstraints();
		constraints.gridx= gridx;
		constraints.gridy= gridy;
		constraints.gridwidth= gridwidth;
		constraints.gridheight= gridheight;
		constraints.weightx= weightx;
		constraints.weighty= weighty;
		constraints.anchor= anchor;
		constraints.fill= fill;
		constraints.insets= insets;
		add(comp, constraints);
	}
	
	public void reset() {
		setLabelValue(fNumberOfErrors, 0);
		setLabelValue(fNumberOfFailures, 0);
		setLabelValue(fNumberOfRuns, 0);
		fTotal= 0;
	}
	
	public void setTotal(int value) {
		fTotal= value;
	}
	
	public void setRunValue(int value) {
		fNumberOfRuns.setText(Integer.toString(value) + "/" + fTotal);
	}
	
	public void setErrorValue(int value) {
		setLabelValue(fNumberOfErrors, value);
	}
	
	public void setFailureValue(int value) {
		setLabelValue(fNumberOfFailures, value);
	}
	
	private String asString(int value) {
		return Integer.toString(value);
	}
	
	private void setLabelValue(JTextField label, int value) {
		label.setText(Integer.toString(value));
	}
}
@@ -39,36 +39,8 @@
 t.*;
-%0Aimport java.awt.GridLayout;
 %0A%0Aim
@@ -452,18 +452,17 @@
 fTotal;%0A
-%09
 %0A
+
 %09public 
@@ -507,18 +507,16 @@
 yout());
- %09
 %0A%09%09fNumb
@@ -634,12 +634,9 @@
 (9);
- %0A%09%09
+%0A
 %0A   
@@ -975,35 +975,25 @@
  8, 0, 0));%0A
-          
 %0A
+
      addToGr
@@ -1353,19 +1353,9 @@
 ));%0A
-          
 %0A
+
     
@@ -1732,11 +1732,9 @@
 ;%0A%09%7D
- %0A%09
+%0A
 %0A%09pr
@@ -2201,11 +2201,9 @@
 ) %7B%0A
-%09%09
 %0A
+
 %09%09Gr
@@ -2563,26 +2563,25 @@
 raints);%0A%09%7D%0A
-%09
 %0A
+
 %09public void
@@ -2714,26 +2714,25 @@
 otal= 0;%0A%09%7D%0A
-%09
 %0A
+
 %09public void
@@ -2770,26 +2770,25 @@
 = value;%0A%09%7D%0A
-%09
 %0A
+
 %09public void
@@ -2877,26 +2877,25 @@
 fTotal);%0A%09%7D%0A
-%09
 %0A
+
 %09public void
@@ -2966,18 +2966,17 @@
 ue);%0A%09%7D%0A
-%09
 %0A
+
 %09public 
@@ -3047,34 +3047,33 @@
 res, value);%0A%09%7D%0A
-%09
 %0A
+
 %09private String 
@@ -3131,17 +3131,16 @@
 ue);%0A%09%7D%0A
-%09
 %0A%09privat

Remove extra import.