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.ldap.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.ldap.config.gui.LdapConfigGui;
028: import org.apache.jmeter.protocol.ldap.sampler.LDAPSampler;
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 LdapTestSamplerGui extends AbstractSamplerGui {
034: private LoginConfigGui loginPanel;
035:
036: private LdapConfigGui ldapDefaultPanel;
037:
038: public LdapTestSamplerGui() {
039: init();
040: }
041:
042: /**
043: * A newly created component can be initialized with the contents of a Test
044: * Element object by calling this method. The component is responsible for
045: * querying the Test Element object for the relevant information to display
046: * in its GUI.
047: *
048: * @param element
049: * the TestElement to configure
050: */
051: public void configure(TestElement element) {
052: super .configure(element);
053: loginPanel.configure(element);
054: ldapDefaultPanel.configure(element);
055: }
056:
057: public TestElement createTestElement() {
058: LDAPSampler sampler = new LDAPSampler();
059: modifyTestElement(sampler);
060: return sampler;
061: }
062:
063: /**
064: * Modifies a given TestElement to mirror the data in the gui components.
065: *
066: * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
067: */
068: public void modifyTestElement(TestElement sampler) {
069: sampler.clear();
070: ((LDAPSampler) sampler).addTestElement(ldapDefaultPanel
071: .createTestElement());
072: ((LDAPSampler) sampler).addTestElement(loginPanel
073: .createTestElement());
074: this .configureTestElement(sampler);
075: }
076:
077: /**
078: * Implements JMeterGUIComponent.clearGui
079: */
080: public void clearGui() {
081: super .clearGui();
082:
083: ldapDefaultPanel.clearGui();
084: loginPanel.clearGui();
085: }
086:
087: public String getLabelResource() {
088: return "ldap_testing_title"; // $NON-NLS-1$
089: }
090:
091: private void init() {
092: setLayout(new BorderLayout(0, 5));
093: setBorder(makeBorder());
094: // MAIN PANEL
095: VerticalPanel mainPanel = new VerticalPanel();
096: loginPanel = new LoginConfigGui(false);
097: ldapDefaultPanel = new LdapConfigGui(false);
098: loginPanel.setBorder(BorderFactory
099: .createTitledBorder(JMeterUtils
100: .getResString("login_config"))); // $NON-NLS-1$
101: add(makeTitlePanel(), BorderLayout.NORTH);
102: mainPanel.add(loginPanel);
103: mainPanel.add(ldapDefaultPanel);
104: add(mainPanel, BorderLayout.CENTER);
105: }
106: }
|