text: Ext.define("Ozone.data.ActiveChannelModel",{extend:"Ext.data.Model",idProperty:"channel",fields:["channel"]});Ext.define("Ozone.data.ActiveLogModel",{extend:"Ext.data.Model",idProperty:"date",fields:["date","channel","message"]});Ext.define("Ozone.components.ChannelListenerPanel",{extend:"Ext.Viewport",alias:["widget.channellistenerpanel","widget.Ozone.components.ChannelListenerPanel"],cls:"channelListenerPanel",initComponent:function(){OWF.Chrome.insertHeaderButtons({items:[{xtype:"widgettool",icon:"./themes/common/images/skin/information.png",itemId:"help",handler:owfdojo.hitch(this,function(a,b){var c=Ozone.eventing.Widget.getInstance();var d=Ozone.state.WidgetState.getInstance({widgetEventingController:c,autoInit:true});if(d){d.getWidgetState({callback:function(e){if(!e.collapsed&&!e.minimized&&e.active){Ext.Msg.alert("About","Channel Listener Widget released with OWF "+Ozone.version.owfversion)}}})}})}]});if(Ozone.lang.getLanguage()=="es"){Ext.apply(this,{languageBundle:{channelSubscriptions:"Suscripciones del canal",addChannel:"Agregue el canal",activeChannels:"Canales activos",activityLog:"Registro de actividad",messageDetail:"Detalle del mensaje",clearLog:"Registro claro",exportLog:"Registro de la exportacion",date:"Fecha",channel:"Canal",message:"Mensaje"}})}else{Ext.apply(this,{languageBundle:{channelSubscriptions:"Channel Subscriptions",addChannel:"Add Channel",activeChannels:"Active Channels",activityLog:"Activity Log",messageDetail:"Message Detail",clearLog:"Clear Log",exportLog:"Export Log",date:"Date",channel:"Channel",message:"Message"}})}Ext.apply(this,{layout:{type:"border"},border:false,frame:false,items:[{itemId:"activeChannelPanel",xtype:"panel",title:this.languageBundle.channelSubscriptions,split:true,border:false,region:"north",width:250,height:150,minSize:100,collapsible:false,layout:"fit",dockedItems:[{xtype:"toolbar",dock:"top",items:[{itemId:"channelToolbarTextField",xtype:"textfield"},"|",{xtype:"button",itemId:"btnChannelToolbarAddChannel",text:this.languageBundle.addChannel,scope:this,handler:function(){this.subscribeToChannel()}},"|",{xtype:"button",text:"Clear Channels",scope:this,handler:function(){this.clearAllChannels()}}]}],items:[{itemId:"activeChannelGrid",xtype:"gridpanel",stateful:false,autoScroll:true,store:Ext.create("Ext.data.Store",{model:"Ozone.data.ActiveChannelModel",proxy:{type:"memory",reader:{root:"rows",type:"json"}}}),multiSelect:false,columns:[{id:"activeChannel",header:this.languageBundle.activeChannels,dataIndex:"channel",sortable:true,flex:1}],listeners:{afterrender:{fn:function(b){OWF.DragAndDrop.onDragStart(function(){b.dragging=true;b.getView().addCls("ddOver")});OWF.DragAndDrop.onDragStop(function(){b.dragging=false;b.getView().removeCls("ddOver")});OWF.DragAndDrop.onDrop(function(c){this.subscribeToChannel(c.dragDropData)},this);var a=b.getView();a.el.on("mouseover",function(d,c,f){if(b.dragging){OWF.DragAndDrop.setDropEnabled(true)}},this);a.el.on("mouseout",function(d,c,f){if(b.dragging){OWF.DragAndDrop.setDropEnabled(false)}},this)},scope:this}}}]},{itemId:"activityLogPanel",region:"center",split:true,border:false,collapsible:false,title:this.languageBundle.activityLog,layout:"fit",dockedItems:[{xtype:"toolbar",dock:"top",items:[{xtype:"button",text:this.languageBundle.messageDetail,scope:this,handler:function(g){var b=this.down("#activityLogGrid");var d=b.getSelectionModel().getSelection();var c=d[0];if(c!==undefined&&c!==null){var e=c.data.message;var a=new Ext.Window({title:"Channel:"+c.data.channel+" on "+c.data.date,height:400,width:400,layout:"fit",items:[{xtype:"textarea",hideLabel:true,value:Ext.htmlDecode(e)}]});a.show()}}},"|",{xtype:"button",text:this.languageBundle.clearLog,scope:this,handler:function(b){var a=this.down("#activityLogGrid");a.getStore().removeAll()}},"|",{xtype:"button",text:this.languageBundle.exportLog,scope:this,handler:function(j){var a=[];a.push("<items>");var e=this.down("#activityLogGrid");var c=e.getStore();for(var d=0;d<c.getCount();d++){var h=c.getAt(d);a.push("<item>");a.push("<date>"+h.data.date+"</date>");a.push("<channel>"+Ext.htmlDecode(h.data.channel)+"</channel>");a.push("<message>"+Ext.htmlDecode(h.data.message)+"</message>");a.push("</item>")}a.push("</items>");var g=a.join("");var b=new Ext.Window({title:"XML Export",height:400,width:400,layout:"fit",items:[{xtype:"textarea",hideLabel:true,value:g}]});b.show()}}]}],items:[{itemId:"activityLogGrid",xtype:"gridpanel",autoScroll:true,stateful:false,store:Ext.create("Ext.data.Store",{model:"Ozone.data.ActiveLogModel",proxy:{type:"memory",reader:{root:"rows",type:"json"}}}),multiSelect:false,columns:[{header:this.languageBundle.date,dataIndex:"date",renderer:Ext.util.Format.dateRenderer("Y-m-d H:i:s:u"),sortable:true,width:150},{header:this.languageBundle.channel,dataIndex:"channel",sortable:true},{id:"message",header:this.languageBundle.message,dataIndex:"message",sortable:true,flex:1}],listeners:{itemdblclick:{fn:function(f,b,h,c,d,j){var a=b;if(a!==undefined&&a!==null){var i=a.data.message;var g=new Ext.Window({title:"Channel:"+a.data.channel+" on "+a.data.date,height:400,width:400,layout:"fit",items:[{xtype:"textarea",hideLabel:true,value:Ext.htmlDecode(i)}]});g.show()}},scope:this}}}]}]});this.callParent();this.on({afterrender:{fn:function(b){var a=OWF.Launcher.getLaunchData();if(a!=null){var c=a;try{c=OWF.Util.parseJson(a)}catch(d){}if(c!=null){this.subscribeToChannel(c.channel);this.addToGrid(null,c.message,c.channel)}}},scope:this}})},subscribeToChannel:function(d){var c=this.down("#channelToolbarTextField");var b=this.down("#activeChannelGrid");var e=d?d:c.getValue();if(e!=null&&e!=""&&b.getStore().findExact("channel",e)==-1){var a=e;b.getStore().insert(0,{channel:Ext.htmlEncode(e)});OWF.Eventing.subscribe(a,owfdojo.hitch(this,this.addToGrid))}},clearAllChannels:function(){var a=this.down("#activeChannelGrid");if(a.getStore().getCount()>0){a.getStore().each(function(b){var c=b.data.channel;OWF.Eventing.unsubscribe(c)},this);a.getStore().removeAll()}},addToGrid:function(c,e,d){var a=d;var b=this.down("#activityLogGrid");b.getStore().insert(0,{date:new Date(),channel:Ext.htmlEncode(a),message:Ext.htmlEncode(e)})},down:function(a){if(this.cmpCache==null){this.cmpCache=Ext.create("Ext.util.MixedCollection")}var b=this.cmpCache.getByKey(a);if(b==null){b=this.callParent(arguments);if(b!=null){this.cmpCache.add(a,b)}}return b}});