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