KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > protocol > http > config > gui > HttpDefaultsGui


1 // $Header: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.java,v 1.13 2004/03/05 01:38:02 sebb Exp $
2
/*
3  * Copyright 2001-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17 */

18
19 package org.apache.jmeter.protocol.http.config.gui;
20
21 import java.awt.BorderLayout JavaDoc;
22 import java.awt.Dimension JavaDoc;
23
24 import javax.swing.Box JavaDoc;
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 /**
37  * @version $Revision: 1.13 $
38  */

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 JavaDoc getLabelResource()
54     {
55         return "url_config_title";
56     }
57
58     /**
59      * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
60      */

61     public TestElement createTestElement()
62     {
63         ConfigTestElement config = new ConfigTestElement();
64         modifyTestElement(config);
65         return config;
66     }
67
68     /**
69      * Modifies a given TestElement to mirror the data in the gui components.
70      * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
71      */

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 JavaDoc(0, 5));
101         setBorder(makeBorder());
102
103         add(makeTitlePanel(), BorderLayout.NORTH);
104
105         Box JavaDoc 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 JavaDoc getPreferredSize()
134     {
135         return getMinimumSize();
136     }
137 }
138
Popular Tags