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