PlotTabContent.js 2.44 KB
/**
 * 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'
    ],
	
    treePlot: null,
    
    //Link to the Plot Element Panel
    plotElementPanel: null,
    
    //linkk to the Plot Tab Panel
    plotTabPanel : null,
    
    //Link to the time selctor
    timeSelector : null,
    
    //Tab Object
    object: null,
    
    constructor: function(config) {
		this.init(config);	    
		this.callParent(arguments);
	},
	
	setTabObject : function(object) {
		this.object = object;
		this.treePlot.buildTree(this.object);
		this.timeSelector.intervalSel.setInterval(this.object.get('startDate'), this.object.get('stopDate'));
		this.addTTs(this.object.get('timeTables'));
	},
	
	addTTs : function(TTarray) {
		// set TTTab	    
		this.timeSelector.setTTTab(TTarray);
	},
	
	updateLinkedToMultiPlotMode : function (isLinkedToMultiPlotMode) {
		this.timeSelector.setVisible(!isLinkedToMultiPlotMode);
		this.plotTabPanel.updateLinkedToMultiPlotMode(isLinkedToMultiPlotMode);
	},
	
	updateTimeObject : function() {
		var timeSource = this.timeSelector.getActiveTimeSource();
    	var tabForm = this.getForm();
    	tabForm.updateRecord(this.object);
    	this.object.set('timesrc', timeSource);
    	if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
        	this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
	},
	
	init : function(config) {
		var me = this;
		
		this.plotElementPanel = config.plotElementPanel;
		this.plotTabPanel = config.plotTabPanel;
		
		this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelectorTab' + config.tabId, border : false, flex: 3, collapsible: true, collapseDirection : 'bottom',  hidden: true} );
		this.treePlot = new amdaPlotComp.PlotTree({flex: 5.6, plotElementPanel: this.plotElementPanel, plotTabContent: this});
		
		var myConf = {
				bodyStyle: { background : '#dfe8f6' },
				border : false,
				defaults: {
					border: false
				},
				layout: {
				    type: 'vbox',
				    pack: 'start',
				    align: 'stretch'
				},
				items: [
				        this.treePlot,
				        this.timeSelector
				]
		};
		
		Ext.apply (this , Ext.apply (arguments, myConf));
		
		
	}
});