Source Code Cross Referenced for Datebox.java in  » Ajax » zk » org » zkoss » mil » 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 » Ajax » zk » org.zkoss.mil 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Datebox.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Jul 5, 2007 11:57:36 AM, Created by henrichen
010:        }}IS_NOTE
011:
012:        Copyright (C) 2007 Potix Corporation. All Rights Reserved.
013:
014:        {{IS_RIGHT
015:        	This program is distributed under GPL Version 2.0 in the hope that
016:        	it will be useful, but WITHOUT ANY WARRANTY.
017:        }}IS_RIGHT
018:         */
019:
020:        package org.zkoss.mil;
021:
022:        import java.util.Date;
023:        import java.util.TimeZone;
024:
025:        import org.zkoss.lang.Objects;
026:        import org.zkoss.util.TimeZones;
027:        import org.zkoss.xml.HTMLs;
028:        import org.zkoss.zk.ui.WrongValueException;
029:        import org.zkoss.zk.ui.ext.client.Inputable;
030:
031:        /**
032:         * Datebox for date, time, and date time entry.
033:         * @author henrichen
034:         *
035:         */
036:        public class Datebox extends Item {
037:            private static final long serialVersionUID = 200707051515L;
038:            private static final int DATE = 1;
039:            private static final int TIME = 2;
040:            private static final int DATE_TIME = 3;
041:
042:            private Date _value = new Date();
043:            private TimeZone _tzone;
044:
045:            public Datebox() {
046:            }
047:
048:            public Datebox(Date value) throws WrongValueException {
049:                setValue(value);
050:            }
051:
052:            public void setValue(Date value) {
053:                if (!Objects.equals(_value, value)) {
054:                    _value = value;
055:                    smartUpdate("dt", "" + (value.getTime() + getTzoneOffset()));
056:                }
057:            }
058:
059:            public Date getValue() {
060:                return _value;
061:            }
062:
063:            /** Returns the time zone that this date box belongs to, or null if
064:             * the default time zone is used.
065:             * <p>The default time zone is determined by {@link TimeZones#getCurrent}.
066:             */
067:            public TimeZone getTimeZone() {
068:                return _tzone;
069:            }
070:
071:            /** Sets the time zone that this date box belongs to, or null if
072:             * the default time zone is used.
073:             * <p>The default time zone is determined by {@link TimeZones#getCurrent}.
074:             */
075:            public void setTimeZone(TimeZone tzone) {
076:                _tzone = tzone;
077:            }
078:
079:            protected int getTzoneOffset() {
080:                final TimeZone tz = _tzone != null ? _tzone : TimeZones
081:                        .getCurrent();
082:                return tz.getRawOffset();
083:            }
084:
085:            protected int getInputMode() {
086:                String mold = getMold();
087:                if ("default".equals(mold)) {
088:                    return DATE;
089:                } else if ("time".equals(mold)) {
090:                    return TIME;
091:                } else if ("date_time".equals(mold)) {
092:                    return DATE_TIME;
093:                }
094:
095:                //default to DATE mode
096:                return DATE;
097:            }
098:
099:            //-- super --//
100:            public String getOuterAttrs() {
101:                final StringBuffer sb = new StringBuffer(64).append(super 
102:                        .getOuterAttrs());
103:                appendAsapAttr(sb, "onChange");
104:                return sb.toString();
105:            }
106:
107:            public String getInnerAttrs() {
108:                final StringBuffer sb = new StringBuffer(64).append(super 
109:                        .getInnerAttrs());
110:                if (_value != null) {
111:                    HTMLs.appendAttribute(sb, "dt", ""
112:                            + (_value.getTime() + getTzoneOffset())); //text
113:                }
114:                HTMLs.appendAttribute(sb, "md", getInputMode()); //InputMode
115:                final TimeZone tz = _tzone != null ? _tzone : TimeZones
116:                        .getCurrent();
117:                HTMLs.appendAttribute(sb, "tz", tz.getID()); //TimeZone
118:                return sb.toString();
119:            }
120:
121:            //-- ComponentCtrl --//
122:            protected Object newExtraCtrl() {
123:                return new ExtraCtrl();
124:            }
125:
126:            /** A utility class to implement {@link #getExtraCtrl}.
127:             * It is used only by component developers.
128:             */
129:            protected class ExtraCtrl implements  Inputable {
130:                //-- Inputable --//
131:                public void setTextByClient(String value)
132:                        throws WrongValueException {
133:                    _value = new Date(Long.parseLong(value) - getTzoneOffset());
134:                }
135:            }
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.