Source Code Cross Referenced for TestPlanGui.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.Container;
023:        import java.util.Collection;
024:
025:        import javax.swing.JCheckBox;
026:        import javax.swing.JMenu;
027:        import javax.swing.JPanel;
028:        import javax.swing.JPopupMenu;
029:        import javax.swing.JTextArea;
030:
031:        import org.apache.jmeter.config.Arguments;
032:        import org.apache.jmeter.config.gui.ArgumentsPanel;
033:        import org.apache.jmeter.gui.AbstractJMeterGuiComponent;
034:        import org.apache.jmeter.gui.action.ActionNames;
035:        import org.apache.jmeter.gui.util.FileListPanel;
036:        import org.apache.jmeter.gui.util.MenuFactory;
037:        import org.apache.jmeter.gui.util.VerticalPanel;
038:        import org.apache.jmeter.testelement.TestElement;
039:        import org.apache.jmeter.testelement.TestPlan;
040:        import org.apache.jmeter.testelement.property.JMeterProperty;
041:        import org.apache.jmeter.threads.gui.ThreadGroupGui;
042:        import org.apache.jmeter.util.JMeterUtils;
043:
044:        /**
045:         * JMeter GUI component representing the test plan which will be executed when
046:         * the test is run.
047:         * 
048:         */
049:        public class TestPlanGui extends AbstractJMeterGuiComponent {
050:
051:            /**
052:             * A checkbox allowing the user to specify whether or not JMeter should do
053:             * functional testing.
054:             */
055:            private JCheckBox functionalMode;
056:
057:            private JCheckBox serializedMode;
058:
059:            /** A panel allowing the user to define variables. */
060:            private ArgumentsPanel argsPanel;
061:
062:            FileListPanel browseJar = null;
063:
064:            /**
065:             * Create a new TestPlanGui.
066:             */
067:            public TestPlanGui() {
068:                init();
069:            }
070:
071:            /**
072:             * When a user right-clicks on the component in the test tree, or selects
073:             * the edit menu when the component is selected, the component will be asked
074:             * to return a JPopupMenu that provides all the options available to the
075:             * user from this component.
076:             * <p>
077:             * The TestPlan will return a popup menu allowing you to add ThreadGroups,
078:             * Listeners, Configuration Elements, Assertions, PreProcessors,
079:             * PostProcessors, and Timers.
080:             * 
081:             * @return a JPopupMenu appropriate for the component.
082:             */
083:            public JPopupMenu createPopupMenu() {
084:                JPopupMenu pop = new JPopupMenu();
085:                JMenu addMenu = new JMenu(JMeterUtils.getResString("add")); // $NON-NLS-1$
086:                addMenu.add(MenuFactory.makeMenuItem(new ThreadGroupGui()
087:                        .getStaticLabel(), ThreadGroupGui.class.getName(),
088:                        ActionNames.ADD));
089:                addMenu.add(MenuFactory.makeMenu(MenuFactory.CONFIG_ELEMENTS,
090:                        ActionNames.ADD));
091:                addMenu.add(MenuFactory.makeMenu(MenuFactory.TIMERS,
092:                        ActionNames.ADD));
093:                addMenu.add(MenuFactory.makeMenu(MenuFactory.PRE_PROCESSORS,
094:                        ActionNames.ADD));
095:                addMenu.add(MenuFactory.makeMenu(MenuFactory.ASSERTIONS,
096:                        ActionNames.ADD));
097:                addMenu.add(MenuFactory.makeMenu(MenuFactory.POST_PROCESSORS,
098:                        ActionNames.ADD));
099:                addMenu.add(MenuFactory.makeMenu(MenuFactory.LISTENERS,
100:                        ActionNames.ADD));
101:                pop.add(addMenu);
102:                MenuFactory.addPasteResetMenu(pop);
103:                MenuFactory.addFileMenu(pop);
104:                return pop;
105:            }
106:
107:            /* Implements JMeterGUIComponent.createTestElement() */
108:            public TestElement createTestElement() {
109:                TestPlan tp = new TestPlan();
110:                modifyTestElement(tp);
111:                return tp;
112:            }
113:
114:            /* Implements JMeterGUIComponent.modifyTestElement(TestElement) */
115:            public void modifyTestElement(TestElement plan) {
116:                super .configureTestElement(plan);
117:                if (plan instanceof  TestPlan) {
118:                    TestPlan tp = (TestPlan) plan;
119:                    tp.setFunctionalMode(functionalMode.isSelected());
120:                    tp.setSerialized(serializedMode.isSelected());
121:                    tp.setUserDefinedVariables((Arguments) argsPanel
122:                            .createTestElement());
123:                    tp.setTestPlanClasspathArray(browseJar.getFiles());
124:                }
125:            }
126:
127:            public String getLabelResource() {
128:                return "test_plan"; // $NON-NLS-1$
129:            }
130:
131:            /**
132:             * This is the list of menu categories this gui component will be available
133:             * under. This implementation returns null, since the TestPlan appears at
134:             * the top level of the tree and cannot be added elsewhere.
135:             * 
136:             * @return a Collection of Strings, where each element is one of the
137:             *         constants defined in MenuFactory
138:             */
139:            public Collection getMenuCategories() {
140:                return null;
141:            }
142:
143:            /**
144:             * A newly created component can be initialized with the contents of a Test
145:             * Element object by calling this method. The component is responsible for
146:             * querying the Test Element object for the relevant information to display
147:             * in its GUI.
148:             * 
149:             * @param el
150:             *            the TestElement to configure
151:             */
152:            public void configure(TestElement el) {
153:                super .configure(el);
154:                if (el instanceof  TestPlan) {
155:                    TestPlan tp = (TestPlan) el;
156:                    functionalMode.setSelected(tp.isFunctionalMode());
157:                    serializedMode.setSelected(tp.isSerialized());
158:                    final JMeterProperty udv = tp
159:                            .getUserDefinedVariablesAsProperty();
160:                    if (udv != null) {
161:                        argsPanel.configure((Arguments) udv.getObjectValue());
162:                    }
163:                    browseJar.setFiles(tp.getTestPlanClasspathArray());
164:                }
165:            }
166:
167:            /**
168:             * Create a panel allowing the user to define variables for the test.
169:             * 
170:             * @return a panel for user-defined variables
171:             */
172:            private JPanel createVariablePanel() {
173:                argsPanel = new ArgumentsPanel(JMeterUtils
174:                        .getResString("user_defined_variables")); // $NON-NLS-1$
175:
176:                return argsPanel;
177:            }
178:
179:            protected Container createClassPathPanel() {
180:                browseJar = new FileListPanel(JMeterUtils
181:                        .getResString("test_plan_classpath_browse"), ".jar"); // $NON-NLS-1$ $NON-NLS-2$
182:                return browseJar;
183:            }
184:
185:            /**
186:             * Initialize the components and layout of this component.
187:             */
188:            private void init() {
189:                setLayout(new BorderLayout(10, 10));
190:                setBorder(makeBorder());
191:
192:                add(makeTitlePanel(), BorderLayout.NORTH);
193:
194:                add(createVariablePanel(), BorderLayout.CENTER);
195:
196:                VerticalPanel southPanel = new VerticalPanel();
197:                serializedMode = new JCheckBox(JMeterUtils
198:                        .getResString("testplan.serialized")); // $NON-NLS-1$
199:                southPanel.add(serializedMode);
200:                functionalMode = new JCheckBox(JMeterUtils
201:                        .getResString("functional_mode")); // $NON-NLS-1$
202:                southPanel.add(functionalMode);
203:                JTextArea explain = new JTextArea(JMeterUtils
204:                        .getResString("functional_mode_explanation")); // $NON-NLS-1$
205:                explain.setEditable(false);
206:                explain.setBackground(this .getBackground());
207:                southPanel.add(explain);
208:                southPanel.add(createClassPathPanel());
209:
210:                add(southPanel, BorderLayout.SOUTH);
211:            }
212:
213:            public void clearGui() {
214:                super .clearGui();
215:                functionalMode.setSelected(false);
216:                serializedMode.setSelected(false);
217:                argsPanel.clear();
218:                browseJar.clearFiles();
219:            }
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.