/** * Project  : AMDA-NG * Name : SampToolBarUI.js * @class amdaUI.SampToolBarUI * @extends Ext.toolbar.Toolbar * @brief Samp toolbar to show connection status (on the taskbar) (View) * @author Benjamin RENARD * @version $Id: SampToolBarUI.js 1088 2012-09-18 13:06:08Z benjamin $ ****************************************************************************** * FT Id : Date : Name - Description ****************************************************************************** * : :23/04/2012: BRE - file creation */ Ext.define ('amdaUI.SampToolBarUI',{ extend: 'Ext.toolbar.Toolbar', alias: 'widget.sampToolBar', constructor: function(config) { this.init(config); this.callParent(arguments); }, onSwitchConnect : Ext.emptyFn, updateStatus : function(isConnected) { var sampButton = this.items.items[1]; sampButton.setIconCls(isConnected ? 'icon-connected' : 'icon-disconnected'); }, updateClients : function(clientsStore) { for (var i = this.items.length-1; i >= 2; i--) this.remove(this.items.items[i].id); for (var i = 0; i < clientsStore.count(); i++) this.add({ xtype: 'box', autoEl: { tag: 'img', src: clientsStore.getAt(i).get('iconUrl'), width: 16, height : 16}}); this.width = 32 + clientsStore.count()*18; this.doLayout(); }, getSampItems : function() { var me = this; return [ '-', { name: 'SAMP connection', iconCls: 'icon-disconnected', tooltip: { text: 'SAMP connection', align: 'bl-tl' }, overflowText: 'SAMP connection', iconCls: 'icon-disconnected', scope: this, handler : function(obj, e) { e.stopEvent(); if (me.onSwitchConnect) me.onSwitchConnect(); } } ]; }, init : function(config) { var me = this; this.onSwitchConnect = config.onSwitchConnect; var myConf = { width : 32, items: me.getSampItems() }; Ext.apply (this , Ext.apply (arguments, myConf)); } });