KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > control > gui > RandomControlGui


1 // $Header: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/control/gui/RandomControlGui.java,v 1.13 2004/03/05 01:32:37 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.control.gui;
20
21 import javax.swing.JCheckBox JavaDoc;
22
23 import org.apache.jmeter.control.InterleaveControl;
24 import org.apache.jmeter.control.RandomController;
25 import org.apache.jmeter.testelement.TestElement;
26 import org.apache.jmeter.util.JMeterUtils;
27 import org.apache.jorphan.gui.layout.VerticalLayout;
28
29 /**
30  * @version $Revision: 1.13 $ on $Date: 2004/03/05 01:32:37 $
31  */

32 public class RandomControlGui extends AbstractControllerGui
33 {
34     private JCheckBox JavaDoc style;
35
36     public RandomControlGui()
37     {
38         init();
39     }
40
41     public TestElement createTestElement()
42     {
43         RandomController ic = new RandomController();
44         modifyTestElement(ic);
45         return ic;
46     }
47
48     /**
49      * Modifies a given TestElement to mirror the data in the gui components.
50      * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
51      */

52     public void modifyTestElement(TestElement ic)
53     {
54         configureTestElement(ic);
55         if (style.isSelected())
56         {
57             ((RandomController) ic).setStyle(
58                 InterleaveControl.IGNORE_SUB_CONTROLLERS);
59         }
60         else
61         {
62             ((RandomController) ic).setStyle(
63                 InterleaveControl.USE_SUB_CONTROLLERS);
64         }
65     }
66
67     public void configure(TestElement el)
68     {
69         super.configure(el);
70         if (((RandomController) el).getStyle()
71             == InterleaveControl.IGNORE_SUB_CONTROLLERS)
72         {
73             style.setSelected(true);
74         }
75         else
76         {
77             style.setSelected(false);
78         }
79     }
80
81     public String JavaDoc getLabelResource()
82     {
83         return "random_control_title";
84     }
85
86     private void init()
87     {
88         setLayout(
89             new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
90         setBorder(makeBorder());
91         add(makeTitlePanel());
92
93         style =
94             new JCheckBox JavaDoc(JMeterUtils.getResString("ignore_subcontrollers"));
95         add(style);
96     }
97 }
98
Popular Tags