Source Code Cross Referenced for TestActionGui.java in  » Testing » jakarta-jmeter » org » apache » jmeter » sampler » gui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » jakarta jmeter » org.apache.jmeter.sampler.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *   http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         * 
017:         */
018:
019:        package org.apache.jmeter.sampler.gui;
020:
021:        import java.awt.event.ActionEvent;
022:        import java.awt.event.ActionListener;
023:        import java.awt.event.FocusEvent;
024:        import java.awt.event.FocusListener;
025:
026:        import javax.swing.ButtonGroup;
027:        import javax.swing.DefaultComboBoxModel;
028:        import javax.swing.JComboBox;
029:        import javax.swing.JLabel;
030:        import javax.swing.JRadioButton;
031:        import javax.swing.JTextField;
032:        import javax.swing.event.ChangeEvent;
033:        import javax.swing.event.ChangeListener;
034:
035:        import org.apache.jmeter.gui.util.HorizontalPanel;
036:        import org.apache.jmeter.sampler.TestAction;
037:        import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
038:        import org.apache.jmeter.testelement.TestElement;
039:        import org.apache.jmeter.util.JMeterUtils;
040:        import org.apache.jorphan.gui.layout.VerticalLayout;
041:
042:        public class TestActionGui extends AbstractSamplerGui {
043:            // Gui components
044:            private JComboBox targetBox;
045:
046:            // private ButtonGroup actionButtons;
047:            private JRadioButton pauseButton;
048:
049:            private JRadioButton stopButton;
050:
051:            private JTextField durationField;
052:
053:            // State variables
054:            private int target;
055:
056:            private int action;
057:
058:            private String durationString;
059:
060:            // String in the panel
061:            private static final String targetLabel = JMeterUtils
062:                    .getResString("test_action_target"); // $NON-NLS-1$
063:
064:            private static final String threadTarget = JMeterUtils
065:                    .getResString("test_action_target_thread"); // $NON-NLS-1$
066:
067:            private static final String testTarget = JMeterUtils
068:                    .getResString("test_action_target_test"); // $NON-NLS-1$
069:
070:            private static final String actionLabel = JMeterUtils
071:                    .getResString("test_action_action"); // $NON-NLS-1$
072:
073:            private static final String pauseAction = JMeterUtils
074:                    .getResString("test_action_pause"); // $NON-NLS-1$
075:
076:            private static final String stopAction = JMeterUtils
077:                    .getResString("test_action_stop"); // $NON-NLS-1$
078:
079:            private static final String durationLabel = JMeterUtils
080:                    .getResString("test_action_duration"); // $NON-NLS-1$
081:
082:            public TestActionGui() {
083:                super ();
084:                target = TestAction.THREAD;
085:                action = TestAction.PAUSE;
086:                durationString = ""; // $NON-NLS-1$
087:                init();
088:            }
089:
090:            public String getLabelResource() {
091:                return "test_action_title"; // $NON-NLS-1$
092:            }
093:
094:            public void configure(TestElement element) {
095:                super .configure(element);
096:                TestAction ta = (TestAction) element;
097:
098:                target = ta.getTarget();
099:                if (target == TestAction.THREAD)
100:                    targetBox.setSelectedItem(threadTarget);
101:                else
102:                    targetBox.setSelectedItem(testTarget);
103:
104:                action = ta.getAction();
105:                if (action == TestAction.PAUSE)
106:                    pauseButton.setSelected(true);
107:                else
108:                    stopButton.setSelected(true);
109:
110:                durationString = ta.getDurationAsString();
111:                durationField.setText(durationString);
112:            }
113:
114:            /**
115:             * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
116:             */
117:            public TestElement createTestElement() {
118:                TestAction ta = new TestAction();
119:                modifyTestElement(ta);
120:                return ta;
121:            }
122:
123:            /**
124:             * Modifies a given TestElement to mirror the data in the gui components.
125:             * 
126:             * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
127:             */
128:            public void modifyTestElement(TestElement element) {
129:                super .configureTestElement(element);
130:                TestAction ta = (TestAction) element;
131:                ta.setAction(action);
132:                ta.setTarget(target);
133:                ta.setDuration(durationString);
134:            }
135:
136:            /**
137:             * Implements JMeterGUIComponent.clearGui
138:             */
139:            public void clearGui() {
140:                super .clearGui();
141:
142:                targetBox.setSelectedIndex(0);
143:                durationString = ""; //$NON-NLS-1$
144:                durationField.setText(""); //$NON-NLS-1$
145:                pauseButton.setSelected(true);
146:                stopButton.setSelected(false);
147:                action = TestAction.PAUSE;
148:                target = TestAction.THREAD;
149:
150:            }
151:
152:            private void init() {
153:                setLayout(new VerticalLayout(5, VerticalLayout.BOTH,
154:                        VerticalLayout.TOP));
155:                setBorder(makeBorder());
156:                add(makeTitlePanel());
157:
158:                // Target
159:                HorizontalPanel targetPanel = new HorizontalPanel();
160:                targetPanel.add(new JLabel(targetLabel));
161:                DefaultComboBoxModel targetModel = new DefaultComboBoxModel();
162:                targetModel.addElement(threadTarget);
163:                targetModel.addElement(testTarget);
164:                targetBox = new JComboBox(targetModel);
165:                targetBox.addActionListener(new ActionListener() {
166:                    public void actionPerformed(ActionEvent e) {
167:                        if (((String) targetBox.getSelectedItem())
168:                                .equals(threadTarget)) {
169:                            target = TestAction.THREAD;
170:                        } else {
171:                            target = TestAction.TEST;
172:                        }
173:                    }
174:                });
175:                targetPanel.add(targetBox);
176:                add(targetPanel);
177:
178:                // Action
179:                HorizontalPanel actionPanel = new HorizontalPanel();
180:                ButtonGroup actionButtons = new ButtonGroup();
181:                pauseButton = new JRadioButton(pauseAction, true);
182:                pauseButton.addChangeListener(new ChangeListener() {
183:                    public void stateChanged(ChangeEvent e) {
184:                        if (pauseButton.isSelected()) {
185:                            action = TestAction.PAUSE;
186:                            durationField.setEnabled(true);
187:                        }
188:
189:                    }
190:                });
191:                stopButton = new JRadioButton(stopAction, false);
192:                stopButton.addChangeListener(new ChangeListener() {
193:                    public void stateChanged(ChangeEvent e) {
194:                        if (stopButton.isSelected()) {
195:                            action = TestAction.STOP;
196:                            durationField.setEnabled(false);
197:                        }
198:                    }
199:                });
200:                actionButtons.add(pauseButton);
201:                actionButtons.add(stopButton);
202:                actionPanel.add(new JLabel(actionLabel));
203:                actionPanel.add(pauseButton);
204:                actionPanel.add(stopButton);
205:                add(actionPanel);
206:
207:                // Duration
208:                HorizontalPanel durationPanel = new HorizontalPanel();
209:                durationField = new JTextField(15);
210:                durationField.setText("");
211:                durationField.addFocusListener(new FocusListener() {
212:                    public void focusLost(FocusEvent e) {
213:                        durationString = durationField.getText();
214:                    }
215:
216:                    public void focusGained(FocusEvent e) {
217:                    }
218:                });
219:                durationPanel.add(new JLabel(durationLabel));
220:                durationPanel.add(durationField);
221:                add(durationPanel);
222:            }
223:
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.