/** * Project  : AMDA-NG * Name : PlotTab.js * @class amdaPlotComp.PlotTab * @extends Ext.form.Panel * @brief Tab content to define a plot * @author Benjamin Renard * @version $Id: PlotTab.js benjamin $ */ Ext.define('amdaPlotComp.PlotTabContent', { extend: 'Ext.form.Panel', requires: [ 'amdaUI.TimeSelectorUI', 'amdaPlotComp.PlotTree', 'amdaPlotComp.PlotOutputForm', 'amdaPlotComp.PlotElementPanel' ], //Link to the Plot Node plotNode: null, timeSelector: null, plotTree: null, plotElement: null, plotOutput: null, tabIndex: 0, constructor: function(config) { this.init(config); this.callParent(arguments); }, setTime : function(startDate, stopDate) { this.timeSelector.intervalSel.setInterval(startDate, stopDate); }, updateTimeObject : function() { var timeSource = this.timeSelector.getActiveTimeSource(); var tabForm = this.getForm(); tabForm.updateRecord(this.plotNode.get('object')); this.plotNode.get('object').set('timesrc', timeSource); if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) this.plotNode.get('object').set('timeTables',this.timeSelector.TTGrid.getStore().data.items); }, doPlot : function() { this.plotNode.get('object').set('tab-index', this.tabIndex); this.plotNode.get('object').set('tab-title', this.getPlotTitle()); this.plotNode.execute(); }, getPlotTitle: function() { return (this.plotNode.get('text') != '') ? this.plotNode.get('text') : 'Plot '+(this.tabIndex + 1); }, savePlot : function() { var object = this.plotNode.get('object'); if (!object) return; if ((object.get('id') != '') && (this.plotNode.get('text') == object.get('name'))) { //update existing request this.plotNode.update(); return; } //save new request var me = this; this.plotNode.isValidName(object.get('name'), function (res) { if (!res) { myDesktopApp.errorMsg('Error during object validation'); return; } if (!res.valid) { if (res.error) { if (res.error.search('subtree') != -1) { Ext.Msg.show( { title : 'Warning', msg: res.error + '
Do you want to overwrite it?', width: 300, buttons: Ext.Msg.OKCANCEL, icon: Ext.Msg.WARNING, fn : me.overwritePlot, scope : me }); } else { myDesktopApp.errorMsg(res.error); } } else { myDesktopApp.errorMsg('Invalid object name'); } return; } me.saveProcess(false); }); }, overwritePlot : function(btn) { if (btn == 'cancel') return; this.saveProcess(true); }, saveProcess : function(toRename) { if (toRename) { this.plotNode.update(); } else { if (this.plotNode.get('object').get('id') != '') { //Duplicate request var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); if (!plotModule) return; this.plotNode = plotModule.linkedNode.get('object').duplicatePlot(this.plotNode); this.updateUI(); } this.plotNode.create(); } }, updateUI : function() { this.plotOutput.setObject(this.plotNode.get('object')); this.timeSelector.intervalSel.setInterval(this.plotNode.get('object').get('startDate'), this.plotNode.get('object').get('stopDate')); this.timeSelector.setTTTab(this.plotNode.get('object').get('timeTables')); this.treePlot.buildTree(this.plotNode.get('object')); }, init : function(config) { this.plotNode = config.plotNode; this.tabIndex = config.tabIndex; this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelectorTab' + this.plotNode.id, border : false, flex: 6, collapsible: true, collapseDirection : 'bottom'} ); this.plotElement = new amdaPlotComp.PlotElementPanel({flex: 11}); this.treePlot = new amdaPlotComp.PlotTree({flex: 11, plotElementPanel: this.plotElement}); this.plotOutput = new amdaPlotComp.PlotOutputForm({flex: 6, collapseDirection : 'bottom', collapsible : true }); var treePanel = new Ext.form.Panel({ flex: 1, layout: { type: 'vbox', pack: 'start', align: 'stretch' }, bodyStyle: { background : '#dfe8f6' }, defaults: { border: false }, items: [ this.treePlot, this.timeSelector ] }); var optionsPanel = new Ext.form.Panel({ flex: 1, layout: { type: 'vbox', pack: 'start', align: 'stretch' }, bodyStyle: { background : '#dfe8f6' }, defaults: { border: false }, items: [ this.plotElement, this.plotOutput ] }); var myConf = { bodyStyle: { background : '#dfe8f6' }, border : false, defaults: { border: false }, layout: { type: 'hbox', pack: 'start', align: 'stretch' }, items: [ treePanel, optionsPanel ], listeners: { afterrender: function(comp, eOpts) { this.updateUI(); }, scope: this } }; Ext.apply (this , Ext.apply (arguments, myConf)); } });