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


001:        /* Calendar.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Mon Apr 24 17:12:27     2006, Created by tomyeh
010:        }}IS_NOTE
011:
012:        Copyright (C) 2006 Potix Corporation. All Rights Reserved.
013:
014:        {{IS_RIGHT
015:        }}IS_RIGHT
016:         */
017:        package org.zkoss.zul;
018:
019:        import java.util.Date;
020:        import java.util.TimeZone;
021:        import java.text.DateFormat;
022:        import java.text.SimpleDateFormat;
023:        import java.text.ParseException;
024:
025:        import org.zkoss.lang.Objects;
026:        import org.zkoss.util.Dates;
027:        import org.zkoss.util.Locales;
028:        import org.zkoss.util.TimeZones;
029:        import org.zkoss.xml.HTMLs;
030:
031:        import org.zkoss.zk.ui.ext.client.InputableX;
032:        import org.zkoss.zk.ui.WrongValueException;
033:        import org.zkoss.zk.ui.event.Events;
034:
035:        import org.zkoss.zul.impl.XulElement;
036:
037:        /**
038:         * A calendar.
039:         *
040:         * <p>Default {@link #getSclass}: calendar.
041:         *
042:         * @author tomyeh
043:         */
044:        public class Calendar extends XulElement {
045:            private TimeZone _tzone;
046:            private Date _value;
047:            /** The name. */
048:            private String _name;
049:            private boolean _compact;
050:
051:            /** Contructs a calendar whose value is default to today.
052:             */
053:            public Calendar() {
054:                this (null);
055:            }
056:
057:            public Calendar(Date value) {
058:                setSclass("calendar");
059:                _value = value != null ? value : Dates.today();
060:                _compact = "zh".equals(Locales.getCurrent().getLanguage());
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:            /** Returns the value that is assigned to this component, never null.
080:             */
081:            public Date getValue() {
082:                return _value;
083:            }
084:
085:            /** Assigns a value to this component.
086:             * @param value the date to assign. If null, today is assumed.
087:             */
088:            public void setValue(Date value) {
089:                if (value == null)
090:                    value = Dates.today();
091:                if (!value.equals(_value)) {
092:                    _value = value;
093:                    smartUpdate("z.value", getDateFormat().format(_value));
094:                }
095:            }
096:
097:            private final DateFormat getDateFormat() {
098:                final DateFormat df = new SimpleDateFormat("yyyy/MM/dd",
099:                        Locales.getCurrent());
100:                final TimeZone tz = _tzone != null ? _tzone : TimeZones
101:                        .getCurrent();
102:                df.setTimeZone(tz);
103:                return df;
104:            }
105:
106:            /** Returns whether to use a compact layout.
107:             * <p>Default: true if zh_TW or zh_CN; false otherwise.
108:             */
109:            public boolean isCompact() {
110:                return _compact;
111:            }
112:
113:            /** Sets whether to use a compact layout.
114:             */
115:            public void setCompact(boolean compact) {
116:                if (_compact != compact) {
117:                    _compact = compact;
118:                    invalidate();
119:                }
120:            }
121:
122:            /** Returns the name of this component.
123:             * <p>Default: null.
124:             * <p>The name is used only to work with "legacy" Web application that
125:             * handles user's request by servlets.
126:             * It works only with HTTP/HTML-based browsers. It doesn't work
127:             * with other kind of clients.
128:             * <p>Don't use this method if your application is purely based
129:             * on ZK's event-driven model.
130:             * @since 3.0.0
131:             */
132:            public String getName() {
133:                return _name;
134:            }
135:
136:            /** Sets the name of this component.
137:             * <p>The name is used only to work with "legacy" Web application that
138:             * handles user's request by servlets.
139:             * It works only with HTTP/HTML-based browsers. It doesn't work
140:             * with other kind of clients.
141:             * <p>Don't use this method if your application is purely based
142:             * on ZK's event-driven model.
143:             *
144:             * @param name the name of this component.
145:             * @since 3.0.0
146:             */
147:            public void setName(String name) {
148:                if (name != null && name.length() == 0)
149:                    name = null;
150:                if (!Objects.equals(_name, name)) {
151:                    _name = name;
152:                    smartUpdate("z.name", _name);
153:                }
154:            }
155:
156:            //-- super --//
157:            public String getOuterAttrs() {
158:                final StringBuffer sb = new StringBuffer(64).append(super 
159:                        .getOuterAttrs());
160:
161:                appendAsapAttr(sb, Events.ON_CHANGE);
162:
163:                HTMLs.appendAttribute(sb, "z.name", _name);
164:                HTMLs.appendAttribute(sb, "z.value", getDateFormat().format(
165:                        _value));
166:                if (_compact)
167:                    sb.append(" z.compact=\"true\"");
168:                return sb.toString();
169:            }
170:
171:            //-- ComponentCtrl --//
172:            protected Object newExtraCtrl() {
173:                return new ExtraCtrl();
174:            }
175:
176:            /** A utility class to implement {@link #getExtraCtrl}.
177:             * It is used only by component developers.
178:             */
179:            protected class ExtraCtrl extends XulElement.ExtraCtrl implements 
180:                    InputableX {
181:                //-- InputableX --//
182:                public boolean setTextByClient(String value)
183:                        throws WrongValueException {
184:                    try {
185:                        final Date newval = getDateFormat().parse(value);
186:                        if (!Objects.equals(_value, newval)) {
187:                            _value = newval;
188:                            return true;
189:                        }
190:                        return false;
191:                    } catch (ParseException ex) {
192:                        throw new InternalError(value);
193:                    }
194:                }
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.