Commit 8b11b1afde966da0a1028fa67671f3409636fb9f
1 parent
3c57b165
Exists in
master
and in
101 other branches
Insert intervals in catalog from plot (#5118)
Showing
5 changed files
with
119 additions
and
44 deletions
Show diff stats
js/app/models/Catalog.js
... | ... | @@ -14,7 +14,8 @@ Ext.define('amdaModel.Catalog', { |
14 | 14 | extend: 'amdaModel.TimeTable', |
15 | 15 | |
16 | 16 | fields : [ |
17 | - { name: 'parameters' } | |
17 | + { name: 'parameters' }, | |
18 | + { name: 'nbParameters', type: 'int', defaultValue: 1} | |
18 | 19 | ], |
19 | 20 | |
20 | 21 | getJsonValues : function (hasId) { |
... | ... | @@ -46,4 +47,4 @@ Ext.define('amdaModel.Catalog', { |
46 | 47 | |
47 | 48 | |
48 | 49 | |
49 | -}); | |
50 | 50 | \ No newline at end of file |
51 | +}); | |
... | ... |
js/app/models/InteractiveNode.js
... | ... | @@ -778,6 +778,7 @@ Ext.define('amdaModel.InteractiveNode', { |
778 | 778 | this.set('object',paramObj); |
779 | 779 | // Edition of parameter into parameter Module |
780 | 780 | this.editInModule(null, this.onReady); |
781 | + this.onReady = null; | |
781 | 782 | } |
782 | 783 | else { |
783 | 784 | // EXCEPTION : parameter not found !? |
... | ... |
js/app/views/CatalogUI.js
... | ... | @@ -63,7 +63,8 @@ Ext.define('amdaUI.CatalogUI', { |
63 | 63 | params[index] = item; |
64 | 64 | }, this); |
65 | 65 | |
66 | - this.object.set('parameters', params); | |
66 | + this.object.set('parameters', params); | |
67 | + this.object.set('nbParameters', params.length); | |
67 | 68 | }, |
68 | 69 | |
69 | 70 | /** |
... | ... | @@ -92,6 +93,24 @@ Ext.define('amdaUI.CatalogUI', { |
92 | 93 | // return the update status |
93 | 94 | return updateStatus; |
94 | 95 | }, |
96 | + | |
97 | + addInterval : function(start, stop) { | |
98 | + var row = this.TTGrid.getStore().getTotalCount(); | |
99 | + var me = this; | |
100 | + this.TTGrid.getSelectionModel().deselectAll(); | |
101 | + AmdaAction.addTTCacheInterval({'start' : start, 'stop' : stop, 'index' : row, 'isCatalog' : true},function (result, e) { | |
102 | + this.status = result.status; | |
103 | + if (!this.TTGrid.getStore().loading) { | |
104 | + this.TTGrid.getStore().reload({ | |
105 | + callback : function(records, options, success) { | |
106 | + me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function() { | |
107 | + me.TTGrid.getView().select(row); | |
108 | + }, me); | |
109 | + } | |
110 | + }); | |
111 | + } | |
112 | + }, this); | |
113 | + }, | |
95 | 114 | |
96 | 115 | updateCount : function() { |
97 | 116 | this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount()); |
... | ... | @@ -367,7 +386,7 @@ Ext.define('amdaUI.CatalogUI', { |
367 | 386 | |
368 | 387 | this.status = null; |
369 | 388 | |
370 | - if (this.object.get('fromPlugin')){ | |
389 | + if (this.object.get('fromPlugin') && (this.object.get('objName') != '')){ | |
371 | 390 | if (this.object.get('objFormat') && this.object.get('objFormat') != ''){ |
372 | 391 | //From uploaded file |
373 | 392 | AmdaAction.initTTCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), this.isCatalog, this.onAfterInit, this); |
... | ... | @@ -381,7 +400,7 @@ Ext.define('amdaUI.CatalogUI', { |
381 | 400 | var typeTT = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id).linkedNode.data.nodeType; |
382 | 401 | |
383 | 402 | if (this.object.get('id') == '') { |
384 | - AmdaAction.initTTCache(this.isCatalog, 1, this.onAfterInit,this); | |
403 | + AmdaAction.initTTCache(this.isCatalog, this.object.get('nbParameters'), this.onAfterInit,this); | |
385 | 404 | } |
386 | 405 | else { |
387 | 406 | //From existing TT file |
... | ... |
js/app/views/PlotComponents/PlotZoomPlug.js
... | ... | @@ -21,6 +21,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
21 | 21 | id: 'plot-zoom-plug', |
22 | 22 | |
23 | 23 | ttModuleId: 'timetab-win', |
24 | + catModuleId: 'catalog-win', | |
24 | 25 | |
25 | 26 | win: null, |
26 | 27 | form: null, |
... | ... | @@ -28,7 +29,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
28 | 29 | tabId: '', |
29 | 30 | panelId: -1, |
30 | 31 | |
31 | - linkedTTNode: null, | |
32 | + linkedTTCatNode: null, | |
32 | 33 | |
33 | 34 | constructor: function (config) { |
34 | 35 | Ext.apply(this, config); |
... | ... | @@ -87,7 +88,10 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
87 | 88 | var start = this.form.getForm().findField('zoom-min-time').getValue(); |
88 | 89 | var stop = this.form.getForm().findField('zoom-max-time').getValue(); |
89 | 90 | |
90 | - myDesktopApp.getLoadedModule(this.ttModuleId, true, function (module) { | |
91 | + var TTCatType = this.form.getForm().findField('ttcat-type').getValue(); | |
92 | + var isCatalog = (TTCatType == 'catalog'); | |
93 | + | |
94 | + myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) { | |
91 | 95 | var targetModuleUI = module.getUiContent(); |
92 | 96 | if (targetModuleUI) |
93 | 97 | targetModuleUI.addInterval(start, stop); |
... | ... | @@ -172,9 +176,9 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
172 | 176 | this.form.getForm().findField('zoom-min-float').setVisible(this.zoomType != 'timeAxis'); |
173 | 177 | this.form.getForm().findField('zoom-max-float').setVisible(this.zoomType != 'timeAxis'); |
174 | 178 | |
175 | - var ttNameField = this.form.getForm().findField('tt-name'); | |
176 | - if (ttNameField) | |
177 | - ttNameField.findParentByType('fieldset').setVisible(this.zoomType == 'timeAxis'); | |
179 | + var ttCatNameField = this.form.getForm().findField('ttcat-name'); | |
180 | + if (ttCatNameField) | |
181 | + ttCatNameField.findParentByType('fieldset').setVisible(this.zoomType == 'timeAxis'); | |
178 | 182 | }, |
179 | 183 | |
180 | 184 | resetMinMaxValue: function () { |
... | ... | @@ -232,9 +236,18 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
232 | 236 | ] |
233 | 237 | }; |
234 | 238 | |
239 | + var insertTypeStore = Ext.create('Ext.data.Store', { | |
240 | + fields: ['key', 'name'], | |
241 | + data : [ | |
242 | + {"key":"timeTable", "name":"TimeTable"}, | |
243 | + {"key":"catalog", "name":"Catalog"} | |
244 | + ] | |
245 | + }); | |
246 | + | |
247 | + var me = this; | |
235 | 248 | var insertTTFieldSet = { |
236 | 249 | xtype: 'fieldset', |
237 | - title: 'TimeTable Insertion', | |
250 | + title: 'Intervals Insertion', | |
238 | 251 | name: 'tt-insertion-fieldset', |
239 | 252 | collapsible: false, |
240 | 253 | layout: { |
... | ... | @@ -244,20 +257,32 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
244 | 257 | }, |
245 | 258 | items: [ |
246 | 259 | { |
260 | + xtype: 'combo', | |
261 | + fieldLabel: 'Insert In', | |
262 | + store: insertTypeStore, | |
263 | + queryMode: 'local', | |
264 | + displayField: 'name', | |
265 | + valueField: 'key', | |
266 | + editable: false, | |
267 | + value: 'timeTable', | |
268 | + name: 'ttcat-type' | |
269 | + }, | |
270 | + { | |
247 | 271 | xtype: 'textfield', |
248 | - fieldLabel: 'TimeTable Name', | |
249 | - name: 'tt-name', | |
272 | + fieldLabel: 'Name', | |
273 | + name: 'ttcat-name', | |
250 | 274 | listeners: |
251 | 275 | { |
252 | 276 | render: function (o, op) { |
253 | - var me = this; | |
254 | - var el = me.el; | |
277 | + var field = this; | |
278 | + var el = this.el; | |
255 | 279 | var dropTarget = Ext.create('Ext.dd.DropTarget', el, { |
256 | 280 | ddGroup: 'explorerTree', |
257 | 281 | notifyOver: function (ddSource, e, data) { |
258 | - if ((data.records[0].data.nodeType == 'timeTable') && (data.records[0].data.leaf)) { | |
259 | - this.valid = true; | |
260 | - return this.dropAllowed; | |
282 | + var TTCatType = me.form.getForm().findField('ttcat-type').getValue(); | |
283 | + if (data.records[0].data.leaf && (data.records[0].data.nodeType == TTCatType)) { | |
284 | + this.valid = true; | |
285 | + return this.dropAllowed; | |
261 | 286 | } |
262 | 287 | this.valid = false; |
263 | 288 | return this.dropNotAllowed; |
... | ... | @@ -265,7 +290,7 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
265 | 290 | notifyDrop: function (ddSource, e, data) { |
266 | 291 | if (!this.valid) |
267 | 292 | return false; |
268 | - me.setValue(data.records[0].get('text')); | |
293 | + field.setValue(data.records[0].get('text')); | |
269 | 294 | return true; |
270 | 295 | } |
271 | 296 | }); |
... | ... | @@ -280,47 +305,61 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
280 | 305 | handler: function () { |
281 | 306 | var me = this; |
282 | 307 | |
283 | - var TTname = this.form.getForm().findField('tt-name').getValue(); | |
308 | + var TTCatType = this.form.getForm().findField('ttcat-type').getValue(); | |
309 | + var TTCatName = this.form.getForm().findField('ttcat-name').getValue(); | |
284 | 310 | |
285 | - myDesktopApp.getLoadedModule(this.ttModuleId, true, function (module) { | |
311 | + var isCatalog = (TTCatType == 'catalog'); | |
312 | + myDesktopApp.getLoadedModule(isCatalog ? this.catModuleId : this.ttModuleId, true, function (module) { | |
286 | 313 | var targetModuleUI = module.getUiContent(); |
287 | - if (me.linkedTTNode && (me.linkedTTNode.get('text') == TTname)) { | |
314 | + if (me.linkedTTCatNode && (me.linkedTTCatNode.get('text') == TTCatName) && (me.linkedTTCatNode.get('nodeType') == TTCatType)) { | |
288 | 315 | if (targetModuleUI) |
289 | 316 | me.insertInterval(); |
290 | 317 | else { |
291 | - me.linkedTTNode.editLeaf(function () { | |
318 | + me.linkedTTCatNode.editLeaf(function () { | |
292 | 319 | me.insertInterval(); |
293 | 320 | }); |
294 | 321 | } |
295 | 322 | } |
296 | 323 | else { |
297 | - if (TTname == '') { | |
298 | - me.linkedTTNode.editLeaf(function () { | |
299 | - me.insertInterval(); | |
300 | - }); | |
301 | - } | |
302 | - | |
303 | 324 | var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); |
304 | - var ttRootNode = explorerTree.getRootNode().findChild('id', 'timeTable-treeRootNode', true); | |
305 | - amdaModel.InteractiveNode.preloadNodes(ttRootNode, function () { | |
325 | + var ttCatRootNode = explorerTree.getRootNode().findChild('id', isCatalog ? 'catalog-treeRootNode' : 'timeTable-treeRootNode', true); | |
326 | + amdaModel.InteractiveNode.preloadNodes(ttCatRootNode, function () { | |
306 | 327 | var nodeWithSameName = null; |
307 | 328 | |
308 | - if (TTname != '') | |
309 | - nodeWithSameName = ttRootNode.findChild('text', TTname, true); | |
329 | + if (TTCatName != '') | |
330 | + nodeWithSameName = ttCatRootNode.findChild('text', TTCatName, true); | |
310 | 331 | |
311 | 332 | if (nodeWithSameName !== null) |
312 | - me.linkedTTNode = nodeWithSameName; | |
333 | + me.linkedTTCatNode = nodeWithSameName; | |
313 | 334 | else { |
314 | - var obj = Ext.create('amdaModel.TimeTable', {name: TTname, fromPlugin: true}); | |
315 | - me.linkedTTNode = Ext.create('amdaModel.TimeTableNode', { | |
316 | - leaf: true, | |
317 | - text: TTname, | |
318 | - nodeType: 'timeTable', | |
319 | - object: obj | |
320 | - }); | |
335 | + module.createLinkedNode(); | |
336 | + module.getLinkedNode().set('text', TTCatName); | |
337 | + me.linkedTTCatNode = module.getLinkedNode(); | |
338 | + var obj = { | |
339 | + name: TTCatName, | |
340 | + fromPlugin: true | |
341 | + }; | |
342 | + if (isCatalog) { | |
343 | + Ext.Msg.prompt('Define Parameters', 'Please enter parameters number for the new xatalog:', function(btn, text){ | |
344 | + if (btn == 'ok'){ | |
345 | + obj.nbParameters = parseInt(text,10); | |
346 | + if (isNaN(obj.nbParameters)) { | |
347 | + obj.nbParameters = 1; | |
348 | + } | |
349 | + module.createObject(obj); | |
350 | + me.linkedTTCatNode.editLeaf(function () { | |
351 | + me.insertInterval(); | |
352 | + }); | |
353 | + } | |
354 | + }); | |
355 | + return; | |
356 | + } | |
357 | + else { | |
358 | + module.createObject(obj); | |
359 | + } | |
321 | 360 | } |
322 | 361 | |
323 | - me.linkedTTNode.editLeaf(function () { | |
362 | + me.linkedTTCatNode.editLeaf(function () { | |
324 | 363 | me.insertInterval(); |
325 | 364 | }); |
326 | 365 | }); |
... | ... | @@ -395,4 +434,4 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { |
395 | 434 | }); |
396 | 435 | return this.form; |
397 | 436 | } |
398 | -}); | |
399 | 437 | \ No newline at end of file |
438 | +}); | |
... | ... |
js/app/views/PlotTabResultUI.js
... | ... | @@ -78,6 +78,7 @@ Ext.define('amdaUI.PlotTabResultUI', { |
78 | 78 | var size = this.getImageSize(); |
79 | 79 | |
80 | 80 | var me = this; |
81 | + var insertIntervalItem = null; | |
81 | 82 | Ext.each(panelContext.plotArea.axes, function (axis) { |
82 | 83 | //Events for zoom on a time axis |
83 | 84 | var onMinTimeSelection = function (posX) { |
... | ... | @@ -152,6 +153,15 @@ Ext.define('amdaUI.PlotTabResultUI', { |
152 | 153 | }, |
153 | 154 | scope: this |
154 | 155 | }); |
156 | + insertIntervalItem = { | |
157 | + text:'Insert Interval in TimeTable or Catalog', | |
158 | + handler : function(item, e) { | |
159 | + zoomPlugin.show(me.tabId, axis.id, panelContext.id); | |
160 | + zoomPlugin.resetMinMaxValue(); | |
161 | + me.panelImage.startZoom(true, 0/*me.toPixelOnResultImage(panelContext.y)*/, size.height /*me.toPixelOnResultImage(panelContext.height)*/, onMinTimeSelection, onMaxTimeSelection); | |
162 | + }, | |
163 | + scope: this | |
164 | + }; | |
155 | 165 | break; |
156 | 166 | case 'y-left' : |
157 | 167 | me.contextualMenu.add({ |
... | ... | @@ -189,6 +199,11 @@ Ext.define('amdaUI.PlotTabResultUI', { |
189 | 199 | } |
190 | 200 | |
191 | 201 | }); |
202 | + | |
203 | + if (insertIntervalItem != null) { | |
204 | + me.contextualMenu.add('-'); | |
205 | + me.contextualMenu.add(insertIntervalItem); | |
206 | + } | |
192 | 207 | }, |
193 | 208 | |
194 | 209 | createPlotImage: function(resultFolder, plotFile) { |
... | ... | @@ -307,7 +322,7 @@ Ext.define('amdaUI.PlotTabResultUI', { |
307 | 322 | if (amdaPlotComp.PlotContextManager.isInPlotArea(panel, sourceXPos, sourceYPos)) |
308 | 323 | me.createZoomItemsForPanel(panel.id); |
309 | 324 | } |
310 | - | |
325 | + | |
311 | 326 | if (me.contextualMenu.items.getCount() > 0) |
312 | 327 | me.contextualMenu.add('-'); |
313 | 328 | |
... | ... |