KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > modifiers > gui > CounterConfigGui


1 // $Header: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/modifiers/gui/CounterConfigGui.java,v 1.11.2.2 2005/03/11 01:56:18 sebb Exp $
2
/*
3  * Copyright 2002-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.modifiers.gui;
20
21 import javax.swing.JCheckBox JavaDoc;
22
23 import org.apache.jmeter.modifiers.CounterConfig;
24 import org.apache.jmeter.processor.gui.AbstractPreProcessorGui;
25 import org.apache.jmeter.testelement.TestElement;
26 import org.apache.jmeter.util.JMeterUtils;
27 import org.apache.jorphan.gui.JLabeledTextField;
28 import org.apache.jorphan.gui.layout.VerticalLayout;
29
30 /**
31  * @version $Revision: 1.11.2.2 $ on $Date: 2005/03/11 01:56:18 $
32  */

33 public class CounterConfigGui extends AbstractPreProcessorGui
34 {
35     private JLabeledTextField startField, incrField, endField, varNameField;
36     private JCheckBox JavaDoc perUserField;
37
38     public CounterConfigGui()
39     {
40         super();
41         init();
42     }
43
44     public String JavaDoc getLabelResource()
45     {
46         return "counter_config_title";
47     }
48     /**
49      * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
50      */

51     public TestElement createTestElement()
52     {
53         CounterConfig config = new CounterConfig();
54         modifyTestElement(config);
55         return config;
56     }
57
58     /**
59      * Modifies a given TestElement to mirror the data in the gui components.
60      * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
61      */

62     public void modifyTestElement(TestElement c)
63     {
64         if (c instanceof CounterConfig)
65         {
66             CounterConfig config = (CounterConfig) c;
67             config.setStart(startField.getText());
68             //Bug 22820 if (endField.getText().length() > 0)
69
{
70                 config.setEnd(endField.getText());
71             }
72             config.setIncrement(incrField.getText());
73             config.setVarName(varNameField.getText());
74             config.setIsPerUser(perUserField.isSelected());
75         }
76         super.configureTestElement(c);
77     }
78
79     public void configure(TestElement element)
80     {
81         super.configure(element);
82         CounterConfig config = (CounterConfig) element;
83         startField.setText(config.getPropertyAsString(CounterConfig.START));
84         endField.setText(config.getPropertyAsString(CounterConfig.END));
85         incrField.setText(config.getPropertyAsString(CounterConfig.INCREMENT));
86         varNameField.setText(config.getVarName());
87         perUserField.setSelected(config.isPerUser());
88     }
89
90     private void init()
91     {
92         setBorder (makeBorder());
93         setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
94         
95         startField =
96             new JLabeledTextField(JMeterUtils.getResString("start")+" ");//TODO proper alignment
97
incrField =
98             new JLabeledTextField(JMeterUtils.getResString("increment"));
99         endField = new JLabeledTextField(JMeterUtils.getResString("max"));
100         varNameField =
101             new JLabeledTextField(JMeterUtils.getResString("var_name"));
102         perUserField =
103             new JCheckBox JavaDoc(JMeterUtils.getResString("counter_per_user"));
104
105         add(makeTitlePanel());
106         add(startField);
107         add(incrField);
108         add(endField);
109         add(varNameField);
110         add(perUserField);
111     }
112 }
113
Popular Tags