text: //>>built
  define("epi/shell/widget/_AddByDefinition",["dojo","dojo/_base/Deferred","dijit","dijit/_Widget","dijit/ToolbarSeparator","dijit/Menu","dijit/MenuSeparator","epi/shell/widget/WidgetFactory","dijit/CheckedMenuItem","dijit/MenuItem","dijit/form/Button","dijit/form/ComboButton","dijit/form/DropDownButton","dijit/form/RadioButton","epi/shell/widget/PopupMenuItem","epi/shell/widget/ToolbarGroup","epi/shell/widget/ToolbarLabel"],function(_1,_2,_3,_4,_5,_6,_7,_8){return _1.declare("epi.shell.widget._AddByDefinition",null,{_widgetTypeTemplates:{checkedmenuitem:{widgetType:"dijit.CheckedMenuItem"},menu:{widgetType:"dijit.Menu"},menuitem:{widgetType:"dijit.MenuItem"},popupmenu:{widgetType:"epi.shell.widget.PopupMenuItem"},button:{widgetType:"dijit.form.Button"},combo:{widgetType:"dijit.form.ComboButton"},dropdown:{widgetType:"epi.shell.widget.ToolbarDropDownButton"},radio:{widgetType:"dijit.form.RadioButton"},toolbargroup:{widgetType:"epi.shell.widget.ToolbarGroup"},label:{widgetType:"epi.shell.widget.ToolbarLabel"}},constructor:function(){this._widgetFactory=new _8();this._widgetMap={};},postMixInProperties:function(){this.connect(this._widgetFactory,"onWidgetHierarchyCreated",_1.hitch(this,function(_9,_a){this._widgetMap[_a.name]=_9;if(_a.firstChildIsContainer){_9.containerWidget=_9.getChildren()[0];}}));var _b=function(_c,_d){var _e=_c.get("dropDown");if(!_e){_e=new _6();_c.set("dropDown",_e);}_e.addChild(_d);if(!_d.separator){_d.set("separator","dijit.MenuSeparator");}};this._widgetFactory.addHandler("dijit.form.ComboButton",_b);},buildRendering:function(){this.inherited(arguments);_1.setSelectable(this.domNode,false);},_toComponentDefinition:function(_f){var _10=this._getComponentDefinitionTemplate(_f);_10.name=_f.name;_10.settings=_1.mixin({label:_f.label||"",showLabel:_f.label,title:_f.title||"",disabled:_f.disabled||false},_f.settings);if(_f.iconClass){_10.settings.iconClass=_f.iconClass;}var _11={onClick:_f.action};_10.connections=_1.mixin(_11,_f.connections);return _10;},_getComponentDefinitionTemplate:function(_12){var _13=_1.mixin({},this._widgetTypeTemplates[_12.type]||this._widgetTypeTemplates["button"]);if(_12.widgetType){_13.widgetType=_12.widgetType;}return _13;},_getWidget:function(_14){return this._widgetMap[_14];},_addSingle:function(_15){if(this._getWidget(_15.name)){return;}var _16=this._getWidget(_15.parent)||this;var _17=this._toComponentDefinition(_15);var def=new _2();_2.when(this._widgetFactory.createWidgets(_16,_17),_1.hitch(this,function(_18){var _19=_18[0];if(_15.tooltip){var _1a=_15.tooltip;var _1b=function(e){_3.showTooltip(_1a,e.target);};var _1c=function(e){_3.hideTooltip(e.target);};this.connect(_19.domNode,"onmouseenter",_1b);this.connect(_19.domNode,"onmouseleave",_1c);}this._addSeparators(_19);def.resolve();}),function(e){console.error(e.stack||e);def.reject(e);});return def;},_addSeparators:function(_1d){var _1e=_1d.getParent();if(!_1e){return;}var _1f=_1e.getChildren();var i=_1.indexOf(_1f,_1d);var _20=(i>0)?_1f[i-1]:null;if(_20&&!this._isSeparator(_20)){if(_1d.separate){this.addSeparator(_1d,"before");}else{if(_20.separate){this.addSeparator(_20,"after");}}}var _21=(_1f.length>i)?_1f[i+1]:null;if(_21&&!this._isSeparator(_21)&&(_1d.separate||_21.separate)){this.addSeparator(_1d,"after");}},_getSiblingOfWidget:function(_22,dir){var _23=_22.domNode;do{_23=_23[dir];}while(_23&&(_23.nodeType!=1||!_3.byNode(_23)));return _23&&_3.byNode(_23);},add:function(_24){var _25=this;var _26=function(_27){var _28=_27.shift();if(!_28){return null;}return _2.when(_25._addSingle(_28),function(){return _26(_27);});};if(_1.isArray(_24)){return _26(_24);}else{this._addSingle(_24);}},addSeparator:function(_29,_2a){var _2b=function(){if(_29.separator){var _2c=_29.separator.replace(/\./g,"/"),_2d=new _1.Deferred();require([_2c],function(_2e){_2d.resolve(new _2e());});return _2d;}return new _5();};_1.when(_2b(),_1.hitch(this,function(_2f){var _30=_29?_29.domNode:this.domNode;_1.place(_2f.domNode,_30,_2a);}));},_removeSingle:function(_31){var _32=this._widgetMap[_31];delete this._widgetMap[_31];if(_32){this._removeSeparators(_32);_32.destroy();}},_removeSeparators:function(_33){if(!_33.domNode){return;}var _34=_33.getParent();if(!_34){return;}var _35;var _36=_34.getChildren();var i=_1.indexOf(_36,_33);var _37=(_36.length>i)?_36[i+1]:null;var _38=(i>0)?_36[i-1]:null;if(_37&&this._isSeparator(_37)&&_36.length>=i+2){_35=_37;_37=_36[i+2];if(_37.separate&&i>0){if(_38&&this._isSeparator(_38)){_38.destroy();return;}}else{_35.destroy();}}if(_38&&this._isSeparator(_38)&&i-2>=0){_35=_38;_38=_36[i-2];if(!_38.separate){_35.destroy();}}},_isSeparator:function(_39){return _39 instanceof _3.ToolbarSeparator||_39 instanceof _3.MenuSeparator;},remove:function(_3a){if(_1.isArray(_3a)){_1.forEach(_3a,_1.hitch(this,this._removeSingle));}else{this._removeSingle(_3a);}},clear:function(){for(var _3b in this._widgetMap){this._removeSingle(_3b);}},destroy:function(){this.clear();this.inherited(arguments);},setItemProperty:function(_3c,_3d,_3e){if(_1.isArray(_3c)){_1.forEach(_3c,function(_3f){this._setInternal(_3f,_3d,_3e);});}else{this._setInternal(_3c,_3d,_3e);}},setItemVisibility:function(_40,_41){var _42=this._widgetMap[_40];if(_42){_1.style(_42.domNode,{visibility:(_41?"visible":"hidden")});}},_setInternal:function(_43,_44,_45){var _46=this._widgetMap[_43];if(_46){_46.set(_44,_45);}}});});