Source Code Cross Referenced for RunTimeGui.java in  » Testing » jakarta-jmeter » org » apache » jmeter » control » 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.control.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.control.gui;
020:
021:        import java.awt.BorderLayout;
022:        import java.awt.event.ActionEvent;
023:        import java.awt.event.ActionListener;
024:
025:        import javax.swing.Box;
026:        import javax.swing.JLabel;
027:        import javax.swing.JPanel;
028:        import javax.swing.JTextField;
029:
030:        import org.apache.jmeter.control.RunTime;
031:        import org.apache.jmeter.testelement.TestElement;
032:        import org.apache.jmeter.util.JMeterUtils;
033:
034:        /**
035:         * The user interface for a controller which specifies that its subcomponents
036:         * should be executed some number of seconds in a loop. This component can be
037:         * used standalone or embedded into some other component.
038:         * 
039:         */
040:
041:        public class RunTimeGui extends AbstractControllerGui implements 
042:                ActionListener {
043:            /**
044:             * A field allowing the user to specify the number of seconds the controller
045:             * should loop.
046:             */
047:            private JTextField seconds;
048:
049:            /**
050:             * Boolean indicating whether or not this component should display its name.
051:             * If true, this is a standalone component. If false, this component is
052:             * intended to be used as a subpanel for another component.
053:             */
054:            private boolean displayName = true;
055:
056:            /**
057:             * Create a new LoopControlPanel as a standalone component.
058:             */
059:            public RunTimeGui() {
060:                this (true);
061:            }
062:
063:            /**
064:             * Create a new LoopControlPanel as either a standalone or an embedded
065:             * component.
066:             * 
067:             * @param displayName
068:             *            indicates whether or not this component should display its
069:             *            name. If true, this is a standalone component. If false, this
070:             *            component is intended to be used as a subpanel for another
071:             *            component.
072:             */
073:            public RunTimeGui(boolean displayName) {
074:                this .displayName = displayName;
075:                init();
076:                setState(1);
077:            }
078:
079:            /**
080:             * A newly created component can be initialized with the contents of a Test
081:             * Element object by calling this method. The component is responsible for
082:             * querying the Test Element object for the relevant information to display
083:             * in its GUI.
084:             * 
085:             * @param element
086:             *            the TestElement to configure
087:             */
088:            public void configure(TestElement element) {
089:                super .configure(element);
090:                if (element instanceof  RunTime) {
091:                    setState(((RunTime) element).getRuntimeString());
092:                } else {
093:                    setState(1);
094:                }
095:            }
096:
097:            /* Implements JMeterGUIComponent.createTestElement() */
098:            public TestElement createTestElement() {
099:                RunTime lc = new RunTime();
100:                modifyTestElement(lc);
101:                return lc;
102:            }
103:
104:            /* Implements JMeterGUIComponent.modifyTestElement(TestElement) */
105:            public void modifyTestElement(TestElement lc) {
106:                configureTestElement(lc);
107:                if (lc instanceof  RunTime) {
108:                    if (seconds.getText().length() > 0) {
109:                        ((RunTime) lc).setRuntime(seconds.getText());
110:                    } else {
111:                        ((RunTime) lc).setRuntime(0);
112:                    }
113:                }
114:            }
115:
116:            /**
117:             * Implements JMeterGUIComponent.clearGui
118:             */
119:            public void clearGui() {
120:                super .clearGui();
121:
122:                seconds.setText("1"); // $NON-NLS-1$
123:            }
124:
125:            /**
126:             * Invoked when an action occurs. This implementation assumes that the
127:             * target component is the infinite seconds checkbox.
128:             * 
129:             * @param event
130:             *            the event that has occurred
131:             */
132:            public void actionPerformed(ActionEvent event) {
133:                seconds.setEnabled(true);
134:            }
135:
136:            public String getLabelResource() {
137:                return "runtime_controller_title"; // $NON-NLS-1$
138:            }
139:
140:            /**
141:             * Initialize the GUI components and layout for this component.
142:             */
143:            private void init() {
144:                // The Loop Controller panel can be displayed standalone or inside
145:                // another panel. For standalone, we want to display the TITLE, NAME,
146:                // etc. (everything). However, if we want to display it within another
147:                // panel, we just display the Loop Count fields (not the TITLE and
148:                // NAME).
149:
150:                // Standalone
151:                if (displayName) {
152:                    setLayout(new BorderLayout(0, 5));
153:                    setBorder(makeBorder());
154:                    add(makeTitlePanel(), BorderLayout.NORTH);
155:
156:                    JPanel mainPanel = new JPanel(new BorderLayout());
157:                    mainPanel.add(createLoopCountPanel(), BorderLayout.NORTH);
158:                    add(mainPanel, BorderLayout.CENTER);
159:                } else {
160:                    // Embedded
161:                    setLayout(new BorderLayout());
162:                    add(createLoopCountPanel(), BorderLayout.NORTH);
163:                }
164:            }
165:
166:            /**
167:             * Create a GUI panel containing the components related to the number of
168:             * seconds which should be executed.
169:             * 
170:             * @return a GUI panel containing the loop count components
171:             */
172:            private JPanel createLoopCountPanel() {
173:                JPanel loopPanel = new JPanel(new BorderLayout(5, 0));
174:
175:                // SECONDS LABEL
176:                JLabel secondsLabel = new JLabel(JMeterUtils
177:                        .getResString("runtime_seconds")); // $NON-NLS-1$
178:                loopPanel.add(secondsLabel, BorderLayout.WEST);
179:
180:                JPanel loopSubPanel = new JPanel(new BorderLayout(5, 0));
181:
182:                // TEXT FIELD
183:                seconds = new JTextField("1", 5); // $NON-NLS-1$
184:                secondsLabel.setLabelFor(seconds);
185:                loopSubPanel.add(seconds, BorderLayout.CENTER);
186:
187:                loopPanel.add(loopSubPanel, BorderLayout.CENTER);
188:
189:                loopPanel
190:                        .add(Box.createHorizontalStrut(secondsLabel
191:                                .getPreferredSize().width
192:                                + seconds.getPreferredSize().width),
193:                                BorderLayout.NORTH);
194:
195:                return loopPanel;
196:            }
197:
198:            /**
199:             * Set the number of seconds which should be reflected in the GUI. The
200:             * secsCount parameter should contain the String representation of an
201:             * integer. This integer will be treated as the number of seconds. If this
202:             * integer is less than 0, the number of seconds will be assumed to be
203:             * infinity.
204:             * 
205:             * @param secsCount
206:             *            the String representation of the number of seconds
207:             */
208:            private void setState(String secsCount) {
209:                seconds.setText(secsCount);
210:                seconds.setEnabled(true);
211:            }
212:
213:            /**
214:             * Set the number of seconds which should be reflected in the GUI. If the
215:             * secsCount is less than 0, the number of seconds will be assumed to be
216:             * infinity.
217:             * 
218:             * @param secsCount
219:             *            the number of seconds
220:             */
221:            private void setState(long secsCount) {
222:                seconds.setEnabled(true);
223:                seconds.setText("" + secsCount); // $NON-NLS-1$
224:            }
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.