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.google.gwt.user.client.Element;
013: import com.gwtext.client.core.JsObject;
014:
015: /**
016: * This class provides the default UI implementation for TreeNodes. The TreeNode UI implementation is separate from the
017: * tree implementation, and allows customizing of the appearance of tree nodes.
018: *
019: * <p>
020: * This class provides access to the user interface components of an TreeNode, through {@link TreeNode#getUI()}.
021: *
022: */
023: public class TreeNodeUI extends JsObject {
024:
025: public TreeNodeUI(JavaScriptObject jsObj) {
026: super (jsObj);
027: }
028:
029: private static TreeNodeUI instance(JavaScriptObject jsObj) {
030: return new TreeNodeUI(jsObj);
031: }
032:
033: /**
034: * Adds one or more CSS classes to the node's UI element. Duplicate classes are automatically filtered out.
035: *
036: * @param cls the CSS class
037: */
038: public native void addClass(String cls) /*-{
039: var ui = this.@com.gwtext.client.core.JsObject::getJsObj()();
040: ui.addClass(cls);
041: }-*/;
042:
043: /**
044: * Removes one or more CSS classes from the node's UI element.
045: *
046: * @param cls the CSS class to remove
047: */
048: public native void removeClass(String cls) /*-{
049: var ui = this.@com.gwtext.client.core.JsObject::getJsObj()();
050: ui.removeClass(cls);
051: }-*/;
052:
053: /**
054: * Hides this node.
055: */
056: public native void hide() /*-{
057: var ui = this.@com.gwtext.client.core.JsObject::getJsObj()();
058: ui.hide();
059: }-*/;
060:
061: /**
062: * Shows this node.
063: */
064: public native void show() /*-{
065: var ui = this.@com.gwtext.client.core.JsObject::getJsObj()();
066: ui.show();
067: }-*/;
068:
069: /**
070: * Sets the checked status of the tree node to the passed value, or, if no value was passed, toggles the checked status.
071: * If the node was rendered with no checkbox, this has no effect.
072: */
073: public native void toggleCheck() /*-{
074: var ui = this.@com.gwtext.client.core.JsObject::getJsObj()();
075: ui.toggleCheck();
076: }-*/;
077:
078: /**
079: * Sets the checked status of the tree node to the passed value, or, if no value was passed, toggles the checked status.
080: * If the node was rendered with no checkbox, this has no effect.
081: *
082: * @param value the new checkbox status
083: */
084: public native void toggleCheck(boolean value) /*-{
085: var ui = this.@com.gwtext.client.core.JsObject::getJsObj()();
086: ui.toggleCheck(value);
087: }-*/;
088:
089: /**
090: * Highlight this node.
091: */
092: public native void highlight() /*-{
093: var ui = this.@com.gwtext.client.core.JsObject::getJsObj()();
094: ui.highlight();
095: }-*/;
096:
097: /**
098: * This returns an element that represents the whole subtree starting with itselt as the
099: * current node. The returned element has wtoe children. The first child represents its
100: * node, and is what is returned when getElNode() is called. The second child containts
101: * an array of its child elements.
102: *
103: * @return the subtree element
104: */
105: public native Element getEl() /*-{
106: var ui = this.@com.gwtext.client.core.JsObject::getJsObj()();
107: return ui.getEl();
108: }-*/;
109:
110: /**
111: * Element for 'this' node.
112: *
113: * @return the underlying element for this node
114: */
115: public native Element getElNode()/*-{
116: var ui = this.@com.gwtext.client.core.JsObject::getJsObj()();
117: return ui.elNode;
118: }-*/;
119:
120: /**
121: * Returns the checked status of the node. If the node was rendered with no checkbox, it returns false.
122: *
123: * @return true if checked
124: */
125: public native boolean isChecked() /*-{
126: var ui = this.@com.gwtext.client.core.JsObject::getJsObj()();
127: return ui.isChecked();
128: }-*/;
129: }
|