01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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;
22:
23: import javax.swing.BorderFactory;
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: public class TCPSamplerGui extends AbstractSamplerGui {
33:
34: private LoginConfigGui loginPanel;
35:
36: private TCPConfigGui TcpDefaultPanel;
37:
38: public TCPSamplerGui() {
39: init();
40: }
41:
42: public void configure(TestElement element) {
43: super .configure(element);
44: loginPanel.configure(element);
45: TcpDefaultPanel.configure(element);
46: }
47:
48: public TestElement createTestElement() {
49: TCPSampler sampler = new TCPSampler();
50: modifyTestElement(sampler);
51: return sampler;
52: }
53:
54: /**
55: * Modifies a given TestElement to mirror the data in the gui components.
56: *
57: * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
58: */
59: public void modifyTestElement(TestElement sampler) {
60: sampler.clear();
61: sampler.addTestElement(TcpDefaultPanel.createTestElement());
62: sampler.addTestElement(loginPanel.createTestElement());
63: this .configureTestElement(sampler);
64: }
65:
66: /**
67: * Implements JMeterGUIComponent.clearGui
68: */
69: public void clearGui() {
70: super .clearGui();
71:
72: TcpDefaultPanel.clearGui();
73: loginPanel.clearGui();
74: }
75:
76: public String getLabelResource() {
77: return "tcp_sample_title"; // $NON-NLS-1$
78: }
79:
80: private void init() {
81: setLayout(new BorderLayout(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(BorderFactory
93: .createTitledBorder(JMeterUtils
94: .getResString("login_config"))); // $NON-NLS-1$
95: mainPanel.add(loginPanel);
96:
97: add(mainPanel, BorderLayout.CENTER);
98: }
99: }
|