Source Code Cross Referenced for Timer.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:        /* Timer.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Mon Sep 26 12:45:22     2005, Created by tomyeh
010:        }}IS_NOTE
011:
012:        Copyright (C) 2005 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:        package org.zkoss.zul;
020:
021:        import org.zkoss.xml.HTMLs;
022:
023:        import org.zkoss.zk.ui.WrongValueException;
024:        import org.zkoss.zk.ui.HtmlBasedComponent;
025:
026:        /**
027:         * Fires one or more {@link org.zkoss.zk.ui.event.Event} after
028:         * a specified delay.
029:         *
030:         * <p>{@link Timer} is a special component that is invisible.
031:         *
032:         * <p>Notice that the timer won't fire any event until it is attached
033:         * to a page.
034:         *
035:         * @author tomyeh
036:         */
037:        public class Timer extends HtmlBasedComponent {
038:            private int _delay;
039:            private boolean _repeats, _running = true;
040:
041:            public Timer() {
042:                super .setVisible(false);
043:            }
044:
045:            public Timer(int delay) {
046:                this ();
047:                _delay = delay;
048:            }
049:
050:            /** Returns the delay, the number of milliseconds between
051:             * successive action events.
052:             * <p>Default: 0 (immediately).
053:             */
054:            public int getDelay() {
055:                return _delay;
056:            }
057:
058:            /** Sets the delay, the number of milliseconds between
059:             * successive action events.
060:             */
061:            public void setDelay(int delay) throws WrongValueException {
062:                if (delay < 0)
063:                    throw new WrongValueException(
064:                            "Negative delay is not allowed: " + delay);
065:                if (delay != _delay) {
066:                    _delay = delay;
067:                    smartUpdate("z.delay", Integer.toString(_delay));
068:                    if (_running)
069:                        smartUpdate("z.init", true); //init
070:                }
071:            }
072:
073:            /** Returns whether the timer shall send Event repeatly.
074:             * <p>Default: false.
075:             */
076:            public boolean isRepeats() {
077:                return _repeats;
078:            }
079:
080:            /** Sets whether the timer shall send Event repeatly.
081:             */
082:            public void setRepeats(boolean repeats) {
083:                if (_repeats != repeats) {
084:                    _repeats = repeats;
085:                    smartUpdate("z.repeats", Boolean.toString(_repeats));
086:                    if (_running)
087:                        smartUpdate("z.init", true); //init
088:                }
089:            }
090:
091:            /** Returns whether this timer is running.
092:             * <p>Default: true.
093:             * @see #stop
094:             * @see #start
095:             */
096:            public boolean isRunning() {
097:                return _running;
098:            }
099:
100:            /** Start or stops the timer.
101:             */
102:            public void setRunning(boolean running) {
103:                if (running)
104:                    start();
105:                else
106:                    stop();
107:            }
108:
109:            /** Stops the timer.
110:             */
111:            public void stop() {
112:                if (_running) {
113:                    _running = false;
114:                    smartUpdate("z.running", false);
115:                }
116:            }
117:
118:            /** Starts the timer.
119:             */
120:            public void start() {
121:                if (!_running) {
122:                    _running = true;
123:                    smartUpdate("z.running", true);
124:                }
125:            }
126:
127:            //-- super --//
128:            public String getOuterAttrs() {
129:                final StringBuffer sb = new StringBuffer(64).append(super 
130:                        .getOuterAttrs());
131:                HTMLs.appendAttribute(sb, "z.delay", _delay);
132:                HTMLs.appendAttribute(sb, "z.repeats", _repeats);
133:                if (!_running)
134:                    sb.append(" z.running=\"false\"");
135:                return sb.toString();
136:            }
137:
138:            //-- Component --//
139:            /** Not allowd. */
140:            public boolean setVisible(boolean visible) {
141:                throw new UnsupportedOperationException(
142:                        "timer is always invisible");
143:            }
144:
145:            /** Not childable. */
146:            public boolean isChildable() {
147:                return false;
148:            }
149:
150:            //-- ComponentCtrl --//
151:            protected Object newExtraCtrl() {
152:                return new ExtraCtrl();
153:            }
154:
155:            /** A utility class to implement {@link #getExtraCtrl}.
156:             * It is used only by component developers.
157:             */
158:            protected class ExtraCtrl extends HtmlBasedComponent.ExtraCtrl
159:                    implements  org.zkoss.zk.ui.ext.client.Timer {
160:                //Timer//
161:                public void onTimer() {
162:                    if (!_repeats)
163:                        stop(); //Bug 1829397
164:                }
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.