Source Code Cross Referenced for Treerow.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:        /* Treerow.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Wed Jul  6 18:56: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.lang.Objects;
022:        import org.zkoss.xml.HTMLs;
023:
024:        import org.zkoss.zk.ui.Component;
025:        import org.zkoss.zk.ui.UiException;
026:        import org.zkoss.zk.ui.event.Events;
027:
028:        import org.zkoss.zul.impl.XulElement;
029:
030:        /**
031:         * A treerow.
032:         *
033:         * @author tomyeh
034:         */
035:        public class Treerow extends XulElement {
036:            /** Returns the {@link Tree} instance containing this element.
037:             */
038:            public Tree getTree() {
039:                for (Component p = this ; (p = p.getParent()) != null;)
040:                    if (p instanceof  Tree)
041:                        return (Tree) p;
042:                return null;
043:            }
044:
045:            /** Returns the level this cell is. The root is level 0.
046:             */
047:            public int getLevel() {
048:                final Component parent = getParent();
049:                return parent != null ? ((Treeitem) parent).getLevel() : 0;
050:            }
051:
052:            /** Returns the parent {@link Treeitem}.
053:             * @deprecated As of release 2.4.1, due to confusing
054:             */
055:            public Treeitem getTreeitem() {
056:                return (Treeitem) getParent();
057:            }
058:
059:            /** Returns the {@link Treechildren} associated with this
060:             * {@link Treerow}.
061:             * In other words, it is {@link Treeitem#getTreechildren} of
062:             * {@link #getParent}.
063:             * @since 2.4.1
064:             * @see Treechildren#getLinkedTreerow
065:             */
066:            public Treechildren getLinkedTreechildren() {
067:                final Component parent = getParent();
068:                return parent != null ? ((Treeitem) parent).getTreechildren()
069:                        : null;
070:            }
071:
072:            //-- super --//
073:            /** Returns the style class.
074:             * Note: 1) if not set (or setSclass(null), "item" is assumed;
075:             * 2) if selected, it appends " seld" to super's getSclass().
076:             */
077:            public String getSclass() {
078:                String scls = super .getSclass();
079:                if (scls == null)
080:                    scls = "item";
081:                final Treeitem ti = getTreeitem();
082:                if (ti != null) {
083:                    if (ti.isDisabled())
084:                        return scls.length() > 0 ? scls + " disd" : "disd";
085:                    else if (ti.isSelected())
086:                        return scls.length() > 0 ? scls + " seld" : "seld";
087:                }
088:                return scls;
089:            }
090:
091:            /** Alwasys throws UnsupportedOperationException since developers shall
092:             * use {@link Treeitem#setContext} instead.
093:             */
094:            public void setContext(String context) {
095:                throw new UnsupportedOperationException("Use treeitem instead");
096:            }
097:
098:            /** Alwasys throws UnsupportedOperationException since developers shall
099:             * use {@link Treeitem#setPopup} instead.
100:             */
101:            public void setPopup(String popup) {
102:                throw new UnsupportedOperationException("Use treeitem instead");
103:            }
104:
105:            /** Alwasys throws UnsupportedOperationException since developers shall
106:             * use {@link Treeitem#setTooltip} instead.
107:             */
108:            public void setTooltip(String tooltip) {
109:                throw new UnsupportedOperationException("Use treeitem instead");
110:            }
111:
112:            /** Returns the same as {@link Treeitem#getContext}.
113:             */
114:            public String getContext() {
115:                final Treeitem ti = getTreeitem();
116:                return ti != null ? ti.getContext() : null;
117:            }
118:
119:            /** Returns the same as {@link Treeitem#getPopup}.
120:             */
121:            public String getPopup() {
122:                final Treeitem ti = getTreeitem();
123:                return ti != null ? ti.getPopup() : null;
124:            }
125:
126:            /** Returns the same as {@link Treeitem#getTooltip}.
127:             */
128:            public String getTooltip() {
129:                final Treeitem ti = getTreeitem();
130:                return ti != null ? ti.getTooltip() : null;
131:            }
132:
133:            /** Returns the same as {@link Treeitem#getTooltiptext}
134:             */
135:            public String getTooltiptext() {
136:                final Treeitem ti = getTreeitem();
137:                return ti != null ? ti.getTooltiptext() : null;
138:            }
139:
140:            protected boolean isAsapRequired(String evtnm) {
141:                if (!Events.ON_OPEN.equals(evtnm))
142:                    return super .isAsapRequired(evtnm);
143:                final Treeitem ti = getTreeitem();
144:                return ti != null && ti.isAsapRequired(evtnm);
145:            }
146:
147:            /** Appends attributes for generating the real checkbox HTML tags
148:             * (name="val"); Used only by component developers.
149:             */
150:            public String getOuterAttrs() {
151:                final String attrs = super .getOuterAttrs();
152:                final Treeitem item = getTreeitem();
153:                if (item == null)
154:                    return attrs;
155:
156:                final StringBuffer sb = new StringBuffer(80).append(attrs);
157:
158:                final Tree tree = getTree();
159:                if (tree != null && tree.getName() != null)
160:                    HTMLs.appendAttribute(sb, "z.value", Objects.toString(item
161:                            .getValue()));
162:                HTMLs.appendAttribute(sb, "z.pitem", item.getUuid());
163:                HTMLs.appendAttribute(sb, "z.sel", item.isSelected());
164:                HTMLs.appendAttribute(sb, "z.disd", item.isDisabled());
165:                HTMLs.appendAttribute(sb, "z.rid", tree.getUuid());
166:                if (item.isContainer())
167:                    HTMLs.appendAttribute(sb, "z.open", item.isOpen());
168:
169:                final Component gp = item.getParent(); //Treechildren
170:                if (gp != null) {
171:                    HTMLs.appendAttribute(sb, "z.ptch", gp.getUuid());
172:                    Component gpitem = gp.getParent();
173:                    if (gpitem instanceof  Treeitem)
174:                        HTMLs.appendAttribute(sb, "z.gpitem", gpitem.getUuid());
175:                }
176:
177:                final Treechildren tcsib = getLinkedTreechildren();
178:                if (tcsib != null) {
179:                    HTMLs.appendAttribute(sb, "z.tchsib", tcsib.getUuid());
180:
181:                    final int pgcnt = tcsib.getPageCount();
182:                    if (pgcnt > 1) {
183:                        HTMLs.appendAttribute(sb, "z.pgc", pgcnt);
184:                        HTMLs.appendAttribute(sb, "z.pgi", tcsib
185:                                .getActivePage());
186:                        HTMLs
187:                                .appendAttribute(sb, "z.pgsz", tcsib
188:                                        .getPageSize());
189:                    }
190:                }
191:
192:                //TODO AREA JEFF ADDED
193:                //Modified for load-on-demand
194:                if (getTree().getModel() != null)
195:                    sb.append("z.onopen=\"true\"");
196:                else
197:                    appendAsapAttr(sb, Events.ON_OPEN);
198:                //it calls isAsapRequired, so it also tested Treeitem for onOpen
199:                //TODO AREA JEFF ADDED END
200:
201:                final String clkattrs = getAllOnClickAttrs(false);
202:                if (clkattrs != null)
203:                    sb.append(clkattrs);
204:                return sb.toString();
205:            }
206:
207:            //-- Component --//
208:            /** Returns whether this is visible.
209:             * whether all its ancestors is open.
210:             */
211:            public boolean isVisible() {
212:                if (!super .isVisible())
213:                    return false;
214:                Component comp = getParent();
215:                if (!(comp instanceof  Treeitem))
216:                    return true;
217:                if (!comp.isVisible())
218:                    return false;
219:
220:                comp = comp.getParent();
221:                return !(comp instanceof  Treechildren)
222:                        || ((Treechildren) comp).isVisible(); //recursive
223:            }
224:
225:            public void setParent(Component parent) {
226:                if (parent != null && !(parent instanceof  Treeitem))
227:                    throw new UiException("Wrong parent: " + parent);
228:                super .setParent(parent);
229:            }
230:
231:            public boolean insertBefore(Component child, Component insertBefore) {
232:                if (!(child instanceof  Treecell))
233:                    throw new UiException("Unsupported child for tree row: "
234:                            + child);
235:                return super.insertBefore(child, insertBefore);
236:            }
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.