1 18 19 package org.apache.jmeter.protocol.http.config.gui; 20 21 import java.awt.BorderLayout ; 22 import java.awt.Dimension ; 23 24 import javax.swing.Box ; 25 26 import org.apache.jmeter.config.ConfigTestElement; 27 import org.apache.jmeter.config.gui.AbstractConfigGui; 28 import org.apache.jmeter.gui.util.VerticalPanel; 29 import org.apache.jmeter.protocol.http.gui.HTTPArgumentsPanel; 30 import org.apache.jmeter.protocol.http.sampler.HTTPSampler; 31 import org.apache.jmeter.testelement.TestElement; 32 import org.apache.jmeter.testelement.property.TestElementProperty; 33 import org.apache.jmeter.util.JMeterUtils; 34 import org.apache.jorphan.gui.JLabeledTextField; 35 36 39 public class HttpDefaultsGui extends AbstractConfigGui 40 { 41 JLabeledTextField protocol; 42 JLabeledTextField domain; 43 JLabeledTextField path; 44 JLabeledTextField port; 45 HTTPArgumentsPanel argPanel; 46 47 public HttpDefaultsGui() 48 { 49 super(); 50 init(); 51 } 52 53 public String getLabelResource() 54 { 55 return "url_config_title"; 56 } 57 58 61 public TestElement createTestElement() 62 { 63 ConfigTestElement config = new ConfigTestElement(); 64 modifyTestElement(config); 65 return config; 66 } 67 68 72 public void modifyTestElement(TestElement config) 73 { 74 super.configureTestElement(config); 75 config.setProperty(HTTPSampler.PROTOCOL, protocol.getText()); 76 config.setProperty(HTTPSampler.DOMAIN, domain.getText()); 77 config.setProperty(HTTPSampler.PATH, path.getText()); 78 config.setProperty( 79 new TestElementProperty( 80 HTTPSampler.ARGUMENTS, 81 argPanel.createTestElement())); 82 config.setProperty(HTTPSampler.PORT, port.getText()); 83 } 84 85 public void configure(TestElement el) 86 { 87 super.configure(el); 88 protocol.setText(el.getPropertyAsString(HTTPSampler.PROTOCOL)); 89 domain.setText(el.getPropertyAsString(HTTPSampler.DOMAIN)); 90 path.setText(el.getPropertyAsString(HTTPSampler.PATH)); 91 port.setText(el.getPropertyAsString(HTTPSampler.PORT)); 92 argPanel.configure( 93 (TestElement) el 94 .getProperty(HTTPSampler.ARGUMENTS) 95 .getObjectValue()); 96 } 97 98 private void init() 99 { 100 setLayout(new BorderLayout (0, 5)); 101 setBorder(makeBorder()); 102 103 add(makeTitlePanel(), BorderLayout.NORTH); 104 105 Box mainPanel = Box.createVerticalBox(); 106 107 VerticalPanel urlPanel = new VerticalPanel(); 108 protocol = 109 new JLabeledTextField( 110 JMeterUtils.getResString("url_config_protocol")); 111 urlPanel.add(protocol); 112 113 domain = 114 new JLabeledTextField( 115 JMeterUtils.getResString("web_server_domain")); 116 urlPanel.add(domain); 117 118 path = new JLabeledTextField(JMeterUtils.getResString("path")); 119 urlPanel.add(path); 120 121 port = 122 new JLabeledTextField(JMeterUtils.getResString("web_server_port")); 123 urlPanel.add(port); 124 125 mainPanel.add(urlPanel); 126 127 argPanel = new HTTPArgumentsPanel(); 128 mainPanel.add(argPanel); 129 130 add(mainPanel, BorderLayout.CENTER); 131 } 132 133 public Dimension getPreferredSize() 134 { 135 return getMinimumSize(); 136 } 137 } 138 | Popular Tags |