Source Code Cross Referenced for AsyncTreeNode.java in  » Ajax » gwtext-2.01 » com » gwtext » client » widgets » tree » 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 » gwtext 2.01 » com.gwtext.client.widgets.tree 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * GWT-Ext Widget Library
003:         * Copyright(c) 2007-2008, GWT-Ext.
004:         * licensing@gwt-ext.com
005:         * 
006:         * http://www.gwt-ext.com/license
007:         */
008:
009:        package com.gwtext.client.widgets.tree;
010:
011:        import com.google.gwt.core.client.JavaScriptObject;
012:        import com.gwtext.client.core.Function;
013:        import com.gwtext.client.util.JavaScriptObjectHelper;
014:        import com.gwtext.client.widgets.tree.event.AsyncTreeNodeListener;
015:
016:        /**
017:         * Provides the abilty to asynchronously lazy load a TreeNodes children. An AsyncTreeNode
018:         * is assigned a {@link TreeLoader} which is reponsible for fetching the tree data and loading it
019:         * into the tree as children. The {@link TreeLoader} can be configured to load tree data from remote Json data
020:         * and {@link com.gwtext.client.widgets.tree.XMLTreeLoader} can be use to load tree data from XML
021:         * returned from a remote URL.
022:         *<p>
023:         * Sample code for loading a Tree node using AsyncTreeNode and XmltreeLoader :
024:         *
025:         * <pre>
026:         * <code>
027:         *
028:         *     final TreePanel treePanel = new TreePanel("cb-tree", new TreePanelConfig() {
029:         *            {
030:         *                setAnimate(true);
031:         *                setEnableDD(true);
032:         *                setContainerScroll(true);
033:         *                setRootVisible(true);
034:         *            }
035:         *        });
036:         *
037:         *     final XMLTreeLoader loader = new XMLTreeLoader(new XMLTreeLoaderConfig() {
038:         *            {
039:         *                setDataUrl("countries-cb.xml");
040:         *                setMethod("get");
041:         *                setRootTag("countries");
042:         *                setFolderIdMapping("@id");
043:         *                setLeafIdMapping("@id");
044:         *                setFolderTitleMapping("@title");
045:         *                setFolderTag("team");
046:         *                setLeafTitleMapping("@title");
047:         *                setLeafTag("country");
048:         *                setQtipMapping("@qtip");
049:         *                setDisabledMapping("@disabled");
050:         *                setCheckedMapping("@checked");
051:         *                setIconMapping("@icon");
052:         *                setAttributeMappings(new String[]{"@rank"});
053:         *            }
054:         *        });
055:         *        AsyncTreeNode root = new AsyncTreeNode("Countries", new AsyncTreeNodeConfig() {
056:         *            {
057:         *                setLoader(loader);
058:         *            }
059:         *        });
060:         *
061:         *        treePanel.setRootNode(root);
062:         *        treePanel.render();
063:         *
064:         *        root.expand();
065:         *        treePanel.expandAll();
066:         * </code>
067:         * </pre>
068:         *
069:         * The above code loads a Tree using the following XML data - countries-cb.xml
070:         *
071:         * <pre>
072:         * <code>
073:         *&lt;countries&gt;
074:         *    &lt;team id="team-a" title="Team A" icon="images/silk/flag_yellow.gif" checked="true"&gt;
075:         *        &lt;country title="Brazil" qtip="Rank 2" rank="2"  checked="false"/&gt;
076:         *        &lt;country title="Canada" qtip="Rank 3" rank="3" checked="false"/&gt;
077:         *        &lt;country title="China" qtip="Rank 4" rank="4" checked="false"/&gt;
078:         *    &lt;/team&gt;
079:         *    &lt;team title="Team B" icon="images/silk/flag_blue.gif"&gt;
080:         *        &lt;country title="Germany" qtip="Captain" checked="true" rank="1"/&gt;
081:         *        &lt;country title="France" qtip="Rank 2" rank="2" checked="false"/&gt;
082:         *        &lt;country title="Canada" qtip="Rank 3" rank="3" checked="false"/&gt;
083:         *        &lt;country title="India" qtip="Rank 4" rank="4" checked="false"/&gt;
084:         *        &lt;country title="Seychelles" qtip="Rank 5" rank="5" checked="false"/&gt;
085:         *    &lt;/team&gt;
086:         *
087:         *    &lt;team title="Team C" icon="images/silk/flag_green.gif"&gt;
088:         *        &lt;country title="United States" qtip="Captain - Rank 1" checked="true" rank="1"/&gt;
089:         *        &lt;country title="Japan" qtip="Rank 2" rank="2" checked="false"/&gt;
090:         *        &lt;country title="Italy" qtip="Rank 3" rank="3" checked="false"/&gt;
091:         *        &lt;country title="Finland" qtip="Rank 4" rank="4" checked="false"/&gt;
092:         *    &lt;/team&gt;
093:         *  &lt;/countries&gt;
094:         * </code>
095:         * </pre>
096:         *
097:         * @see TreeLoader
098:         * @see com.gwtext.client.widgets.tree.XMLTreeLoader
099:         */
100:
101:        public class AsyncTreeNode extends TreeNode {
102:
103:            /**
104:             * Construct a new AsyncTreeNode
105:             *
106:             * @param treeLoader the tree loader
107:             */
108:            public AsyncTreeNode(TreeLoader treeLoader) {
109:                setLoader(treeLoader);
110:            }
111:
112:            /**
113:             * Construct a new AsyncTreeNode
114:             *
115:             * @param treeLoader the tree loader
116:             * @param text the node label / display text
117:             */
118:            public AsyncTreeNode(String text, TreeLoader treeLoader) {
119:                setText(text);
120:                setLoader(treeLoader);
121:            }
122:
123:            /**
124:             * Construct a new AsyncTreeNode
125:             *
126:             * @param treeLoader the tree loader
127:             * @param text the node label / display text
128:             * @param expanded true to expand
129:             */
130:            public AsyncTreeNode(String text, TreeLoader treeLoader,
131:                    boolean expanded) {
132:                setText(text);
133:                setLoader(treeLoader);
134:                setExpanded(expanded);
135:            }
136:
137:            protected native JavaScriptObject create(JavaScriptObject config)/*-{
138:                    return new $wnd.Ext.tree.AsyncTreeNode(config);
139:                }-*/;
140:
141:            /**
142:             * Returns true if this node has been loaded.
143:             *
144:             * @return true if node loaded
145:             */
146:            public native boolean isLoaded() /*-{
147:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
148:                   return node.isLoaded();
149:               }-*/;
150:
151:            /**
152:             * Returns true if this node is currently loading.
153:             *
154:             * @return true if node loading
155:             */
156:            public native boolean isLoading() /*-{
157:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
158:                   return node.isLoading();
159:               }-*/;
160:
161:            /**
162:             * Return the TreeLoader associated with this node.
163:             * 
164:             * @return the tree loader
165:             */
166:            public native TreeLoader getLoader()/*-{
167:                    var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
168:                    var loader = node.loader;
169:                    return @com.gwtext.client.widgets.tree.TreeLoader::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(loader);
170:                }-*/;
171:
172:            /**
173:             * Trigger a reload for this node.
174:             */
175:            public native void reload() /*-{
176:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
177:                   node.reload();
178:               }-*/;
179:
180:            /**
181:             * Trigger a reload for this node.
182:             *
183:             * @param callback the callback to execute when the reload is complete
184:             */
185:            public native void reload(Function callback) /*-{
186:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
187:                   node.reload(function() {
188:                           callback.@com.gwtext.client.core.Function::execute()();
189:            		});           
190:            }-*/;
191:
192:            /**
193:             * Adds an AsyncTreeNode Listener.
194:             *
195:             * @param listener the listener
196:             */
197:            public native void addListener(AsyncTreeNodeListener listener)/*-{
198:                    var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
199:                    var nodeJ = this;
200:
201:                     node.addListener('beforeload',
202:                             function(source) {
203:                                return listener.@com.gwtext.client.widgets.tree.event.AsyncTreeNodeListener::doBeforeLoad(Lcom/gwtext/client/widgets/tree/AsyncTreeNode;)(nodeJ);
204:            			    }
205:                      );
206:
207:                     node.addListener('load',
208:                             function(source) {
209:                                listener.@com.gwtext.client.widgets.tree.event.AsyncTreeNodeListener::onLoad(Lcom/gwtext/client/widgets/tree/AsyncTreeNode;)(nodeJ);
210:            			    }
211:                      );
212:                }-*/;
213:
214:            //config options     
215:            public void setLoader(TreeLoader loader) {
216:                JavaScriptObjectHelper.setAttribute(configJS, "loader", loader
217:                        .getJsObj());
218:            }
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.