private void buildTree ( MapModel mapModel ) { treeGrid . setWidth100 ( ) ; treeGrid . setHeight100 ( ) ; treeGrid . setShowHeader ( false ) ; tree = new RefreshableTree ( ) ; final TreeNode nodeRoot = new TreeNode ( "ROOT" ) ; tree . setRoot ( nodeRoot ) ; // invisible ROOT node (ROOT node is required) ClientLayerTreeInfo layerTreeInfo = mapModel . getMapInfo ( ) . getLayerTree ( ) ; if ( layerTreeInfo != null ) { ClientLayerTreeNodeInfo treeNode = layerTreeInfo . getTreeNode ( ) ; processNode ( treeNode , nodeRoot , tree , mapModel , false ) ; } treeGrid . setData ( tree ) ; treeGrid . addLeafClickHandler ( this ) ; treeGrid . addFolderClickHandler ( this ) ; // -- add event listeners to layers for ( Layer < ? > layer : mapModel . getLayers ( ) ) { registrations . add ( layer . addLayerChangedHandler ( new LayerChangedHandler ( ) { public void onLabelChange ( LayerLabeledEvent event ) { } public void onVisibleChange ( LayerShownEvent event ) { for ( TreeNode node : tree . getAllNodes ( ) ) { if ( node . getName ( ) . equals ( event . getLayer ( ) . getLabel ( ) ) ) { if ( node instanceof LayerTreeTreeNode ) { ( ( LayerTreeTreeNode ) node ) . updateIcon ( ) ; } } } } } ) ) ; } }
Builds up the tree showing the layers