def refresh_button_state( self ):
    
    bake_layers = pmc.ls( typ = 'BakeLayer' )
    
    one_selected = False
    if pmc.treeView( self.__layer_tree, q = True, si = True ) == None:
      pass 
    elif len( pmc.treeView( self.__layer_tree, q = True, si = True ) ) == 1:
      one_selected = True
      sel_layer = pmc.treeView( self.__layer_tree, q = True, si = True )[ 0 ]
    
    connected_layers = [ ]
    
    if one_selected:
      selected_is_high = utils.is_high( sel_layer )
      if selected_is_high:
        connected_layers = utils.get_connected_low_layers( sel_layer )
      else:
        connected_layers = utils.get_connected_high_layers( sel_layer )
    

    for layer in bake_layers:
      
      if one_selected == True:
        if selected_is_high == utils.is_high( layer ):
          pmc.treeView( self.__layer_tree,
                        e = True,
                        eb = ( layer, 2, False ),
                        i = ( layer, 2, '' ) )
          
          
        
        else:
          if utils.get_bake_layer( layer ) in connected_layers:
            image = bake_layer_tool.get_image( 'link_icon.png' )
          else:
            image = bake_layer_tool.get_image( 'unlink_icon.png' )
  
            
          pmc.treeView( self.__layer_tree,
                        e = True,
                        eb = ( layer, 2, True ),
                        i = ( layer, 2, image ) )
      
      else:
        pmc.treeView( self.__layer_tree,
                      e = True,
                      eb = ( layer, 2, False ),
                      i = ( layer, 2, '' ) )
  def refresh( self ):

    bake_layers = pmc.ls( typ = 'BakeLayer' )
    
    for layer in bake_layers:
      pass

    # Build the new layout
    
    pmc.treeView( self.__layer_tree, e = True, removeAll = True )
    
    for layer in bake_layers:
      
      # Create Button
      if utils.is_high( layer ):
        h_l_button = 'H'
        low = False
        rd_button = False
      else:
        h_l_button = 'L'
        low = True
        rd_button = bake_layer_tool.get_image( 'ray_dist.png' )

      pmc.treeView( self.__layer_tree,
                    e = True,
                    addItem = ( layer.name( ), '' ) )
      
      pmc.treeView( self.__layer_tree,
                    e = True,
                    bti = ( layer.name( ), 1, h_l_button ) )
      
      
      pmc.treeView( self.__layer_tree,
                    e = True,
                    eb = ( layer, 3, low ),
                    i = ( layer, 3, rd_button ) )
      
      
      
    self.refresh_button_state()