1 18 19 package org.apache.jmeter.control.gui; 20 21 import java.awt.BorderLayout ; 22 23 import javax.swing.JLabel ; 24 import javax.swing.JPanel ; 25 import javax.swing.JTextField ; 26 27 import org.apache.jmeter.control.SwitchController; 28 import org.apache.jmeter.testelement.TestElement; 29 import org.apache.jmeter.util.JMeterUtils; 30 31 34 public class SwitchControllerGui extends AbstractControllerGui 35 { 36 private static final String SWITCH_LABEL = "switch_controller_label"; 37 38 private JTextField switchValue; 39 40 public SwitchControllerGui() 41 { 42 init(); 43 } 44 45 public TestElement createTestElement() 46 { 47 SwitchController ic = new SwitchController(); 48 modifyTestElement(ic); 49 return ic; 50 } 51 52 56 public void modifyTestElement(TestElement ic) 57 { 58 configureTestElement(ic); 59 ((SwitchController) ic).setSelection(switchValue.getText()); 60 } 61 62 public void configure(TestElement el) 63 { 64 super.configure(el); 65 switchValue.setText(((SwitchController) el).getSelection()); 66 } 67 68 public String getLabelResource() 69 { 70 return "switch_controller_title"; 71 } 72 73 private void init() 74 { 75 setLayout(new BorderLayout (0, 5)); 76 setBorder(makeBorder()); 77 add(makeTitlePanel(), BorderLayout.NORTH); 78 79 JPanel mainPanel = new JPanel (new BorderLayout ()); 80 mainPanel.add(createSwitchPanel(), BorderLayout.NORTH); 81 add(mainPanel, BorderLayout.CENTER); 82 } 83 84 private JPanel createSwitchPanel() { 85 JPanel switchPanel = new JPanel (new BorderLayout (5, 0)); 86 JLabel selectionLabel = 87 new JLabel (JMeterUtils.getResString( SWITCH_LABEL )); 88 switchValue = new JTextField (""); 89 selectionLabel.setLabelFor(switchValue); 90 switchPanel.add(selectionLabel, BorderLayout.WEST); 91 switchPanel.add(switchValue, BorderLayout.CENTER); 92 return switchPanel; 93 } 94 95 } 96 | Popular Tags |