001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.jmeter.protocol.ftp.control.gui;
020:
021: import java.awt.BorderLayout;
022:
023: import javax.swing.BorderFactory;
024:
025: import org.apache.jmeter.config.gui.LoginConfigGui;
026: import org.apache.jmeter.gui.util.VerticalPanel;
027: import org.apache.jmeter.protocol.ftp.config.gui.FtpConfigGui;
028: import org.apache.jmeter.protocol.ftp.sampler.FTPSampler;
029: import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
030: import org.apache.jmeter.testelement.TestElement;
031: import org.apache.jmeter.util.JMeterUtils;
032:
033: public class FtpTestSamplerGui extends AbstractSamplerGui {
034: private LoginConfigGui loginPanel;
035:
036: private FtpConfigGui ftpDefaultPanel;
037:
038: public FtpTestSamplerGui() {
039: init();
040: }
041:
042: public void configure(TestElement element) {
043: super .configure(element);
044: loginPanel.configure(element);
045: ftpDefaultPanel.configure(element);
046: }
047:
048: public TestElement createTestElement() {
049: FTPSampler sampler = new FTPSampler();
050: modifyTestElement(sampler);
051: return sampler;
052: }
053:
054: /**
055: * Modifies a given TestElement to mirror the data in the gui components.
056: *
057: * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
058: */
059: public void modifyTestElement(TestElement sampler) {
060: sampler.clear();
061: ((FTPSampler) sampler).addTestElement(ftpDefaultPanel
062: .createTestElement());
063: ((FTPSampler) sampler).addTestElement(loginPanel
064: .createTestElement());
065: this .configureTestElement(sampler);
066: }
067:
068: /**
069: * Implements JMeterGUIComponent.clearGui
070: */
071: public void clearGui() {
072: super .clearGui();
073:
074: ftpDefaultPanel.clearGui();
075: loginPanel.clearGui();
076: }
077:
078: public String getLabelResource() {
079: return "ftp_testing_title"; // $NON-NLS-1$
080: }
081:
082: private void init() {
083: setLayout(new BorderLayout(0, 5));
084: setBorder(makeBorder());
085:
086: add(makeTitlePanel(), BorderLayout.NORTH);
087:
088: VerticalPanel mainPanel = new VerticalPanel();
089:
090: ftpDefaultPanel = new FtpConfigGui(false);
091: mainPanel.add(ftpDefaultPanel);
092:
093: loginPanel = new LoginConfigGui(false);
094: loginPanel.setBorder(BorderFactory
095: .createTitledBorder(JMeterUtils
096: .getResString("login_config"))); // $NON-NLS-1$
097: mainPanel.add(loginPanel);
098:
099: add(mainPanel, BorderLayout.CENTER);
100: }
101: }
|