1 18 19 package org.apache.jmeter.gui; 20 import java.awt.BorderLayout ; 21 22 import javax.swing.BorderFactory ; 23 import javax.swing.ButtonGroup ; 24 import javax.swing.JPanel ; 25 import javax.swing.JRadioButton ; 26 27 import org.apache.jmeter.testelement.OnErrorTestElement; 28 import org.apache.jmeter.util.JMeterUtils; 29 30 34 public class OnErrorPanel extends JPanel 35 { 36 private JRadioButton continueBox; 38 private JRadioButton stopThrdBox; 39 private JRadioButton stopTestBox; 40 41 private JPanel createOnErrorPanel() 42 { 43 JPanel panel = new JPanel (); 44 panel.setBorder( 45 BorderFactory.createTitledBorder( 46 JMeterUtils.getResString("sampler_on_error_action"))); 47 48 ButtonGroup group = new ButtonGroup (); 49 50 continueBox = 51 new JRadioButton (JMeterUtils.getResString("sampler_on_error_continue")); 52 group.add(continueBox); 53 continueBox.setSelected(true); 54 panel.add(continueBox); 55 56 stopThrdBox = 57 new JRadioButton (JMeterUtils.getResString("sampler_on_error_stop_thread")); 58 group.add(stopThrdBox); 59 panel.add(stopThrdBox); 60 61 stopTestBox = 62 new JRadioButton (JMeterUtils.getResString("sampler_on_error_stop_test")); 63 group.add(stopTestBox); 64 panel.add(stopTestBox); 65 66 return panel; 67 } 68 71 public OnErrorPanel() 72 { 73 init(); 74 } 75 76 79 private void init() 80 { 81 setLayout(new BorderLayout (5, 0)); 82 add(createOnErrorPanel()); 83 } 84 public void configure(int errorAction) 85 { 86 stopTestBox.setSelected(errorAction == OnErrorTestElement.ON_ERROR_STOPTEST); 87 stopThrdBox.setSelected(errorAction == OnErrorTestElement.ON_ERROR_STOPTHREAD); 88 continueBox.setSelected(errorAction == OnErrorTestElement.ON_ERROR_CONTINUE); 89 } 90 91 public int getOnErrorSetting() 92 { 93 if (stopTestBox.isSelected()) return OnErrorTestElement.ON_ERROR_STOPTEST; 94 if (stopThrdBox.isSelected()) return OnErrorTestElement.ON_ERROR_STOPTHREAD; 95 96 return OnErrorTestElement.ON_ERROR_CONTINUE; 98 } 99 } 100 | Popular Tags |