ResultUI.js 1.73 KB
/**
 * Project   : AMDA-NG
 * Name      : ResultUI.js
 * @class 	 amdaUI.ResultUI
 * @extends  Ext. 
 * @brief	 Result  Module UI definition (View)
 * @author 	  
 * @version  $Id: ResultUI.js 1052 2012-07-20 14:21:37Z elena $            
 */

Ext.define('amdaUI.ResultUI', {
	extend: 'Ext.container.Container',
	alias: 'widget.panelResult',
	
	requires: ['amdaUI.TabResultUI'],

	constructor: function(config) {
		this.init(config);
		this.callParent(arguments);	
	},
    
	getTabResult: function(nodeType) {
		var tabId = 'tab-'+nodeType;      
		return this.tabPanel.getComponent(tabId);
	},
    
	setObject: function(obj){},
    
	setResult: function(linkedNode){
		var configResult = {nodeType: linkedNode.get('jobType')}; 
		var panelResult = this.getTabResult(linkedNode.get('jobType'));
	
		if (!panelResult) {
			// create the plot Tab Result Panel	    
			panelResult = Ext.create('widget.tabResult',configResult);
			// add it
			this.tabPanel.add(panelResult);	  	      
		} 
		// focus on it
		this.tabPanel.setActiveTab(panelResult);
		var format = linkedNode.get('object').get('format');
		if (!format) format = 'unknown';	  
		var compression = linkedNode.get('object').get('compression');	     
		if (!compression) compression = 'unknown';	  

		panelResult.addResult(
			linkedNode.get('text'),
			linkedNode.get('object').get('resultId'),
			linkedNode.get('object').get('folderId'),
			compression.toLowerCase(),
			format.toLowerCase(),
			linkedNode.get('id'));
	},
    
	init : function(config)	{
		this.tabPanel = Ext.create('Ext.tab.Panel',{	   
			layout: { type :'vbox' },        
				activeTab: 0
		});
	
		var myConf = {
			layout: 'fit',   
			items: [ this.tabPanel ]
		};
		Ext.apply(this, Ext.apply(arguments, myConf));	    	    
	}    
});