Source Code Cross Referenced for Slider.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:        /* Slider.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Thu Sep 29 20:16:03     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.lang.Objects;
022:        import org.zkoss.xml.HTMLs;
023:
024:        import org.zkoss.zk.ui.WrongValueException;
025:        import org.zkoss.zk.ui.event.Events;
026:        import org.zkoss.zk.ui.ext.client.Scrollable;
027:
028:        import org.zkoss.zul.impl.XulElement;
029:
030:        /**
031:         * A slider.
032:         *
033:         * <p>To customize the look, you can specify the style class with
034:         * {@link #setSclass}. Then, the following style classes are generated
035:         * to style the look. Assume that the style class is "slider"
036:         * <ul>
037:         * <li>slider-bk: the center background</li>
038:         * <li>slider-bkl: the left background</li>
039:         * <li>slider-bkr: the right background</li>
040:         * <li>slider-btn: the bottom background</li>
041:         * </ul>
042:         *
043:         * <p>If {@link #getSclass} is empty and {@link #getMold} is "default",
044:         * "slider" is assumed. If {@link #getMold} is "sphere", "slidersph" is assumed.
045:         *
046:         * @author tomyeh
047:         */
048:        public class Slider extends XulElement {
049:            private int _curpos, _maxpos = 100, _pginc = 10;
050:            /** The name. */
051:            private String _name;
052:            private String _slidingtext = "{0}";
053:
054:            public Slider() {
055:                setWidth("100px");
056:            }
057:
058:            /**
059:             * @param curpos the current position (default: 0)
060:             */
061:            public Slider(int curpos) {
062:                this ();
063:                setCurpos(curpos);
064:            }
065:
066:            /**
067:             * Returns the sliding text.
068:             * <p>Default : "{0}"
069:             * @since 3.0.1
070:             */
071:            public String getSlidingtext() {
072:                return _slidingtext;
073:            }
074:
075:            /**
076:             * Sets the sliding text.
077:             * The syntax "{0}" will be replaced with the position at client side.
078:             * @since 3.0.1
079:             */
080:            public void setSlidingtext(String slidingtext) {
081:                if (slidingtext == null || slidingtext.length() == 0)
082:                    slidingtext = "{0}";
083:                if (!_slidingtext.equals(slidingtext)) {
084:                    _slidingtext = slidingtext;
085:                    smartUpdate("z.slidingtext", _slidingtext);
086:                }
087:            }
088:
089:            /** Returns the current position of the slider.
090:             *
091:             * <p>Default: 0.
092:             */
093:            public final int getCurpos() {
094:                return _curpos;
095:            }
096:
097:            /** Sets the current position of the slider.
098:             * If negative, 0 is assumed. If larger than {@link #getMaxpos},
099:             * {@link #getMaxpos} is assumed.
100:             */
101:            public final void setCurpos(int curpos) throws WrongValueException {
102:                if (curpos < 0)
103:                    curpos = 0;
104:                else if (curpos > _maxpos)
105:                    curpos = _maxpos;
106:
107:                if (_curpos != curpos) {
108:                    _curpos = curpos;
109:                    smartUpdate("z.curpos", _curpos);
110:                }
111:            }
112:
113:            /** Returns the maximum position of the slider.
114:             *
115:             * <p>Default: 100.
116:             */
117:            public final int getMaxpos() {
118:                return _maxpos;
119:            }
120:
121:            /** Sets the maximum position of the slider.
122:             *
123:             * @exception WrongValueException if non-positive maxpos is passed
124:             */
125:            public final void setMaxpos(int maxpos) throws WrongValueException {
126:                if (maxpos <= 0)
127:                    throw new WrongValueException(
128:                            "Nonpositive is not allowed: " + maxpos);
129:
130:                if (_maxpos != maxpos) {
131:                    if (_curpos > maxpos)
132:                        setCurpos(maxpos);
133:                    _maxpos = maxpos;
134:                    smartUpdate("z.maxpos", _maxpos);
135:                }
136:            }
137:
138:            /** Returns the amount that the value of {@link #getCurpos}
139:             * changes by when the tray of the scroll bar is clicked. 
140:             *
141:             * <p>Default: 10.
142:             */
143:            public final int getPageIncrement() {
144:                return _pginc;
145:            }
146:
147:            /** Sets the amount that the value of {@link #getCurpos}
148:             * changes by when the tray of the scroll bar is clicked.
149:             */
150:            public final void setPageIncrement(int pginc)
151:                    throws WrongValueException {
152:                if (pginc <= 0)
153:                    throw new WrongValueException(
154:                            "Nonpositive is not allowed: " + pginc);
155:                if (_pginc != pginc) {
156:                    _pginc = pginc;
157:                    smartUpdate("z.pginc", _pginc);
158:                }
159:            }
160:
161:            /** Returns the name of this component.
162:             * <p>Default: null.
163:             * <p>The name is used only to work with "legacy" Web application that
164:             * handles user's request by servlets.
165:             * It works only with HTTP/HTML-based browsers. It doesn't work
166:             * with other kind of clients.
167:             * <p>Don't use this method if your application is purely based
168:             * on ZK's event-driven model.
169:             * @since 3.0.0
170:             */
171:            public String getName() {
172:                return _name;
173:            }
174:
175:            /** Sets the name of this component.
176:             * <p>The name is used only to work with "legacy" Web application that
177:             * handles user's request by servlets.
178:             * It works only with HTTP/HTML-based browsers. It doesn't work
179:             * with other kind of clients.
180:             * <p>Don't use this method if your application is purely based
181:             * on ZK's event-driven model.
182:             *
183:             * @param name the name of this component.
184:             * @since 3.0.0
185:             */
186:            public void setName(String name) {
187:                if (name != null && name.length() == 0)
188:                    name = null;
189:                if (!Objects.equals(_name, name)) {
190:                    _name = name;
191:                    smartUpdate("z.name", _name);
192:                }
193:            }
194:
195:            //-- super --//
196:            public String getOuterAttrs() {
197:                final StringBuffer sb = new StringBuffer(64).append(super 
198:                        .getOuterAttrs());
199:                HTMLs.appendAttribute(sb, "z.name", _name);
200:                HTMLs.appendAttribute(sb, "z.curpos", _curpos);
201:                HTMLs.appendAttribute(sb, "z.maxpos", _maxpos);
202:                HTMLs.appendAttribute(sb, "z.pginc", _pginc);
203:                HTMLs.appendAttribute(sb, "z.slidingtext", getSlidingtext());
204:
205:                appendAsapAttr(sb, Events.ON_SCROLL);
206:                appendAsapAttr(sb, Events.ON_SCROLLING);
207:                appendAsapAttr(sb, Events.ON_RIGHT_CLICK);
208:                //no z.dbclk to avoid confusion
209:                //no z.lfclk since it will be supported by sld.js
210:
211:                return sb.toString();
212:            }
213:
214:            //-- Component --//
215:            /** Not childable. */
216:            public boolean isChildable() {
217:                return false;
218:            }
219:
220:            //-- ComponentCtrl --//
221:            protected Object newExtraCtrl() {
222:                return new ExtraCtrl();
223:            }
224:
225:            /** A utility class to implement {@link #getExtraCtrl}.
226:             * It is used only by component developers.
227:             */
228:            protected class ExtraCtrl extends XulElement.ExtraCtrl implements 
229:                    Scrollable {
230:                //-- Scrollable --//
231:                public final void setCurposByClient(int curpos) {
232:                    if (curpos < 0)
233:                        throw new WrongValueException(
234:                                "Negative is not allowed: " + curpos);
235:                    _curpos = curpos;
236:                }
237:            }
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.