KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > protocol > http > modifier > gui > URLRewritingModifierGui


1 // $Header: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/modifier/gui/URLRewritingModifierGui.java,v 1.12.2.1 2004/10/07 17:52:35 sebb Exp $
2
/*
3  * Copyright 2001-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * 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.modifier.gui;
20
21 import java.awt.BorderLayout JavaDoc;
22
23 import javax.swing.JCheckBox JavaDoc;
24
25 import org.apache.jmeter.gui.util.VerticalPanel;
26 import org.apache.jmeter.processor.gui.AbstractPreProcessorGui;
27 import org.apache.jmeter.protocol.http.modifier.URLRewritingModifier;
28 import org.apache.jmeter.testelement.TestElement;
29 import org.apache.jmeter.util.JMeterUtils;
30 import org.apache.jorphan.gui.JLabeledTextField;
31
32 /**
33  * @version $Revision: 1.12.2.1 $ last updated $Date: 2004/10/07 17:52:35 $
34  */

35 public class URLRewritingModifierGui extends AbstractPreProcessorGui
36 {
37     JLabeledTextField argumentName;
38     JCheckBox JavaDoc pathExt;
39     JCheckBox JavaDoc pathExtNoEquals;
40     JCheckBox JavaDoc pathExtNoQuestionmark;
41
42     public String JavaDoc getLabelResource()
43     {
44         return "http_url_rewriting_modifier_title";
45     }
46
47     public URLRewritingModifierGui()
48     {
49         init();
50     }
51
52     private void init()
53     {
54         setLayout(new BorderLayout JavaDoc(0, 5));
55         setBorder(makeBorder());
56
57         add(makeTitlePanel(), BorderLayout.NORTH);
58
59         VerticalPanel mainPanel = new VerticalPanel();
60
61         argumentName =
62             new JLabeledTextField(
63                 JMeterUtils.getResString("session_argument_name"),
64                 10);
65         mainPanel.add(argumentName);
66
67         pathExt =
68             new JCheckBox JavaDoc(JMeterUtils.getResString("Path_Extension_choice"));
69         mainPanel.add(pathExt);
70
71         pathExtNoEquals =
72             new JCheckBox JavaDoc(
73                 JMeterUtils.getResString("path_extension_dont_use_equals"));
74         mainPanel.add(pathExtNoEquals);
75
76         pathExtNoQuestionmark =
77             new JCheckBox JavaDoc(
78                 JMeterUtils.getResString("path_extension_dont_use_questionmark"));
79         mainPanel.add(pathExtNoQuestionmark);
80
81         add(mainPanel, BorderLayout.CENTER);
82     }
83
84     /* (non-Javadoc)
85      * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
86      */

87     public TestElement createTestElement()
88     {
89         URLRewritingModifier modifier = new URLRewritingModifier();
90         modifyTestElement(modifier);
91         return modifier;
92     }
93
94     /**
95      * Modifies a given TestElement to mirror the data in the gui components.
96      * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
97      */

98     public void modifyTestElement(TestElement modifier)
99     {
100         this.configureTestElement(modifier);
101         ((URLRewritingModifier) modifier).setArgumentName(
102             argumentName.getText());
103         ((URLRewritingModifier) modifier).setPathExtension(
104             pathExt.isSelected());
105         ((URLRewritingModifier) modifier).setPathExtensionNoEquals(
106             pathExtNoEquals.isSelected());
107         ((URLRewritingModifier) modifier).setPathExtensionNoQuestionmark(
108                 pathExtNoQuestionmark.isSelected());
109     }
110
111     public void configure(TestElement el)
112     {
113         argumentName.setText(((URLRewritingModifier) el).getArgumentName());
114         pathExt.setSelected(((URLRewritingModifier) el).isPathExtension());
115         pathExtNoEquals.setSelected(
116             ((URLRewritingModifier) el).isPathExtensionNoEquals());
117         pathExtNoQuestionmark.setSelected(
118                 ((URLRewritingModifier) el).isPathExtensionNoQuestionmark());
119
120         super.configure(el);
121     }
122 }
123
Popular Tags