AmdaModule.js 2.05 KB
/** 
 * Project  : AMDA-NG4
 * Name     : AmdaModule.js
 * @class   amdaDesktop.AmdaModule 
 * @extends Ext.ux.desktop.Module
 * @brief   Generic Module controller definition for AMDA project
 * @author  CDA
 * @version $Id: AmdaModule.js 1761 2013-09-13 13:18:03Z myriam $
 */

Ext.define('amdaDesktop.AmdaModule', {
	extend: 'Ext.ux.desktop.Module',

	/**
	* @cfg {String} id
	* @required
	*/
	id : '',
	
	/**
	* @cfg {String} icon
	* @required
	*/
	icon : '',
	
	/**
	* @cfg {String} title
	* @required
	*/
	title : '',
	
	/**
	* @cfg {String} contentId
	* @required
	*/
	contentId : '',
	
	constructor : function(config){
		this.callParent(arguments);
	},

	/**
	* Module without launcher in Start Menu
	*/
	init: function(){
		this.launcher = null; 
	},
	
	/**
	* Function which return the UI content of this module
	* @return {Object} The Ui content class of this module
	*/
	getUiContent : function (){
		return Ext.getCmp(this.contentId);
	},
       
	/**
	* Window Creation method of the Module
	*/
	createWindow : function (onshowfn) {	  
		var desktop = this.app.getDesktop();		
		var win = desktop.getWindow(this.id);	

		if (!win) {
			win = desktop.createWindow({
				id : this.id,
				title : this.title,
				width : this.width,
				minWidth : this.width,
				height : this.height,
				minHeight: this.height,
				iconCls : this.icon,
				border : false,
				//constrainHeader : true,
				layout : 'fit',
				stateful : true,
				stateId : this.id,
				stateEvents: ['move','show','resize'],
				tools: [{
					type:'help',
					qtip: this.helpTitle,
					scope:this,
					handler: function(event, toolEl, panel){
						var me = this;
						myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function(module) {
							module.createWindow(me.helpFile, me.helpTitle);
						});
					}
				}],
				items : [{
					xtype :  this.uiType,					  
					id : this.contentId
				}]
			});
		}
	 
		if (onshowfn) {
			win.on({
				show : onshowfn,
				scope : this
			});
		}
		if (!win.isVisible()) {
			win.show();
		}
		else if (onshowfn) {
			onshowfn();
		}
	}
});