01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.client.widgets.tree;
09:
10: import com.gwtext.client.core.BaseConfig;
11: import com.gwtext.client.core.SortDir;
12: import com.gwtext.client.util.JavaScriptObjectHelper;
13:
14: /**
15: * Configuration class for {@link TreeSorter}.
16: */
17: public class TreeSorterConfig extends BaseConfig {
18:
19: /**
20: * True for case sensitive sort (defaults to false)
21: *
22: * @param caseSensitive true for case sensitive sort
23: */
24: public void setCaseSensitive(boolean caseSensitive) {
25: JavaScriptObjectHelper.setAttribute(jsObj, "caseSensitive",
26: caseSensitive);
27: }
28:
29: /**
30: * The direction to sort (asc or desc) (defaults to asc).
31: *
32: * @param dir the sort direction
33: */
34: public void setDir(SortDir dir) {
35: JavaScriptObjectHelper.setAttribute(jsObj, "dir", dir
36: .getDirection().toLowerCase());
37: }
38:
39: /**
40: * True to sort leaf nodes under non leaf nodes.
41: *
42: * @param folderSort true to sort leaf nodes under non leaf nodes.
43: */
44: public void setFolderSort(boolean folderSort) {
45: JavaScriptObjectHelper.setAttribute(jsObj, "folderSort",
46: folderSort);
47: }
48:
49: /**
50: * The attribute used to determine leaf nodes in folder sort (defaults to "leaf")
51: *
52: * @param leafAttr the leaf attribute
53: */
54: public void setLeafAttr(String leafAttr) {
55: JavaScriptObjectHelper
56: .setAttribute(jsObj, "leafAttr", leafAttr);
57: }
58:
59: /**
60: * The named attribute on the node to sort by (defaults to text).
61: *
62: * @param property the sort property
63: */
64: public void setProperty(String property) {
65: JavaScriptObjectHelper
66: .setAttribute(jsObj, "property", property);
67: }
68:
69: /**
70: * A custom function used to convert node values before sorting.
71: *
72: * @param sortType the sort function
73: */
74: public native void setSortType(TreeSortFunction sortType) /*-{
75: var config = this.@com.gwtext.client.core.JsObject::getJsObj()();
76: config['sortType'] = function(node) {
77: var nodeJ = @com.gwtext.client.widgets.tree.TreeNode::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(node);
78: return sortType.@com.gwtext.client.widgets.tree.TreeSortFunction::sortValue(Lcom/gwtext/client/widgets/tree/TreeNode;)(nodeJ);
79: }
80: }-*/;
81: }
|