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.modifier.gui;
020:
021: import java.awt.BorderLayout;
022:
023: import javax.swing.JCheckBox;
024:
025: import org.apache.jmeter.gui.util.VerticalPanel;
026: import org.apache.jmeter.processor.gui.AbstractPreProcessorGui;
027: import org.apache.jmeter.protocol.http.modifier.URLRewritingModifier;
028: import org.apache.jmeter.testelement.TestElement;
029: import org.apache.jmeter.util.JMeterUtils;
030: import org.apache.jorphan.gui.JLabeledTextField;
031:
032: public class URLRewritingModifierGui extends AbstractPreProcessorGui {
033: private JLabeledTextField argumentName;
034:
035: private JCheckBox pathExt;
036:
037: private JCheckBox pathExtNoEquals;
038:
039: private JCheckBox pathExtNoQuestionmark;
040:
041: private JCheckBox shouldCache;
042:
043: public String getLabelResource() {
044: return "http_url_rewriting_modifier_title"; // $NON-NLS-1$
045: }
046:
047: public URLRewritingModifierGui() {
048: init();
049: }
050:
051: private void init() {
052: setLayout(new BorderLayout(0, 5));
053: setBorder(makeBorder());
054:
055: add(makeTitlePanel(), BorderLayout.NORTH);
056:
057: VerticalPanel mainPanel = new VerticalPanel();
058:
059: argumentName = new JLabeledTextField(JMeterUtils
060: .getResString("session_argument_name"), 10); // $NON-NLS-1$
061: mainPanel.add(argumentName);
062:
063: pathExt = new JCheckBox(JMeterUtils
064: .getResString("path_extension_choice")); // $NON-NLS-1$
065: mainPanel.add(pathExt);
066:
067: pathExtNoEquals = new JCheckBox(JMeterUtils
068: .getResString("path_extension_dont_use_equals")); // $NON-NLS-1$
069: mainPanel.add(pathExtNoEquals);
070:
071: pathExtNoQuestionmark = new JCheckBox(JMeterUtils
072: .getResString("path_extension_dont_use_questionmark")); // $NON-NLS-1$
073: mainPanel.add(pathExtNoQuestionmark);
074:
075: shouldCache = new JCheckBox(JMeterUtils
076: .getResString("cache_session_id")); // $NON-NLS-1$
077: shouldCache.setSelected(true);
078: mainPanel.add(shouldCache);
079:
080: add(mainPanel, BorderLayout.CENTER);
081: }
082:
083: /*
084: * (non-Javadoc)
085: *
086: * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
087: */
088: public TestElement createTestElement() {
089: URLRewritingModifier modifier = new URLRewritingModifier();
090: modifyTestElement(modifier);
091: return modifier;
092: }
093:
094: /**
095: * Modifies a given TestElement to mirror the data in the gui components.
096: *
097: * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
098: */
099: public void modifyTestElement(TestElement modifier) {
100: this .configureTestElement(modifier);
101: URLRewritingModifier rewritingModifier = ((URLRewritingModifier) modifier);
102: rewritingModifier.setArgumentName(argumentName.getText());
103: rewritingModifier.setPathExtension(pathExt.isSelected());
104: rewritingModifier.setPathExtensionNoEquals(pathExtNoEquals
105: .isSelected());
106: rewritingModifier
107: .setPathExtensionNoQuestionmark(pathExtNoQuestionmark
108: .isSelected());
109: rewritingModifier.setShouldCache((shouldCache.isSelected()));
110: }
111:
112: /**
113: * Implements JMeterGUIComponent.clearGui
114: */
115: public void clearGui() {
116: super .clearGui();
117:
118: argumentName.setText(""); //$NON-NLS-1$
119: pathExt.setSelected(false);
120: pathExtNoEquals.setSelected(false);
121: pathExtNoQuestionmark.setSelected(false);
122: shouldCache.setSelected(false);
123: }
124:
125: public void configure(TestElement el) {
126: URLRewritingModifier rewritingModifier = ((URLRewritingModifier) el);
127: argumentName.setText(rewritingModifier.getArgumentName());
128: pathExt.setSelected(rewritingModifier.isPathExtension());
129: pathExtNoEquals.setSelected(rewritingModifier
130: .isPathExtensionNoEquals());
131: pathExtNoQuestionmark.setSelected(rewritingModifier
132: .isPathExtensionNoQuestionmark());
133: shouldCache.setSelected(rewritingModifier.shouldCache());
134:
135: super.configure(el);
136: }
137: }
|