Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.protocol.http.config.gui » [javadoc | source]

    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.http.config.gui;
   20   
   21   import java.awt.BorderLayout;
   22   import java.awt.Dimension;
   23   
   24   import javax.swing.JCheckBox;
   25   
   26   import org.apache.jmeter.config.ConfigTestElement;
   27   import org.apache.jmeter.config.gui.AbstractConfigGui;
   28   import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
   29   import org.apache.jmeter.testelement.AbstractTestElement;
   30   import org.apache.jmeter.testelement.TestElement;
   31   import org.apache.jmeter.testelement.property.BooleanProperty;
   32   import org.apache.jmeter.util.JMeterUtils;
   33   
   34   public class HttpDefaultsGui extends AbstractConfigGui {
   35   
   36       private JCheckBox imageParser;
   37   
   38       private UrlConfigGui urlConfig;
   39   
   40       public HttpDefaultsGui() {
   41           super();
   42           init();
   43       }
   44   
   45       public String getLabelResource() {
   46           return "url_config_title"; // $NON-NLS-1$
   47       }
   48   
   49       /**
   50        * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
   51        */
   52       public TestElement createTestElement() {
   53           ConfigTestElement config = new ConfigTestElement();
   54           modifyTestElement(config);
   55           return config;
   56       }
   57   
   58       /**
   59        * Modifies a given TestElement to mirror the data in the gui components.
   60        *
   61        * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
   62        */
   63       public void modifyTestElement(TestElement config) {
   64           ConfigTestElement cfg = (ConfigTestElement ) config;
   65           ConfigTestElement el = (ConfigTestElement) urlConfig.createTestElement();
   66           cfg.clear(); // need to clear because the
   67           cfg.addConfigElement(el);
   68           super.configureTestElement(config);
   69           if (imageParser.isSelected()) {
   70               config.setProperty(new BooleanProperty(HTTPSamplerBase.IMAGE_PARSER, true));
   71           } else {
   72               config.removeProperty(HTTPSamplerBase.IMAGE_PARSER);
   73           }
   74       }
   75   
   76       /**
   77        * Implements JMeterGUIComponent.clearGui
   78        */
   79       public void clearGui() {
   80           super.clearGui();
   81           urlConfig.clear();
   82           imageParser.setSelected(false);
   83       }
   84   
   85       public void configure(TestElement el) {
   86           super.configure(el);
   87           urlConfig.configure(el);
   88           imageParser.setSelected(((AbstractTestElement) el).getPropertyAsBoolean(HTTPSamplerBase.IMAGE_PARSER));
   89       }
   90   
   91       private void init() {
   92           setLayout(new BorderLayout(0, 5));
   93           setBorder(makeBorder());
   94   
   95           add(makeTitlePanel(), BorderLayout.NORTH);
   96   
   97           urlConfig = new UrlConfigGui(false);
   98           add(urlConfig, BorderLayout.CENTER);
   99   
  100           imageParser = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images")); // $NON-NLS-1$
  101           add(imageParser, BorderLayout.SOUTH);
  102       }
  103   
  104       public Dimension getPreferredSize() {
  105           return getMinimumSize();
  106       }
  107   }

Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.protocol.http.config.gui » [javadoc | source]