01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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:
21: import java.awt.BorderLayout;
22:
23: import javax.swing.BorderFactory;
24: import javax.swing.ButtonGroup;
25: import javax.swing.JPanel;
26: import javax.swing.JRadioButton;
27:
28: import org.apache.jmeter.testelement.OnErrorTestElement;
29: import org.apache.jmeter.util.JMeterUtils;
30:
31: public class OnErrorPanel extends JPanel {
32: // Sampler error action buttons
33: private JRadioButton continueBox;
34:
35: private JRadioButton stopThrdBox;
36:
37: private JRadioButton stopTestBox;
38:
39: private JPanel createOnErrorPanel() {
40: JPanel panel = new JPanel();
41: panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils
42: .getResString("sampler_on_error_action"))); //$NON-NLS-1$
43:
44: ButtonGroup group = new ButtonGroup();
45:
46: continueBox = new JRadioButton(JMeterUtils
47: .getResString("sampler_on_error_continue")); //$NON-NLS-1$
48: group.add(continueBox);
49: continueBox.setSelected(true);
50: panel.add(continueBox);
51:
52: stopThrdBox = new JRadioButton(JMeterUtils
53: .getResString("sampler_on_error_stop_thread")); //$NON-NLS-1$
54: group.add(stopThrdBox);
55: panel.add(stopThrdBox);
56:
57: stopTestBox = new JRadioButton(JMeterUtils
58: .getResString("sampler_on_error_stop_test")); //$NON-NLS-1$
59: group.add(stopTestBox);
60: panel.add(stopTestBox);
61:
62: return panel;
63: }
64:
65: /**
66: * Create a new NamePanel with the default name.
67: */
68: public OnErrorPanel() {
69: init();
70: }
71:
72: /**
73: * Initialize the GUI components and layout.
74: */
75: private void init() {
76: setLayout(new BorderLayout(5, 0));
77: add(createOnErrorPanel());
78: }
79:
80: public void configure(int errorAction) {
81: stopTestBox
82: .setSelected(errorAction == OnErrorTestElement.ON_ERROR_STOPTEST);
83: stopThrdBox
84: .setSelected(errorAction == OnErrorTestElement.ON_ERROR_STOPTHREAD);
85: continueBox
86: .setSelected(errorAction == OnErrorTestElement.ON_ERROR_CONTINUE);
87: }
88:
89: public int getOnErrorSetting() {
90: if (stopTestBox.isSelected())
91: return OnErrorTestElement.ON_ERROR_STOPTEST;
92: if (stopThrdBox.isSelected())
93: return OnErrorTestElement.ON_ERROR_STOPTHREAD;
94:
95: // Defaults to continue
96: return OnErrorTestElement.ON_ERROR_CONTINUE;
97: }
98: }
|