Source Code Cross Referenced for BaseBeanInfo.java in  » Swing-Library » l2fprod-common » com » l2fprod » common » 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 » l2fprod common » com.l2fprod.common.beans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * L2FProd.com Common Components 7.3 License.
003:         *
004:         * Copyright 2005-2007 L2FProd.com
005:         *
006:         * Licensed under the Apache License, Version 2.0 (the "License");
007:         * you may not use this file except in compliance with the License.
008:         * You may obtain a copy of the License at
009:         *
010:         *     http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS,
014:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License.
017:         */package com.l2fprod.common.beans;
018:
019:        import com.l2fprod.common.util.ResourceManager;
020:
021:        import java.awt.Image;
022:        import java.beans.BeanDescriptor;
023:        import java.beans.IntrospectionException;
024:        import java.beans.PropertyDescriptor;
025:        import java.beans.SimpleBeanInfo;
026:        import java.util.ArrayList;
027:        import java.util.Iterator;
028:        import java.util.List;
029:        import java.util.MissingResourceException;
030:
031:        /**
032:         * A convenient class to build beaninfos by adding and removing
033:         * properties. <br>
034:         */
035:        public class BaseBeanInfo extends SimpleBeanInfo {
036:
037:            private Class type;
038:
039:            private BeanDescriptor beanDescriptor;
040:
041:            private List properties = new ArrayList(0);
042:
043:            public BaseBeanInfo(Class type) {
044:                this .type = type;
045:            }
046:
047:            public final Class getType() {
048:                return type;
049:            }
050:
051:            public ResourceManager getResources() {
052:                return ResourceManager.get(getType());
053:            }
054:
055:            public BeanDescriptor getBeanDescriptor() {
056:                if (beanDescriptor == null) {
057:                    beanDescriptor = new DefaultBeanDescriptor(this );
058:                }
059:                return beanDescriptor;
060:            }
061:
062:            public PropertyDescriptor[] getPropertyDescriptors() {
063:                return (PropertyDescriptor[]) properties
064:                        .toArray(new PropertyDescriptor[0]);
065:            }
066:
067:            public int getPropertyDescriptorCount() {
068:                return properties.size();
069:            }
070:
071:            public PropertyDescriptor getPropertyDescriptor(int index) {
072:                return (PropertyDescriptor) properties.get(index);
073:            }
074:
075:            protected PropertyDescriptor addPropertyDescriptor(
076:                    PropertyDescriptor property) {
077:                properties.add(property);
078:                return property;
079:            }
080:
081:            public ExtendedPropertyDescriptor addProperty(String propertyName) {
082:                ExtendedPropertyDescriptor descriptor;
083:                try {
084:                    if (propertyName == null
085:                            || propertyName.trim().length() == 0) {
086:                        throw new IntrospectionException("bad property name");
087:                    }
088:
089:                    descriptor = ExtendedPropertyDescriptor
090:                            .newPropertyDescriptor(propertyName, getType());
091:
092:                    try {
093:                        descriptor.setDisplayName(getResources().getString(
094:                                propertyName));
095:                    } catch (MissingResourceException e) {
096:                        // ignore, the resource may not be provided
097:                    }
098:                    try {
099:                        descriptor.setShortDescription(getResources()
100:                                .getString(propertyName + ".shortDescription"));
101:                    } catch (MissingResourceException e) {
102:                        // ignore, the resource may not be provided
103:                    }
104:                    addPropertyDescriptor(descriptor);
105:                    return descriptor;
106:                } catch (IntrospectionException e) {
107:                    throw new RuntimeException(e);
108:                }
109:            }
110:
111:            /**
112:             * Removes the first occurrence of the property named <code>propertyName</code>
113:             * @param propertyName
114:             * @return the removed PropertyDescriptor or null if not found.
115:             */
116:            public PropertyDescriptor removeProperty(String propertyName) {
117:                if (propertyName == null) {
118:                    throw new IllegalArgumentException(
119:                            "Property name can not be null");
120:                }
121:                for (Iterator iter = properties.iterator(); iter.hasNext();) {
122:                    PropertyDescriptor property = (PropertyDescriptor) iter
123:                            .next();
124:                    if (propertyName.equals(property.getName())) {
125:                        // remove the property from the list
126:                        iter.remove();
127:                        return property;
128:                    }
129:                }
130:                return null;
131:            }
132:
133:            /**
134:             * Get the icon for displaying this bean.
135:             * 
136:             * @param kind Kind of icon.
137:             * @return Image for bean, or null if none.
138:             */
139:            public Image getIcon(int kind) {
140:                return null;
141:            }
142:
143:            /**
144:             * Return a text describing the object.
145:             * 
146:             * @param value an <code>Object</code> value
147:             * @return a text describing the object.
148:             */
149:            public String getText(Object value) {
150:                return value.toString();
151:            }
152:
153:            /**
154:             * Return a text describing briefly the object. The text will be used
155:             * whereever a explanation is needed to give to the user
156:             * 
157:             * @param value an <code>Object</code> value
158:             * @return a <code>String</code> value
159:             */
160:            public String getDescription(Object value) {
161:                return getText(value);
162:            }
163:
164:            /**
165:             * Return a text describing the object. The text will be displayed in a
166:             * tooltip.
167:             * 
168:             * @param value an <code>Object</code> value
169:             * @return a <code>String</code> value
170:             */
171:            public String getToolTipText(Object value) {
172:                return getText(value);
173:            }
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.