ResultModule.js
3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
* 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);
}
});
}
});
}
});