Source Code Cross Referenced for Button.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:        /* Button.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Wed Jun  8 10:31:02     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.Desktop;
025:        import org.zkoss.zk.ui.UiException;
026:        import org.zkoss.zk.ui.WrongValueException;
027:        import org.zkoss.zk.ui.event.Events;
028:
029:        import org.zkoss.zul.impl.LabelImageElement;
030:
031:        /**
032:         * A button.
033:         *
034:         * @author tomyeh
035:         */
036:        public class Button extends LabelImageElement {
037:            private String _orient = "horizontal", _dir = "normal";
038:            private String _href, _target;
039:            private int _tabindex = -1;
040:            private boolean _disabled;
041:            private boolean _readonly;
042:
043:            public Button() {
044:            }
045:
046:            public Button(String label) {
047:                setLabel(label);
048:            }
049:
050:            public Button(String label, String image) {
051:                setLabel(label);
052:                setImage(image);
053:            }
054:
055:            /** Returns whether it is disabled.
056:             * <p>Default: false.
057:             */
058:            public boolean isDisabled() {
059:                return _disabled;
060:            }
061:
062:            /** Sets whether it is disabled.
063:             */
064:            public void setDisabled(boolean disabled) {
065:                if (_disabled != disabled) {
066:                    _disabled = disabled;
067:                    smartUpdate("disabled", _disabled);
068:                }
069:            }
070:
071:            /** Returns the direction.
072:             * <p>Default: "normal".
073:             */
074:            public String getDir() {
075:                return _dir;
076:            }
077:
078:            /** Sets the direction.
079:             * @param dir either "normal" or "reverse".
080:             */
081:            public void setDir(String dir) throws WrongValueException {
082:                if (!"normal".equals(dir) && !"reverse".equals(dir))
083:                    throw new WrongValueException(dir);
084:
085:                if (!Objects.equals(_dir, dir)) {
086:                    _dir = dir;
087:                    invalidate();
088:                }
089:            }
090:
091:            /** Returns the orient.
092:             * <p>Default: "horizontal".
093:             */
094:            public String getOrient() {
095:                return _orient;
096:            }
097:
098:            /** Sets the orient.
099:             * @param orient either "horizontal" or "vertical".
100:             */
101:            public void setOrient(String orient) throws WrongValueException {
102:                if (!"horizontal".equals(orient) && !"vertical".equals(orient))
103:                    throw new WrongValueException(orient);
104:
105:                if (!Objects.equals(_orient, orient)) {
106:                    _orient = orient;
107:                    invalidate();
108:                }
109:            }
110:
111:            /** Returns the href that the browser shall jump to, if an user clicks
112:             * this button.
113:             * <p>Default: null. If null, the button has no function unless you
114:             * specify the onClick event listener.
115:             * <p>If it is not null, the onClick event won't be sent.
116:             */
117:            public String getHref() {
118:                return _href;
119:            }
120:
121:            /** Sets the href.
122:             */
123:            public void setHref(String href) {
124:                if (href != null && href.length() == 0)
125:                    href = null;
126:                if (!Objects.equals(_href, href)) {
127:                    _href = href;
128:                    smartUpdateDeferred("z.href", new EncodedHref()); //Bug 1850895
129:                }
130:            }
131:
132:            /** Returns the target frame or window.
133:             *
134:             * <p>Note: it is useful only if href ({@link #setHref}) is specified
135:             * (i.e., use the onClick listener).
136:             *
137:             * <p>Default: null.
138:             */
139:            public String getTarget() {
140:                return _target;
141:            }
142:
143:            /** Sets the target frame or window.
144:             * @param target the name of the frame or window to hyperlink.
145:             */
146:            public void setTarget(String target) {
147:                if (target != null && target.length() == 0)
148:                    target = null;
149:
150:                if (!Objects.equals(_target, target)) {
151:                    _target = target;
152:                    smartUpdate("z.target", _target);
153:                }
154:            }
155:
156:            /** Returns the tab order of this component.
157:             * <p>Default: -1 (means the same as browser's default).
158:             */
159:            public int getTabindex() {
160:                return _tabindex;
161:            }
162:
163:            /** Sets the tab order of this component.
164:             */
165:            public void setTabindex(int tabindex) throws WrongValueException {
166:                if (_tabindex != tabindex) {
167:                    _tabindex = tabindex;
168:                    if (tabindex < 0)
169:                        smartUpdate("tabindex", null);
170:                    else
171:                        smartUpdate("tabindex", Integer.toString(_tabindex));
172:                }
173:            }
174:
175:            /** Returns whether it is readonly.
176:             * <p>Default: false.
177:             * <p>This method has no real effect.
178:             * See <a href="http://www.w3.org/TR/html4/interact/forms.html">w3.org</a>
179:             * @deprecated As of release 2.4.1, since this method has no real effect.
180:             */
181:            public boolean isReadonly() {
182:                return _readonly;
183:            }
184:
185:            /** Sets whether it is readonly.
186:             * <p>This method has no real effect.
187:             * See <a href="http://www.w3.org/TR/html4/interact/forms.html">w3.org</a>
188:             * @deprecated As of release 2.4.1, since this method has no real effect.
189:             */
190:            public void setReadonly(boolean readonly) {
191:                _readonly = readonly;
192:            }
193:
194:            private String getEncodedHref() {
195:                final Desktop dt = getDesktop();
196:                return _href != null && dt != null ? dt.getExecution()
197:                        .encodeURL(_href) : null;
198:                //if desktop is null, it doesn't belong to any execution
199:            }
200:
201:            //-- super --//
202:            public String getOuterAttrs() {
203:                final StringBuffer sb = new StringBuffer(64).append(super 
204:                        .getOuterAttrs());
205:                HTMLs.appendAttribute(sb, "z.href", getEncodedHref());
206:                HTMLs.appendAttribute(sb, "z.target", getTarget());
207:
208:                appendAsapAttr(sb, Events.ON_FOCUS);
209:                appendAsapAttr(sb, Events.ON_BLUR);
210:                appendAsapAttr(sb, Events.ON_RIGHT_CLICK);
211:                appendAsapAttr(sb, Events.ON_DOUBLE_CLICK);
212:                //no z.lfclk since it is handled by widget.js
213:
214:                if (isDisabled())
215:                    HTMLs.appendAttribute(sb, "disabled", "disabled");
216:                if (_tabindex >= 0)
217:                    HTMLs.appendAttribute(sb, "tabindex", _tabindex);
218:                return sb.toString();
219:            }
220:
221:            //Component//
222:            /** No child is allowed.
223:             */
224:            public boolean isChildable() {
225:                return false;
226:            }
227:
228:            private class EncodedHref implements 
229:                    org.zkoss.zk.ui.util.DeferredValue {
230:                public String getValue() {
231:                    return getEncodedHref();
232:                }
233:            }
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.