KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > protocol > tcp > control > gui > TCPSamplerGui


1 // $Header: /home/cvs/jakarta-jmeter/src/protocol/tcp/org/apache/jmeter/protocol/tcp/control/gui/TCPSamplerGui.java,v 1.5 2004/03/05 01:39:07 sebb Exp $
2
/*
3  * Copyright 2003-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.tcp.control.gui;
20
21 import java.awt.BorderLayout JavaDoc;
22
23 import javax.swing.BorderFactory JavaDoc;
24 import org.apache.jmeter.config.gui.LoginConfigGui;
25 import org.apache.jmeter.gui.util.VerticalPanel;
26 import org.apache.jmeter.protocol.tcp.config.gui.TCPConfigGui;
27 import org.apache.jmeter.protocol.tcp.sampler.TCPSampler;
28 import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
29 import org.apache.jmeter.testelement.TestElement;
30 import org.apache.jmeter.util.JMeterUtils;
31
32 /**
33  * @version $Revision: 1.5 $ $Date: 2004/03/05 01:39:07 $
34  */

35 public class TCPSamplerGui extends AbstractSamplerGui
36 {
37     
38     private LoginConfigGui loginPanel;
39
40     private TCPConfigGui TcpDefaultPanel;
41
42     public TCPSamplerGui()
43     {
44         init();
45     }
46
47     public void configure(TestElement element)
48     {
49         super.configure(element);
50         loginPanel.configure(element);
51         TcpDefaultPanel.configure(element);
52     }
53
54     public TestElement createTestElement()
55     {
56         TCPSampler sampler = new TCPSampler();
57         modifyTestElement(sampler);
58         return sampler;
59     }
60
61     /**
62      * Modifies a given TestElement to mirror the data in the gui components.
63      * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
64      */

65     public void modifyTestElement(TestElement sampler)
66     {
67         sampler.clear();
68         ((TCPSampler) sampler).addTestElement(
69             TcpDefaultPanel.createTestElement());
70         ((TCPSampler) sampler).addTestElement(loginPanel.createTestElement());
71         this.configureTestElement(sampler);
72     }
73
74     public String JavaDoc getLabelResource()
75     {
76         return "tcp_sample_title";
77     }
78     
79     private void init()
80     {
81         setLayout(new BorderLayout JavaDoc(0, 5));
82         setBorder(makeBorder());
83
84         add(makeTitlePanel(), BorderLayout.NORTH);
85
86         VerticalPanel mainPanel = new VerticalPanel();
87
88         TcpDefaultPanel = new TCPConfigGui(false);
89         mainPanel.add(TcpDefaultPanel);
90
91         loginPanel = new LoginConfigGui(false);
92         loginPanel.setBorder(
93             BorderFactory.createTitledBorder(
94                 JMeterUtils.getResString("login_config")));
95         mainPanel.add(loginPanel);
96
97         add(mainPanel, BorderLayout.CENTER);
98     }
99 }
100
Popular Tags