Hello

I've done some changes to the ViewResultsVisualizer as well, hopefully for the better
Changes
- added a Previous button, so that it's easier to navigate between samples
- added a field which shows the SampleResult.success
- added a field which shows the current sample no displayed
- changed the layout, use BorderLayout instead of GridBagLayout
- added locale support for the next button text

I also had to change the reporters/ResultCollector.java, to allow for navigation
to a previous sample, and to get the current sample no

Any comments are appreciated.

Regards
Alf Hogemark


Index: messages.properties
===================================================================
RCS file: 
/home/cvspublic/jakarta-jmeter/src/org/apache/jmeter/resources/messages.properties,v
retrieving revision 1.45
diff -r1.45 messages.properties
165a166,169
> view_results_sample_no=Sample Number
> view_results_sample_success=Sample success
> view_results_previous_sample=Previous
> view_results_next_sample=Next

Index: messages_no.properties
===================================================================
RCS file: 
/home/cvspublic/jakarta-jmeter/src/org/apache/jmeter/resources/messages_no.properties,v
retrieving revision 1.1
diff -r1.1 messages_no.properties
152a153,156
> view_results_sample_no=Sampel nummer
> view_results_sample_success=Sampel suksess
> view_results_previous_sample=Forrige
> view_results_next_sample=Neste

