Source Code Cross Referenced for PropertyEditorFactory.java in  » Mail-Clients » pooka » net » suberic » util » gui » propedit » 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 » Mail Clients » pooka » net.suberic.util.gui.propedit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.suberic.util.gui.propedit;
002:
003:        import javax.swing.*;
004:        import net.suberic.util.*;
005:        import java.util.*;
006:        import java.awt.Container;
007:        import java.awt.Component;
008:
009:        /**
010:         * A factory which can be used to create PropertyEditorUI's.
011:         */
012:        public class PropertyEditorFactory {
013:            // the property that defines the different editor classes for the
014:            // registry.
015:            public static String SOURCE_PROPERTY = "PropertyEditor";
016:
017:            // the VariableBundle that holds both the properties and the editor
018:            // definitions.
019:
020:            VariableBundle sourceBundle;
021:
022:            // the propertyType to className mapping
023:            Map typeToClassMap = new HashMap();
024:
025:            /**
026:             * Creates a PropertyEditorFactory using the given VariableBundle as
027:             * a source.
028:             */
029:            public PropertyEditorFactory(VariableBundle bundle) {
030:                sourceBundle = bundle;
031:                createTypeToClassMap();
032:            }
033:
034:            /**
035:             * Creates the typeToClassMap.
036:             */
037:            private void createTypeToClassMap() {
038:
039:                try {
040:                    Class parentClass = Class
041:                            .forName("net.suberic.util.gui.propedit.SwingPropertyEditor");
042:
043:                    Vector propertyTypes = sourceBundle.getPropertyAsVector(
044:                            SOURCE_PROPERTY, "");
045:                    for (int i = 0; i < propertyTypes.size(); i++) {
046:                        String currentType = (String) propertyTypes.get(i);
047:                        String className = sourceBundle.getProperty(
048:                                SOURCE_PROPERTY + "." + currentType + ".class",
049:                                "");
050:                        try {
051:                            Class currentClass = Class.forName(className);
052:                            if (parentClass.isAssignableFrom(currentClass)) {
053:                                typeToClassMap.put(currentType, currentClass);
054:                            }
055:                        } catch (Exception e) {
056:                            System.out
057:                                    .println("error registering class for property type "
058:                                            + currentType + ":  " + e);
059:                        }
060:                    }
061:                } catch (Exception e) {
062:                    System.out
063:                            .println("caught exception initializing PropertyEditorFactory:  "
064:                                    + e);
065:                    e.printStackTrace();
066:                }
067:            }
068:
069:            /**
070:             * Shows an error message.
071:             */
072:            public void showError(Object component, String errorMessage) {
073:                JOptionPane.showMessageDialog((Component) component,
074:                        errorMessage);
075:            }
076:
077:            /**
078:             * Shows an input dialog.
079:             */
080:            public String showInputDialog(SwingPropertyEditor dpe, String query) {
081:                return JOptionPane.showInputDialog(dpe, query);
082:            }
083:
084:            /**
085:             * Creates and displays an editor window.  
086:             */
087:            public void showNewEditorWindow(String title, List properties) {
088:                showNewEditorWindow(title, properties, properties);
089:            }
090:
091:            /**
092:             * Creates and displays an editor window.  
093:             */
094:            public void showNewEditorWindow(String title, List properties,
095:                    List templates) {
096:                showNewEditorWindow(title, properties, templates, null);
097:            }
098:
099:            /**
100:             * Creates and displays an editor window.  
101:             */
102:            public void showNewEditorWindow(String title, List properties,
103:                    List templates, PropertyEditorManager mgr) {
104:                JFrame jf = (JFrame) createEditorWindow(title, properties,
105:                        templates, mgr);
106:                jf.show();
107:            }
108:
109:            /**
110:             * Creates and displays an editor window.  
111:             */
112:            public void showNewEditorWindow(String title,
113:                    PropertyEditorUI editor) {
114:                JFrame jf = new JFrame(title);
115:                jf.getContentPane().add(
116:                        new PropertyEditorPane(editor.getManager(),
117:                                (SwingPropertyEditor) editor, jf));
118:                jf.setSize(200, 200);
119:                jf.pack();
120:                jf.show();
121:            }
122:
123:            /**
124:             * This method returns an EditorWindow (a JFrame in this
125:             * implementation) which has an editor for each property in the
126:             * properties List.  The title string is the title of the 
127:             * JInternalFrame.
128:             */
129:            public Container createEditorWindow(String title, List properties) {
130:                return createEditorWindow(title, properties, properties,
131:                        new PropertyEditorManager(sourceBundle, this ));
132:            }
133:
134:            /**
135:             * This method returns an EditorWindow (a JFrame in this
136:             * implementation) which has an editor for each property in the
137:             * properties List.  The title string is the title of the 
138:             * JFrame.
139:             */
140:            public Container createEditorWindow(String title, List properties,
141:                    List templates) {
142:                return createEditorWindow(title, properties, templates,
143:                        new PropertyEditorManager(sourceBundle, this ));
144:            }
145:
146:            /**
147:             * This method returns an EditorWindow (a JFrame in this
148:             * implementation) which has an editor for each property in the
149:             * properties Vector.  The title string is the title of the 
150:             * JInternalFrame.
151:             */
152:            public Container createEditorWindow(String title, List properties,
153:                    List templates, PropertyEditorManager mgr) {
154:                JFrame jf = new JFrame(title);
155:                jf.getContentPane().add(
156:                        new PropertyEditorPane(mgr, properties, templates, jf));
157:                jf.setSize(200, 200);
158:                jf.pack();
159:                return jf;
160:            }
161:
162:            /**
163:             * Creates an appropriate PropertyEditorUI for the given property and
164:             * editorTemplate, using the given PropertyEditorManager.
165:             */
166:            public PropertyEditorUI createEditor(String property,
167:                    String editorTemplate, PropertyEditorManager mgr) {
168:
169:                return createEditor(property, editorTemplate, mgr, true);
170:            }
171:
172:            /**
173:             * Creates an appropriate PropertyEditorUI for the given property and
174:             * editorTemplate, using the given PropertyEditorManager.
175:             */
176:            public PropertyEditorUI createEditor(String property,
177:                    String editorTemplate, PropertyEditorManager mgr,
178:                    boolean enabled) {
179:                String type = sourceBundle.getProperty(editorTemplate
180:                        + ".propertyType", "");
181:                return createEditor(property, editorTemplate, type, mgr,
182:                        enabled);
183:            }
184:
185:            /**
186:             * Creates an appropriate PropertyEditorUI for the given property and
187:             * editorTemplate, using the given PropertyEditorManager.
188:             */
189:            public PropertyEditorUI createEditor(String property,
190:                    String editorTemplate, String type,
191:                    PropertyEditorManager mgr, boolean enabled) {
192:
193:                //System.err.println("creating editor for property " + property + ", template " + editorTemplate + ", type " + type);
194:
195:                Class editorClass = (Class) typeToClassMap.get(type);
196:                if (editorClass == null) {
197:                    editorClass = (Class) typeToClassMap.get("String");
198:                }
199:
200:                PropertyEditorUI returnValue = null;
201:                try {
202:                    returnValue = (PropertyEditorUI) editorClass.newInstance();
203:                } catch (Exception e) {
204:                    System.err.println("error creating editor for property "
205:                            + property + ":  " + e);
206:                    returnValue = new StringEditorPane();
207:                }
208:                returnValue.configureEditor(property, editorTemplate, mgr,
209:                        enabled);
210:                return returnValue;
211:            }
212:
213:            /**
214:             * Creates an appropriate PropertyEditorUI for the given property and
215:             * editorTemplate, using the given PropertyEditorManager.
216:             */
217:            public PropertyEditorUI createEditor(List properties,
218:                    List editorTemplates, PropertyEditorManager mgr) {
219:                return new CompositeEditorPane(properties, editorTemplates, mgr);
220:            }
221:
222:            /**
223:             * Gets the source bundle for this factory.
224:             */
225:            public VariableBundle getSourceBundle() {
226:                return sourceBundle;
227:            }
228:
229:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.