/** * Project  : AMDA-NG * Name : ResultModule.js * @class amdaDesktop.ResultModule * @extends amdaDesktop.InteractiveModule * @brief Result Module controller definition * @author * @version $Id: ResultModule.js 1052 2012-07-20 14:21:37Z elena $ */ Ext.define('amdaDesktop.ResultModule', { extend: 'amdaDesktop.InteractiveModule', requires: ['amdaUI.ResultUI'], contentId : 'resultUI', width : 500, height : 250, /** * @cfg {String} data models * @required */ nodeDataModel : 'amdaModel.BkgJobNode', uiType : 'panelResult', nodeType : null, helpTitle :'Help on Result Module', init : function() { //force the launcher to null to don't add this item on start menu this.launcher = null; }, /** * Window Creation method of the Module */ createWindow : function () { // init Result Win 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, height : this.height, iconCls : this.icon, border : false, constrainHeader : true, layout : 'fit', stateful : true, stateId : this.id, stateEvents: ['move','show','resize'], // closable : false, tools : [{ type:'help', qtip: this.helpTitle, handler: function(event, toolEl, panel){ //TODO: help logic } }], items : [ { xtype : this.uiType, id : this.contentId }], listeners: { scope: this, beforeclose : function() { if (this.linkedNodes) this.linkedNodes.clear(); } } }); } win.show(); var linkedNode = this.getLinkedNode(); if (win && linkedNode.get('jobType')) { if (!this.linkedNodes || !this.linkedNodes.getByKey(linkedNode.get('processId'))){ this.getUiContent().setResult(linkedNode); this.addLinkedNode(linkedNode); } } }, //TODO override interactive module method : is it needed??? setLinkedNode : function (myLinkedNode){ this.linkedNode = myLinkedNode; }, /** * add the current node into this module * @param {amdaModel.InteractiveNode} myLinkedNode */ addLinkedNode : function (myLinkedNode){ if (!this.linkedNodes){ this.linkedNodes = new Ext.util.MixedCollection(); } if (myLinkedNode.get('processId')){ // add new linkedNode to this module this.linkedNodes.add(myLinkedNode.get('processId'),myLinkedNode); } }, /** * remove deleted node from this module; delete corresponding FieldSet * @param {amdaModel.InteractiveNode} linkedNode * @param int index */ removeLinkedNode : function(linkedNode, index) { this.linkedNodes.remove(index); var type = linkedNode.get('jobType'); var processId = linkedNode.get('processId'); var tabPanel = this.getUiContent().items.items[0]; var thePanel; tabPanel.items.each(function(item){ if (item.id == 'tab-'+type) { thePanel = item; thePanel.items.each(function(item) { if (processId == item.intId){ thePanel.remove(item); } }); } }); } });