1 18 19 package org.apache.jmeter.protocol.http.modifier.gui; 20 21 import java.awt.BorderLayout ; 22 import java.awt.Dimension ; 23 24 import javax.swing.BorderFactory ; 25 import javax.swing.JLabel ; 26 import javax.swing.JPanel ; 27 import javax.swing.JScrollPane ; 28 import javax.swing.JTextArea ; 29 import javax.swing.JTextField ; 30 31 import org.apache.jmeter.processor.gui.AbstractPreProcessorGui; 32 import org.apache.jmeter.protocol.http.modifier.UserParameterModifier; 33 import org.apache.jmeter.testelement.TestElement; 34 import org.apache.jmeter.util.JMeterUtils; 35 36 41 public class UserParameterModifierGui extends AbstractPreProcessorGui 42 { 43 private JTextField fileNameField; 47 48 52 public UserParameterModifierGui() 53 { 54 super(); 55 init(); 56 } 57 58 public TestElement createTestElement() 59 { 60 UserParameterModifier mod = new UserParameterModifier(); 61 modifyTestElement(mod); 62 return mod; 63 } 64 65 69 public void modifyTestElement(TestElement mod) 70 { 71 this.configureTestElement(mod); 72 ((UserParameterModifier) mod).setXmlUri(fileNameField.getText()); 73 } 74 75 public void updateGui() 76 { 77 } 78 79 public String getLabelResource() 80 { 81 return "http_user_parameter_modifier"; 82 } 83 84 public void configure(TestElement el) 85 { 86 super.configure(el); 87 fileNameField.setText(((UserParameterModifier) el).getXmlUri()); 88 } 89 90 93 private void init() 94 { 95 setLayout(new BorderLayout (0, 5)); 96 setBorder(makeBorder()); 97 add(makeTitlePanel(), BorderLayout.NORTH); 98 99 JPanel mainPanel = new JPanel (new BorderLayout (0, 5)); 100 mainPanel.add(getFileLocator(), BorderLayout.NORTH); 101 102 JTextArea helpText = 104 new JTextArea (JMeterUtils.getResString("user_param_mod_help_note")); 105 helpText.setLineWrap(true); 106 helpText.setWrapStyleWord(true); 107 helpText.setBackground(getBackground()); 108 helpText.setEditable(false); 109 JLabel dummyLabel = new JLabel (); 110 helpText.setFont(dummyLabel.getFont()); 111 helpText.setForeground(dummyLabel.getForeground()); 112 JScrollPane scroller = new JScrollPane (helpText); 113 scroller.setBorder(BorderFactory.createEmptyBorder()); 114 mainPanel.add(scroller, BorderLayout.CENTER); 115 116 add(mainPanel, BorderLayout.CENTER); 117 } 118 119 private JPanel getFileLocator() 120 { 121 fileNameField = new JTextField ("users.xml", 15); 122 JLabel label = new JLabel (JMeterUtils.getResString("filename")); 123 label.setLabelFor(fileNameField); 124 125 JPanel fileLocator = new JPanel (new BorderLayout ()); 126 fileLocator.add(label, BorderLayout.WEST); 127 fileLocator.add(fileNameField, BorderLayout.CENTER); 128 return fileLocator; 129 } 130 131 public Dimension getPreferredSize() 132 { 133 return getMinimumSize(); 134 } 135 } | Popular Tags |