Source Code Cross Referenced for Toolbarbutton.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:        /* Toolbarbutton.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Thu Jun 23 11:33:45     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:
027:        import org.zkoss.zul.impl.LabelImageElement;
028:
029:        /**
030:         * A tool button.
031:         *
032:         * <p>The default CSS class is "button".
033:         *
034:         * <p>Non-xul extension: Toolbarbutton supports {@link #getHref}. If {@link #getHref}
035:         * is not null, the onClick handler is ignored and this element is degenerated
036:         * to HTML's A tag.
037:         *
038:         * @author tomyeh
039:         */
040:        public class Toolbarbutton extends LabelImageElement {
041:            private String _orient = "horizontal", _dir = "normal";
042:            private String _href, _target;
043:            private int _tabindex = -1;
044:            private boolean _disabled = false;
045:
046:            public Toolbarbutton() {
047:            }
048:
049:            public Toolbarbutton(String label) {
050:                setLabel(label);
051:            }
052:
053:            public Toolbarbutton(String label, String image) {
054:                setLabel(label);
055:                setImage(image);
056:            }
057:
058:            public String getSclass() {
059:                String scls = super .getSclass();
060:                if (isDisabled())
061:                    return scls != null && scls.length() > 0 ? scls + " disd"
062:                            : "disd";
063:                return scls;
064:            }
065:
066:            /**
067:             * Sets whether it is disabled.
068:             * @since 3.0.1
069:             */
070:            public void setDisabled(boolean disabled) {
071:                if (_disabled != disabled) {
072:                    _disabled = disabled;
073:                    invalidate();
074:                }
075:            }
076:
077:            /** Returns whether it is disabled.
078:             * <p>Default: false.
079:             * @since 3.0.1
080:             */
081:            public boolean isDisabled() {
082:                return _disabled;
083:            }
084:
085:            /** Returns the direction.
086:             * <p>Default: "normal".
087:             */
088:            public String getDir() {
089:                return _dir;
090:            }
091:
092:            /** Sets the direction.
093:             * @param dir either "normal" or "reverse".
094:             */
095:            public void setDir(String dir) throws WrongValueException {
096:                if (!"normal".equals(dir) && !"reverse".equals(dir))
097:                    throw new WrongValueException(dir);
098:
099:                if (!Objects.equals(_dir, dir)) {
100:                    _dir = dir;
101:                    invalidate();
102:                }
103:            }
104:
105:            /** Returns the href.
106:             * <p>Default: null. If null, the button has no function unless you
107:             * specify the onClick handler.
108:             */
109:            public String getHref() {
110:                return _href;
111:            }
112:
113:            /** Sets the href.
114:             */
115:            public void setHref(String href) throws WrongValueException {
116:                if (href != null && href.length() == 0)
117:                    href = null;
118:                if (!Objects.equals(_href, href)) {
119:                    _href = href;
120:                    invalidate();
121:                }
122:            }
123:
124:            /** Returns the orient.
125:             * <p>Default: "horizontal".
126:             */
127:            public String getOrient() {
128:                return _orient;
129:            }
130:
131:            /** Sets the orient.
132:             * @param orient either "horizontal" or "vertical".
133:             */
134:            public void setOrient(String orient) throws WrongValueException {
135:                if (!"horizontal".equals(orient) && !"vertical".equals(orient))
136:                    throw new WrongValueException("orient cannot be " + orient);
137:
138:                if (!Objects.equals(_orient, orient)) {
139:                    _orient = orient;
140:                    invalidate();
141:                }
142:            }
143:
144:            /** Returns the target frame or window.
145:             *
146:             * <p>Note: it is useful only if href ({@link #setHref}) is specified
147:             * (i.e., use the onClick listener).
148:             *
149:             * <p>Default: null.
150:             */
151:            public String getTarget() {
152:                return _target;
153:            }
154:
155:            /** Sets the target frame or window.
156:             * @param target the name of the frame or window to hyperlink.
157:             */
158:            public void setTarget(String target) {
159:                if (target != null && target.length() == 0)
160:                    target = null;
161:
162:                if (!Objects.equals(_target, target)) {
163:                    _target = target;
164:                    smartUpdate("target", _target);
165:                }
166:            }
167:
168:            /** Returns the tab order of this component.
169:             * <p>Default: -1 (means the same as browser's default).
170:             */
171:            public int getTabindex() {
172:                return _tabindex;
173:            }
174:
175:            /** Sets the tab order of this component.
176:             */
177:            public void setTabindex(int tabindex) throws WrongValueException {
178:                if (_tabindex != tabindex) {
179:                    _tabindex = tabindex;
180:                    if (tabindex < 0)
181:                        smartUpdate("tabindex", null);
182:                    else
183:                        smartUpdate("tabindex", Integer.toString(_tabindex));
184:                }
185:            }
186:
187:            //-- super --//
188:            public String getOuterAttrs() {
189:                final StringBuffer sb = new StringBuffer(64).append(super 
190:                        .getOuterAttrs());
191:
192:                appendAsapAttr(sb, Events.ON_FOCUS);
193:                appendAsapAttr(sb, Events.ON_BLUR);
194:                appendAsapAttr(sb, Events.ON_RIGHT_CLICK);
195:                //no z.dbclk to avoid confusing
196:                //no z.lfclk since it is handled by widget.js
197:
198:                if (_href == null) {
199:                    sb.append(" href=\"javascript:;\"");
200:                } else {
201:                    sb.append(" href=\"").append(
202:                            getDesktop().getExecution().encodeURL(_href))
203:                            .append('"');
204:                    //When hyper to other page, we always show progress dlg
205:                }
206:                HTMLs.appendAttribute(sb, "z.disd", isDisabled());
207:                HTMLs.appendAttribute(sb, "target", _target);
208:
209:                if (_tabindex >= 0)
210:                    HTMLs.appendAttribute(sb, "tabindex", _tabindex);
211:                return sb.toString();
212:            }
213:
214:            //Component//
215:            /** No child is allowed.
216:             */
217:            public boolean isChildable() {
218:                return false;
219:            }
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.