KickJava   Java API By Example, From Geeks To Geeks.

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


1 // $Header: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/control/gui/Attic/SwitchControllerGui.java,v 1.1.2.1 2005/03/14 00:10:52 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 java.awt.BorderLayout JavaDoc;
22
23 import javax.swing.JLabel JavaDoc;
24 import javax.swing.JPanel JavaDoc;
25 import javax.swing.JTextField JavaDoc;
26
27 import org.apache.jmeter.control.SwitchController;
28 import org.apache.jmeter.testelement.TestElement;
29 import org.apache.jmeter.util.JMeterUtils;
30
31 /**
32  * @version $Revision: 1.1.2.1 $ on $Date: 2005/03/14 00:10:52 $
33  */

34 public class SwitchControllerGui extends AbstractControllerGui
35 {
36    private static final String JavaDoc SWITCH_LABEL = "switch_controller_label";
37
38     private JTextField JavaDoc switchValue;
39
40     public SwitchControllerGui()
41     {
42         init();
43     }
44
45     public TestElement createTestElement()
46     {
47         SwitchController ic = new SwitchController();
48         modifyTestElement(ic);
49         return ic;
50     }
51
52     /**
53      * Modifies a given TestElement to mirror the data in the gui components.
54      * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
55      */

56     public void modifyTestElement(TestElement ic)
57     {
58         configureTestElement(ic);
59         ((SwitchController) ic).setSelection(switchValue.getText());
60     }
61
62     public void configure(TestElement el)
63     {
64         super.configure(el);
65         switchValue.setText(((SwitchController) el).getSelection());
66     }
67
68     public String JavaDoc getLabelResource()
69     {
70         return "switch_controller_title";
71     }
72
73     private void init()
74     {
75         setLayout(new BorderLayout JavaDoc(0, 5));
76         setBorder(makeBorder());
77         add(makeTitlePanel(), BorderLayout.NORTH);
78
79         JPanel JavaDoc mainPanel = new JPanel JavaDoc(new BorderLayout JavaDoc());
80         mainPanel.add(createSwitchPanel(), BorderLayout.NORTH);
81         add(mainPanel, BorderLayout.CENTER);
82     }
83
84     private JPanel JavaDoc createSwitchPanel() {
85         JPanel JavaDoc switchPanel = new JPanel JavaDoc(new BorderLayout JavaDoc(5, 0));
86         JLabel JavaDoc selectionLabel =
87         new JLabel JavaDoc(JMeterUtils.getResString( SWITCH_LABEL ));
88         switchValue = new JTextField JavaDoc("");
89         selectionLabel.setLabelFor(switchValue);
90         switchPanel.add(selectionLabel, BorderLayout.WEST);
91         switchPanel.add(switchValue, BorderLayout.CENTER);
92         return switchPanel;
93     }
94
95 }
96
Popular Tags