PlotTabNode.js
4.18 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/**
* Project : AMDA-NG4
* Name : PlotTabNode.js
* @class amdaModel.PlotTabNode
* @extends amdaModel.ExecutableNode
* @brief Basic Model of Node corresponding to a tab of a plot request
* @author Benjamin Renard
*/
Ext.define('amdaModel.PlotTabNode', {
extend: 'amdaModel.ExecutableNode',
fields : [
{name : 'tabid', type:'string', defaultValue:'', persist: false}
],
statics: {
nodeType: 'plottab'
},
constructor : function(config){
this.callParent(arguments);
this.set('moduleId',myDesktopApp.dynamicModules.plot.id);
//this.set('objectDataModel','amdaPlotObj.PlotRequestObject');
this.set('nodeType',this.self.nodeType);
this.set('leaf',true);
this.set('iconCls','icon-plot-page');
},
allMenuItems : function() {
var menuItems =
[
{
fnId : 'ptab-openTab',
text : 'Open in new Plot Request'
}, {
fnId : 'ptab-insertTab',
text : 'Insert in current Plot Request'
}, {
fnId : 'ptab-renameTab',
text : 'Rename Plot Tab'
}];
return menuItems;
},
allMenuMultiItems : function() {
var menuMulti = [
];
return menuMulti;
},
getAllContextMenuItems: function(){
return this.allMenuItems();
},
getMultiContextMenuItems: function(){
return this.allMenuMultiItems();
},
onMenuItemClick : function(menu,item,event) {
var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length);
switch (fnId) {
case 'openTab':
this.insertPlotTabRequest(true);
break;
case 'insertTab':
this.insertPlotTabRequest(false);
break;
case 'renameTab':
this.renameTab();
break;
default:
break;
}
},
insertPlotTabRequest : function(inNewRequest) {
var me = this;
amdaModel.InteractiveNode.preloadNodes(this.parentNode.getRootNode(), function() {
AmdaAction.getObject(me.parentNode.get('id'), me.parentNode.get('nodeType'), function (result,remoteEvent) {
var paramObj = Ext.create(me.parentNode.get('objectDataModel'), result);
var tabData = null;
paramObj.tabs().each(function(tab) {
if (tab.get('id') == me.get('tabid')) {
tabData = tab.getJsonValues();
}
});
if (tabData != null) {
if (inNewRequest) {
tabData['id'] = 1;
paramObj.set('id','');
paramObj.set('name', '');
paramObj.set('folderId', '');
paramObj.set('active-tab-id', 1);
paramObj.set('last-tab-id', 1);
paramObj.set('last-plotted-tab', 1);
paramObj.loadTabs([tabData]);
myDesktopApp.getLoadedModule(me.get('moduleId'), true, function (module) {
module.setContextNode(me.parentNode.getRootNode());
module.createWindow(function () {
var uiContent = module.getUiContent();
if (uiContent != null) {
uiContent.resetProcess(paramObj.getJsonValues());
}
});
});
}
else {
myDesktopApp.getLoadedModule(me.get('moduleId'), true, function (module) {
module.createWindow(function () {
var uiContent = module.getUiContent();
if (uiContent != null) {
var tabObj = new amdaPlotObj.PlotTabObject(tabData);
uiContent.insertPlotTab(tabData);
}
});
});
}
}
}, me);
});
},
editPlotTab : function() {
var me = this;
this.parentNode.editLeaf(function () {
myDesktopApp.getLoadedModule(me.get('moduleId'), true, function (module) {
var uiContent = module.getUiContent();
if (uiContent != null) {
uiContent.forceActiveTab(me.get('tabid'));
}
});
});
},
renameTab: function() {
if (this.myGetOwnerTree()) {
var item = this.myGetOwnerTree().getSelectionModel().selected.items[0];
this.myGetOwnerTree().fireEvent('edition', this.myGetOwnerTree().view, item);
}
},
rename: function(value,callBackFn) {
var dataToSend = {id : this.get('tabid'), old_name: this.modified.text, name: value, parent : this.data.parentId, leaf: this.isLeaf(), nodeType: this.get('nodeType')};
AmdaAction.renameObject(dataToSend, callBackFn);
},
});