       @setClass "expanded"
       callback?()
 
+
   collapse:(callback)->
 
     if @getOptions().animated

      @unsetClass "expanded"
      callback?()

  mouseDown:->

    KD.getSingleton("windowController").setKeyView @
    no

  keyDown:(event)->

    @emit "KeyDownOnTreeView", event

  destroy:->

    KD.getSingleton("windowController").revertKeyView @

    super


module.exports = class JTreeView extends KDListView

  constructor:(options = {}, data)->

    options.animated ?= no
    options.cssClass  = KD.utils.curry 'jtreeview expanded', options.cssClass

    super options, data


  toggle:(callback)->

    if @expanded then @collapse callback else @expand callback


  expand:(callback)->

