Source Code Cross Referenced for SavePropertyDialog.java in  » Testing » jakarta-jmeter » org » apache » jmeter » 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.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, WITHOUT
013:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
014:         * License for the specific language governing permissions and limitations
015:         * under the License.
016:         *  
017:         */
018:
019:        /*
020:         * Created on Sep 15, 2004
021:         */
022:        package org.apache.jmeter.gui;
023:
024:        import java.awt.BorderLayout;
025:        import java.awt.Frame;
026:        import java.awt.GridLayout;
027:        import java.awt.event.ActionEvent;
028:        import java.awt.event.ActionListener;
029:        import java.lang.reflect.Method;
030:        import java.util.HashMap;
031:        import java.util.Map;
032:
033:        import javax.swing.JButton;
034:        import javax.swing.JCheckBox;
035:        import javax.swing.JDialog;
036:        import javax.swing.JPanel;
037:
038:        import org.apache.jmeter.samplers.SampleSaveConfiguration;
039:        import org.apache.jmeter.util.JMeterUtils;
040:        import org.apache.jorphan.logging.LoggingManager;
041:        import org.apache.jorphan.reflect.Functor;
042:        import org.apache.log.Logger;
043:
044:        /**
045:         * Generates Configure pop-up dialogue for Listeners from all methods in SampleSaveConfiguration
046:         * with the signature "boolean saveXXX()". 
047:         * There must be a corresponding "void setXXX(boolean)" method, and a property save_XXX which is
048:         * used to name the field on the dialogue.
049:         * 
050:         * @author mstover
051:         */
052:        public class SavePropertyDialog extends JDialog implements 
053:                ActionListener {
054:
055:            private static final Logger log = LoggingManager
056:                    .getLoggerForClass();
057:
058:            private static Map functors = new HashMap();
059:
060:            private static final long serialVersionUID = 1;
061:
062:            private static final String NAME_SAVE_PFX = "save"; // $NON-NLS-1$ i.e. boolean saveXXX()
063:            private static final String NAME_SET_PREFIX = "set"; // $NON-NLS-1$ i.e. void setXXX(boolean)
064:            private static final String RESOURCE_PREFIX = "save_"; // $NON-NLS-1$ e.g. save_XXX property
065:            private static final int NAME_SAVE_PFX_LEN = NAME_SAVE_PFX.length();
066:
067:            private SampleSaveConfiguration saveConfig;
068:
069:            public SavePropertyDialog() {
070:                log.warn("Constructor only intended for use in testing"); // $NON-NLS-1$
071:            }
072:
073:            /**
074:             * @param owner
075:             * @param title
076:             * @param modal
077:             * @throws java.awt.HeadlessException
078:             */
079:            public SavePropertyDialog(Frame owner, String title, boolean modal,
080:                    SampleSaveConfiguration s)
081:            // throws HeadlessException
082:            {
083:                super (owner, title, modal);
084:                saveConfig = s;
085:                log.debug("SampleSaveConfiguration = " + saveConfig);// $NON-NLS-1$
086:                dialogInit();
087:            }
088:
089:            private int countMethods(Method[] m) {
090:                int count = 0;
091:                for (int i = 0; i < m.length; i++) {
092:                    if (m[i].getName().startsWith(NAME_SAVE_PFX)) {
093:                        count++;
094:                    }
095:                }
096:                return count;
097:            }
098:
099:            /*
100:             * (non-Javadoc)
101:             * 
102:             * @see javax.swing.JDialog#dialogInit()
103:             */
104:            protected void dialogInit() {
105:                if (saveConfig != null) {
106:                    super .dialogInit();
107:                    this .getContentPane().setLayout(new BorderLayout());
108:                    Method[] methods = SampleSaveConfiguration.class
109:                            .getMethods();
110:                    int x = (countMethods(methods) / 3) + 1;
111:                    log.debug("grid panel is " + 3 + " by " + x);
112:                    JPanel checkPanel = new JPanel(new GridLayout(x, 3));
113:                    for (int i = 0; i < methods.length; i++) {
114:                        String name = methods[i].getName();
115:                        if (name.startsWith(NAME_SAVE_PFX)
116:                                && methods[i].getParameterTypes().length == 0) {
117:                            try {
118:                                name = name.substring(NAME_SAVE_PFX_LEN);
119:                                JCheckBox check = new JCheckBox(JMeterUtils
120:                                        .getResString(RESOURCE_PREFIX + name)// $NON-NLS-1$
121:                                        , ((Boolean) methods[i].invoke(
122:                                                saveConfig, new Object[0]))
123:                                                .booleanValue());
124:                                checkPanel.add(check, BorderLayout.NORTH);
125:                                check.addActionListener(this );
126:                                String actionCommand = NAME_SET_PREFIX + name; // $NON-NLS-1$
127:                                check.setActionCommand(actionCommand);
128:                                if (!functors.containsKey(actionCommand)) {
129:                                    functors.put(actionCommand, new Functor(
130:                                            actionCommand));
131:                                }
132:                            } catch (Exception e) {
133:                                log.warn("Problem creating save config dialog",
134:                                        e);
135:                            }
136:                        }
137:                    }
138:                    getContentPane().add(checkPanel, BorderLayout.NORTH);
139:                    JButton exit = new JButton(JMeterUtils.getResString("done")); // $NON-NLS-1$
140:                    this .getContentPane().add(exit, BorderLayout.SOUTH);
141:                    exit.addActionListener(new ActionListener() {
142:                        public void actionPerformed(ActionEvent e) {
143:                            dispose();
144:                        }
145:                    });
146:                }
147:            }
148:
149:            /*
150:             * (non-Javadoc)
151:             * 
152:             * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
153:             */
154:            public void actionPerformed(ActionEvent e) {
155:                String action = e.getActionCommand();
156:                Functor f = (Functor) functors.get(action);
157:                f.invoke(saveConfig, new Object[] { Boolean
158:                        .valueOf(((JCheckBox) e.getSource()).isSelected()) });
159:            }
160:
161:            /**
162:             * @return Returns the saveConfig.
163:             */
164:            public SampleSaveConfiguration getSaveConfig() {
165:                return saveConfig;
166:            }
167:
168:            /**
169:             * @param saveConfig
170:             *            The saveConfig to set.
171:             */
172:            public void setSaveConfig(SampleSaveConfiguration saveConfig) {
173:                this.saveConfig = saveConfig;
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.