Source Code Cross Referenced for DateEditor.java in  » Workflow-Engines » osbl-1_0 » org » conform » wings » editor » 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 » Workflow Engines » osbl 1_0 » org.conform.wings.editor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.conform.wings.editor;
002:
003:        import org.conform.*;
004:        import org.conform.format.Format;
005:        import org.conform.format.FormatFactory;
006:        import org.wings.*;
007:        import org.wings.session.SessionManager;
008:        import org.wings.text.SDateFormatter;
009:        import org.wingx.XCalendar;
010:
011:        import java.text.ParseException;
012:        import java.util.Arrays;
013:
014:        public class DateEditor extends FormattedTextEditor {
015:            public SComponent createComponent(final PropertyMeta propertyMeta) {
016:                FormatDateFormatter dateFormatter = new FormatDateFormatter(
017:                        propertyMeta.getFormat());
018:                XCalendar calendar = new XCalendar(null, dateFormatter);
019:
020:                // explicitly set the formatter, so that the formatter factory is not querying
021:                // the text property in order to decide, if the NullFormatter would be apropriate
022:                calendar.getFormattedTextField().setFormatter(dateFormatter);
023:
024:                DocumentPropertyAdapter documentPropertyAdapter = new DocumentPropertyAdapter(
025:                        propertyMeta);
026:                Format format = propertyMeta.getFormat();
027:                documentPropertyAdapter.setFormat(format);
028:                calendar.getFormattedTextField().setDocument(
029:                        documentPropertyAdapter);
030:                calendar.getFormattedTextField().setToolTipText(
031:                        format.getHelp());
032:                calendar.setPreferredSize(SDimension.FULLWIDTH);
033:
034:                configureComponent(propertyMeta, calendar, false);
035:                return calendar;
036:            }
037:
038:            public void configureComponent(PropertyMeta propertyMeta,
039:                    SComponent component, boolean erroneous) {
040:                XCalendar calendar = (XCalendar) component;
041:                calendar.setEnabled(propertyMeta.isWritable());
042:                calendar.setVisible(propertyMeta.isReadable());
043:                DefaultEditorStyles.applyEditorAlignment(propertyMeta,
044:                        component);
045:                DefaultEditorStyles.applyEditorState(propertyMeta, calendar
046:                        .getFormattedTextField(), erroneous);
047:            }
048:
049:            public void setPropertyData(SComponent component,
050:                    PropertyData propertyData) {
051:                XCalendar calendar = (XCalendar) component;
052:                BeanData beanData = propertyData.getBeanData();
053:                if (beanData != null) {
054:                    beanData.addPropertyChangeListener(propertyData
055:                            .getPropertyMeta().getName(),
056:                            new ComponentInvalidator(component));
057:                    beanData.addPropertyChangeListener(propertyData
058:                            .getPropertyMeta().getName(),
059:                            new ComponentInvalidator(calendar
060:                                    .getFormattedTextField()));
061:                }
062:                ((DocumentPropertyAdapter) calendar.getFormattedTextField()
063:                        .getDocument()).setPropertyData(propertyData);
064:            }
065:
066:            public PropertyData getPropertyData(SComponent component) {
067:                XCalendar calendar = (XCalendar) component;
068:                STextComponent textComponent = calendar.getFormattedTextField();
069:                return ((DocumentPropertyAdapter) textComponent.getDocument())
070:                        .getPropertyData();
071:            }
072:
073:            private static class FormatDateFormatter extends SDateFormatter {
074:                private final Format format;
075:
076:                public FormatDateFormatter(Format format) {
077:                    this .format = format;
078:                }
079:
080:                public Object stringToValue(String text) throws ParseException {
081:                    setLocale();
082:                    Object value = text != null ? format.parse(text) : null;
083:                    unsetLocale();
084:                    return value;
085:                }
086:
087:                public String valueToString(Object value) throws ParseException {
088:                    setLocale();
089:                    String text = value != null ? format.format(value) : null;
090:                    unsetLocale();
091:                    return text;
092:                }
093:
094:                private boolean set;
095:
096:                private FormatFactory setLocale() {
097:                    FormatFactory instance = FormatFactory.getInstance();
098:                    if (instance.getLocale() == null) {
099:                        instance.setLocale(SessionManager.getSession()
100:                                .getLocale());
101:                        set = true;
102:                    } else
103:                        set = false;
104:                    return instance;
105:                }
106:
107:                private void unsetLocale() {
108:                    if (set)
109:                        FormatFactory.getInstance().setLocale(null);
110:                }
111:            }
112:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.