/**
   * Initialize the LayerTree, using a MapWidget as base reference. It will display the map's
   * layers, as configured in the XML configuration, and select/deselect the layer as the user
   * clicks on them in the tree.
   *
   * @param mapWidget map widget this layer tree is connected to
   * @since 1.6.0
   */
  @Api
  public LayerTree(final MapWidget mapWidget) {
    super();
    setHeight100();
    this.mapModel = mapWidget.getMapModel();
    htmlSelectedLayer.setWidth100();

    // Wait for the MapModel to be loaded
    mapModel.addMapModelChangedHandler(
        new MapModelChangedHandler() {

          public void onMapModelChanged(MapModelChangedEvent event) {
            if (!initialized) {
              buildTree(mapModel);
              toolStrip = buildToolstrip(mapWidget);

              // display the toolbar and the tree
              VLayout vLayout = new VLayout();
              vLayout.setSize("100%", "100%");
              vLayout.addMember(toolStrip);
              htmlSelectedLayer.setBackgroundColor(WidgetLayout.layerTreeBackground);
              htmlSelectedLayer.setAlign(Alignment.CENTER);
              vLayout.addMember(htmlSelectedLayer);
              vLayout.addMember(treeGrid);
              LayerTree.this.addChild(vLayout);
            }
            initialized = true;
            treeGrid.markForRedraw();
            LayerTree.this.markForRedraw();
          }
        });
    mapModel.addLayerSelectionHandler(this);
  }