Commit eec153c1703707034973e28e18bf79fea027f46c
1 parent
a2d616d1
Exists in
master
and in
112 other branches
formattage, nettoyage
Showing
4 changed files
with
1065 additions
and
1106 deletions
Show diff stats
js/app/models/CatalogNode.js
... | ... | @@ -24,68 +24,54 @@ Ext.define('amdaModel.CatalogNode', { |
24 | 24 | if (this.get('leaf')) this.set('iconCls', 'icon-catalog'); |
25 | 25 | }, |
26 | 26 | |
27 | - localMenuItems : function() { | |
28 | - var menuItems = | |
29 | - [ | |
30 | - { | |
31 | - fnId : 'leaf-shareLeaf', | |
32 | - text : 'Share '+this.self.objectName, | |
33 | - hidden : true | |
34 | - },{ | |
35 | - fnId : 'leaf-download', | |
36 | - text : 'Download '+ this.self.objectName, | |
37 | - hidden : true | |
38 | - },{ | |
39 | - fnId : 'leaf-visu', | |
40 | - text : 'Visualize '+ this.self.objectName, | |
41 | - hidden : true | |
42 | - }]; | |
43 | - | |
44 | - return menuItems; | |
45 | - }, | |
27 | + localMenuItems : function() { | |
28 | + var menuItems = | |
29 | + [ | |
30 | + { | |
31 | + fnId : 'leaf-shareLeaf', | |
32 | + text : 'Share '+this.self.objectName, | |
33 | + hidden : true | |
34 | + },{ | |
35 | + fnId : 'leaf-download', | |
36 | + text : 'Download '+ this.self.objectName, | |
37 | + hidden : true | |
38 | + },{ | |
39 | + fnId : 'leaf-visu', | |
40 | + text : 'Visualize '+ this.self.objectName, | |
41 | + hidden : true | |
42 | + }]; | |
43 | + | |
44 | + return menuItems; | |
45 | + }, | |
46 | 46 | |
47 | - localMultiMenuItems : function() { | |
48 | - var menuItems = | |
49 | - [{ | |
50 | - fnId : 'mult-shareMulti', | |
51 | - text : 'Share selected '+this.self.objectName+'s' | |
52 | - },{ | |
53 | - fnId : 'mult-downloadMulti', | |
54 | - text : 'Download selected '+this.self.objectName+'s' | |
55 | - }]; | |
56 | - | |
57 | - return menuItems; | |
58 | - }, | |
59 | - | |
60 | - ttDownload : function() { | |
61 | - alert('NOT IMPLEMENTED YET'); | |
62 | - }, | |
63 | - | |
64 | - downloadMulti: function() { | |
65 | - alert('NOT IMPLEMENTED YET'); | |
66 | - }, | |
67 | - | |
68 | - shareNode: function(node) { | |
69 | - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id, true, function (module) { | |
70 | - module.shareCatalog({'name' : node.get('text'), 'id' : node.get('id')}); | |
71 | - }); | |
72 | - }, | |
47 | + localMultiMenuItems : function() { | |
48 | + var menuItems = | |
49 | + [{ | |
50 | + fnId : 'mult-shareMulti', | |
51 | + text : 'Share selected '+this.self.objectName+'s' | |
52 | + },{ | |
53 | + fnId : 'mult-downloadMulti', | |
54 | + text : 'Download selected '+this.self.objectName+'s' | |
55 | + }]; | |
56 | + | |
57 | + return menuItems; | |
58 | + }, | |
59 | + | |
60 | + shareNode: function(node) { | |
61 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id, true, function (module) { | |
62 | + module.shareCatalog({'name' : node.get('text'), 'id' : node.get('id')}); | |
63 | + }); | |
64 | + }, | |
73 | 65 | |
74 | - visu : function(contextNode) { | |
75 | - | |
76 | - var me = this; | |
77 | - | |
78 | - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) { | |
79 | - | |
80 | - // Catalog & TimeTable nodes normally use no objects in the tree | |
81 | - var obj = {'id' : me.get('id'), 'name' : me.get('text') }; | |
82 | - object = Ext.create(me.get('objectDataModel'), obj); | |
83 | - me.set('object',object); | |
84 | - | |
85 | - module.setLinkedNode(me); | |
86 | - | |
87 | - module.createWindow(); | |
88 | - | |
89 | - }); | |
90 | - } | |
66 | + visu : function(contextNode) { | |
67 | + var me = this; | |
68 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) { | |
69 | + // Catalog & TimeTable nodes normally use no objects in the tree | |
70 | + var obj = {'id' : me.get('id'), 'name' : me.get('text') }; | |
71 | + object = Ext.create(me.get('objectDataModel'), obj); | |
72 | + me.set('object',object); | |
73 | + module.setLinkedNode(me); | |
74 | + module.createWindow(); | |
75 | + }); | |
76 | + } | |
91 | 77 | }); |
... | ... |
js/app/models/InteractiveNode.js
... | ... | @@ -9,816 +9,795 @@ |
9 | 9 | */ |
10 | 10 | |
11 | 11 | Ext.define('amdaModel.InteractiveNode', { |
12 | - extend: 'amdaModel.AmdaNode', | |
12 | + extend: 'amdaModel.AmdaNode', | |
13 | 13 | |
14 | - requires: [ | |
15 | - 'amdaPlotObj.PlotRequestObject' | |
16 | - ], | |
14 | + requires: [ | |
15 | + 'amdaPlotObj.PlotRequestObject' | |
16 | + ], | |
17 | 17 | |
18 | - fields: [ | |
19 | - {name: 'contextNode', type: 'amdaModel.AmdaNode', persist: false}, | |
20 | - {name: 'objectDataModel', type: 'string', persist: false}, | |
21 | - {name: 'object', type: 'object', persist: false}, | |
22 | - {name: 'moduleId', type: 'string', persist: false}, | |
23 | - {name: 'filtered', type: 'boolean', defaultValue: false, persist: false}, | |
24 | - {name: 'disable', type: 'boolean', defaultValue: false, persist: false} | |
25 | - ], | |
18 | + fields: [ | |
19 | + {name: 'contextNode', type: 'amdaModel.AmdaNode', persist: false}, | |
20 | + {name: 'objectDataModel', type: 'string', persist: false}, | |
21 | + {name: 'object', type: 'object', persist: false}, | |
22 | + {name: 'moduleId', type: 'string', persist: false}, | |
23 | + {name: 'filtered', type: 'boolean', defaultValue: false, persist: false}, | |
24 | + {name: 'disable', type: 'boolean', defaultValue: false, persist: false} | |
25 | + ], | |
26 | 26 | |
27 | - statics: { | |
28 | - preloadNodes : function(node,onready) | |
29 | - { | |
30 | - var me = this; | |
31 | - | |
32 | - var nodesToLoad = new Array(); | |
33 | - nodesToLoad.push(node); | |
34 | - this.preloadTreeNode(node, nodesToLoad, function (node) | |
35 | - { | |
36 | - var isFinish = true; | |
37 | - nodesToLoad.forEach(function (element, index, array) | |
38 | - { | |
39 | - if (!element.isLoaded()) | |
40 | - isFinish = false; | |
41 | - }); | |
42 | - | |
43 | - if (isFinish && onready) | |
44 | - onready.call(); | |
45 | - }); | |
46 | - }, | |
27 | + statics: { | |
28 | + preloadNodes : function(node,onready) | |
29 | + { | |
30 | + var me = this; | |
31 | + | |
32 | + var nodesToLoad = new Array(); | |
33 | + nodesToLoad.push(node); | |
34 | + this.preloadTreeNode(node, nodesToLoad, function (node) | |
35 | + { | |
36 | + var isFinish = true; | |
37 | + nodesToLoad.forEach(function (element, index, array) | |
38 | + { | |
39 | + if (!element.isLoaded()) | |
40 | + isFinish = false; | |
41 | + }); | |
42 | + if (isFinish && onready) | |
43 | + onready.call(); | |
44 | + }); | |
45 | + }, | |
47 | 46 | |
48 | - preloadTreeNode : function(node, nodesToLoad, onloaded) | |
49 | - { | |
50 | - var me = this; | |
51 | - | |
52 | - if (node.isLoaded()) | |
53 | - { | |
54 | - node.eachChild(function(n) | |
55 | - { | |
56 | - if (!n.isLoaded() && !n.isLeaf()) | |
57 | - { | |
58 | - nodesToLoad.push(n); | |
59 | - me.preloadTreeNode(n,nodesToLoad,onloaded); | |
60 | - } | |
61 | - }); | |
62 | - | |
63 | - if (onloaded) | |
64 | - onloaded.call(me,node); | |
65 | - return; | |
66 | - } | |
67 | - | |
68 | - node.store.load({ | |
69 | - node : node, | |
70 | - callback : function(records, operation, successful) | |
71 | - { | |
72 | - records.forEach(function (record) | |
73 | - { | |
74 | - if (!record.isLoaded() && !record.isLeaf()) | |
75 | - { | |
76 | - nodesToLoad.push(record); | |
77 | - me.preloadTreeNode(record,nodesToLoad,onloaded); | |
78 | - } | |
79 | - }); | |
80 | - if (onloaded) | |
81 | - onloaded.call(me,node); | |
82 | - } | |
83 | - }); | |
84 | - } | |
85 | - }, | |
47 | + preloadTreeNode : function(node, nodesToLoad, onloaded) | |
48 | + { | |
49 | + var me = this; | |
50 | + | |
51 | + if (node.isLoaded()) | |
52 | + { | |
53 | + node.eachChild(function(n) | |
54 | + { | |
55 | + if (!n.isLoaded() && !n.isLeaf()) | |
56 | + { | |
57 | + nodesToLoad.push(n); | |
58 | + me.preloadTreeNode(n,nodesToLoad,onloaded); | |
59 | + } | |
60 | + }); | |
61 | + | |
62 | + if (onloaded) | |
63 | + onloaded.call(me,node); | |
64 | + return; | |
65 | + } | |
66 | + | |
67 | + node.store.load({ | |
68 | + node : node, | |
69 | + callback : function(records, operation, successful) | |
70 | + { | |
71 | + records.forEach(function (record) | |
72 | + { | |
73 | + if (!record.isLoaded() && !record.isLeaf()) | |
74 | + { | |
75 | + nodesToLoad.push(record); | |
76 | + me.preloadTreeNode(record,nodesToLoad,onloaded); | |
77 | + } | |
78 | + }); | |
79 | + if (onloaded) | |
80 | + onloaded.call(me,node); | |
81 | + } | |
82 | + }); | |
83 | + } | |
84 | + }, | |
86 | 85 | |
87 | - constructor : function(config) | |
88 | - { | |
89 | - this.callParent(arguments); | |
90 | - this.set('nodeType',this.self.nodeType); | |
91 | - this.set('ownerTreeId',amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
92 | - // if id of this node have root category suffix | |
93 | - if (Ext.util.Format.substr(this.get('id'), -(amdaUI.ExplorerUI.CAT_SUFFIX.length), this.get('id').length) === amdaUI.ExplorerUI.CAT_SUFFIX) | |
94 | - { | |
95 | - // set the expanded property to true | |
96 | - this.set('expanded',true); | |
97 | - } | |
98 | - }, | |
86 | + constructor : function(config) | |
87 | + { | |
88 | + this.callParent(arguments); | |
89 | + this.set('nodeType',this.self.nodeType); | |
90 | + this.set('ownerTreeId',amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
91 | + // if id of this node have root category suffix | |
92 | + if (Ext.util.Format.substr(this.get('id'), -(amdaUI.ExplorerUI.CAT_SUFFIX.length), this.get('id').length) === amdaUI.ExplorerUI.CAT_SUFFIX) | |
93 | + { | |
94 | + // set the expanded property to true | |
95 | + this.set('expanded',true); | |
96 | + } | |
97 | + }, | |
99 | 98 | |
100 | - /** | |
101 | - * this method is overriden into ExecutableNode to return true | |
102 | - */ | |
103 | - isExecutable: function() | |
104 | - { | |
105 | - return false; | |
106 | - }, | |
99 | +/** | |
100 | +* this method is overriden into ExecutableNode to return true | |
101 | +*/ | |
102 | + isExecutable: function() | |
103 | + { | |
104 | + return false; | |
105 | + }, | |
107 | 106 | |
108 | - /** | |
109 | - * open Module with THIS NODE | |
110 | - */ | |
111 | - editInModule : function (contextNode, onReady) | |
112 | - { | |
113 | - // set the contextNode of this node | |
114 | - this.set('contextNode',contextNode); | |
115 | - // parameter module | |
116 | - var me = this; | |
117 | - myDesktopApp.getLoadedModule(this.get('moduleId'),true, function (module) { | |
118 | - // If the node to edit is not already linked to this module | |
119 | - if (module.getLinkedNode() != me) | |
120 | - { | |
121 | - // set relative node into parameter Module | |
122 | - module.setLinkedNode(me); | |
123 | - if (contextNode==null) | |
124 | - { | |
125 | - // set the root node as contextNode | |
126 | - contextNode = me.getRootNode(); | |
127 | - } | |
128 | - module.setContextNode(contextNode); | |
129 | - | |
130 | - } else if (module.getLinkedNode() != null){ | |
131 | - //TODO the node to edit is already edited | |
132 | - // myDesktopApp.warningMsg('This object is being edited'); | |
133 | - //Sol1: msg alert: "warning this node is already edited! If you want to get the original, please press the 'reset' button"->'OK' | |
134 | - //Sol2: msg with user choice: "warning this node is already edited! Would you confirm this action and lost your modification?"->'Confirm','Cancel' | |
135 | - } | |
136 | - // Opening parameter window | |
137 | - module.createWindow(onReady); | |
138 | - }); | |
139 | - | |
140 | - | |
141 | - }, | |
107 | +/** | |
108 | +* open Module with THIS NODE | |
109 | +*/ | |
110 | + editInModule : function (contextNode, onReady) | |
111 | + { | |
112 | + // set the contextNode of this node | |
113 | + this.set('contextNode',contextNode); | |
114 | + // parameter module | |
115 | + var me = this; | |
116 | + myDesktopApp.getLoadedModule(this.get('moduleId'),true, function (module) { | |
117 | + // If the node to edit is not already linked to this module | |
118 | + if (module.getLinkedNode() != me) | |
119 | + { | |
120 | + // set relative node into parameter Module | |
121 | + module.setLinkedNode(me); | |
122 | + if (contextNode==null) | |
123 | + { | |
124 | + // set the root node as contextNode | |
125 | + contextNode = me.getRootNode(); | |
126 | + } | |
127 | + module.setContextNode(contextNode); | |
128 | + | |
129 | + } else if (module.getLinkedNode() != null){ | |
130 | + //TODO the node to edit is already edited | |
131 | + // myDesktopApp.warningMsg('This object is being edited'); | |
132 | + //Sol1: msg alert: "warning this node is already edited! If you want to get the original, please press the 'reset' button"->'OK' | |
133 | + //Sol2: msg with user choice: "warning this node is already edited! Would you confirm this action and lost your modification?"->'Confirm','Cancel' | |
134 | + } | |
135 | + // Opening parameter window | |
136 | + module.createWindow(onReady); | |
137 | + }); | |
138 | + }, | |
142 | 139 | |
143 | - /** | |
144 | - * Method to rename the workspace node | |
145 | - */ | |
146 | - rename: function(value,callBackFn) | |
147 | - { | |
148 | - var dataToSend = {id : this.get('id'), old_name: this.modified.text, name: value, parent : this.parentNode.get('id'), leaf: this.isLeaf(), nodeType: this.get('nodeType')}; | |
149 | - AmdaAction.renameObject(dataToSend, callBackFn); | |
150 | - }, | |
140 | +/** | |
141 | +* Method to rename the workspace node | |
142 | +*/ | |
143 | + rename: function(value,callBackFn) | |
144 | + { | |
145 | + var dataToSend = {id : this.get('id'), old_name: this.modified.text, name: value, parent : this.parentNode.get('id'), leaf: this.isLeaf(), nodeType: this.get('nodeType')}; | |
146 | + AmdaAction.renameObject(dataToSend, callBackFn); | |
147 | + }, | |
151 | 148 | |
152 | - /** | |
153 | - * Method to rename the workspace node when D&D | |
154 | - */ | |
155 | - renameDD: function(parentId, callBackFn) | |
156 | - { | |
157 | - var dataToSend = {id : this.get('id'), old_name: this.get('name'), name: this.get('name'), parent : parentId, leaf: this.isLeaf(), nodeType: this.get('nodeType')}; | |
158 | - AmdaAction.renameObject(dataToSend, callBackFn); | |
159 | - }, | |
149 | +/** | |
150 | +* Method to rename the workspace node when D&D | |
151 | +*/ | |
152 | + renameDD: function(parentId, callBackFn) | |
153 | + { | |
154 | + var dataToSend = {id : this.get('id'), old_name: this.get('name'), name: this.get('name'), parent : parentId, leaf: this.isLeaf(), nodeType: this.get('nodeType')}; | |
155 | + AmdaAction.renameObject(dataToSend, callBackFn); | |
156 | + }, | |
160 | 157 | |
161 | - /** | |
162 | - * validation method on name (used in module forms) | |
163 | - * @param name the name to validate | |
164 | - * @returns | |
165 | - */ | |
166 | - isValidName : function(name, callBackFn) | |
167 | - { | |
168 | - var dataToSend = {name: name, nodeType: this.get('nodeType'), leaf: this.isLeaf()}; | |
169 | - AmdaAction.validNameObject(dataToSend, callBackFn); | |
170 | - }, | |
158 | +/** | |
159 | +* validation method on name (used in module forms) | |
160 | +* @param name the name to validate | |
161 | +* @returns | |
162 | +*/ | |
163 | + isValidName : function(name, callBackFn) | |
164 | + { | |
165 | + var dataToSend = {name: name, nodeType: this.get('nodeType'), leaf: this.isLeaf()}; | |
166 | + AmdaAction.validNameObject(dataToSend, callBackFn); | |
167 | + }, | |
171 | 168 | |
172 | - /** | |
173 | - * Method to persist modifications of an AmdaObject by Server side and update the workspace | |
174 | - * node linked to a Module | |
175 | - */ | |
176 | - update : function(opt) | |
177 | - { | |
178 | - AmdaAction.modifyObject(this.get('object').getJsonValues(true), function(res,e){ | |
169 | +/** | |
170 | +* Method to persist modifications of an AmdaObject by Server side and update the workspace | |
171 | +* node linked to a Module | |
172 | +*/ | |
173 | + update : function(opt) | |
174 | + { | |
175 | + AmdaAction.modifyObject(this.get('object').getJsonValues(true), function(res,e){ | |
179 | 176 | |
180 | - if(e.status) { | |
181 | - if (res.id) { | |
182 | - if (!this.get('contextNode')) { | |
183 | - // set the root node of 'Derived Parameters' tree as contextNode | |
184 | - this.set('contextNode',this.getRootNode()); | |
185 | - } | |
186 | - this.get('contextNode').expand(false,false); | |
187 | - this.myGetOwnerTree().getSelectionModel().select(this); | |
188 | - | |
189 | - if (opt) | |
190 | - { | |
191 | - var scope = opt.scope ? opt.scope : this; | |
192 | - if (opt.callback) | |
193 | - opt.callback.call(scope,'update'); | |
194 | - } | |
195 | - | |
196 | - Ext.Msg.alert('Complete', 'Object '+this.get('object').get('name')+' has been modified'); | |
197 | - // fix the modifications for object | |
198 | - this.get('object').commit(); | |
199 | - | |
200 | - if (res.info) { | |
201 | - this.set('info',res.info); | |
202 | - } | |
203 | - | |
204 | - if (this.get('nodeType') == 'myDataParam') { | |
205 | - if (res.isSpectra) { | |
206 | - this.set('iconCls', 'icon-spectra'); | |
207 | - } | |
208 | - else { | |
209 | - if (res.size > 1) this.set('iconCls', 'icon-unknowntype'); | |
210 | - } | |
211 | - } | |
212 | - | |
213 | - // update my data on possibble mask change | |
214 | - if (res.updateMyData) { | |
215 | - this.updateMyData(); | |
216 | - this.updateMask(res.mask); | |
217 | - } | |
218 | - // reload object into the view of corresponding Module | |
219 | - var me = this; | |
220 | - myDesktopApp.getLoadedModule(this.get('moduleId'), true, function (module) { | |
221 | - module.getUiContent().setObject(me.get('object')); | |
222 | - }); | |
223 | - } | |
224 | - else { | |
225 | - //TODO proper error message handling | |
226 | - // error code from server; but e.status==true | |
227 | - // revert all modifications since last load or commit | |
228 | - this.get('object').reject(); | |
229 | - myDesktopApp.errorMsg(res.error); | |
230 | - } | |
231 | - } | |
232 | - else { | |
233 | - // revert all modifications since last load or commit | |
234 | - this.get('object').reject(); | |
235 | - myDesktopApp.errorMsg(e.message); | |
236 | - } | |
237 | - },this); | |
238 | - }, | |
177 | + if(e.status) { | |
178 | + if (res.id) { | |
179 | + if (!this.get('contextNode')) { | |
180 | + // set the root node of 'Derived Parameters' tree as contextNode | |
181 | + this.set('contextNode',this.getRootNode()); | |
182 | + } | |
183 | + this.get('contextNode').expand(false,false); | |
184 | + this.myGetOwnerTree().getSelectionModel().select(this); | |
185 | + | |
186 | + if (opt) | |
187 | + { | |
188 | + var scope = opt.scope ? opt.scope : this; | |
189 | + if (opt.callback) | |
190 | + opt.callback.call(scope,'update'); | |
191 | + } | |
192 | + | |
193 | + Ext.Msg.alert('Complete', 'Object '+this.get('object').get('name')+' has been modified'); | |
194 | + // fix the modifications for object | |
195 | + this.get('object').commit(); | |
196 | + | |
197 | + if (res.info) { | |
198 | + this.set('info',res.info); | |
199 | + } | |
200 | + | |
201 | + if (this.get('nodeType') == 'myDataParam') { | |
202 | + if (res.isSpectra) { | |
203 | + this.set('iconCls', 'icon-spectra'); | |
204 | + } | |
205 | + else { | |
206 | + if (res.size > 1) this.set('iconCls', 'icon-unknowntype'); | |
207 | + } | |
208 | + } | |
209 | + | |
210 | + // update my data on possibble mask change | |
211 | + if (res.updateMyData) { | |
212 | + this.updateMyData(); | |
213 | + this.updateMask(res.mask); | |
214 | + } | |
215 | + // reload object into the view of corresponding Module | |
216 | + var me = this; | |
217 | + myDesktopApp.getLoadedModule(this.get('moduleId'), true, function (module) { | |
218 | + module.getUiContent().setObject(me.get('object')); | |
219 | + }); | |
220 | + } | |
221 | + else { | |
222 | + //TODO proper error message handling | |
223 | + // error code from server; but e.status==true | |
224 | + // revert all modifications since last load or commit | |
225 | + this.get('object').reject(); | |
226 | + myDesktopApp.errorMsg(res.error); | |
227 | + } | |
228 | + } | |
229 | + else { | |
230 | + // revert all modifications since last load or commit | |
231 | + this.get('object').reject(); | |
232 | + myDesktopApp.errorMsg(e.message); | |
233 | + } | |
234 | + },this); | |
235 | + }, | |
239 | 236 | |
240 | - /** | |
241 | - * Method to create a new AmdaObject by server side and create the workspace node linked to a Module | |
242 | - * under its contextNode or the root node corresponding to this nodeType category | |
243 | - */ | |
244 | - create : function(opt) | |
245 | - { | |
246 | - if (!this.get('contextNode') || (this.get('contextNode').data.id == 'sharedtimeTable-treeRootNode') || (this.get('contextNode').data.id == 'sharedcatalog-treeRootNode')) { | |
247 | - // set the root node of 'Derived Parameters' tree as contextNode | |
248 | - this.set('contextNode',this.getRootNode()); | |
249 | - } | |
250 | - | |
251 | - // call the Ext.Direct method to create parameter | |
252 | - AmdaAction.createObject(this.get('object').getJsonValues(false), this.get('contextNode').get('id'), function(res,e){ | |
253 | - //success | |
254 | - if(e.status) | |
255 | - { | |
256 | - // if correct response received | |
257 | - if (res.id) { //if (res.id || res.error == 'NAME_EXISTS') { | |
258 | - // 'save as' case ; delete old node if it exists | |
259 | - if (this.toRename) | |
260 | - { | |
261 | - this.toRename = false; | |
262 | - var myRoot = this.getRootNode(); | |
263 | - // search the same named node to override | |
264 | - var updateNode = myRoot.findChild('text',this.get('object').get('name'),true); | |
265 | - // destroy the overrided node | |
266 | - updateNode.parentNode.removeChild(updateNode);//TODO ??if destroy==true => too many recursions.... | |
267 | - updateNode.destroy(); | |
268 | - } | |
269 | - // set text of this node | |
270 | - this.set('text',this.get('object').get('name')); | |
271 | - //set id of this node | |
272 | - this.set('id',res.id); | |
273 | - this.internalId = res.id; | |
274 | - // set id of node's object | |
275 | - this.get('object').set('id',res.id); | |
276 | - | |
277 | - if (res.created){ | |
278 | - // set the created date | |
279 | - this.get('object').set('created',res.created); | |
280 | - } | |
237 | +/** | |
238 | +* Method to create a new AmdaObject by server side and create the workspace node linked to a Module | |
239 | +* under its contextNode or the root node corresponding to this nodeType category | |
240 | +*/ | |
241 | + create : function(opt) | |
242 | + { | |
243 | + if (!this.get('contextNode') || (this.get('contextNode').data.id == 'sharedtimeTable-treeRootNode') || (this.get('contextNode').data.id == 'sharedcatalog-treeRootNode')) { | |
244 | + // set the root node of 'Derived Parameters' tree as contextNode | |
245 | + this.set('contextNode',this.getRootNode()); | |
246 | + } | |
247 | + // call the Ext.Direct method to create parameter | |
248 | + AmdaAction.createObject(this.get('object').getJsonValues(false), this.get('contextNode').get('id'), function(res,e){ | |
249 | + //success | |
250 | + if(e.status) | |
251 | + { | |
252 | + // if correct response received | |
253 | + if (res.id) { //if (res.id || res.error == 'NAME_EXISTS') { | |
254 | + // 'save as' case ; delete old node if it exists | |
255 | + if (this.toRename) | |
256 | + { | |
257 | + this.toRename = false; | |
258 | + var myRoot = this.getRootNode(); | |
259 | + // search the same named node to override | |
260 | + var updateNode = myRoot.findChild('text',this.get('object').get('name'),true); | |
261 | + // destroy the overrided node | |
262 | + updateNode.parentNode.removeChild(updateNode);//TODO ??if destroy==true => too many recursions.... | |
263 | + updateNode.destroy(); | |
264 | + } | |
265 | + // set text of this node | |
266 | + this.set('text',this.get('object').get('name')); | |
267 | + //set id of this node | |
268 | + this.set('id',res.id); | |
269 | + this.internalId = res.id; | |
270 | + // set id of node's object | |
271 | + this.get('object').set('id',res.id); | |
281 | 272 | |
282 | - if (res.info){ | |
283 | - // set the tooltip | |
284 | - this.set('info',res.info); | |
285 | - //set globalStart & global Stop to be used for time selection | |
286 | - if (this.get('nodeType') == 'myDataParam') | |
287 | - { | |
288 | - var startStop = res.info.split("<br/>"); | |
289 | - var globalStart = startStop[1].substr(0,19); | |
290 | - var globalStop = startStop[1].substr(20); | |
291 | - | |
292 | - this.set('globalStart', globalStart); | |
293 | - this.set('globalStop', globalStop); | |
294 | - | |
295 | - if (res.mask) | |
296 | - this.set('linkedMask', res.mask); | |
297 | - if (res.size) | |
298 | - this.set('size', res.size); | |
299 | - | |
300 | - if (res.isSpectra) { | |
301 | - this.set('iconCls', 'icon-spectra'); | |
302 | - } | |
303 | - else { | |
304 | - if (res.size > 1) this.set('iconCls', 'icon-unknowntype'); | |
305 | - } | |
306 | - } | |
307 | - } | |
273 | + if (res.created){ | |
274 | + // set the created date | |
275 | + this.get('object').set('created',res.created); | |
276 | + } | |
308 | 277 | |
309 | - //TODO do we need this commission ??? | |
310 | - // fix the modifications for object | |
311 | - this.get('object').commit(); | |
312 | - // if ownerTree panel is not active | |
313 | - if (this.myGetOwnerTree().ownerCt.getActiveTab()!==this.myGetOwnerTree()) | |
314 | - { | |
315 | - // set ownerTree panel as the active tab - to enable selection of this node his ownerTree must have a view | |
316 | - this.myGetOwnerTree().ownerCt.setActiveTab(this.myGetOwnerTree()); | |
317 | - } | |
278 | + if (res.info){ | |
279 | + // set the tooltip | |
280 | + this.set('info',res.info); | |
281 | + //set globalStart & global Stop to be used for time selection | |
282 | + if (this.get('nodeType') == 'myDataParam') | |
283 | + { | |
284 | + var startStop = res.info.split("<br/>"); | |
285 | + var globalStart = startStop[1].substr(0,19); | |
286 | + var globalStop = startStop[1].substr(20); | |
287 | + | |
288 | + this.set('globalStart', globalStart); | |
289 | + this.set('globalStop', globalStop); | |
290 | + | |
291 | + if (res.mask) | |
292 | + this.set('linkedMask', res.mask); | |
293 | + if (res.size) | |
294 | + this.set('size', res.size); | |
295 | + | |
296 | + if (res.isSpectra) { | |
297 | + this.set('iconCls', 'icon-spectra'); | |
298 | + } | |
299 | + else { | |
300 | + if (res.size > 1) | |
301 | + this.set('iconCls', 'icon-unknowntype'); | |
302 | + } | |
303 | + } | |
304 | + } | |
305 | + //TODO do we need this commission ??? | |
306 | + // fix the modifications for object | |
307 | + this.get('object').commit(); | |
308 | + // if ownerTree panel is not active | |
309 | + if (this.myGetOwnerTree().ownerCt.getActiveTab()!==this.myGetOwnerTree()) | |
310 | + { | |
311 | + // set ownerTree panel as the active tab - to enable selection of this node his ownerTree must have a view | |
312 | + this.myGetOwnerTree().ownerCt.setActiveTab(this.myGetOwnerTree()); | |
313 | + } | |
318 | 314 | |
319 | - Ext.Msg.alert('Complete', 'New object '+this.get('object').get('name')+' has been created'); | |
320 | - // expand the contextNode | |
321 | - this.get('contextNode').expand(false, function() | |
322 | - { | |
323 | - if (!this.get('contextNode').findChild('text',this.get('text'))) { | |
324 | - // create node in tree as child of contextNode | |
325 | - this.get('contextNode').appendChild(this); | |
326 | - } | |
327 | - // select the new node | |
328 | - this.myGetOwnerTree().getSelectionModel().select(this); | |
329 | - if (opt) | |
330 | - { | |
331 | - var scope = opt.scope ? opt.scope : this; | |
332 | - if (opt.callback) | |
333 | - opt.callback.call(scope,'create'); | |
334 | - } | |
335 | - | |
336 | - }, this); | |
315 | + Ext.Msg.alert('Complete', 'New object '+this.get('object').get('name')+' has been created'); | |
316 | + // expand the contextNode | |
317 | + this.get('contextNode').expand(false, function() | |
318 | + { | |
319 | + if (!this.get('contextNode').findChild('text',this.get('text'))) { | |
320 | + // create node in tree as child of contextNode | |
321 | + this.get('contextNode').appendChild(this); | |
322 | + } | |
323 | + // select the new node | |
324 | + this.myGetOwnerTree().getSelectionModel().select(this); | |
325 | + if (opt) | |
326 | + { | |
327 | + var scope = opt.scope ? opt.scope : this; | |
328 | + if (opt.callback) | |
329 | + opt.callback.call(scope,'create'); | |
330 | + } | |
331 | + }, this); | |
337 | 332 | |
338 | - // myDataParamNode - update MyData subtree | |
339 | - //TODO put this in mydataparamnode | |
340 | - if (res.updateMyData) { | |
341 | - this.updateMyData(); | |
342 | - this.updateMask(res.mask); | |
343 | - } | |
344 | - | |
345 | - } | |
346 | - // error code from server; but e.status==true | |
347 | - else { | |
348 | - myDesktopApp.errorMsg(res.error); | |
349 | - // revert all modifications since last load or commit | |
350 | - this.get('object').reject(); | |
351 | - } | |
352 | - } | |
353 | - // failure: e.status == false | |
354 | - else { | |
355 | - // revert all modifications since last load or commit | |
356 | - this.get('object').reject(); | |
357 | - //TODO: this.destroy(); | |
358 | - myDesktopApp.errorMsg(e.message); | |
359 | - } | |
360 | - },this); | |
361 | - }, | |
333 | + // myDataParamNode - update MyData subtree | |
334 | + //TODO put this in mydataparamnode | |
335 | + if (res.updateMyData) { | |
336 | + this.updateMyData(); | |
337 | + this.updateMask(res.mask); | |
338 | + } | |
339 | + | |
340 | + } | |
341 | + // error code from server; but e.status==true | |
342 | + else { | |
343 | + myDesktopApp.errorMsg(res.error); | |
344 | + // revert all modifications since last load or commit | |
345 | + this.get('object').reject(); | |
346 | + } | |
347 | + } | |
348 | + // failure: e.status == false | |
349 | + else { | |
350 | + // revert all modifications since last load or commit | |
351 | + this.get('object').reject(); | |
352 | + //TODO: this.destroy(); | |
353 | + myDesktopApp.errorMsg(e.message); | |
354 | + } | |
355 | + },this); | |
356 | + }, | |
362 | 357 | |
363 | - /** | |
364 | - * Generic part of Context Menu | |
365 | - * | |
366 | - */ | |
367 | - allMenuItems : function() { | |
368 | - var src = this.self.objectName; | |
369 | - var menuItems = | |
370 | - [ { | |
371 | - fnId : 'root-createLeaf', | |
372 | - text : 'Create '+ src | |
373 | - }, { | |
374 | - fnId : 'root-createDir', | |
375 | - text : 'Create Folder' | |
376 | - }, { | |
377 | - fnId : 'dire-createLeaf', | |
378 | - text : 'Create ' + src | |
379 | - }, { | |
380 | - fnId : 'dire-createDir', | |
381 | - text : 'Create Folder' | |
382 | - }, { | |
383 | - fnId : 'dire-renameNode', | |
384 | - text : 'Rename Folder' | |
385 | - }, { | |
386 | - fnId : 'dire-deleteNode', | |
387 | - text : 'Delete Folder' | |
388 | - }, { | |
389 | - fnId : 'leaf-editLeaf', | |
390 | - text : 'Edit ' + src | |
391 | - }, { | |
392 | - fnId : 'leaf-renameNode', | |
393 | - text : 'Rename ' + src | |
394 | - }, { | |
395 | - fnId : 'leaf-deleteNode', | |
396 | - text : 'Delete '+ src | |
397 | - } ]; | |
398 | - return menuItems; | |
399 | - }, | |
358 | +/** | |
359 | +* Generic part of Context Menu | |
360 | +* | |
361 | +*/ | |
362 | + allMenuItems : function() { | |
363 | + var src = this.self.objectName; | |
364 | + var menuItems = | |
365 | + [ { | |
366 | + fnId : 'root-createLeaf', | |
367 | + text : 'Create '+ src | |
368 | + }, { | |
369 | + fnId : 'root-createDir', | |
370 | + text : 'Create Folder' | |
371 | + }, { | |
372 | + fnId : 'dire-createLeaf', | |
373 | + text : 'Create ' + src | |
374 | + }, { | |
375 | + fnId : 'dire-createDir', | |
376 | + text : 'Create Folder' | |
377 | + }, { | |
378 | + fnId : 'dire-renameNode', | |
379 | + text : 'Rename Folder' | |
380 | + }, { | |
381 | + fnId : 'dire-deleteNode', | |
382 | + text : 'Delete Folder' | |
383 | + }, { | |
384 | + fnId : 'leaf-editLeaf', | |
385 | + text : 'Edit ' + src | |
386 | + }, { | |
387 | + fnId : 'leaf-renameNode', | |
388 | + text : 'Rename ' + src | |
389 | + }, { | |
390 | + fnId : 'leaf-deleteNode', | |
391 | + text : 'Delete '+ src | |
392 | + } ]; | |
393 | + return menuItems; | |
394 | + }, | |
400 | 395 | |
401 | - allMenuMultiItems : function() { | |
402 | - var menuMulti = [ | |
403 | - { | |
404 | - fnId : 'mult-deleteMulti', | |
405 | - text : 'Delete selected ' + this.self.objectName + 's' | |
406 | - } | |
407 | - ]; | |
408 | - return menuMulti; | |
409 | - }, | |
410 | - | |
411 | - getAllContextMenuItems: function(){ | |
412 | - return this.allMenuItems(); | |
413 | - }, | |
396 | + allMenuMultiItems : function() { | |
397 | + var menuMulti = [ | |
398 | + { | |
399 | + fnId : 'mult-deleteMulti', | |
400 | + text : 'Delete selected ' + this.self.objectName + 's' | |
401 | + } | |
402 | + ]; | |
403 | + return menuMulti; | |
404 | + }, | |
414 | 405 | |
415 | - getMultiContextMenuItems: function(){ | |
416 | - return this.allMenuMultiItems(); | |
417 | - }, | |
406 | + getAllContextMenuItems: function(){ | |
407 | + return this.allMenuItems(); | |
408 | + }, | |
409 | + | |
410 | + getMultiContextMenuItems: function(){ | |
411 | + return this.allMenuMultiItems(); | |
412 | + }, | |
418 | 413 | |
419 | - /** | |
420 | - * default implementation | |
421 | - * no menu display if there's no override of this function | |
422 | - */ | |
423 | - getMultiContextMenuItems: function(){ | |
424 | - return null; | |
425 | - }, | |
414 | +/** | |
415 | +* default implementation | |
416 | +* no menu display if there's no override of this function | |
417 | +*/ | |
418 | + getMultiContextMenuItems: function(){ | |
419 | + return null; | |
420 | + }, | |
426 | 421 | |
427 | - /** | |
428 | - * Context Menu Actions | |
429 | - * | |
430 | - */ | |
431 | - onMenuItemClick : function(menu,item,event) { | |
432 | - // fnId parsing : | |
433 | - var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length); | |
422 | +/** | |
423 | +* Context Menu Actions | |
424 | +* | |
425 | +*/ | |
426 | + onMenuItemClick : function(menu,item,event) { | |
427 | + // fnId parsing : | |
428 | + var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length); | |
434 | 429 | |
435 | - switch (fnId) { | |
430 | + switch (fnId) { | |
431 | + case 'deleteNode': | |
432 | + this.deleteNode(); | |
433 | + break; | |
434 | + case 'createDir': | |
435 | + this.createDir(); | |
436 | + break; | |
437 | + case 'createLeaf': | |
438 | + this.createLeaf(this); | |
439 | + break; | |
440 | + case 'renameNode': | |
441 | + this.renameNode(); | |
442 | + break; | |
443 | + case 'editLeaf': | |
444 | + this.editLeaf(); | |
445 | + break; | |
446 | + case 'deleteMulti': | |
447 | + this.deleteMulti(); | |
448 | + break; | |
449 | + case 'plotParam': | |
450 | + this.createPlot(this); | |
451 | + break; | |
452 | + case 'downParam': | |
453 | + this.createDownload(this); | |
454 | + break; | |
455 | + default: | |
456 | + break; | |
457 | + } // switch end | |
458 | + }, | |
459 | + | |
460 | + getTimeFromNode: function(node) { | |
461 | + | |
462 | + var startString = new String(node.get('globalStart')); | |
463 | + var stopString = new String(node.get('globalStop')); | |
464 | + var startDate = new Date(startString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); | |
465 | + var stopDate = new Date(stopString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); | |
466 | + if (stopDate - startDate > 86400000 ) { | |
467 | + var startTime = Ext.Date.add(stopDate, Ext.Date.DAY, -1); | |
468 | + var timeObj = {start: Ext.Date.format(startTime, 'Y/m/d H:i:s'), stop: Ext.Date.format(stopDate, 'Y/m/d H:i:s')}; | |
469 | + } | |
470 | + else { | |
471 | + var timeObj = {start: node.get('globalStart'), stop: node.get('globalStop')}; | |
472 | + } | |
473 | + return timeObj; | |
474 | + }, | |
436 | 475 | |
437 | - case 'deleteNode': | |
438 | - this.deleteNode(); | |
439 | - break; | |
440 | - case 'createDir': | |
441 | - this.createDir(); | |
442 | - break; | |
443 | - case 'createLeaf': | |
444 | - this.createLeaf(this); | |
445 | - break; | |
446 | - case 'renameNode': | |
447 | - this.renameNode(); | |
448 | - break; | |
449 | - case 'editLeaf': | |
450 | - this.editLeaf(); | |
451 | - break; | |
452 | - case 'deleteMulti': | |
453 | - this.deleteMulti(); | |
454 | - break; | |
455 | - case 'plotParam': | |
456 | - this.createPlot(this); | |
457 | - break; | |
458 | - case 'downParam': | |
459 | - this.createDownload(this); | |
460 | - break; | |
461 | - default: | |
462 | - break; | |
463 | - } // switch end | |
464 | - }, | |
465 | - | |
466 | - | |
467 | - getTimeFromNode: function(node) { | |
468 | - | |
469 | - var startString = new String(node.get('globalStart')); | |
470 | - var stopString = new String(node.get('globalStop')); | |
471 | - var startDate = new Date(startString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); | |
472 | - var stopDate = new Date(stopString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); | |
473 | - if (stopDate - startDate > 86400000 ) { | |
474 | - var startTime = Ext.Date.add(stopDate, Ext.Date.DAY, -1); | |
475 | - var timeObj = {start: Ext.Date.format(startTime, 'Y/m/d H:i:s'), stop: Ext.Date.format(stopDate, 'Y/m/d H:i:s')}; | |
476 | - } | |
477 | - else { | |
478 | - var timeObj = {start: node.get('globalStart'), stop: node.get('globalStop')}; | |
479 | - } | |
480 | - return timeObj; | |
481 | - | |
482 | - }, | |
483 | - | |
484 | - createPlot: function(node) | |
485 | - { | |
486 | - if (node.get('disable')) return; | |
487 | - | |
488 | - var me = this; | |
489 | - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) { | |
490 | - if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.plot.id)) { | |
491 | - var request = Ext.create(amdaPlotObj.PlotRequestObject.$className); | |
492 | - var newNode = Ext.create(amdaModel.PlotNode.$className, { object : request }); | |
493 | - // edit newNode into Plot Module with node as contextNode | |
494 | - newNode.editInModule(); | |
495 | - if(node.get('globalStart') != 'depending on mission' && ( node.get('nodeType') == 'localParam' || | |
496 | - node.get('nodeType') == 'myDataParam')) { | |
497 | - module.getUiContent().setTimeFromData(me.getTimeFromNode(node)); | |
498 | - } | |
499 | - } | |
500 | - module.getUiContent().addParameter(node); | |
501 | - }); | |
502 | - }, | |
476 | + createPlot: function(node) | |
477 | + { | |
478 | + if (node.get('disable')) return; | |
479 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) { | |
480 | + if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.plot.id)) { | |
481 | + var request = Ext.create(amdaPlotObj.PlotRequestObject.$className); | |
482 | + var newNode = Ext.create(amdaModel.PlotNode.$className, { object : request }); | |
483 | + // edit newNode into Plot Module with node as contextNode | |
484 | + newNode.editInModule(); | |
485 | + if(node.get('globalStart') != 'depending on mission' && ( node.get('nodeType') == 'localParam' || | |
486 | + node.get('nodeType') == 'myDataParam')) { | |
487 | + module.getUiContent().setTimeFromData(node.getTimeFromNode(node)); | |
488 | + } | |
489 | + } | |
490 | + module.getUiContent().addParameter(node); | |
491 | + }); | |
492 | + }, | |
503 | 493 | |
504 | - createDownload: function(node) | |
505 | - { | |
506 | - if (node.get('disable')) return; | |
507 | - | |
508 | - if (node.get('notyet')) { | |
509 | - myDesktopApp.warningMsg('Sorry! access to this parameter is restricted.'); | |
510 | - return; | |
511 | - } | |
512 | - | |
513 | - var me = this; | |
514 | - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id, true, function (module) { | |
515 | - if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.download.id)) { | |
516 | - var request = Ext.create(amdaModel.Download.$className); | |
517 | - amdaModel.DownloadNode.set('object',request); | |
518 | - // singleton! | |
519 | - amdaModel.DownloadNode.editInModule(); | |
520 | - if(node.get('globalStart') != 'depending on mission' && ( node.get('nodeType') == 'localParam' || | |
521 | - node.get('nodeType') == 'myDataParam')) { | |
522 | - module.getUiContent().setTimeFromData(me.getTimeFromNode(node)); | |
523 | - } | |
524 | - } | |
525 | - if (node.get('needsArgs') && !node.get('isSpectra')) { | |
526 | - module.getUiContent().fireEvent('openParamEditor',node.get('id')); | |
527 | - } | |
528 | - else { | |
529 | - var paramName; | |
530 | - var components = null; | |
531 | - switch (node.$className) { | |
532 | - case 'amdaModel.AliasNode' : | |
533 | - paramName = "#"+node.get('text'); | |
534 | - break; | |
535 | - case 'amdaModel.DerivedParamNode' : | |
536 | - paramName = "ws_"+node.get('text'); | |
537 | - break; | |
538 | - case 'amdaModel.MyDataParamNode' : | |
539 | - paramName = 'wsd_'+node.get('text'); | |
540 | - break; | |
541 | - default : | |
542 | - if (node.get('alias')!= "" ) | |
543 | - paramName = "#"+node.get('alias'); | |
544 | - else | |
545 | - paramName = node.get('id'); | |
546 | - } | |
547 | - | |
548 | - var component_info = node.get('component_info'); | |
549 | - if (component_info && component_info.parentId) { | |
550 | - //It's a component | |
551 | - paramName = component_info.parentId; | |
552 | - components = []; | |
553 | - if (component_info.index1) | |
554 | - components['index1'] = component_info.index1; | |
555 | - if (component_info.index2) | |
556 | - components['index2'] = component_info.index2; | |
557 | - } | |
558 | - | |
559 | - module.addParam(paramName,true,node.get('needsArgs'),components); | |
560 | - } | |
561 | - }); | |
562 | - | |
563 | - | |
564 | - }, | |
565 | - deleteNode: function() { | |
566 | - | |
567 | - // if the target is a directory | |
568 | - if (!this.isLeaf()) { | |
569 | - // determine if this directory is empty before launching the delete confirmation method | |
570 | - this.isNotEmptyDir(this.confirmDirectoryDeletion); | |
571 | - | |
572 | - // else (the target is a leaf) | |
573 | - } else { | |
574 | - // no confirmation prompt for leaves | |
575 | - this.confirmDirectoryDeletion(false); | |
576 | - } | |
577 | - }, | |
494 | + createDownload: function(node) | |
495 | + { | |
496 | + if (node.get('disable')) return; | |
497 | + | |
498 | + if (node.get('notyet')) { | |
499 | + myDesktopApp.warningMsg('Sorry! access to this parameter is restricted.'); | |
500 | + return; | |
501 | + } | |
502 | + | |
503 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id, true, function (module) { | |
504 | + if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.download.id)) { | |
505 | + var request = Ext.create(amdaModel.Download.$className); | |
506 | + amdaModel.DownloadNode.set('object',request); | |
507 | + // singleton! | |
508 | + amdaModel.DownloadNode.editInModule(); | |
509 | + if(node.get('globalStart') != 'depending on mission' && ( node.get('nodeType') == 'localParam' || | |
510 | + node.get('nodeType') == 'myDataParam')) { | |
511 | + module.getUiContent().setTimeFromData(node.getTimeFromNode(node)); | |
512 | + } | |
513 | + } | |
514 | + if (node.get('needsArgs') && !node.get('isSpectra')) { | |
515 | + module.getUiContent().fireEvent('openParamEditor',node.get('id')); | |
516 | + } | |
517 | + else { | |
518 | + var paramName; | |
519 | + var components = null; | |
520 | + switch (node.$className) { | |
521 | + case 'amdaModel.AliasNode' : | |
522 | + paramName = "#"+node.get('text'); | |
523 | + break; | |
524 | + case 'amdaModel.DerivedParamNode' : | |
525 | + paramName = "ws_"+node.get('text'); | |
526 | + break; | |
527 | + case 'amdaModel.MyDataParamNode' : | |
528 | + paramName = 'wsd_'+node.get('text'); | |
529 | + break; | |
530 | + default : | |
531 | + if (node.get('alias')!= "" ) | |
532 | + paramName = "#"+node.get('alias'); | |
533 | + else | |
534 | + paramName = node.get('id'); | |
535 | + } | |
536 | + var component_info = node.get('component_info'); | |
537 | + if (component_info && component_info.parentId) { | |
538 | + //It's a component | |
539 | + paramName = component_info.parentId; | |
540 | + components = []; | |
541 | + if (component_info.index1) | |
542 | + components['index1'] = component_info.index1; | |
543 | + if (component_info.index2) | |
544 | + components['index2'] = component_info.index2; | |
545 | + } | |
546 | + module.addParam(paramName,true,node.get('needsArgs'),components); | |
547 | + } | |
548 | + }); | |
549 | + }, | |
550 | + | |
551 | + deleteNode: function() { | |
552 | + // if the target is a directory | |
553 | + if (!this.isLeaf()) { | |
554 | + // determine if this directory is empty before launching the delete confirmation method | |
555 | + this.isNotEmptyDir(this.confirmDirectoryDeletion); | |
556 | + // else (the target is a leaf) | |
557 | + } else { | |
558 | + // no confirmation prompt for leaves | |
559 | + this.confirmDirectoryDeletion(false); | |
560 | + } | |
561 | + }, | |
578 | 562 | |
579 | - /** | |
580 | - * this method return if node has Childs even if it was not already loaded | |
581 | - */ | |
582 | - isNotEmptyDir : function(callbackFn) { | |
583 | - var hasChilds; | |
584 | - // if node not already loaded | |
585 | - if (!this.isLoaded()){ | |
586 | - // call directFunction to load this node | |
587 | - AmdaAction.getTree({node:this.get('id'),nodeType:this.get('nodeType')},function(res,e){ | |
588 | - callbackFn.call(this,res.length>0?true:false); | |
589 | - },this); | |
590 | - } | |
591 | - else { | |
592 | - callbackFn.call(this,this.hasChildNodes()); | |
593 | - } | |
594 | - }, | |
563 | +/** | |
564 | +* this method return if node has Childs even if it was not already loaded | |
565 | +*/ | |
566 | + isNotEmptyDir : function(callbackFn) { | |
567 | + var hasChilds; | |
568 | + // if node not already loaded | |
569 | + if (!this.isLoaded()){ | |
570 | + // call directFunction to load this node | |
571 | + AmdaAction.getTree({node:this.get('id'),nodeType:this.get('nodeType')},function(res,e){ | |
572 | + callbackFn.call(this,res.length>0?true:false); | |
573 | + },this); | |
574 | + } | |
575 | + else { | |
576 | + callbackFn.call(this,this.hasChildNodes()); | |
577 | + } | |
578 | + }, | |
595 | 579 | |
596 | - /** | |
597 | - * this method is used to display a confirmation message | |
598 | - */ | |
599 | - confirmDirectoryDeletion : function(isNotEmptyDir) | |
600 | - { | |
601 | - // if this is a non-empty directory | |
602 | - if (isNotEmptyDir) { | |
603 | - // Prompt to the user if he also wants to delete its content | |
604 | - Ext.Msg.confirm('non-empty directory', 'The target is a non-empty directory!<br>Do you want to continue and also delete its content?', function(btn, text){ | |
605 | - if (btn == 'yes'){ | |
606 | - // do delete | |
607 | - this.realDelete(); | |
608 | - } | |
609 | - },this); | |
610 | - } else { | |
611 | - this.realDelete(); | |
612 | - } | |
613 | - }, | |
580 | +/** | |
581 | +* this method is used to display a confirmation message | |
582 | +*/ | |
583 | + confirmDirectoryDeletion : function(isNotEmptyDir) | |
584 | + { | |
585 | + // if this is a non-empty directory | |
586 | + if (isNotEmptyDir) { | |
587 | + // Prompt to the user if he also wants to delete its content | |
588 | + Ext.Msg.confirm('non-empty directory', 'The target is a non-empty directory!<br>Do you want to continue and also delete its content?', function(btn, text){ | |
589 | + if (btn == 'yes'){ | |
590 | + // do delete | |
591 | + this.realDelete(); | |
592 | + } | |
593 | + },this); | |
594 | + } | |
595 | + else { | |
596 | + this.realDelete(); | |
597 | + } | |
598 | + }, | |
614 | 599 | |
615 | - /* | |
616 | - * Call the extDirect method to delete parameter | |
617 | - * Callback method needed to execute node deletion in tree if id in result or to show error msg | |
618 | - */ | |
619 | - realDelete : function() | |
620 | - { | |
621 | - AmdaAction.deleteObject({id: this.get('id'), leaf: this.isLeaf(), nodeType: this.get('nodeType')}, function(res,e){ | |
622 | - //TODO proper errors handling | |
623 | - // node deletion in tree | |
624 | - if (res) { // if success | |
625 | - if (res.id) { | |
626 | - //Ext.Msg.show({title:'Warning', msg: 'Requests with parameter '+node.data.text+' are deleted', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); | |
627 | - if (this.parentNode) { | |
628 | - if (this.isLeaf()){ | |
629 | - var moduleId = this.get('moduleId'); | |
630 | - // if really interactive node | |
631 | - if (moduleId) { | |
632 | - var me = this; | |
633 | - myDesktopApp.getLoadedModule(moduleId, true, function (module) { | |
634 | - var editedNode = module.getLinkedNode(); | |
635 | - // file node is not linked directly to the module | |
636 | - var isThisFile = false; | |
600 | +/* | |
601 | +* Call the extDirect method to delete parameter | |
602 | +* Callback method needed to execute node deletion in tree if id in result or to show error msg | |
603 | +*/ | |
604 | + realDelete : function() | |
605 | + { | |
606 | + AmdaAction.deleteObject({id: this.get('id'), leaf: this.isLeaf(), nodeType: this.get('nodeType')}, function(res,e){ | |
607 | + //TODO proper errors handling | |
608 | + // node deletion in tree | |
609 | + if (res) { // if success | |
610 | + if (res.id) { | |
611 | + //Ext.Msg.show({title:'Warning', msg: 'Requests with parameter '+node.data.text+' are deleted', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); | |
612 | + if (this.parentNode) { | |
613 | + if (this.isLeaf()){ | |
614 | + var moduleId = this.get('moduleId'); | |
615 | + // if really interactive node | |
616 | + if (moduleId) { | |
617 | + var me = this; | |
618 | + myDesktopApp.getLoadedModule(moduleId, true, function (module) { | |
619 | + var editedNode = module.getLinkedNode(); | |
620 | + // file node is not linked directly to the module | |
621 | + var isThisFile = false; | |
622 | + | |
623 | + if (editedNode && editedNode.$className == 'amdaModel.MyDataParamNode') | |
624 | + if (editedNode.get('fileObject').get('fileName') == me.get('text')) | |
625 | + isThisFile = true; | |
637 | 626 | |
638 | - if (editedNode && editedNode.$className == 'amdaModel.MyDataParamNode') | |
639 | - if (editedNode.get('fileObject').get('fileName') == me.get('text')) | |
640 | - isThisFile = true; | |
641 | - | |
642 | - if (me.$className == 'amdaModel.DerivedParamNode') | |
643 | - { | |
644 | - var obj = { | |
645 | - paramId : 'ws_'+me.get('text') | |
646 | - }; | |
647 | - AmdaAction.compilParamDelete(obj); | |
648 | - } | |
627 | + if (me.$className == 'amdaModel.DerivedParamNode') | |
628 | + { | |
629 | + var obj = { | |
630 | + paramId : 'ws_'+me.get('text') | |
631 | + }; | |
632 | + AmdaAction.compilParamDelete(obj); | |
633 | + } | |
649 | 634 | |
650 | - if (editedNode === me || isThisFile){ | |
651 | - var newNode = Ext.ModelManager.create({leaf : true}, me.$className); | |
652 | - // several tabs could be connected to one node | |
653 | - if (moduleId === myDesktopApp.dynamicModules.plot.id) { | |
654 | - var linkedNodes = module.linkedNodes; | |
655 | - | |
656 | - if (linkedNodes) { | |
657 | - linkedNodes.each(function(key, value){ | |
658 | - if (value === me) { | |
659 | - linkedNodes.replace(key,newNode); | |
660 | - var tabPanel = module.getUiContent().tabPanel.items.getByKey(key); | |
661 | - tabPanel.setObject(Ext.create(amdaModel.Plot.$className, {})); | |
662 | - } | |
663 | - }, me); | |
664 | - } | |
665 | - } | |
666 | - newNode.editInModule(); | |
667 | - } | |
668 | - }); | |
669 | - | |
670 | - } | |
671 | - } | |
672 | - | |
673 | - //update mask info in myData | |
674 | - if (res.maskDesc && !res.maskDeleted) { | |
675 | - this.parentNode.set('info', res.maskDesc); | |
676 | - this.updateMyDataParam(res.mask, res.maskDesc); | |
677 | - } | |
678 | - | |
679 | - this.remove(); | |
680 | - } | |
681 | - //TODO Several special node-dependent actions - to move to node functions.. | |
682 | - // nodes of another nodeType to be deleted as they depend on deleted node | |
683 | - if (res.params) { | |
684 | - this.deleteDependence(res.params); | |
685 | - //TODO reset | |
686 | - } | |
687 | - | |
688 | - // mask was deleted or updated - to update mydata tree | |
689 | - if (res.maskDeleted) { | |
690 | - this.updateMyData(); | |
691 | - } | |
692 | - | |
693 | - } | |
694 | - else { | |
695 | - myDesktopApp.warningMsg(res.error); | |
696 | - } | |
697 | - } | |
698 | - else { | |
699 | - myDesktopApp.errorMsg(e.message); | |
700 | - } | |
701 | - }, this); | |
702 | - }, | |
635 | + if (editedNode === me || isThisFile){ | |
636 | + var newNode = Ext.ModelManager.create({leaf : true}, me.$className); | |
637 | + // several tabs could be connected to one node | |
638 | + if (moduleId === myDesktopApp.dynamicModules.plot.id) { | |
639 | + var linkedNodes = module.linkedNodes; | |
640 | + | |
641 | + if (linkedNodes) { | |
642 | + linkedNodes.each(function(key, value){ | |
643 | + if (value === me) { | |
644 | + linkedNodes.replace(key,newNode); | |
645 | + var tabPanel = module.getUiContent().tabPanel.items.getByKey(key); | |
646 | + tabPanel.setObject(Ext.create(amdaModel.Plot.$className, {})); | |
647 | + } | |
648 | + }, me); | |
649 | + } | |
650 | + } | |
651 | + newNode.editInModule(); | |
652 | + } | |
653 | + }); | |
654 | + } | |
655 | + } | |
656 | + //update mask info in myData | |
657 | + if (res.maskDesc && !res.maskDeleted) { | |
658 | + this.parentNode.set('info', res.maskDesc); | |
659 | + this.updateMyDataParam(res.mask, res.maskDesc); | |
660 | + } | |
661 | + this.remove(); | |
662 | + } | |
663 | + //TODO Several special node-dependent actions - to move to node functions.. | |
664 | + // nodes of another nodeType to be deleted as they depend on deleted node | |
665 | + if (res.params) { | |
666 | + this.deleteDependence(res.params); | |
667 | + //TODO reset | |
668 | + } | |
669 | + // mask was deleted or updated - to update mydata tree | |
670 | + if (res.maskDeleted) { | |
671 | + this.updateMyData(); | |
672 | + } | |
673 | + } | |
674 | + else { | |
675 | + myDesktopApp.warningMsg(res.error); | |
676 | + } | |
677 | + } | |
678 | + else { | |
679 | + myDesktopApp.errorMsg(e.message); | |
680 | + } | |
681 | + }, this); | |
682 | + }, | |
703 | 683 | |
704 | - /* | |
705 | - * Delete musti selection | |
706 | - */ | |
707 | - deleteMulti: function() | |
708 | - { | |
709 | - var selection = this.myGetOwnerTree().getSelectionModel().selected.items; | |
710 | - alert(selection.length +' to delete!'); | |
711 | - Ext.Array.each(selection,function(item,index,allItems){ | |
712 | - item.deleteNode(); | |
713 | - }) | |
714 | - }, | |
684 | +/* | |
685 | +* Delete musti selection | |
686 | +*/ | |
687 | + deleteMulti: function() | |
688 | + { | |
689 | + var selection = this.myGetOwnerTree().getSelectionModel().selected.items; | |
690 | + alert(selection.length +' to delete!'); | |
691 | + Ext.Array.each(selection,function(item,index,allItems){ | |
692 | + item.deleteNode(); | |
693 | + }) | |
694 | + }, | |
715 | 695 | |
716 | - /* | |
717 | - * Create Folder | |
718 | - */ | |
719 | - createDir: function() { | |
720 | - var me = this; | |
721 | - amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), | |
722 | - function() | |
723 | - { | |
724 | - var newNode = Ext.create(me.$className, | |
725 | - { | |
726 | - leaf : false, nodeType : me.get('nodeType'), | |
727 | - text : amdaModel.AmdaNode.NEW_DIR_NAME, | |
728 | - children : [] | |
729 | - }); | |
696 | +/* | |
697 | +* Create Folder | |
698 | +*/ | |
699 | + createDir: function() { | |
700 | + var me = this; | |
701 | + amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), | |
702 | + function() | |
703 | + { | |
704 | + var newNode = Ext.create(me.$className, | |
705 | + { | |
706 | + leaf : false, nodeType : me.get('nodeType'), | |
707 | + text : amdaModel.AmdaNode.NEW_DIR_NAME, | |
708 | + children : [] | |
709 | + }); | |
730 | 710 | |
731 | - // insert the new node as a child of node | |
732 | - newNode = me.insertChild(0, newNode); | |
733 | - // start text edition on this new directory node | |
734 | - me.expand(false); | |
735 | - newNode.expand(false); | |
711 | + // insert the new node as a child of node | |
712 | + newNode = me.insertChild(0, newNode); | |
713 | + // start text edition on this new directory node | |
714 | + me.expand(false); | |
715 | + newNode.expand(false); | |
736 | 716 | |
737 | - // select the new node | |
738 | - me.myGetOwnerTree().getSelectionModel().select(newNode); | |
739 | - // call the renameNode method for this new node | |
740 | - newNode.renameNode(); | |
741 | - }); | |
742 | - }, | |
717 | + // select the new node | |
718 | + me.myGetOwnerTree().getSelectionModel().select(newNode); | |
719 | + // call the renameNode method for this new node | |
720 | + newNode.renameNode(); | |
721 | + }); | |
722 | + }, | |
743 | 723 | |
744 | - /* | |
745 | - * | |
746 | - */ | |
747 | - createLeaf: function(contextNode) { | |
748 | - // create new node with the same type than the contextNode | |
749 | - var newNode = Ext.create(contextNode.$className, {leaf : true}); | |
724 | +/* | |
725 | +* | |
726 | +*/ | |
727 | + createLeaf: function(contextNode) { | |
728 | + // create new node with the same type than the contextNode | |
729 | + var newNode = Ext.create(contextNode.$className, {leaf : true}); | |
750 | 730 | |
751 | - // load the rootNode and recursively all its child nodes | |
752 | - amdaModel.InteractiveNode.preloadNodes(contextNode.getRootNode(), | |
753 | - function() | |
754 | - { | |
755 | - // edit newNode into Parameter Module with node as contextNode | |
756 | - newNode.editInModule(contextNode); | |
757 | - }); | |
758 | - }, | |
731 | + // load the rootNode and recursively all its child nodes | |
732 | + amdaModel.InteractiveNode.preloadNodes(contextNode.getRootNode(), | |
733 | + function() | |
734 | + { | |
735 | + // edit newNode into Parameter Module with node as contextNode | |
736 | + newNode.editInModule(contextNode); | |
737 | + }); | |
738 | + }, | |
759 | 739 | |
760 | - renameNode: function() { | |
761 | - if (this.myGetOwnerTree()) | |
762 | - { | |
763 | - // load the rootNode and recursively all its child nodes if not already loaded | |
764 | - var me = this; | |
765 | - amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), | |
766 | - function() | |
767 | - { | |
768 | - // fire the edition event on tree | |
769 | - me.myGetOwnerTree().fireEvent('edition',me.myGetOwnerTree().view, me.myGetOwnerTree().getSelectionModel().selected.items[0]); | |
770 | - }); | |
771 | - } | |
772 | - else | |
773 | - { | |
774 | - myDesktopApp.errorMsg('tree is undefined'); | |
775 | - //TODO: log error... tree is undefined | |
776 | - } | |
777 | - }, | |
778 | - | |
779 | - /* | |
780 | - * load the rootNode and recursively all its child nodes | |
781 | - * to know all names of DerivedParameters | |
782 | - */ | |
783 | - editLeaf: function(onReady) | |
784 | - { | |
785 | - var me = this; | |
786 | - amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), | |
787 | - function() | |
788 | - { | |
789 | - if (me.get('object')) | |
790 | - { | |
791 | - // launch edition of parameter into parameter module | |
792 | - me.editInModule(null, onReady); | |
793 | - } | |
794 | - else | |
795 | - { | |
796 | - // call the ext method to get the details of parameter | |
797 | - // the edition of real parameter is done into callback method getObjectCallback | |
798 | - AmdaAction.getObject(me.get('id'), me.get('nodeType'), me.getObjectCallback, me); | |
799 | - } | |
800 | - }); | |
801 | - }, | |
740 | + renameNode: function() | |
741 | + { | |
742 | + if (this.myGetOwnerTree()) | |
743 | + { | |
744 | + // load the rootNode and recursively all its child nodes if not already loaded | |
745 | + var me = this; | |
746 | + amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), | |
747 | + function() | |
748 | + { | |
749 | + // fire the edition event on tree | |
750 | + me.myGetOwnerTree().fireEvent('edition',me.myGetOwnerTree().view, me.myGetOwnerTree().getSelectionModel().selected.items[0]); | |
751 | + }); | |
752 | + } | |
753 | + else | |
754 | + { | |
755 | + myDesktopApp.errorMsg('tree is undefined'); | |
756 | + } | |
757 | + }, | |
802 | 758 | |
803 | - /* | |
804 | - * | |
805 | - */ | |
806 | - getObjectCallback : function(result,remoteEvent) | |
807 | - { | |
808 | - var t = remoteEvent.getTransaction(); | |
809 | - | |
810 | - if (result) { | |
811 | - var paramObj = Ext.create(this.get('objectDataModel'), result); | |
759 | +/* | |
760 | +* load the rootNode and recursively all its child nodes | |
761 | +* to know all names of DerivedParameters | |
762 | +*/ | |
763 | + editLeaf: function(onReady) | |
764 | + { | |
765 | + var me = this; | |
766 | + amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), | |
767 | + function() | |
768 | + { | |
769 | + if (me.get('object')) | |
770 | + { | |
771 | + // launch edition of parameter into parameter module | |
772 | + me.editInModule(null, onReady); | |
773 | + } | |
774 | + else | |
775 | + { | |
776 | + // call the ext method to get the details of parameter | |
777 | + // the edition of real parameter is done into callback method getObjectCallback | |
778 | + AmdaAction.getObject(me.get('id'), me.get('nodeType'), me.getObjectCallback, me); | |
779 | + } | |
780 | + }); | |
781 | + }, | |
812 | 782 | |
813 | - // set parameter into node | |
814 | - this.set('object',paramObj); | |
815 | - // Edition of parameter into parameter Module | |
816 | - this.editInModule(); | |
817 | - } | |
818 | - else { | |
819 | - // EXCEPTION : parameter not found !? | |
820 | - myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '" | |
821 | - + this.get('name') + "' found!"); | |
822 | - } | |
823 | - } | |
783 | +/* | |
784 | +* | |
785 | +*/ | |
786 | + getObjectCallback : function(result,remoteEvent) | |
787 | + { | |
788 | + var t = remoteEvent.getTransaction(); | |
789 | + | |
790 | + if (result) { | |
791 | + var paramObj = Ext.create(this.get('objectDataModel'), result); | |
792 | + // set parameter into node | |
793 | + this.set('object',paramObj); | |
794 | + // Edition of parameter into parameter Module | |
795 | + this.editInModule(); | |
796 | + } | |
797 | + else { | |
798 | + // EXCEPTION : parameter not found !? | |
799 | + myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '" | |
800 | + + this.get('name') + "' found!"); | |
801 | + } | |
802 | + } | |
824 | 803 | }); |
... | ... |
js/app/models/LocalParamNode.js
... | ... | @@ -10,243 +10,240 @@ |
10 | 10 | |
11 | 11 | Ext.define('amdaModel.LocalParamNode', |
12 | 12 | { |
13 | - extend: 'amdaModel.InteractiveNode', | |
14 | - | |
15 | - statics: | |
16 | - { | |
17 | - nodeType: 'localParam' | |
18 | - }, | |
19 | - | |
20 | - fields: | |
21 | - [ | |
22 | - {name: 'alias', type:'string', persist: false}, | |
23 | - {name: 'isParameter', type: 'boolean', persist: false}, | |
24 | - {name: 'notyet', type: 'boolean', defaultValue: false, persist: false}, | |
25 | - {name: 'needsArgs', type: 'boolean', persist: false}, | |
26 | - {name: 'isSpectra', type: 'boolean', defaultValue: false, persist: false}, | |
27 | - {name: 'isStack', type: 'boolean', defaultValue: true, persist: false}, | |
28 | - {name: 'globalStart', type: 'string', persist: false}, | |
29 | - {name: 'globalStop', type: 'string', persist: false}, | |
30 | - {name: 'timeRestriction', type: 'boolean', persist: false}, | |
31 | - {name: 'rank', type: 'integer', persist: false, defaultValue: null} | |
32 | - ], | |
13 | + extend: 'amdaModel.InteractiveNode', | |
14 | + | |
15 | + statics: | |
16 | + { | |
17 | + nodeType: 'localParam' | |
18 | + }, | |
33 | 19 | |
34 | - constructor : function(config) | |
35 | - { | |
36 | - this.callParent(arguments); | |
20 | + fields: | |
21 | + [ | |
22 | + {name: 'alias', type:'string', persist: false}, | |
23 | + {name: 'isParameter', type: 'boolean', persist: false}, | |
24 | + {name: 'notyet', type: 'boolean', defaultValue: false, persist: false}, | |
25 | + {name: 'needsArgs', type: 'boolean', persist: false}, | |
26 | + {name: 'isSpectra', type: 'boolean', defaultValue: false, persist: false}, | |
27 | + {name: 'isStack', type: 'boolean', defaultValue: true, persist: false}, | |
28 | + {name: 'globalStart', type: 'string', persist: false}, | |
29 | + {name: 'globalStop', type: 'string', persist: false}, | |
30 | + {name: 'timeRestriction', type: 'boolean', persist: false}, | |
31 | + {name: 'rank', type: 'integer', persist: false, defaultValue: null} | |
32 | + ], | |
37 | 33 | |
38 | - this.set('allowDrop', true); | |
39 | - this.set('moduleId',myDesktopApp.dynamicModules.param.id); | |
40 | - this.set('objectDataModel',amdaModel.Parameter.$className); | |
41 | - | |
42 | - // if future missions or 'depending on mission' | |
43 | - if (this.get('globalStart')) { | |
44 | - var now = Ext.Date.format(new Date(), 'Y/m/d'); | |
45 | - if ( this.get('globalStart') > now ) | |
46 | - this.set('cls','predicted'); | |
47 | - } | |
48 | - // time restriction on parameters | |
49 | - if (this.get('timeRestriction')) { | |
50 | - // this.set('cls','predicted'); | |
51 | - var id = this.get('id'); | |
52 | - var bracketPos = id.indexOf("("); | |
53 | - if (bracketPos > 0) { | |
54 | - id = Ext.String.insert(id, '_restr', bracketPos); | |
55 | - } | |
56 | - else { | |
57 | - id += '_restr'; | |
58 | - } | |
59 | - this.set('id', id); | |
60 | - } | |
61 | - | |
62 | - if (this.get('rank')) { | |
63 | - var rank = this.get('rank'); | |
64 | - if (rank == 1) this.set('iconCls', 'icon-mercury'); | |
65 | - if (rank == 2) this.set('iconCls', 'icon-venus'); | |
66 | - if (rank == 5) this.set('iconCls', 'icon-earth'); | |
67 | - if (rank == 6) this.set('iconCls', 'icon-earth'); | |
68 | - if (rank == 7) this.set('iconCls', 'icon-mars'); | |
69 | - if (rank == 8) this.set('iconCls', 'icon-jupiter'); | |
70 | - if (rank == 9) this.set('iconCls', 'icon-saturn'); | |
71 | - if (rank == 93) this.set('iconCls', 'icon-comet'); | |
72 | - if (rank == 3) this.set('iconCls', 'icon-sw'); | |
73 | - if (rank == 4) this.set('iconCls', 'icon-sw'); | |
74 | - if (rank >= 99) this.set('iconCls', 'icon-solarsystem'); | |
75 | - } | |
34 | + constructor : function(config) | |
35 | + { | |
36 | + this.callParent(arguments); | |
37 | + | |
38 | + this.set('allowDrop', true); | |
39 | + this.set('moduleId',myDesktopApp.dynamicModules.param.id); | |
40 | + this.set('objectDataModel',amdaModel.Parameter.$className); | |
41 | + | |
42 | + // if future missions or 'depending on mission' | |
43 | + if (this.get('globalStart')) { | |
44 | + var now = Ext.Date.format(new Date(), 'Y/m/d'); | |
45 | + if ( this.get('globalStart') > now ) | |
46 | + this.set('cls','predicted'); | |
47 | + } | |
48 | + // time restriction on parameters | |
49 | + if (this.get('timeRestriction')) { | |
50 | + // this.set('cls','predicted'); | |
51 | + var id = this.get('id'); | |
52 | + var bracketPos = id.indexOf("("); | |
53 | + if (bracketPos > 0) { | |
54 | + id = Ext.String.insert(id, '_restr', bracketPos); | |
55 | + } | |
56 | + else { | |
57 | + id += '_restr'; | |
58 | + } | |
59 | + this.set('id', id); | |
60 | + } | |
61 | + | |
62 | + if (this.get('rank')) { | |
63 | + var rank = this.get('rank'); | |
64 | + if (rank == 1) this.set('iconCls', 'icon-mercury'); | |
65 | + if (rank == 2) this.set('iconCls', 'icon-venus'); | |
66 | + if (rank == 5) this.set('iconCls', 'icon-earth'); | |
67 | + if (rank == 6) this.set('iconCls', 'icon-earth'); | |
68 | + if (rank == 7) this.set('iconCls', 'icon-mars'); | |
69 | + if (rank == 8) this.set('iconCls', 'icon-jupiter'); | |
70 | + if (rank == 9) this.set('iconCls', 'icon-saturn'); | |
71 | + if (rank == 93) this.set('iconCls', 'icon-comet'); | |
72 | + if (rank == 3) this.set('iconCls', 'icon-sw'); | |
73 | + if (rank == 4) this.set('iconCls', 'icon-sw'); | |
74 | + if (rank >= 99) this.set('iconCls', 'icon-solarsystem'); | |
75 | + } | |
76 | 76 | |
77 | - if (this.get('isParameter')) | |
78 | - { | |
79 | - if (this.get('leaf')) this.set('iconCls', 'icon-scalar'); | |
80 | - else this.set('iconCls', 'icon-vector'); | |
81 | - | |
82 | - if (this.get('isStack') || this.get('isSpectra')) this.set('iconCls', 'icon-spectra'); | |
83 | - } | |
84 | - }, | |
85 | - | |
86 | - allMenuItems : function() | |
87 | - { | |
88 | - var menuItems = | |
89 | - [{ | |
90 | - fnId : 'root-collapseAll', | |
91 | - text : 'Close All', | |
92 | - hidden : true | |
93 | - }, { | |
94 | - fnId : 'dire-collapseAll', | |
95 | - text : 'Close All', | |
96 | - hidden : true | |
97 | - }, { | |
98 | - fnId : 'para-plotParam', | |
99 | - text : 'Plot Parameter', | |
100 | - hidden : true | |
101 | - }, { | |
102 | - fnId : 'para-downParam', | |
103 | - text : 'Download Parameter', | |
104 | - hidden : true | |
105 | - },{ | |
106 | - fnId : 'leaf-createAlias', | |
107 | - text : 'Create/Edit Alias', | |
108 | - hidden : true | |
109 | - },{ | |
110 | - fnId : 'leaf-createDerivedParam', | |
111 | - text : 'Create Derived Parameter', | |
112 | - hidden : true | |
113 | - },{ | |
114 | - fnId : 'leaf-plotParam', | |
115 | - text : 'Plot Parameter', | |
116 | - hidden : true | |
117 | - }, { | |
118 | - fnId : 'leaf-downParam', | |
119 | - text : 'Download Parameter', | |
120 | - hidden : true | |
121 | - }]; | |
77 | + if (this.get('isParameter')) | |
78 | + { | |
79 | + if (this.get('leaf')) | |
80 | + this.set('iconCls', 'icon-scalar'); | |
81 | + else | |
82 | + this.set('iconCls', 'icon-vector'); | |
83 | + | |
84 | + if (this.get('isStack') || this.get('isSpectra')) | |
85 | + this.set('iconCls', 'icon-spectra'); | |
86 | + } | |
87 | + }, | |
122 | 88 | |
123 | - return menuItems; | |
124 | - }, | |
89 | + allMenuItems : function() | |
90 | + { | |
91 | + var menuItems = | |
92 | + [{ | |
93 | + fnId : 'root-collapseAll', | |
94 | + text : 'Close All', | |
95 | + hidden : true | |
96 | + }, { | |
97 | + fnId : 'dire-collapseAll', | |
98 | + text : 'Close All', | |
99 | + hidden : true | |
100 | + }, { | |
101 | + fnId : 'para-plotParam', | |
102 | + text : 'Plot Parameter', | |
103 | + hidden : true | |
104 | + }, { | |
105 | + fnId : 'para-downParam', | |
106 | + text : 'Download Parameter', | |
107 | + hidden : true | |
108 | + },{ | |
109 | + fnId : 'leaf-createAlias', | |
110 | + text : 'Create/Edit Alias', | |
111 | + hidden : true | |
112 | + },{ | |
113 | + fnId : 'leaf-createDerivedParam', | |
114 | + text : 'Create Derived Parameter', | |
115 | + hidden : true | |
116 | + },{ | |
117 | + fnId : 'leaf-plotParam', | |
118 | + text : 'Plot Parameter', | |
119 | + hidden : true | |
120 | + }, { | |
121 | + fnId : 'leaf-downParam', | |
122 | + text : 'Download Parameter', | |
123 | + hidden : true | |
124 | + }]; | |
125 | 125 | |
126 | + return menuItems; | |
127 | + }, | |
126 | 128 | |
127 | - onMenuItemClick : function(menu,item,event) | |
128 | - { | |
129 | - switch (item.fnId) | |
130 | - { | |
131 | - case 'root-collapseAll': | |
132 | - case 'dire-collapseAll': | |
133 | - if(this && !this.isLeaf()) { | |
134 | - this.collapse(true); | |
135 | - } | |
136 | - break; | |
137 | - case 'leaf-plotParam': | |
138 | - case 'para-plotParam': | |
139 | - this.createPlot(this); | |
140 | - break; | |
141 | - case 'leaf-downParam': | |
142 | - case 'para-downParam': | |
143 | - this.createDownload(this); | |
144 | - break; | |
145 | - case 'leaf-createDerivedParam': | |
146 | - if (!this.get('notyet')) | |
147 | - this.createLeaf(this); | |
148 | - else | |
149 | - myDesktopApp.warningMsg("Sorry! access to this parameter is restricted"); | |
150 | - break; | |
151 | - case 'leaf-createAlias': | |
152 | - if (!this.get('notyet')) | |
153 | - this.createAlias(this); | |
154 | - else | |
155 | - myDesktopApp.warningMsg("Sorry! access to this parameter is restricted"); | |
156 | - | |
157 | - break; | |
158 | - default: | |
159 | - break; | |
160 | - | |
161 | - } | |
162 | - }, | |
163 | - | |
129 | + onMenuItemClick : function(menu,item,event) | |
130 | + { | |
131 | + switch (item.fnId) | |
132 | + { | |
133 | + case 'root-collapseAll': | |
134 | + case 'dire-collapseAll': | |
135 | + if(this && !this.isLeaf()) { | |
136 | + this.collapse(true); | |
137 | + } | |
138 | + break; | |
139 | + case 'leaf-plotParam': | |
140 | + case 'para-plotParam': | |
141 | + this.createPlot(this); | |
142 | + break; | |
143 | + case 'leaf-downParam': | |
144 | + case 'para-downParam': | |
145 | + this.createDownload(this); | |
146 | + break; | |
147 | + case 'leaf-createDerivedParam': | |
148 | + if (!this.get('notyet')) | |
149 | + this.createLeaf(this); | |
150 | + else | |
151 | + myDesktopApp.warningMsg("Sorry! access to this parameter is restricted"); | |
152 | + break; | |
153 | + case 'leaf-createAlias': | |
154 | + if (!this.get('notyet')) | |
155 | + this.createAlias(this); | |
156 | + else | |
157 | + myDesktopApp.warningMsg("Sorry! access to this parameter is restricted"); | |
158 | + | |
159 | + break; | |
160 | + default: | |
161 | + break; | |
162 | + } | |
163 | + }, | |
164 | 164 | |
165 | - createLeaf: function(node) | |
166 | - { | |
167 | - | |
168 | - // instanciate a Parameter object with the current data in his buidchain | |
169 | - var param = Ext.create(this.get('objectDataModel'));//, { buildchain: node.get('alias') ? "#"+node.get('alias') : node.get('id') }); | |
170 | - // instanciate a DerivedParamNode with this param object | |
171 | - var newNode = Ext.create(amdaModel.DerivedParamNode.$className, {leaf : true, object : param}); | |
172 | - | |
173 | - // edit newNode into Parameter Module with node as contextNode | |
174 | - newNode.editInModule(); | |
175 | - | |
176 | - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id, true, function(module) { | |
177 | - var paramName; | |
178 | - var components = null; | |
179 | - if (node.get('alias')!= "" ) | |
180 | - paramName = "#"+node.get('alias'); | |
181 | - else | |
182 | - paramName = node.get('id'); | |
183 | - var component_info = node.get('component_info'); | |
184 | - if (component_info && component_info.parentId) { | |
185 | - //It's a component | |
186 | - paramName = component_info.parentId; | |
187 | - components = []; | |
188 | - if (component_info.index1) | |
189 | - components['index1'] = component_info.index1; | |
190 | - if (component_info.index2) | |
191 | - components['index2'] = component_info.index2; | |
192 | - } | |
193 | - | |
194 | - module.addParam(paramName,true,node.get('needsArgs'),components); | |
195 | - }); | |
196 | - | |
197 | - }, | |
165 | + createLeaf: function(node) | |
166 | + { | |
167 | + // instanciate a Parameter object with the current data in his buidchain | |
168 | + var param = Ext.create(this.get('objectDataModel'));//, { buildchain: node.get('alias') ? "#"+node.get('alias') : node.get('id') }); | |
169 | + // instanciate a DerivedParamNode with this param object | |
170 | + var newNode = Ext.create(amdaModel.DerivedParamNode.$className, {leaf : true, object : param}); | |
198 | 171 | |
199 | - createAlias: function(node) | |
200 | - { | |
201 | - var win = myDesktopApp.desktop.getWindow('alias-win'); | |
202 | - if (!node.get('needsArgs') && node.get('leaf')) | |
203 | - { | |
204 | - if(!win) | |
205 | - { | |
206 | - var win = myDesktopApp.desktop.createWindow( | |
207 | - { | |
208 | - border: false, | |
209 | - id : 'alias-win', | |
210 | - title : 'Create Alias', | |
211 | - width : 400, | |
212 | - height : 200, | |
213 | - layout : 'border', | |
214 | - maximizable : false, | |
215 | - items : | |
216 | - [{ | |
217 | - xtype : 'alias', | |
218 | - region : 'center', | |
219 | - margins : | |
220 | - { | |
221 | - top: 0, | |
222 | - right: 5, | |
223 | - bottom: 5, | |
224 | - left: 5 | |
225 | - }, | |
226 | - paramNode : node, | |
227 | - id : 'aliasUI' | |
228 | - }] | |
229 | - }); | |
230 | - } | |
231 | - else | |
232 | - { | |
233 | - //Set data into Alias Widget | |
234 | - win.items.items[0].paramNode = node; | |
235 | - win.items.items[0].setAlias(node); | |
236 | - } | |
237 | - win.show(); | |
238 | - } | |
239 | - else | |
240 | - { | |
241 | - var message = 'Sorry, parameter ' + node.get('id') + ' cannot have alias'; | |
242 | - Ext.Msg.alert('Impossible Create Alias', message); | |
243 | - if (win) win.close(); | |
244 | - } | |
245 | - }, | |
172 | + // edit newNode into Parameter Module with node as contextNode | |
173 | + newNode.editInModule(); | |
174 | + | |
175 | + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id, true, function(module) { | |
176 | + var paramName; | |
177 | + var components = null; | |
178 | + if (node.get('alias')!= "" ) | |
179 | + paramName = "#"+node.get('alias'); | |
180 | + else | |
181 | + paramName = node.get('id'); | |
182 | + var component_info = node.get('component_info'); | |
183 | + if (component_info && component_info.parentId) { | |
184 | + //It's a component | |
185 | + paramName = component_info.parentId; | |
186 | + components = []; | |
187 | + if (component_info.index1) | |
188 | + components['index1'] = component_info.index1; | |
189 | + if (component_info.index2) | |
190 | + components['index2'] = component_info.index2; | |
191 | + } | |
192 | + | |
193 | + module.addParam(paramName,true,node.get('needsArgs'),components); | |
194 | + }); | |
195 | + }, | |
196 | + | |
197 | + createAlias: function(node) | |
198 | + { | |
199 | + var win = myDesktopApp.desktop.getWindow('alias-win'); | |
200 | + if (!node.get('needsArgs') && node.get('leaf')) | |
201 | + { | |
202 | + if(!win) | |
203 | + { | |
204 | + var win = myDesktopApp.desktop.createWindow( | |
205 | + { | |
206 | + border: false, | |
207 | + id : 'alias-win', | |
208 | + title : 'Create Alias', | |
209 | + width : 400, | |
210 | + height : 200, | |
211 | + layout : 'border', | |
212 | + maximizable : false, | |
213 | + items : | |
214 | + [{ | |
215 | + xtype : 'alias', | |
216 | + region : 'center', | |
217 | + margins : | |
218 | + { | |
219 | + top: 0, | |
220 | + right: 5, | |
221 | + bottom: 5, | |
222 | + left: 5 | |
223 | + }, | |
224 | + paramNode : node, | |
225 | + id : 'aliasUI' | |
226 | + }] | |
227 | + }); | |
228 | + } | |
229 | + else | |
230 | + { | |
231 | + //Set data into Alias Widget | |
232 | + win.items.items[0].paramNode = node; | |
233 | + win.items.items[0].setAlias(node); | |
234 | + } | |
235 | + win.show(); | |
236 | + } | |
237 | + else | |
238 | + { | |
239 | + var message = 'Sorry, parameter ' + node.get('id') + ' cannot have alias'; | |
240 | + Ext.Msg.alert('Impossible Create Alias', message); | |
241 | + if (win) win.close(); | |
242 | + } | |
243 | + }, | |
246 | 244 | |
247 | - isParameter : function() | |
248 | - { | |
249 | - return this.get('isParameter'); | |
250 | - } | |
251 | - | |
245 | + isParameter : function() | |
246 | + { | |
247 | + return this.get('isParameter'); | |
248 | + } | |
252 | 249 | }); |
... | ... |
js/app/models/TimeTableNode.js
... | ... | @@ -14,7 +14,7 @@ Ext.define('amdaModel.TimeTableNode', { |
14 | 14 | |
15 | 15 | statics: { |
16 | 16 | nodeType: 'timeTable', |
17 | - objectName: 'Time Table' | |
17 | + objectName: 'TimeTable' | |
18 | 18 | }, |
19 | 19 | |
20 | 20 | constructor : function(config) |
... | ... | @@ -51,7 +51,7 @@ Ext.define('amdaModel.TimeTableNode', { |
51 | 51 | [ |
52 | 52 | { |
53 | 53 | fnId : 'mult-downloadMulti', |
54 | - text : 'Download selected '+this.self.objectName+'s' | |
54 | + text : 'Download selected '+ this.self.objectName + 's' | |
55 | 55 | },{ |
56 | 56 | fnId : 'mult-operationsMulti', |
57 | 57 | text : 'Operations' |
... | ... | @@ -81,7 +81,7 @@ Ext.define('amdaModel.TimeTableNode', { |
81 | 81 | this.callParent(arguments); |
82 | 82 | |
83 | 83 | var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length); |
84 | - | |
84 | + | |
85 | 85 | switch (fnId) { |
86 | 86 | |
87 | 87 | case 'shareLeaf': |
... | ... | @@ -114,48 +114,45 @@ Ext.define('amdaModel.TimeTableNode', { |
114 | 114 | |
115 | 115 | default: |
116 | 116 | break; |
117 | - } // switch end | |
118 | - | |
117 | + } // switch end | |
119 | 118 | }, |
120 | 119 | |
121 | - ttDownload : function() { | |
122 | - // download Module | |
123 | - var me = this; | |
124 | - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id, true, function (module) { | |
125 | - module.createWindow(); | |
126 | - var uidownload = module.getUiContent(); | |
127 | - uidownload.addTTdownload(me.get('text'), me.get('id')); | |
128 | - }); | |
129 | - }, | |
120 | + ttDownload : function() { | |
121 | + // download Module | |
122 | + var me = this; | |
123 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id, true, function (module) { | |
124 | + module.createWindow(); | |
125 | + var uidownload = module.getUiContent(); | |
126 | + uidownload.addTTdownload(me.get('text'), me.get('id')); | |
127 | + }); | |
128 | + }, | |
130 | 129 | |
131 | - ttOperations : function() { | |
132 | - var me = this; | |
133 | - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt_op.id, true, function (module) { | |
134 | - module.createWindow(); | |
135 | - module.getUiContent().addTT(me.get('text'), me.get('id')); | |
136 | - }); | |
137 | - | |
138 | - }, | |
130 | + ttOperations : function() { | |
131 | + var me = this; | |
132 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt_op.id, true, function (module) { | |
133 | + module.createWindow(); | |
134 | + module.getUiContent().addTT(me.get('text'), me.get('id')); | |
135 | + }); | |
136 | + }, | |
139 | 137 | |
140 | - shareNode: function(node) { | |
141 | - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id, true, function (module) { | |
142 | - module.shareTT({'name' : node.get('text'), 'id' : node.get('id')}); | |
143 | - }); | |
144 | - }, | |
138 | + shareNode: function(node) { | |
139 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id, true, function (module) { | |
140 | + module.shareTT({'name' : node.get('text'), 'id' : node.get('id')}); | |
141 | + }); | |
142 | + }, | |
145 | 143 | |
146 | - downloadMulti: function(){ | |
147 | - var selection = this.myGetOwnerTree().getSelectionModel().selected.items; | |
148 | -// alert(selection.length+' to download!'); | |
149 | - Ext.Array.each(selection,function(item,index,allItems){ | |
150 | - item.ttDownload(); | |
151 | - }) | |
152 | - }, | |
144 | + downloadMulti: function(){ | |
145 | + var selection = this.myGetOwnerTree().getSelectionModel().selected.items; | |
146 | + Ext.Array.each(selection,function(item,index,allItems){ | |
147 | + item.ttDownload(); | |
148 | + }) | |
149 | + }, | |
153 | 150 | |
154 | - operationsMulti: function(){ | |
155 | - var selection = this.myGetOwnerTree().getSelectionModel().selected.items; | |
156 | - alert(selection.length+' time tables to send into operationsTT module!'); | |
157 | - Ext.Array.each(selection,function(item,index,allItems){ | |
158 | - item.ttOperations(); | |
159 | - }) | |
160 | - } | |
151 | + operationsMulti: function(){ | |
152 | + var selection = this.myGetOwnerTree().getSelectionModel().selected.items; | |
153 | + alert(selection.length+' time tables to send into operationsTT module!'); | |
154 | + Ext.Array.each(selection,function(item,index,allItems){ | |
155 | + item.ttOperations(); | |
156 | + }) | |
157 | + } | |
161 | 158 | }); |
... | ... |