1 18 19 package org.apache.jmeter.modifiers.gui; 20 21 import javax.swing.JCheckBox ; 22 23 import org.apache.jmeter.modifiers.CounterConfig; 24 import org.apache.jmeter.processor.gui.AbstractPreProcessorGui; 25 import org.apache.jmeter.testelement.TestElement; 26 import org.apache.jmeter.util.JMeterUtils; 27 import org.apache.jorphan.gui.JLabeledTextField; 28 import org.apache.jorphan.gui.layout.VerticalLayout; 29 30 33 public class CounterConfigGui extends AbstractPreProcessorGui 34 { 35 private JLabeledTextField startField, incrField, endField, varNameField; 36 private JCheckBox perUserField; 37 38 public CounterConfigGui() 39 { 40 super(); 41 init(); 42 } 43 44 public String getLabelResource() 45 { 46 return "counter_config_title"; 47 } 48 51 public TestElement createTestElement() 52 { 53 CounterConfig config = new CounterConfig(); 54 modifyTestElement(config); 55 return config; 56 } 57 58 62 public void modifyTestElement(TestElement c) 63 { 64 if (c instanceof CounterConfig) 65 { 66 CounterConfig config = (CounterConfig) c; 67 config.setStart(startField.getText()); 68 { 70 config.setEnd(endField.getText()); 71 } 72 config.setIncrement(incrField.getText()); 73 config.setVarName(varNameField.getText()); 74 config.setIsPerUser(perUserField.isSelected()); 75 } 76 super.configureTestElement(c); 77 } 78 79 public void configure(TestElement element) 80 { 81 super.configure(element); 82 CounterConfig config = (CounterConfig) element; 83 startField.setText(config.getPropertyAsString(CounterConfig.START)); 84 endField.setText(config.getPropertyAsString(CounterConfig.END)); 85 incrField.setText(config.getPropertyAsString(CounterConfig.INCREMENT)); 86 varNameField.setText(config.getVarName()); 87 perUserField.setSelected(config.isPerUser()); 88 } 89 90 private void init() 91 { 92 setBorder (makeBorder()); 93 setLayout(new VerticalLayout(5, VerticalLayout.LEFT)); 94 95 startField = 96 new JLabeledTextField(JMeterUtils.getResString("start")+" "); incrField = 98 new JLabeledTextField(JMeterUtils.getResString("increment")); 99 endField = new JLabeledTextField(JMeterUtils.getResString("max")); 100 varNameField = 101 new JLabeledTextField(JMeterUtils.getResString("var_name")); 102 perUserField = 103 new JCheckBox (JMeterUtils.getResString("counter_per_user")); 104 105 add(makeTitlePanel()); 106 add(startField); 107 add(incrField); 108 add(endField); 109 add(varNameField); 110 add(perUserField); 111 } 112 } 113 | Popular Tags |