Source Code Cross Referenced for Node.java in  » Ajax » gwtext-2.01 » com » gwtext » client » data » 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.data 
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.data;
010:
011:        import com.google.gwt.core.client.JavaScriptObject;
012:        import com.gwtext.client.core.JsObject;
013:        import com.gwtext.client.data.event.NodeListener;
014:        import com.gwtext.client.util.JavaScriptObjectHelper;
015:
016:        import java.util.Comparator;
017:
018:        /**
019:         * A data Node class.
020:         */
021:        public class Node extends JsObject {
022:
023:            protected JavaScriptObject configJS = JavaScriptObjectHelper
024:                    .createObject();
025:
026:            /**
027:             * Create a new Node instance.
028:             */
029:            public Node() {
030:            }
031:
032:            public Node(JavaScriptObject jsObj) {
033:                super (jsObj);
034:            }
035:
036:            private static Node instance(JavaScriptObject node) {
037:                return new Node(node);
038:            }
039:
040:            protected native JavaScriptObject create(JavaScriptObject config)/*-{
041:                    return new $wnd.Ext.data.Node(config);    
042:                }-*/;
043:
044:            protected Node createNode(JavaScriptObject jsNode) {
045:                return new Node(jsNode);
046:            }
047:
048:            public JavaScriptObject getJsObj() {
049:                if (jsObj == null) {
050:                    jsObj = create(configJS);
051:                    setUserObject(userObject);
052:                }
053:                return jsObj;
054:            }
055:
056:            /**
057:             * Associate a user defined Object with the node.
058:             *
059:             * @param o the user data object
060:             */
061:            private native void setUserObjectCreated(Object o) /*-{
062:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
063:                   node.attributes._data = o;
064:               }-*/;
065:
066:            /**
067:             * Return the user defined object associated with the node.
068:             *
069:             * @return the user defined object , null if not defined
070:             */
071:            private native Object getUserObjectCreated() /*-{
072:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
073:
074:                   //need to convert javascript undefined to null before passing to java layer
075:                   if(node.attributes._data === undefined) {
076:                       return null;
077:                   } else {
078:                       return node.attributes._data;
079:                  }
080:               }-*/;
081:
082:            private static native Object getUserObject(JavaScriptObject node) /*-{
083:                   //need to convert javascript undefined to null before passing to java layer
084:                   if(node.attributes._data === undefined) {
085:                       return null;
086:                   } else {
087:                       return node.attributes._data;
088:                  }
089:               }-*/;
090:
091:            /**
092:             * Sets a attribute on the node.
093:             *
094:             * @param name  the attribute name
095:             * @param value the attribute value
096:             */
097:            public native void setAttribute(String name, Object value) /*-{
098:            	var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
099:            	node.attributes[name] = value;
100:            }-*/;
101:
102:            /**
103:             * Sets a attribute on the node.
104:             *
105:             * @param name  the attribute name
106:             * @param value the attribute value
107:             */
108:            public native void setAttribute(String name, String value) /*-{
109:            	var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
110:            	node.attributes[name] = value;
111:            }-*/;
112:
113:            protected native void setAttribute(String name,
114:                    JavaScriptObject value) /*-{
115:            	var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
116:            	node.attributes[name] = value;
117:            }-*/;
118:
119:            /**
120:             * Returns a node's attribute as String.
121:             *
122:             * @param name the attribute name
123:             * @return attribute value as String
124:             */
125:            public native String getAttribute(String name) /*-{
126:            	var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
127:            	var value = node.attributes[name];
128:            	return value == null || value === undefined ? null : value.toString();
129:            }-*/;
130:
131:            /**
132:             * Returns a node's Object attribute.
133:             *
134:             * @param name the attribute name
135:             * @return attribute value
136:             * @see #setAttribute(String, Object)
137:             */
138:            public native Object getAttributeAsObject(String name) /*-{
139:            	var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
140:            	var value = node.attributes[name];
141:            	return value === undefined ? null : value;
142:            }-*/;
143:
144:            /**
145:             * Returns all child nodes of this node.
146:             *
147:             * @return node's child nodes, null if none present
148:             */
149:            public Node[] getChildNodes() {
150:                JavaScriptObject[] jsNodes = JavaScriptObjectHelper
151:                        .getAttributeAsJavaScriptObjectArray(getJsObj(),
152:                                "childNodes");
153:                if (jsNodes == null)
154:                    return null;
155:                Node[] nodes = new Node[jsNodes.length];
156:                for (int i = 0; i < jsNodes.length; i++) {
157:                    JavaScriptObject jsNode = jsNodes[i];
158:                    nodes[i] = createNode(jsNode);
159:                }
160:                return nodes;
161:            }
162:
163:            /**
164:             * Return the first direct child node of this node, or null if this node has no child nodes.
165:             *
166:             * @return the first child node
167:             */
168:            public native Node getFirstChild() /*-{
169:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
170:                   if(node.firstChild == null || node.firstChild === undefined)  {
171:                       return null;
172:                   } else {
173:                       return this.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(node.firstChild);
174:                   }
175:               }-*/;
176:
177:            /**
178:             * Return the node's ID.
179:             *
180:             * @return the node ID, null if not defined
181:             */
182:            public native String getId() /*-{
183:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
184:                   return node.id === undefined ? null : node.id;
185:               }-*/;
186:
187:            /**
188:             * Set the Node's ID.
189:             *
190:             * @param id the node ID
191:             */
192:            private native void setIdCreated(String id) /*-{
193:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
194:                   node.id = id;
195:               }-*/;
196:
197:            /**
198:             * return the last direct child node of this node, or null if this node has no child nodes.
199:             *
200:             * @return the last child node
201:             */
202:            public native Node getLastChild() /*-{
203:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
204:                   if(node.lastChild == null || node.lastChild === undefined)  {
205:                       return null;
206:                   } else {
207:                       return this.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(node.lastChild);
208:                   }
209:               }-*/;
210:
211:            /**
212:             * Return the node immediately following this node in the tree, or null if there is no sibling node.
213:             *
214:             * @return this nodes next sibling
215:             */
216:            public native Node getNextSibling() /*-{
217:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
218:                   if(node.nextSibling == null || node.nextSibling === undefined)  {
219:                       return null;
220:                   } else {
221:                       return this.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(node.nextSibling);
222:                   }
223:               }-*/;
224:
225:            /**
226:             * The parent node for this node.
227:             *
228:             * @return the parent node, null if root node
229:             */
230:            public native Node getParentNode() /*-{
231:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
232:                   if(node.parentNode == null || node.parentNode === undefined)  {
233:                       return null;
234:                   } else {
235:                       return this.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(node.parentNode);
236:                   }
237:               }-*/;
238:
239:            /**
240:             * Return the node immediately preceding this node in the tree, or null if there is no sibling node.
241:             *
242:             * @return this nodes previosu sibling
243:             */
244:            public native Node getPreviousSibling() /*-{
245:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
246:                   if(node.previousSibling == null || node.previousSibling === undefined)  {
247:                       return null;
248:                   } else {
249:                       return this.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(node.previousSibling);
250:                   }
251:               }-*/;
252:
253:            /**
254:             * Insert node as the last child node of this node.
255:             *
256:             * @param child node to append
257:             */
258:            public native void appendChild(Node child) /*-{
259:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
260:                   var childJS = child.@com.gwtext.client.core.JsObject::getJsObj()();
261:                   node.appendChild(childJS);
262:               }-*/;
263:
264:            /**
265:             * Bubbles up the tree from this node, calling the specified function with each node. If the callback method returns false at
266:             * any point, the bubble is stopped.
267:             *
268:             * @param cb the callback function handle
269:             */
270:            public native void bubble(NodeTraversalCallback cb)/*-{
271:                    var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
272:                              var nodeJ = this;
273:                              node.bubble(function(n) {
274:                                  var nj = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(n);
275:                                  return cb.@com.gwtext.client.data.NodeTraversalCallback::execute(Lcom/gwtext/client/data/Node;)(nj);
276:                        });
277:                }-*/;
278:
279:            /**
280:             * Cascades down the tree from this node, calling the specified function with each node. If the callback method returns
281:             * false at any point, the cascade is stopped on that branch.
282:             *
283:             * @param cb the callback function handle
284:             */
285:            public native void cascade(NodeTraversalCallback cb)/*-{
286:                    var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
287:                         var nodeJ = this;
288:                         node.cascade(function(n) {
289:                             var nj = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(n);
290:                             return cb.@com.gwtext.client.data.NodeTraversalCallback::execute(Lcom/gwtext/client/data/Node;)(nj);
291:                         });
292:                }-*/;
293:
294:            /**
295:             * Returns true if this node is an ancestor (at any point) of the passed node.
296:             *
297:             * @param child the node
298:             * @return true if contains
299:             */
300:            public native boolean contains(Node child) /*-{
301:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
302:                   var childJS = child.@com.gwtext.client.core.JsObject::getJsObj()();
303:                   return node.contains(childJS);
304:               }-*/;
305:
306:            /**
307:             * Interates the child nodes of this node, calling the specified function with each node. If the callback function
308:             * returns false at any point, the iteration stops.
309:             *
310:             * @param cb the callback function handle
311:             */
312:            public native void eachChild(NodeTraversalCallback cb)/*-{
313:                    var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
314:                         var nodeJ = this;
315:                         node.eachChild(function(n) {
316:                             var nj = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(n);
317:                             return cb.@com.gwtext.client.data.NodeTraversalCallback::execute(Lcom/gwtext/client/data/Node;)(nj);
318:                         });
319:                     }-*/;
320:
321:            //skipping findChild in favor of more powerful and flexible findChildBy API
322:            /**
323:             * Finds the first child by a custom callback function. The child matches if the function passed returns true.
324:             *
325:             * @param cb the callback function handle
326:             * @return the child or null if not found
327:             */
328:            public native Node findChildBy(NodeTraversalCallback cb)/*-{
329:                    var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
330:                    var nodeJ = this;
331:                    var nodeC = node.findChildBy(function(n) {
332:                             var nj = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(n);
333:                             return cb.@com.gwtext.client.data.NodeTraversalCallback::execute(Lcom/gwtext/client/data/Node;)(nj);
334:                    });
335:                    return nodeC == null ? null : nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(nodeC);
336:                }-*/;
337:
338:            /**
339:             * Returns depth of this node (the root node has a depth of 0).
340:             *
341:             * @return the depth of this node
342:             */
343:            public native int getDepth() /*-{
344:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
345:                   return node.getDepth();
346:               }-*/;
347:
348:            /**
349:             * Returns the tree this node is in.
350:             *
351:             * @return the owner tree
352:             */
353:            public native Tree getOwnerTree()/*-{
354:                    var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
355:                    var treeJS = node.getOwnerTree();
356:                    return treeJS == null ? null : @com.gwtext.client.data.Tree::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(treeJS);
357:                }-*/;
358:
359:            /**
360:             * Returns the path for this node. The path can be used to expand or select this node programmatically.
361:             *
362:             * @return the path
363:             */
364:            public native String getPath() /*-{
365:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
366:                   return node.getPath();
367:               }-*/;
368:
369:            /**
370:             * Returns the path for this node. The path can be used to expand or select this node programmatically.
371:             *
372:             * @param attr the attr to use for the path (defaults to the node's id)
373:             * @return the path
374:             */
375:            public native String getPath(String attr) /*-{
376:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
377:                   return node.getPath(attr);
378:               }-*/;
379:
380:            /**
381:             * Returns the index of a child node.
382:             *
383:             * @param child the child node
384:             * @return the index of the node or -1 if it was not found
385:             */
386:            public native int indexOf(Node child) /*-{
387:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
388:                   var childJS = child.@com.gwtext.client.core.JsObject::getJsObj()();
389:                   return node.indexOf(childJS);
390:               }-*/;
391:
392:            /**
393:             * Inserts the first node before the second node in this nodes childNodes collection.
394:             *
395:             * @param node    the node to insert
396:             * @param nodeRef the node to insert before (if null the node is appended)
397:             * @return the inserted node
398:             */
399:            public native Node insertBefore(Node node, Node nodeRef) /*-{
400:                   var self = this.@com.gwtext.client.core.JsObject::getJsObj()();
401:                   var node1 = node.@com.gwtext.client.core.JsObject::getJsObj()();
402:                   var node2 = nodeRef.@com.gwtext.client.core.JsObject::getJsObj()();
403:                   self.insertBefore(node1, node2);
404:                   return node;
405:               }-*/;
406:
407:            /**
408:             * Returns true if the passed node is an ancestor (at any point) of this node.
409:             *
410:             * @param node the node to test
411:             * @return true of ancestor
412:             */
413:            public native boolean isAncestor(Node node) /*-{
414:                   var self = this.@com.gwtext.client.core.JsObject::getJsObj()();
415:                   var nodeJS = node.@com.gwtext.client.core.JsObject::getJsObj()();
416:                   return self.isAncestor(nodeJS);
417:               }-*/;
418:
419:            /**
420:             * Returns true if this node is the first child of its parent.
421:             *
422:             * @return true if first node
423:             */
424:            public native boolean isFirst() /*-{
425:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
426:                   return node.isFirst();
427:               }-*/;
428:
429:            /**
430:             * Returns true if this node is the last child of its parent.
431:             *
432:             * @return true if last
433:             */
434:            public native boolean isLast() /*-{
435:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
436:                   return node.isLast();
437:               }-*/;
438:
439:            /**
440:             * Returns true if this node is a leaf.
441:             *
442:             * @return true if leaf node
443:             */
444:            public native boolean isLeaf() /*-{
445:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
446:                   return node.isLeaf();
447:               }-*/;
448:
449:            /**
450:             * Returns the child node at the specified index.
451:             *
452:             * @param index the index
453:             * @return the child at index, null if none present
454:             */
455:            public native Node item(int index)/*-{
456:                    var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
457:                    var itemNode = node.item(index);
458:                    if(itemNode == null || itemNode === undefined) return null;
459:                    return this.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(itemNode);
460:                }-*/;
461:
462:            /**
463:             * Removes this node from it's parent.
464:             */
465:            public native void remove() /*-{
466:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
467:                   node.remove();
468:               }-*/;
469:
470:            /**
471:             * Removes a child node from this node.
472:             *
473:             * @param child the node to remove
474:             * @return the removed node
475:             */
476:            public native Node removeChild(Node child) /*-{
477:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
478:                   var childJS = child.@com.gwtext.client.core.JsObject::getJsObj()();
479:                   var nodeRemoved = node.removeChild(childJS);
480:                   if(nodeRemoved == null || nodeRemoved === undefined) return null;
481:                   return this.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(nodeRemoved);
482:               }-*/;
483:
484:            /**
485:             * Replaces one child node in this node with another.
486:             *
487:             * @param newChild the replacement node
488:             * @param oldChild the node to replace
489:             * @return the replaced node
490:             */
491:            public native Node replaceChild(Node newChild, Node oldChild) /*-{
492:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
493:                   var newChildJS = newChild.@com.gwtext.client.core.JsObject::getJsObj()();
494:                   var oldChildJS = oldChild.@com.gwtext.client.core.JsObject::getJsObj()();
495:                   var nodeReplaced = node.replaceChild(newChildJS, oldChildJS);
496:                   if(nodeReplaced == null || nodeReplaced === undefined) return null;
497:                   return this.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(nodeReplaced);
498:               }-*/;
499:
500:            /**
501:             * Sorts this nodes children using the supplied sort function.
502:             *
503:             * @param c the Comparator return 0 if equal, -1 if first node less than second, 1 if first greater than second
504:             */
505:            public native void sort(Comparator c) /*-{
506:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
507:                   var nodeJ = this;
508:                   node.sort(function(n1, n2) {
509:                       var n1J = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(n1);
510:                       var n2J = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(n2);
511:                       return c.@java.util.Comparator::compare(Ljava/lang/Object;Ljava/lang/Object;)(n1J, n2J);
512:                   })
513:               }-*/;
514:
515:            /**
516:             * Add a Node listener.
517:             *
518:             * @param listener the listener
519:             */
520:            public native void addListener(NodeListener listener) /*-{
521:                   
522:                   var node = this.@com.gwtext.client.core.JsObject::getJsObj()();
523:                   var nodeJ = this;
524:
525:            	node.addListener('append',
526:            				function(tree, self, newNode, index) {
527:            					var treeJ = @com.gwtext.client.data.Tree::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(tree);
528:            					var newNodeJ = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(newNode);
529:            					listener.@com.gwtext.client.data.event.NodeListener::onAppend(Lcom/gwtext/client/data/Tree;Lcom/gwtext/client/data/Node;Lcom/gwtext/client/data/Node;I)(treeJ, nodeJ, newNodeJ, index);
530:            				}
531:            	);
532:
533:            	node.addListener('beforeappend',
534:            				function(tree, self, newNode) {
535:            					var treeJ = @com.gwtext.client.data.Tree::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(tree);
536:            					var newNodeJ = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(newNode);
537:            					return listener.@com.gwtext.client.data.event.NodeListener::doBeforeAppend(Lcom/gwtext/client/data/Tree;Lcom/gwtext/client/data/Node;Lcom/gwtext/client/data/Node;)(treeJ, nodeJ, newNodeJ);
538:            				}
539:            	);
540:
541:            	node.addListener('beforeinsert',
542:            				function(tree, self, newNode, refNode) {
543:            					var treeJ = @com.gwtext.client.data.Tree::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(tree);
544:            					var newNodeJ = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(newNode);
545:            					var refNodeJ = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(refNode);
546:            					return listener.@com.gwtext.client.data.event.NodeListener::doBeforeInsert(Lcom/gwtext/client/data/Tree;Lcom/gwtext/client/data/Node;Lcom/gwtext/client/data/Node;Lcom/gwtext/client/data/Node;)(treeJ, nodeJ, newNodeJ, refNodeJ);
547:            				}
548:            	);
549:
550:            	node.addListener('beforemove',
551:            				function(tree, self, oldParent, newParent, index) {
552:            					var treeJ = @com.gwtext.client.data.Tree::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(tree);
553:            					var oldParentJ = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(oldParent);
554:            					var newParentJ = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(newParent);
555:            					return listener.@com.gwtext.client.data.event.NodeListener::doBeforeMove(Lcom/gwtext/client/data/Tree;Lcom/gwtext/client/data/Node;Lcom/gwtext/client/data/Node;Lcom/gwtext/client/data/Node;I)(treeJ, nodeJ, oldParentJ, newParentJ, index);
556:            				}
557:            	);
558:
559:            	node.addListener('beforeremove',
560:            				function(tree, self, removeNode) {
561:            					var treeJ = @com.gwtext.client.data.Tree::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(tree);
562:            					var removeNodeJ = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(removeNode);
563:            					return listener.@com.gwtext.client.data.event.NodeListener::doBeforeRemove(Lcom/gwtext/client/data/Tree;Lcom/gwtext/client/data/Node;Lcom/gwtext/client/data/Node;)(treeJ, nodeJ, removeNodeJ);
564:            				}
565:            	);
566:
567:            	node.addListener('insert',
568:            				function(tree, self, newNode, refNode) {
569:            					var treeJ = @com.gwtext.client.data.Tree::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(tree);
570:            					var newNodeJ = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(newNode);
571:            					var refNodeJ = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(refNode);
572:            					listener.@com.gwtext.client.data.event.NodeListener::onInsert(Lcom/gwtext/client/data/Tree;Lcom/gwtext/client/data/Node;Lcom/gwtext/client/data/Node;Lcom/gwtext/client/data/Node;)(treeJ, nodeJ, newNodeJ, refNodeJ);
573:            				}
574:            	);
575:
576:            	node.addListener('move',
577:            				function(tree, self, oldParent, newParent, index) {
578:            					var treeJ = @com.gwtext.client.data.Tree::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(tree);
579:            					var oldParentJ = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(oldParent);
580:            					var newParentJ = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(newParent);
581:            					listener.@com.gwtext.client.data.event.NodeListener::onMove(Lcom/gwtext/client/data/Tree;Lcom/gwtext/client/data/Node;Lcom/gwtext/client/data/Node;Lcom/gwtext/client/data/Node;I)(treeJ, nodeJ, oldParentJ, newParentJ, index);
582:            				}
583:            	);
584:
585:            	node.addListener('remove',
586:            				function(tree, self, removeNode) {
587:            					var treeJ = @com.gwtext.client.data.Tree::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(tree);
588:            					var removeNodeJ = nodeJ.@com.gwtext.client.data.Node::createNode(Lcom/google/gwt/core/client/JavaScriptObject;)(removeNode);
589:            					listener.@com.gwtext.client.data.event.NodeListener::onRemove(Lcom/gwtext/client/data/Tree;Lcom/gwtext/client/data/Node;Lcom/gwtext/client/data/Node;)(treeJ, nodeJ, removeNodeJ);
590:            				}
591:            	);
592:             }-*/;
593:
594:            public boolean equals(Object o) {
595:                if (this  == o)
596:                    return true;
597:                if (o == null || !(o instanceof  Node))
598:                    return false;
599:
600:                Node node = (Node) o;
601:                String id = getId();
602:                String oid = node.getId();
603:                if (id != null ? !id.equals(oid) : oid != null)
604:                    return false;
605:                return true;
606:            }
607:
608:            public int hashCode() {
609:                String id = getId();
610:                return (id != null ? id.hashCode() : 0);
611:            }
612:
613:            //config options
614:
615:            private Object userObject;
616:
617:            /**
618:             * Associate a user defined Object with the node.
619:             *
620:             * @param userObject the user data object
621:             */
622:            public void setUserObject(Object userObject) {
623:                if (!isCreated()) {
624:                    this .userObject = userObject;
625:                } else {
626:                    setUserObjectCreated(userObject);
627:                }
628:            }
629:
630:            /**
631:             * Return the user defined object
632:             *
633:             * @return the user defined object
634:             */
635:            public Object getUserObject() {
636:                if (!isCreated()) {
637:                    return userObject;
638:                } else {
639:                    return getUserObjectCreated();
640:                }
641:            }
642:
643:            /**
644:             * Set the Node's ID.
645:             *
646:             * @param id the node ID
647:             */
648:            public void setId(String id) {
649:                if (!isCreated()) {
650:                    JavaScriptObjectHelper.setAttribute(configJS, "id", id);
651:                } else {
652:                    setIdCreated(id);
653:                }
654:            }
655:
656:            /**
657:             * Sets whether the node is a leaf.
658:             *
659:             * @param leaf true if leaf
660:             */
661:            public void setLeaf(boolean leaf) {
662:                JavaScriptObjectHelper.setAttribute(configJS, "leaf", leaf);
663:            }
664:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.