(function(){"use strict";u8.Crm.Widgets.ListingTree=function(e,t){this.Widget(e,$.extend({},u8.Crm.Widgets.ListingTree.defaults,t));$assert(this.model,"Missing required property 'model'.");$assert(u8.tools.isInstanceOfClass(this.model,"u8.Crm.Widgets.ListingTreeModel"),"Required property 'model' is invalid.");this.model.bind("onSelectionChange",this._onModelSelectionChange.bind(this));this._isCreated=false;this._create();u8.tools.createdWhenReady(this)};u8.Crm.Widgets.ListingTree.makeClass({name:"ListingTree",deriveFrom:u8.Base.Widgets.Widget,events:["Create","ValueChange"]});u8.Crm.Widgets.ListingTree.defaults={};$.extend(u8.Crm.Widgets.ListingTree.prototype,{setValue:function(e){if(e==this.value){return}this.value=e;this.model.setValue(e);if(this._isCreated){this.raise("ValueChange")}},getValue:function(){return this.value},_create:function(){var e=this.model.getSelection();this._tree=u8.widget("Tree",this.element,{parent:this,model:this.model.getTree(),selectedNode:e,onCheck:this._onNodeCheck.bind(this)});if(e){this._tree.setExpanded(e)}},_onNodeCheck:function(e,t){if(!t.node){return}this.model.setSelection(t.value?t.node:null)},_onModelSelectionChange:function(e){this.setValue(e.getValue())}})})();