1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. 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.java.control.gui; 20 21 import java.awt.BorderLayout; 22 23 import org.apache.jmeter.protocol.java.config.JavaConfig; 24 import org.apache.jmeter.protocol.java.config.gui.JavaConfigGui; 25 import org.apache.jmeter.protocol.java.sampler.JavaSampler; 26 import org.apache.jmeter.samplers.gui.AbstractSamplerGui; 27 import org.apache.jmeter.testelement.TestElement; 28 29 /** 30 * The <code>JavaTestSamplerGui</code> class provides the user interface for 31 * the {@link JavaSampler}. 32 * 33 */ 34 public class JavaTestSamplerGui extends AbstractSamplerGui { 35 /** Panel containing the configuration options. */ 36 private JavaConfigGui javaPanel = null; 37 38 /** 39 * Constructor for JavaTestSamplerGui 40 */ 41 public JavaTestSamplerGui() { 42 super(); 43 init(); 44 } 45 46 public String getLabelResource() { 47 return "java_request"; // $NON-NLS-1$ 48 } 49 50 /** 51 * Initialize the GUI components and layout. 52 */ 53 private void init() { 54 setLayout(new BorderLayout(0, 5)); 55 setBorder(makeBorder()); 56 57 add(makeTitlePanel(), BorderLayout.NORTH); 58 59 javaPanel = new JavaConfigGui(false); 60 61 add(javaPanel, BorderLayout.CENTER); 62 } 63 64 /* Implements JMeterGuiComponent.createTestElement() */ 65 public TestElement createTestElement() { 66 JavaSampler sampler = new JavaSampler(); 67 modifyTestElement(sampler); 68 return sampler; 69 } 70 71 /* Implements JMeterGuiComponent.modifyTestElement(TestElement) */ 72 public void modifyTestElement(TestElement sampler) { 73 sampler.clear(); 74 JavaConfig config = (JavaConfig) javaPanel.createTestElement(); 75 configureTestElement(sampler); 76 sampler.addTestElement(config); 77 } 78 79 /* Overrides AbstractJMeterGuiComponent.configure(TestElement) */ 80 public void configure(TestElement el) { 81 super.configure(el); 82 javaPanel.configure(el); 83 } 84 }