Source Code Cross Referenced for DynamicBeanInfo.java in  » Swing-Library » abeille-forms-designer » com » jeta » forms » gui » beans » 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 » Swing Library » abeille forms designer » com.jeta.forms.gui.beans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2004 JETA Software, Inc.  All rights reserved.
003:         * 
004:         * Redistribution and use in source and binary forms, with or without modification, 
005:         * are permitted provided that the following conditions are met:
006:         *
007:         *  o Redistributions of source code must retain the above copyright notice, 
008:         *    this list of conditions and the following disclaimer.
009:         *
010:         *  o Redistributions in binary form must reproduce the above copyright notice, 
011:         *    this list of conditions and the following disclaimer in the documentation 
012:         *    and/or other materials provided with the distribution.
013:         *
014:         *  o Neither the name of JETA Software nor the names of its contributors may 
015:         *    be used to endorse or promote products derived from this software without 
016:         *    specific prior written permission.
017:         *
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
020:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
021:         * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
022:         * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
023:         * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
024:         * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
025:         * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
026:         * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
027:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028:         */
029:
030:        package com.jeta.forms.gui.beans;
031:
032:        import java.awt.Image;
033:        import java.beans.BeanDescriptor;
034:        import java.beans.BeanInfo;
035:        import java.beans.IntrospectionException;
036:        import java.beans.MethodDescriptor;
037:        import java.beans.PropertyDescriptor;
038:        import java.util.Collection;
039:        import java.util.Iterator;
040:        import java.util.TreeMap;
041:
042:        import com.jeta.forms.gui.common.FormUtils;
043:        import com.jeta.forms.store.properties.JETAProperty;
044:
045:        /**
046:         * A <code>DynamicBeanInfo</code> is a BeanInfo for a Java Bean that also has
047:         * the ability to dynamically add and remove PropertyDescriptors for that bean.
048:         * 
049:         * @author Jeff Tassin
050:         */
051:        public class DynamicBeanInfo {
052:            /**
053:             * The actual BeanInfo for the Java Bean.
054:             */
055:            private BeanInfo m_delegate;
056:
057:            /**
058:             * An ordered set of JETAPropertyDescriptor objects m_props<String,PropertyDescriptor>
059:             * where String is the property name.
060:             */
061:            private TreeMap m_props = new TreeMap();
062:
063:            /**
064:             * Creates a <code>DynamicBeanInfo</code> instance with the specified
065:             * BeanInfo delegate.
066:             * 
067:             * @param delegate
068:             *            the actual BeanInfo for the associated Java Bean class.
069:             */
070:            public DynamicBeanInfo(BeanInfo delegate)
071:                    throws IntrospectionException, IllegalAccessException {
072:                this (delegate, null);
073:            }
074:
075:            /**
076:             * Creates a <code>DynamicBeanInfo</code> instance with the specified
077:             * BeanInfo delegate and adds a set of custom properties for the associated
078:             * Java Bean class.
079:             * 
080:             * @param delegate
081:             *            the default BeanInfo for the bean.
082:             * @param customProps
083:             *            a collection of JETAProperty objects that are in addition to
084:             *            the default properties for the bean.
085:             */
086:            public DynamicBeanInfo(BeanInfo delegate, Collection customProps)
087:                    throws IntrospectionException, IllegalAccessException {
088:                m_delegate = delegate;
089:
090:                PropertyDescriptor[] pds = delegate.getPropertyDescriptors();
091:                for (int index = 0; index < pds.length; index++) {
092:                    StandardPropertyDescriptor std_pds = new StandardPropertyDescriptor(
093:                            pds[index]);
094:                    m_props.put(std_pds.getName(), std_pds);
095:                }
096:
097:                if (customProps != null) {
098:                    Iterator iter = customProps.iterator();
099:                    while (iter.hasNext()) {
100:                        JETAProperty prop = (JETAProperty) iter.next();
101:                        FormUtils.safeAssert(prop.getName() != null);
102:                        m_props.put(prop.getName(),
103:                                new DynamicPropertyDescriptor(prop.getName(),
104:                                        prop.getClass(), prop.isPreferred(),
105:                                        prop.isTransient()));
106:                    }
107:                }
108:                /** this is not used in the designer */
109:                removePropertyDescriptor("debugGraphicsOptions");
110:            }
111:
112:            /**
113:             * BeanInfo implementation. Just forward the call to the delegate.
114:             */
115:            public int getDefaultPropertyIndex() {
116:                return m_delegate.getDefaultPropertyIndex();
117:            }
118:
119:            /**
120:             * BeanInfo implementation. Just forward the call to the delegate.
121:             */
122:            public Image getIcon(int i) {
123:                return m_delegate.getIcon(i);
124:            }
125:
126:            /**
127:             * BeanInfo implementation. Just forward the call to the delegate.
128:             */
129:            public BeanDescriptor getBeanDescriptor() {
130:                return m_delegate.getBeanDescriptor();
131:            }
132:
133:            /**
134:             * BeanInfo implementation. Just forward the call to the delegate.
135:             */
136:            public BeanInfo[] getAdditionalBeanInfo() {
137:                return m_delegate.getAdditionalBeanInfo();
138:            }
139:
140:            /**
141:             * BeanInfo implementation. Just forward the call to the delegate.
142:             */
143:            public MethodDescriptor[] getMethodDescriptors() {
144:                return m_delegate.getMethodDescriptors();
145:            }
146:
147:            /**
148:             * Return the property descriptor with the given name. Null is returned if
149:             * the descriptor is not found.
150:             * 
151:             * @return a the property descriptor with the given name.
152:             */
153:            public JETAPropertyDescriptor getPropertyDescriptor(String propName) {
154:                return (JETAPropertyDescriptor) m_props.get(propName);
155:            }
156:
157:            /**
158:             * Returns the property descriptors for the Java Bean class associated with
159:             * this bean information.
160:             * 
161:             * @return a collection of JETAPropertyDescriptor objects
162:             */
163:            public Collection getPropertyDescriptors() {
164:                return m_props.values();
165:            }
166:
167:            /**
168:             * Registers a property descriptor for this info object. This allows us to
169:             * add properties dynamically.
170:             * 
171:             * @param prop
172:             *            the property descriptor to register with this bean
173:             *            information.
174:             */
175:            void register(JETAPropertyDescriptor prop) {
176:                if (prop != null) {
177:                    m_props.put(prop.getName(), prop);
178:                }
179:            }
180:
181:            /**
182:             * Removes a property descriptor from this info object. This allows us to
183:             * remove properties that are either deprecated or irrelevent for the
184:             * designer.
185:             * 
186:             * @param propName
187:             *            the name of the property descriptor to remove.
188:             */
189:            void removePropertyDescriptor(String propName) {
190:                m_props.remove(propName);
191:            }
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.