Source Code Cross Referenced for GUIFactory.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,
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.gui;
020:
021:        import java.util.HashMap;
022:        import java.util.Map;
023:
024:        import javax.swing.ImageIcon;
025:        import javax.swing.JComponent;
026:
027:        import org.apache.jmeter.testbeans.gui.TestBeanGUI;
028:
029:        /**
030:         * Provides a way to register and retrieve GUI classes and icons.
031:         * 
032:         * @author Oliver Rossmueller
033:         * @version $Revision: 493779 $
034:         */
035:        public final class GUIFactory {
036:            /** A Map from String to JComponent of registered GUI classes. */
037:            private static final Map GUI_MAP = new HashMap();
038:
039:            /** A Map from String to ImageIcon of registered icons. */
040:            private static final Map ICON_MAP = new HashMap();
041:
042:            /** A Map from String to ImageIcon of registered icons. */
043:            private static final Map DISABLED_ICON_MAP = new HashMap();
044:
045:            /**
046:             * Prevent instantiation since this is a static utility class.
047:             */
048:            private GUIFactory() {
049:            }
050:
051:            /**
052:             * Get an icon which has previously been registered for this class object.
053:             * 
054:             * @param elementClass
055:             *            the class object which we want to get an icon for
056:             * 
057:             * @return the associated icon, or null if this class or its superclass has
058:             *         not been registered
059:             */
060:            public static ImageIcon getIcon(Class elementClass) {
061:                return getIcon(elementClass, true);
062:
063:            }
064:
065:            /**
066:             * Get icon/disabledicon which has previously been registered for this class
067:             * object.
068:             * 
069:             * @param elementClass
070:             *            the class object which we want to get an icon for
071:             * @param enabled -
072:             *            is icon enabled
073:             * 
074:             * @return the associated icon, or null if this class or its superclass has
075:             *         not been registered
076:             */
077:            public static ImageIcon getIcon(Class elementClass, boolean enabled) {
078:                String key = elementClass.getName();
079:                ImageIcon icon = (ImageIcon) (enabled ? ICON_MAP.get(key)
080:                        : DISABLED_ICON_MAP.get(key));
081:
082:                if (icon != null) {
083:                    return icon;
084:                }
085:
086:                if (elementClass.getSuperclass() != null) {
087:                    return getIcon(elementClass.getSuperclass(), enabled);
088:                }
089:
090:                return null;
091:            }
092:
093:            /**
094:             * Get a component instance which has previously been registered for this
095:             * class object.
096:             * 
097:             * @param elementClass
098:             *            the class object which we want to get an instance of
099:             * 
100:             * @return an instance of the class, or null if this class or its superclass
101:             *         has not been registered
102:             */
103:            public static JComponent getGUI(Class elementClass) {
104:                // TODO: This method doesn't appear to be used.
105:                String key = elementClass.getName();
106:                JComponent gui = (JComponent) GUI_MAP.get(key);
107:
108:                if (gui != null) {
109:                    return gui;
110:                }
111:
112:                if (elementClass.getSuperclass() != null) {
113:                    return getGUI(elementClass.getSuperclass());
114:                }
115:
116:                return null;
117:            }
118:
119:            /**
120:             * Register an icon so that it can later be retrieved via
121:             * {@link #getIcon(Class)}. The key should match the fully-qualified class
122:             * name for the class used as the parameter when retrieving the icon.
123:             * 
124:             * @param key
125:             *            the name which can be used to retrieve this icon later
126:             * @param icon
127:             *            the icon to store
128:             */
129:            public static void registerIcon(String key, ImageIcon icon) {
130:                ICON_MAP.put(key, icon);
131:            }
132:
133:            /**
134:             * Register an icon so that it can later be retrieved via
135:             * {@link #getIcon(Class)}. The key should match the fully-qualified class
136:             * name for the class used as the parameter when retrieving the icon.
137:             * 
138:             * @param key
139:             *            the name which can be used to retrieve this icon later
140:             * @param icon
141:             *            the icon to store
142:             */
143:            public static void registerDisabledIcon(String key, ImageIcon icon) {
144:                DISABLED_ICON_MAP.put(key, icon);
145:            }
146:
147:            /**
148:             * Register a GUI class so that it can later be retrieved via
149:             * {@link #getGUI(Class)}. The key should match the fully-qualified class
150:             * name for the class used as the parameter when retrieving the GUI.
151:             * 
152:             * @param key
153:             *            the name which can be used to retrieve this GUI later
154:             * @param guiClass
155:             *            the class object for the GUI component
156:             * @param testClass
157:             *            the class of the objects edited by this GUI
158:             * 
159:             * @throws InstantiationException
160:             *             if an instance of the GUI class can not be instantiated
161:             * @throws IllegalAccessException
162:             *             if access rights do not permit an instance of the GUI class
163:             *             to be created
164:             */
165:            public static void registerGUI(String key, Class guiClass,
166:                    Class testClass) throws InstantiationException,
167:                    IllegalAccessException {
168:                // TODO: This method doesn't appear to be used.
169:                JMeterGUIComponent gui;
170:
171:                if (guiClass == TestBeanGUI.class) {
172:                    gui = new TestBeanGUI(testClass);
173:                } else {
174:                    gui = (JMeterGUIComponent) guiClass.newInstance();
175:                }
176:                GUI_MAP.put(key, gui);
177:            }
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.