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.control.gui;
20:
21: import javax.swing.JCheckBox;
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: public class RandomControlGui extends AbstractControllerGui {
30: private JCheckBox style;
31:
32: public RandomControlGui() {
33: init();
34: }
35:
36: public TestElement createTestElement() {
37: RandomController ic = new RandomController();
38: modifyTestElement(ic);
39: return ic;
40: }
41:
42: /**
43: * Modifies a given TestElement to mirror the data in the gui components.
44: *
45: * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
46: */
47: public void modifyTestElement(TestElement ic) {
48: configureTestElement(ic);
49: if (style.isSelected()) {
50: ((RandomController) ic)
51: .setStyle(InterleaveControl.IGNORE_SUB_CONTROLLERS);
52: } else {
53: ((RandomController) ic)
54: .setStyle(InterleaveControl.USE_SUB_CONTROLLERS);
55: }
56: }
57:
58: /**
59: * Implements JMeterGUIComponent.clearGui
60: */
61: public void clearGui() {
62: super .clearGui();
63: style.setSelected(false);
64: }
65:
66: public void configure(TestElement el) {
67: super .configure(el);
68: if (((RandomController) el).getStyle() == InterleaveControl.IGNORE_SUB_CONTROLLERS) {
69: style.setSelected(true);
70: } else {
71: style.setSelected(false);
72: }
73: }
74:
75: public String getLabelResource() {
76: return "random_control_title"; // $NON-NLS-1$
77: }
78:
79: private void init() {
80: setLayout(new VerticalLayout(5, VerticalLayout.BOTH,
81: VerticalLayout.TOP));
82: setBorder(makeBorder());
83: add(makeTitlePanel());
84:
85: style = new JCheckBox(JMeterUtils
86: .getResString("ignore_subcontrollers")); // $NON-NLS-1$
87: add(style);
88: }
89: }
|