KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > gui > OnErrorPanel


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/OnErrorPanel.java,v 1.3.2.1 2004/07/01 23:09:54 sebb Exp $
2
/*
3  * Copyright 2003-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.gui;
20 import java.awt.BorderLayout JavaDoc;
21
22 import javax.swing.BorderFactory JavaDoc;
23 import javax.swing.ButtonGroup JavaDoc;
24 import javax.swing.JPanel JavaDoc;
25 import javax.swing.JRadioButton JavaDoc;
26
27 import org.apache.jmeter.testelement.OnErrorTestElement;
28 import org.apache.jmeter.util.JMeterUtils;
29
30 /**
31  *
32  * @version $Revision: 1.3.2.1 $ $Date: 2004/07/01 23:09:54 $
33  */

34 public class OnErrorPanel extends JPanel JavaDoc
35 {
36     // Sampler error action buttons
37
private JRadioButton JavaDoc continueBox;
38     private JRadioButton JavaDoc stopThrdBox;
39     private JRadioButton JavaDoc stopTestBox;
40
41     private JPanel JavaDoc createOnErrorPanel()
42     {
43         JPanel JavaDoc panel = new JPanel JavaDoc();
44         panel.setBorder(
45             BorderFactory.createTitledBorder(
46                 JMeterUtils.getResString("sampler_on_error_action")));
47
48         ButtonGroup JavaDoc group = new ButtonGroup JavaDoc();
49
50         continueBox =
51             new JRadioButton JavaDoc(JMeterUtils.getResString("sampler_on_error_continue"));
52         group.add(continueBox);
53         continueBox.setSelected(true);
54         panel.add(continueBox);
55
56         stopThrdBox =
57             new JRadioButton JavaDoc(JMeterUtils.getResString("sampler_on_error_stop_thread"));
58         group.add(stopThrdBox);
59         panel.add(stopThrdBox);
60
61         stopTestBox =
62             new JRadioButton JavaDoc(JMeterUtils.getResString("sampler_on_error_stop_test"));
63         group.add(stopTestBox);
64         panel.add(stopTestBox);
65
66         return panel;
67     }
68     /**
69      * Create a new NamePanel with the default name.
70      */

71     public OnErrorPanel()
72     {
73         init();
74     }
75
76     /**
77      * Initialize the GUI components and layout.
78      */

79     private void init()
80     {
81         setLayout(new BorderLayout JavaDoc(5, 0));
82         add(createOnErrorPanel());
83     }
84     public void configure(int errorAction)
85     {
86         stopTestBox.setSelected(errorAction == OnErrorTestElement.ON_ERROR_STOPTEST);
87         stopThrdBox.setSelected(errorAction == OnErrorTestElement.ON_ERROR_STOPTHREAD);
88         continueBox.setSelected(errorAction == OnErrorTestElement.ON_ERROR_CONTINUE);
89     }
90     
91     public int getOnErrorSetting()
92     {
93         if (stopTestBox.isSelected()) return OnErrorTestElement.ON_ERROR_STOPTEST;
94         if (stopThrdBox.isSelected()) return OnErrorTestElement.ON_ERROR_STOPTHREAD;
95
96         // Defaults to continue
97
return OnErrorTestElement.ON_ERROR_CONTINUE;
98     }
99 }
100
Popular Tags