诗歌常识题库

当前位置:首页 > 当代文学 > GXT —— TreePanel 组件(一)

GXT —— TreePanel 组件(一)

时间:2019-08-13 整理:本站 点击:141次
示例源码这里以菜单为例,来展示TreePanel的使用。 ;;;;;;;;;;;;;;;;;;;;TreeExampleContentPanel{TreeExample(){setHea...

	GXT —— TreePanel 组件(一)

示例源码这里以菜单为例,来展示TreePanel的使用。

;;;;;;;;;;;;;;;;;;;;TreeExampleContentPanel{TreeExample(){setHeadingHtml("TreeExample");setSize(250,400);setLayout(AccordionLayout());ModelTypemodelType=ModelType();();();();(_TYPE);(_LEVEL);(_NODE_ID);Stringurl=()+"menu/";RequestBuilderbuilder=RequestBuilder(,url);HttpProxyListModelDataproxy=HttpProxyListModelData(builder);JsonReaderListModelDatareader=JsonReaderListModelData(modelType);(reader,,AsyncCallbackListModelData(){onSuccess(ListModelDataresult){ListTreeNodetreeNodes=(result);ListTreeNodepanels=ArrayListTreeNodeListTreeNoderoots=ArrayListTreeNodeListTreeNodeleafs=ArrayListTreeNode(TreeNodenode:treeNodes){(().ordinal()==()){(node);}(().ordinal()==()){(node);}{(node);}}(panels);onRender(panels,roots,leafs);layout();}onFailure(Throwablecaught){}});}onRender(ListTreeNodepanels,ListTreeNoderoots,ListTreeNodeleafs){(TreeNodepanelNode:panels){ContentPanelpanel=ContentPanel();(());TreeStoreModelDatastore=TreeStoreModelDataTreePanelModelDatatree=TreePanelModelData(store);();ListTreeNodepanelNodeChildren=hasChildrenNode(panelNode,roots);(()0){(TreeNoderoot:panelNodeChildren){ListTreeNoderootNodeChildren=hasChildrenNode(root,leafs);ModelDatamodelData=(root);(()0){(modelData,);(TreeNodeleaf:rootNodeChildren){ModelDatam=(leaf);(modelData,m,);}}{(modelData,);}(modelData,);}}(tree);add(panel);}}ListTreeNodehasChildrenNode(TreeNodenode,ListTreeNodenodes){ListTreeNodechildren=ArrayListTreeNode(()0){(TreeNoden:nodes){(()==()){(n);}}}(()0){(children);}children;}}这里需要注意的是,取树节点数据这个过程是在异步回调方法里面完成的。 在这期间内,页面上的ContentPanel是已经被渲染出来了的,但这个ContentPanel里面的内容是空的,什么都还没有,因为这时候异步回调方法还没有执行完成,自然是没有数据。 在异步回调方法的最后不要忘记去调一下layout(true),来重新渲染一次ContentPanel,否则面板内容是空的。

;;;;;;;;ControllerRequestMapping("/menu")TreeNodeController{ResourceDataServiceservice;RequestMapping("/treenodes")StringfindTreeNodes(Modelmodel){(,(,()));_CODE;}};;;;;;ServiceDataService{ResourceDatadata;ListTreeNodefindTreeNodes(){();}};;;;;;ComponentData{ListTreeNodetreeNodes;ListTreeNodebuildTreeNodes(){ListTreeNodetreeNodes=ArrayListTreeNodeTreeNodeusersManagementNode=TreeNode("用户管理",,0);TreeNodegoodsManagementNode=TreeNode("商品管理",,1);TreeNodeorderManagementNode=TreeNode("订单管理",,2);(usersManagementNode);(goodsManagementNode);(orderManagementNode);(TreeNode("系统用户管理",,0,()));(TreeNode("会员账号管理",,1,()));(TreeNode("在售商品",,2,()));(TreeNode("下架商品",,3,()));(TreeNode("缺货通知",,4,()));(TreeNode("到货通知",,5,()));(TreeNode("未确认订单",,6,()));(TreeNode("待发货订单",,7,()));(TreeNode("已发货订单",,8,()));(TreeNode("未付款订单",,9,()));(TreeNode("已完成订单",,10,()));.treeNodes=treeNodes;treeNodes;}ListTreeNodegetTreeNodes(){treeNodes==buildTreeNodes():treeNodes;}};;;;;;;;TreeNodeUtil{TreeNodeUtil(){}TreeNodemodelData2TreeNode(ModelDatamodelData){TreeNodenode=TreeNode();Doubleid=();Stringtext=();DoublepriorLevel=(_LEVEL);DoubleparentNodeId=(_NODE_ID);Stringtype=(_TYPE);NodeTypenodeType=(type);(());(text);(nodeType);(());(());node;}ListTreeNodemodelDatas2TreeNodes(ListModelDatamodelDatas){ListTreeNodetreeNodes=ArrayListTreeNode(ModelDatamodelData:modelDatas){(modelData2TreeNode(modelData));}treeNodes;}ModelDatatreeNode2ModelData(TreeNodetreeNode){ModelDatamodelData=BaseModelData();(,());(,());(_LEVEL,());(_NODE_ID,());(_TYPE,().getValue());modelData;}ListModelDatatreeNodes2ModelDatas(ListTreeNodetreeNodes){ListModelDatamodelDatas=ArrayListModelData(TreeNodetreeNode:treeNodes){(treeNode2ModelData(treeNode));}modelDatas;}};TreeNodeComparableTreeNode{id;count;Stringtext;NodeTypenodeType;priorLevel;parentNodeId;NULL=-1;TreeNode(){.id=++count;}TreeNode(Stringtext,NodeTypenodetype,priorLevel){(text,nodetype,priorLevel,NULL);}TreeNode(Stringtext,NodeTypenodetype,priorLevel,parentNodeId){();.text=text;.nodeType=nodetype;.priorLevel=priorLevel;.parentNodeId=parentNodeId;}NodeType{ROOT("ROOT"),LEAF("LEAF"),PANEL("PANEL");Stringvalue;NodeType(Stringvalue){.value=value;}StringgetValue(){value;}NodeTypevalueOfString(Stringvalue){(("ROOT")){ROOT;}(("LEAF")){LEAF;}(("PANEL")){PANEL;}}OverrideStringtoString(){value;}}OverridecompareTo(TreeNodeo){.:-1;}StringgetText(){text;}setText(Stringtext){.text=text;}NodeTypegetNodeType(){nodeType;}setNodeType(NodeTypenodeType){.nodeType=nodeType;}getPriorLevel(){priorLevel;}setPriorLevel(priorLevel){.priorLevel=priorLevel;}getParentNodeId(){parentNodeId;}setParentNodeId(parentNodeId){.parentNodeId=parentNodeId;}getId(){id;}setId(id){.id=id;}};ITreeNode{StringID="id";StringTEXT="text";StringNODE_TYPE="nodeType";StringPRIOR_LEVEL="priorLevel";StringPARENT_NODE_ID="parentNodeId";}。

------分隔线----------------------------

本月热点

网站地图 | 由诗歌常识题库提供的文章均由网友转载于网络,若本站转载中的文章侵犯了您的权益,请与本站管理员联系. Copyright © 2006-2019 www.hf0866.com诗歌常识题库-诗歌范文-诗歌网 All Rights Reserved.