1 18 19 package org.apache.jmeter.timers.gui; 20 21 import javax.swing.Box ; 22 import javax.swing.JComponent ; 23 import javax.swing.JLabel ; 24 import javax.swing.JOptionPane ; 25 import javax.swing.JTextField ; 26 27 import org.apache.jmeter.testelement.TestElement; 28 import org.apache.jmeter.timers.ConstantTimer; 29 import org.apache.jmeter.util.JMeterUtils; 30 import org.apache.jorphan.gui.layout.VerticalLayout; 31 32 37 public class ConstantTimerGui extends AbstractTimerGui 38 { 39 42 private static final String DEFAULT_DELAY = "300"; 43 44 private static final String DELAY_FIELD = "Delay Field"; 45 46 private JTextField delayField; 47 48 51 public ConstantTimerGui() 52 { 53 init(); 54 } 55 56 62 public static void error(Exception e, JComponent thrower) 63 { 64 JOptionPane.showMessageDialog(thrower, e, "Error", JOptionPane.ERROR_MESSAGE); 65 } 66 67 public String getLabelResource() 68 { 69 return "constant_timer_title"; 70 } 71 72 77 public TestElement createTestElement() 78 { 79 ConstantTimer timer = new ConstantTimer(); 80 modifyTestElement(timer); 81 return timer; 82 } 83 84 88 public void modifyTestElement(TestElement timer) 89 { 90 this.configureTestElement(timer); 91 ((ConstantTimer) timer).setDelay(delayField.getText()); 92 } 93 94 99 public void configure(TestElement el) 100 { 101 super.configure(el); 102 delayField.setText(((ConstantTimer) el).getDelay()); 103 } 104 105 108 private void init() 109 { 110 setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP)); 111 112 setBorder(makeBorder()); 113 add(makeTitlePanel()); 114 115 Box delayPanel = Box.createHorizontalBox(); 116 JLabel delayLabel = new JLabel (JMeterUtils.getResString("constant_timer_delay")); 117 delayPanel.add(delayLabel); 118 119 delayField = new JTextField (6); 120 delayField.setText(DEFAULT_DELAY); 121 delayField.setName(DELAY_FIELD); 122 delayPanel.add(delayField); 123 add(delayPanel); 124 } 125 128 public void clear() 129 { 130 delayField.setText(DEFAULT_DELAY); 131 super.clear(); 132 } 133 } 134 | Popular Tags |