Source Code Cross Referenced for TreeLoader.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.Connection;
013:        import com.gwtext.client.core.Function;
014:        import com.gwtext.client.core.JsObject;
015:        import com.gwtext.client.core.UrlParam;
016:        import com.gwtext.client.util.JavaScriptObjectHelper;
017:        import com.gwtext.client.widgets.tree.event.TreeLoaderListener;
018:
019:        /**
020:         * A TreeLoader provides for lazy loading of an {@link TreeNode}'s child nodes from a specified URL.
021:         * The response must be a Json array definition who's elements are node definition objects. eg:
022:         * <pre>
023:         * <code>
024:         *
025:         * [{ 'id': 1, 'text': 'A folder Node', 'leaf': false },
026:         * { 'id': 2, 'text': 'A leaf Node', 'leaf': true }]
027:         *
028:         * </code>
029:         * </pre>
030:         *
031:         * A server request is sent, and child nodes are loaded only when a node is expanded. The loading node's
032:         * id is passed to the server under the parameter name "node" to enable the server to produce the correct
033:         * child nodes.
034:
035:         */
036:        public class TreeLoader extends JsObject {
037:
038:            protected JavaScriptObject configJS = JavaScriptObjectHelper
039:                    .createObject();
040:
041:            public TreeLoader(JavaScriptObject jsObj) {
042:                super (jsObj);
043:                configJS = jsObj;
044:            }
045:
046:            /**
047:             * Create a new TreeLoader.
048:             *
049:             */
050:            public TreeLoader() {
051:            }
052:
053:            public JavaScriptObject getJsObj() {
054:                if (!isCreated()) {
055:                    jsObj = create(configJS);
056:                }
057:                return jsObj;
058:            }
059:
060:            protected native JavaScriptObject create(JavaScriptObject config)/*-{
061:                    return new $wnd.Ext.tree.TreeLoader(config);
062:                }-*/;
063:
064:            public static TreeLoader instance(JavaScriptObject jsObj) {
065:                return new TreeLoader(jsObj);
066:            }
067:
068:            /**
069:             * Specify HTTP parameters to be passed to each request for child nodes.
070:             * 
071:             * @param params the params
072:             */
073:            private void setBaseParamsCreated(UrlParam[] params) {
074:                JavaScriptObject paramObj = UrlParam.getJsObj(params);
075:                JavaScriptObjectHelper.setAttribute(jsObj, "baseParams",
076:                        paramObj);
077:            }
078:
079:            //todo add pluggable createNode strategy
080:            //createNode()
081:            /**
082:             * Load a TreeNode from the URL specified in the TreeLoader configuration. This is called automatically when a node
083:             * is expanded, but may be used to reload a node (or append new children if the clearOnLoad option is false.)
084:             */
085:            public native void load() /*-{
086:                   var tree = this.@com.gwtext.client.core.JsObject::getJsObj()();
087:                   tree.load();
088:               }-*/;
089:
090:            /**
091:             * Load a TreeNode from the URL specified in the TreeLoader configuration. This is called automatically when a node
092:             * is expanded, but may be used to reload a node (or append new children if the clearOnLoad option is false.)
093:             *
094:             * @param callback the callback to execute on load
095:             */
096:            public native void load(Function callback) /*-{
097:                   var tree = this.@com.gwtext.client.core.JsObject::getJsObj()();
098:                   tree.load(function() {
099:            		callback.@com.gwtext.client.core.Function::execute()();
100:            	});
101:               }-*/;
102:
103:            /**
104:             * Add a TreeLoader listener.
105:             *
106:             * @param listener the listener
107:             */
108:            public native void addListener(TreeLoaderListener listener)/*-{
109:                    var loader = this.@com.gwtext.client.core.JsObject::getJsObj()();
110:                    var loaderJ = this;
111:
112:                     loader.addListener('beforeload',
113:                             function(loader, node) {
114:                                var nodeJ = @com.gwtext.client.widgets.tree.TreeNode::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(node);
115:                                return listener.@com.gwtext.client.widgets.tree.event.TreeLoaderListener::doBeforeLoad(Lcom/gwtext/client/widgets/tree/TreeLoader;Lcom/gwtext/client/widgets/tree/TreeNode;)(loaderJ, nodeJ)
116:            			    }
117:                      );
118:
119:                     loader.addListener('load',
120:                             function(loader, node, response) {
121:                                var nodeJ = @com.gwtext.client.widgets.tree.TreeNode::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(node);
122:                                return listener.@com.gwtext.client.widgets.tree.event.TreeLoaderListener::onLoad(Lcom/gwtext/client/widgets/tree/TreeLoader;Lcom/gwtext/client/widgets/tree/TreeNode;Ljava/lang/String;)(loaderJ, nodeJ, response);
123:            			    }
124:                      );
125:                        loader.addListener('loadexception',
126:                             function(loader, node, response) {
127:                                var nodeJ = @com.gwtext.client.widgets.tree.TreeNode::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(node);
128:                                return listener.@com.gwtext.client.widgets.tree.event.TreeLoaderListener::onLoadException(Lcom/gwtext/client/widgets/tree/TreeLoader;Lcom/gwtext/client/widgets/tree/TreeNode;Ljava/lang/String;)(loaderJ, nodeJ, response);
129:            			    }
130:                      );
131:                }-*/;
132:
133:            //config options
134:
135:            /**
136:             * The request parameters to be added to all nodes created by this loader.
137:             * If the attributes sent by the server have an attribute in this object, they take priority.
138:             *
139:             * @param params the url params
140:             */
141:            public void setBaseAttrs(UrlParam[] params) {
142:                JavaScriptObject paramObj = UrlParam.getJsObj(params);
143:                JavaScriptObjectHelper.setAttribute(configJS, "baseAttrs",
144:                        paramObj);
145:            }
146:
147:            /**
148:             * The URL from which to request a Json string which specifies an array of node definition object representing the
149:             * child nodes to be loaded.
150:             *
151:             * @param dataUrl the data URL
152:             */
153:            public void setDataUrl(String dataUrl) {
154:                JavaScriptObjectHelper.setAttribute(configJS, "dataUrl",
155:                        dataUrl);
156:            }
157:
158:            public void setPreloadChildren(boolean preloadChildren) {
159:                JavaScriptObjectHelper.setAttribute(configJS,
160:                        "preloadChildren ", preloadChildren);
161:            }
162:
163:            /**
164:             * The request method (GET OR POST).
165:             *
166:             * @param method the request method
167:             * @see com.gwtext.client.core.Connection#GET
168:             * @see com.gwtext.client.core.Connection#POST
169:             */
170:            public void setMethod(Connection.Method method) {
171:                JavaScriptObjectHelper.setAttribute(configJS, "requestMethod",
172:                        method.getMethod());
173:            }
174:
175:            /**
176:             * The request method (GET OR POST).
177:             *
178:             * @param method the request method
179:             * @deprecated Use {@link #setMethod(com.gwtext.client.core.Connection.Method)}
180:             */
181:            public void setMethod(String method) {
182:                JavaScriptObjectHelper.setAttribute(configJS, "requestMethod",
183:                        method);
184:            }
185:
186:            /**
187:             * Request properties which specify HTTP parameters to be passed to each request for child nodes.
188:             *
189:             * @param params the request params
190:             */
191:            public void setBaseParams(UrlParam[] params) {
192:                if (!isCreated()) {
193:                    JavaScriptObject paramObj = UrlParam.getJsObj(params);
194:                    JavaScriptObjectHelper.setAttribute(configJS, "baseParams",
195:                            paramObj);
196:                } else {
197:                    setBaseParamsCreated(params);
198:                }
199:            }
200:
201:            /**
202:             * Default to true. Remove previously existing child nodes before loading.
203:             *
204:             * @param clearOnLoad true to clear on load
205:             */
206:            public void setClearOnLoad(boolean clearOnLoad) {
207:                JavaScriptObjectHelper.setAttribute(configJS, "clearOnLoad",
208:                        clearOnLoad);
209:            }
210:
211:            //todo  uiProviders
212:
213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.