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.http.config.gui;
020:
021: import java.awt.BorderLayout;
022: import java.awt.Dimension;
023:
024: import javax.swing.JCheckBox;
025:
026: import org.apache.jmeter.config.ConfigTestElement;
027: import org.apache.jmeter.config.gui.AbstractConfigGui;
028: import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
029: import org.apache.jmeter.testelement.AbstractTestElement;
030: import org.apache.jmeter.testelement.TestElement;
031: import org.apache.jmeter.testelement.property.BooleanProperty;
032: import org.apache.jmeter.util.JMeterUtils;
033:
034: public class HttpDefaultsGui extends AbstractConfigGui {
035:
036: private JCheckBox imageParser;
037:
038: private UrlConfigGui urlConfig;
039:
040: public HttpDefaultsGui() {
041: super ();
042: init();
043: }
044:
045: public String getLabelResource() {
046: return "url_config_title"; // $NON-NLS-1$
047: }
048:
049: /**
050: * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
051: */
052: public TestElement createTestElement() {
053: ConfigTestElement config = new ConfigTestElement();
054: modifyTestElement(config);
055: return config;
056: }
057:
058: /**
059: * Modifies a given TestElement to mirror the data in the gui components.
060: *
061: * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
062: */
063: public void modifyTestElement(TestElement config) {
064: ConfigTestElement cfg = (ConfigTestElement) config;
065: ConfigTestElement el = (ConfigTestElement) urlConfig
066: .createTestElement();
067: cfg.clear(); // need to clear because the
068: cfg.addConfigElement(el);
069: super .configureTestElement(config);
070: if (imageParser.isSelected())
071: config.setProperty(new BooleanProperty(
072: HTTPSamplerBase.IMAGE_PARSER, true));
073: else {
074: config.removeProperty(HTTPSamplerBase.IMAGE_PARSER);
075: }
076: }
077:
078: /**
079: * Implements JMeterGUIComponent.clearGui
080: */
081: public void clearGui() {
082: super .clearGui();
083: urlConfig.clear();
084: imageParser.setSelected(false);
085: }
086:
087: public void configure(TestElement el) {
088: super .configure(el);
089: urlConfig.configure(el);
090: imageParser.setSelected(((AbstractTestElement) el)
091: .getPropertyAsBoolean(HTTPSamplerBase.IMAGE_PARSER));
092: }
093:
094: private void init() {
095: setLayout(new BorderLayout(0, 5));
096: setBorder(makeBorder());
097:
098: add(makeTitlePanel(), BorderLayout.NORTH);
099:
100: urlConfig = new UrlConfigGui(false);
101: add(urlConfig, BorderLayout.CENTER);
102:
103: imageParser = new JCheckBox(JMeterUtils
104: .getResString("web_testing_retrieve_images")); // $NON-NLS-1$
105: add(imageParser, BorderLayout.SOUTH);
106: }
107:
108: public Dimension getPreferredSize() {
109: return getMinimumSize();
110: }
111: }
|