/** * Project  : AMDA-NG * Name : MultiPlotUI.js * @class amdaUI.MultiPlotUI * @extends Ext. panel.Panel * @brief MultiPlot UI definition (View) * @author * @version $Id: MultiPlotUI.js benjamin */ Ext.define('amdaUI.MultiPlotUI', { extend: 'Ext.form.Panel', plotWin: null, timeSelector: null, plotSelector: null, constructor: function(config) { this.init(config); this.callParent(arguments); }, refreshMultiPlot: function() { var me = this; var tabsInfo = this.plotWin.plotTabs.getTabsInfo(); this.plotSelector.removeAll(); Ext.Array.each(tabsInfo, function(tabInfo) { me.plotSelector.add( { boxLabel: tabInfo.name, checked: tabInfo.object.get('multi-selected'), listeners: { change: function(field, newValue, oldValue, eOpts) { tabInfo.object.set('multi-selected', newValue); tabInfo.tabContent.enableTimeSelection(!newValue); } } } ); tabInfo.tabContent.enableTimeSelection(!tabInfo.object.get('multi-selected')); }); }, doMultiPlot: function() { if (!this.isValidRequest()) { return false; } // At least one plot must be selected var nbSelected = 0; this.plotSelector.items.each(function(item) { if (item.checked) ++nbSelected; }); if (nbSelected == 0) { myDesktopApp.errorMsg('At least one Plot must be selected'); return false; } this.plotWin.plotTabs.updatePlotTabs() // Execute multiplot request var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); plotModule.linkedNode.execute(); }, updateTimeObject : function() { var timeSource = this.timeSelector.getActiveTimeSource(); this.getForm().updateRecord(this.plotWin.object); this.plotWin.object.set('timesrc', timeSource); if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) this.plotWin.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items); }, isValidRequest : function() { this.updateTimeObject(); if (!this.timeSelector.isValid(false)) { myDesktopApp.errorMsg('Error in Time definition'); return false; } return true; }, init : function(config) { var me = this; this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'multiplot-time-selector', border : false, collapsible: false, height: 180} ); this.plotSelector = Ext.create('Ext.form.CheckboxGroup', { xtype: 'checkboxgroup', flex: 1, columns: 3, minHeight: 40, autoScroll: true, fieldLabel: 'Select plots to synchronize', labelAlign: 'top' }); var myConf = { layout: { type: 'vbox', pack: 'start', align: 'stretch' }, items: [ this.plotSelector, this.timeSelector ], listeners: { afterrender: function() { me.refreshMultiPlot(); me.timeSelector.intervalSel.setInterval(me.plotWin.object.get('startDate'), me.plotWin.object.get('stopDate')); me.timeSelector.intervalSel.updateStop(); me.timeSelector.setTTTab(me.plotWin.object.get('timeTables')); me.timeSelector.timeSrc.setActiveTab(me.plotWin.object.get('timesrc')); } }, fbar: [ '->', { xtype: 'button', text: 'Plot', scope: this, handler: function(button) { this.doMultiPlot(); } } ] }; Ext.apply(this, Ext.apply(arguments, myConf)); } });