Commit a73f0195d91386d7160140be3b0919da0d662c5d

Authored by Benjamin Renard
1 parent a2fd2741

Insert interval in TT from interactive plot UI

js/app/controllers/InteractiveModule.js
@@ -37,7 +37,7 @@ Ext.define('amdaDesktop.InteractiveModule', { @@ -37,7 +37,7 @@ Ext.define('amdaDesktop.InteractiveModule', {
37 /** 37 /**
38 * Window Creation method of the Module 38 * Window Creation method of the Module
39 */ 39 */
40 - createWindow : function () { 40 + createWindow : function (onShowEvent) {
41 41
42 if (this.linkedNode === null){ 42 if (this.linkedNode === null){
43 this.createLinkedNode(); 43 this.createLinkedNode();
@@ -135,6 +135,8 @@ Ext.define('amdaDesktop.InteractiveModule', { @@ -135,6 +135,8 @@ Ext.define('amdaDesktop.InteractiveModule', {
135 // configuration of empty catalog 135 // configuration of empty catalog
136 if (this.isOperationOnShow) 136 if (this.isOperationOnShow)
137 this.operationOnShow(); 137 this.operationOnShow();
  138 + if (onShowEvent)
  139 + onShowEvent();
138 } 140 }
139 }); 141 });
140 } else { 142 } else {
js/app/controllers/TimeTableModule.js
@@ -40,7 +40,7 @@ Ext.define('amdaDesktop.TimeTableModule', { @@ -40,7 +40,7 @@ Ext.define('amdaDesktop.TimeTableModule', {
40 /** 40 /**
41 * @override 41 * @override
42 */ 42 */
43 - createWindow : function() { 43 + createWindow : function(onshowfn) {
44 44
45 this.callParent(arguments); 45 this.callParent(arguments);
46 var win = this.app.getDesktop().getWindow(this.id); 46 var win = this.app.getDesktop().getWindow(this.id);
js/app/models/InteractiveNode.js
@@ -104,7 +104,7 @@ Ext.define('amdaModel.InteractiveNode', { @@ -104,7 +104,7 @@ Ext.define('amdaModel.InteractiveNode', {
104 /** 104 /**
105 * open Module with THIS NODE 105 * open Module with THIS NODE
106 */ 106 */
107 - editInModule : function (contextNode) 107 + editInModule : function (contextNode, onReady)
108 { 108 {
109 // set the contextNode of this node 109 // set the contextNode of this node
110 this.set('contextNode',contextNode); 110 this.set('contextNode',contextNode);
@@ -130,7 +130,7 @@ Ext.define('amdaModel.InteractiveNode', { @@ -130,7 +130,7 @@ Ext.define('amdaModel.InteractiveNode', {
130 //Sol2: msg with user choice: "warning this node is already edited! Would you confirm this action and lost your modification?"->'Confirm','Cancel' 130 //Sol2: msg with user choice: "warning this node is already edited! Would you confirm this action and lost your modification?"->'Confirm','Cancel'
131 } 131 }
132 // Opening parameter window 132 // Opening parameter window
133 - module.createWindow(); 133 + module.createWindow(onReady);
134 }); 134 });
135 135
136 136
@@ -454,7 +454,7 @@ Ext.define('amdaModel.InteractiveNode', { @@ -454,7 +454,7 @@ Ext.define('amdaModel.InteractiveNode', {
454 this.renameNode(); 454 this.renameNode();
455 break; 455 break;
456 case 'editLeaf': 456 case 'editLeaf':
457 - this.editLeaf(this); 457 + this.editLeaf();
458 break; 458 break;
459 case 'deleteMulti': 459 case 'deleteMulti':
460 this.deleteMulti(); 460 this.deleteMulti();
@@ -776,7 +776,7 @@ Ext.define('amdaModel.InteractiveNode', { @@ -776,7 +776,7 @@ Ext.define('amdaModel.InteractiveNode', {
776 * load the rootNode and recursively all its child nodes 776 * load the rootNode and recursively all its child nodes
777 * to know all names of DerivedParameters 777 * to know all names of DerivedParameters
778 */ 778 */
779 - editLeaf: function() 779 + editLeaf: function(onReady)
780 { 780 {
781 var me = this; 781 var me = this;
782 amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), 782 amdaModel.InteractiveNode.preloadNodes(this.getRootNode(),
@@ -785,7 +785,7 @@ Ext.define('amdaModel.InteractiveNode', { @@ -785,7 +785,7 @@ Ext.define('amdaModel.InteractiveNode', {
785 if (me.get('object')) 785 if (me.get('object'))
786 { 786 {
787 // launch edition of parameter into parameter module 787 // launch edition of parameter into parameter module
788 - me.editInModule(); 788 + me.editInModule(null, onReady);
789 } 789 }
790 else 790 else
791 { 791 {
js/app/models/MyDataNode.js
@@ -80,7 +80,7 @@ Ext.define('amdaModel.MyDataNode', { @@ -80,7 +80,7 @@ Ext.define('amdaModel.MyDataNode', {
80 break; 80 break;
81 81
82 case 'editLeaf': 82 case 'editLeaf':
83 - this.editLeaf(this); 83 + this.editLeaf();
84 break; 84 break;
85 85
86 case 'upload': 86 case 'upload':
js/app/models/MyDataParamNode.js
@@ -101,7 +101,7 @@ Ext.define('amdaModel.MyDataParamNode', { @@ -101,7 +101,7 @@ Ext.define('amdaModel.MyDataParamNode', {
101 break; 101 break;
102 102
103 case 'editLeaf': 103 case 'editLeaf':
104 - this.editLeaf(this); 104 + this.editLeaf();
105 break; 105 break;
106 106
107 case 'upload': 107 case 'upload':
js/app/models/PlotNode.js
@@ -100,7 +100,7 @@ Ext.define('amdaModel.PlotNode', { @@ -100,7 +100,7 @@ Ext.define('amdaModel.PlotNode', {
100 break; 100 break;
101 101
102 case 'editPlot': 102 case 'editPlot':
103 - this.editLeaf(this); 103 + this.editLeaf();
104 break; 104 break;
105 105
106 case 'editDownload': 106 case 'editDownload':
js/app/views/PlotComponents/PlotZoomPlug.js
@@ -26,6 +26,8 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { @@ -26,6 +26,8 @@ Ext.define('amdaPlotComp.PlotZoomPlug', {
26 tabId : '', 26 tabId : '',
27 panelId : -1, 27 panelId : -1,
28 28
  29 + linkedTTNode : null,
  30 +
29 constructor: function(config) { 31 constructor: function(config) {
30 Ext.apply(this, config); 32 Ext.apply(this, config);
31 this.callParent(arguments); 33 this.callParent(arguments);
@@ -84,10 +86,13 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { @@ -84,10 +86,13 @@ Ext.define('amdaPlotComp.PlotZoomPlug', {
84 if (this.zoomType != 'timeAxis') 86 if (this.zoomType != 'timeAxis')
85 return; 87 return;
86 88
  89 + var start = this.form.getForm().findField('zoom-min-time').getValue();
  90 + var stop = this.form.getForm().findField('zoom-max-time').getValue();
  91 +
87 myDesktopApp.getLoadedModule(this.ttModuleId, true, function(module){ 92 myDesktopApp.getLoadedModule(this.ttModuleId, true, function(module){
88 - var targetModuleUI = targetModule.getUiContent();  
89 - //if (targetModuleUI)  
90 - // targetModuleUI.addInterval(this.start,this.stop); 93 + var targetModuleUI = module.getUiContent();
  94 + if (targetModuleUI)
  95 + targetModuleUI.addInterval(start,stop);
91 }); 96 });
92 }, 97 },
93 98
@@ -287,19 +292,59 @@ Ext.define('amdaPlotComp.PlotZoomPlug', { @@ -287,19 +292,59 @@ Ext.define('amdaPlotComp.PlotZoomPlug', {
287 text: 'Insert Interval', 292 text: 'Insert Interval',
288 scope: this, 293 scope: this,
289 handler: function(){ 294 handler: function(){
290 - if (this.zoomType != 'timeAxis')  
291 - return;  
292 -  
293 - this.start = this.form.getForm().findField('zoom-min-time').getValue();  
294 - this.stop = this.form.getForm().findField('zoom-max-time').getValue();  
295 - // new TimeTable or typed manually  
296 var me = this; 295 var me = this;
297 - var targetModule = myDesktopApp.getLoadedModule(this.ttModuleId, true, function(module) {  
298 - var targetModuleUI = module.getUiContent();  
299 - var TTname = me.form.getForm().findField('tt-name').getValue();  
300 - //ToDo  
301 - });  
302 - 296 +
  297 + var TTname = this.form.getForm().findField('tt-name').getValue();
  298 +
  299 + myDesktopApp.getLoadedModule(this.ttModuleId, true, function(module){
  300 + var targetModuleUI = module.getUiContent();
  301 + if (me.linkedTTNode && (me.linkedTTNode.get('text') == TTname))
  302 + {
  303 + if (targetModuleUI)
  304 + me.insertInterval();
  305 + else
  306 + {
  307 + me.linkedTTNode.editLeaf(function () {
  308 + me.insertInterval();
  309 + });
  310 + }
  311 + }
  312 + else
  313 + {
  314 + if (TTname == '')
  315 + {
  316 + me.linkedTTNode.editLeaf(function () {
  317 + me.insertInterval();
  318 + });
  319 + }
  320 +
  321 + var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);
  322 + var ttRootNode = explorerTree.getRootNode().findChild('id','timeTable-treeRootNode',true);
  323 + amdaModel.InteractiveNode.preloadNodes(ttRootNode, function() {
  324 + var nodeWithSameName = null;
  325 +
  326 + if (TTname != '')
  327 + nodeWithSameName = ttRootNode.findChild('text', TTname, true);
  328 +
  329 + if (nodeWithSameName !== null)
  330 + me.linkedTTNode = nodeWithSameName;
  331 + else
  332 + {
  333 + var obj = Ext.create('amdaModel.TimeTable', {name : TTname, fromPlugin : true});
  334 + me.linkedTTNode = Ext.create('amdaModel.TimeTableNode', {
  335 + leaf : true,
  336 + text : TTname,
  337 + nodeType : 'timeTable',
  338 + object : obj
  339 + });
  340 + }
  341 +
  342 + me.linkedTTNode.editLeaf(function () {
  343 + me.insertInterval();
  344 + });
  345 + });
  346 + }
  347 + });
303 } 348 }
304 } 349 }
305 ] 350 ]
js/app/views/TimeTableUI.js
@@ -226,10 +226,18 @@ Ext.define('amdaUI.TimeTableUI', { @@ -226,10 +226,18 @@ Ext.define('amdaUI.TimeTableUI', {
226 226
227 addInterval : function(start, stop) 227 addInterval : function(start, stop)
228 { 228 {
  229 + var row = this.TTGrid.getStore().getTotalCount();
  230 + var me = this;
229 this.TTGrid.getSelectionModel().deselectAll(); 231 this.TTGrid.getSelectionModel().deselectAll();
230 - AmdaAction.addTTCacheInterval({'start' : start, 'stop' : stop},function (result, e) {  
231 - this.TTGrid.getStore().reload();  
232 - this.status = result.status; 232 + AmdaAction.addTTCacheInterval({'start' : start, 'stop' : stop, 'index' : row},function (result, e) {
  233 + this.status = result.status;
  234 + this.TTGrid.getStore().reload({
  235 + callback : function(records, options, success) {
  236 + me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function() {
  237 + me.TTGrid.getView().select(row);
  238 + }, me);
  239 + }
  240 + });
233 }, this); 241 }, this);
234 }, 242 },
235 243