Index: ViewResultsVisualizer.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-jmeter/src/org/apache/jmeter/visualizers/ViewResultsVisualizer.java,v
retrieving revision 1.17
diff -r1.17 ViewResultsVisualizer.java
80,83c80,90
<  private JTextArea display;
<  private JButton next;
<  private JTextField label;
<  private ResultCollector model;
---
>  private static final String SAMPLE_NO = "sample_no";
>  private static final String PREVIOUS_SAMPLE = "previous_sample";
>  private static final String NEXT_SAMPLE = "next_sample";
> 
>  private JTextArea sampleDisplay = null;
>  private JButton previousButton = null;
>  private JButton nextButton = null;
>  private JTextField sampleNo = null;
>  private JTextField sampleSuccess = null;
>  private JTextField sampleName = null;
>  private ResultCollector model = null;
102c109
<   this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
---
>      this.setLayout(new BorderLayout());
121,147c128,177
<   // INNER PANEL
<   JPanel innerPanel = new JPanel();
<   innerPanel.setPreferredSize(new Dimension(640, 480));
<   label = new JTextField();
<   display = new JTextArea();
<   next = new JButton("Next");
<   next.addActionListener(this);
<   innerPanel.setLayout(new GridBagLayout());
<   GridBagConstraints gbc = new GridBagConstraints();
<   gbc.gridx = gbc.gridy = 0;
<   gbc.fill = gbc.BOTH;
<   gbc.weightx = 1;
<   gbc.weighty = 0;
<   innerPanel.add(label, gbc.clone());
< 
<   gbc.gridy++;
<   gbc.weighty = 1;
<   innerPanel.add(new JScrollPane(display), gbc.clone());
< 
<   gbc.gridy++;
<   gbc.fill = gbc.NONE;
<   gbc.weightx = gbc.weighty = 0;
<   gbc.anchor = gbc.CENTER;
<   innerPanel.add(next, gbc.clone());
< 
<   mainPanel.add(innerPanel);
<   this.add(mainPanel);
---
>   // The header panel
>   JPanel headerPanel = new JPanel();
>   headerPanel.setLayout(new FlowLayout());
>   JLabel sampleNoLabel = new 
>JLabel(JMeterUtils.getResString("view_results_sample_no"));
>   sampleNo = new JTextField(10);
>   // TO DO - enable the user to enter the sample no he wants
>   sampleNo.setEditable(false);
>   sampleNo.setActionCommand(SAMPLE_NO);
>   sampleNo.addActionListener(this);
>   sampleNo.setForeground(Color.black);
>          sampleNo.setBackground(getBackground());
>   JLabel sampleSuccessLabel = new 
>JLabel(JMeterUtils.getResString("view_results_sample_success"));
>   sampleSuccess = new JTextField(10);
>   sampleSuccess.setEditable(false);
>   sampleSuccess.setForeground(Color.black);
>          sampleSuccess.setBackground(getBackground());
>   headerPanel.add(sampleNoLabel);
>   headerPanel.add(sampleNo);
>   headerPanel.add(sampleSuccessLabel);
>   headerPanel.add(sampleSuccess);
> 
>   // The result display
>   JPanel samplePanel = new JPanel();
>   samplePanel.setLayout(new BorderLayout());
>   sampleName = new JTextField();
>   sampleDisplay = new JTextArea();
>   samplePanel.add(sampleName, BorderLayout.NORTH);
>   samplePanel.add(new JScrollPane(sampleDisplay), BorderLayout.CENTER);
> 
>   // The navigation display
>   JPanel navigationPanel = new JPanel();
>   navigationPanel.setLayout(new FlowLayout());
>   previousButton = new 
>JButton(JMeterUtils.getResString("view_results_previous_sample"));
>   previousButton.setActionCommand(PREVIOUS_SAMPLE);
>   previousButton.addActionListener(this);
>   nextButton = new JButton(JMeterUtils.getResString("view_results_next_sample"));
>   nextButton.setActionCommand(NEXT_SAMPLE);
>   nextButton.addActionListener(this);
>   navigationPanel.add(previousButton);
>   navigationPanel.add(nextButton);
> 
>   // Set up the result panel
>   JPanel resultPanel = new JPanel();
>   resultPanel.setLayout(new BorderLayout());
>   resultPanel.add(headerPanel, BorderLayout.NORTH);
>   resultPanel.add(samplePanel, BorderLayout.CENTER);
>   resultPanel.add(navigationPanel, BorderLayout.SOUTH);
>   
>   this.add(mainPanel, BorderLayout.NORTH);
>   this.add(resultPanel, BorderLayout.CENTER);
157c187,194
<   if(label.getText().equals(""))
---
>   if(model.getCurrentSampleNo() > 0)
>   {
>    sampleNo.setText(new Integer(model.getCurrentSampleNo()).toString());
>    sampleSuccess.setText(new 
>Boolean(model.getCurrentSample().isSuccessfull()).toString());
>    sampleName.setText(model.getSampleLabel());
>    sampleDisplay.setText(model.getTextResponse());
>   }
>   else
159,161c196
<    model.next();
<    label.setText(model.getSampleLabel());
<    display.setText(model.getTextResponse());
---
>    clear();
170,171c205,208
<   label.setText("");
<   display.setText("");
---
>   sampleNo.setText("");
>   sampleSuccess.setText("");
>   sampleName.setText("");
>   sampleDisplay.setText("");
181,182c218,237
<   label.setText("");
<   updateGui();
---
>   boolean sampleUpdated = false;
>   if(e.getActionCommand().equals(SAMPLE_NO))
>   {
>    // The user has entered a sample no he wants
>    // TO DO
>   }
>   else if(e.getActionCommand().equals(PREVIOUS_SAMPLE))
>   {
>    // The user wants the previous sample
>    sampleUpdated = model.previous();
>   }
>   else if(e.getActionCommand().equals(NEXT_SAMPLE))
>   {
>    // The user wants the next sample
>    sampleUpdated = model.next();
>   }
>   if(sampleUpdated)
>   {
>    updateGui();
>   }


Index: ResultCollector.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-jmeter/src/org/apache/jmeter/reporters/ResultCollector.java,v
retrieving revision 1.23
diff -r1.23 ResultCollector.java
183a184,200
>  /**
>   * Get the current sample number
>   *
>   * @return the current sample number
>   */
>  public int getCurrentSampleNo()
>  {
>   // current is indexed from 0, while we index sample no from 1
>   return current + 1;
>  }
> 
>  /**
>   * Make the next sample the current sample
>   *
>   * @return true if a new sample has been made the current,
>   * false otherwise
>   */
194a212,230
>   }
> 
>  /**
>   * Make the previous sample the current sample
>   *
>   * @return true if a new sample has been made the current,
>   * false otherwise
>   */
>   public boolean previous()
>   {
>   if(current > 0)
>   {
>    current--;
>    return true;
>   }
>   else
>   {
>    return false;
>   }

Reply via email to