Commit ebbb3638f39b8fc2076e5fb1de43ae72ffeda848

Authored by Benjamin Renard
1 parent 0ead0129

Edit plot tab on double click

js/app/controllers/AmdaModule.js
... ... @@ -99,7 +99,12 @@ Ext.define('amdaDesktop.AmdaModule', {
99 99 show : onshowfn,
100 100 scope : this
101 101 });
102   - }
103   - win.show();
  102 + }
  103 + if (!win.isVisible()) {
  104 + win.show();
  105 + }
  106 + else if (onshowfn) {
  107 + onshowfn();
  108 + }
104 109 }
105 110 });
... ...
js/app/controllers/InteractiveModule.js
... ... @@ -144,7 +144,13 @@ Ext.define('amdaDesktop.InteractiveModule', {
144 144 // second arg 'true' is used in CatalogUI to mark if Grid Reconfiguration is needed
145 145 this.getUiContent().setObject(this.linkedNode.get('object'), true);
146 146 }
147   - win.show();
  147 +
  148 + if (!win.isVisible()) {
  149 + win.show();
  150 + }
  151 + else if (onShowEvent) {
  152 + onShowEvent();
  153 + }
148 154 },
149 155 /**
150 156 * Mechanism to attach a Module to the Workspace Explorer to enable interactions
... ... @@ -256,4 +262,4 @@ Ext.define('amdaDesktop.InteractiveModule', {
256 262 return null;
257 263 }
258 264  
259   -});
260 265 \ No newline at end of file
  266 +});
... ...
js/app/controllers/PlotModule.js
... ... @@ -208,5 +208,12 @@ Ext.define('amdaDesktop.PlotModule', {
208 208 getWindowResult: function(winResultId){
209 209 if (!this.plotResultWindowsManager.get(winResultId)) return null;
210 210 return this.plotResultWindowsManager.get(winResultId);
  211 + },
  212 +
  213 + forceTabSelection: function(tabId) {
  214 + var uiContent = this.getUiContent();
  215 + if (uiContent != null) {
  216 + uiContent.forceActiveTab(tabId);
211 217 }
  218 + }
212 219 });
... ...
js/app/models/PlotNode.js
... ... @@ -43,6 +43,7 @@ Ext.define('amdaModel.PlotNode', {
43 43 me.appendChild(tabNode);
44 44 });
45 45 }
  46 + this.set('tabs', tabs);
46 47 }
47 48 },
48 49  
... ...
js/app/models/PlotObjects/PlotRequestObject.js
... ... @@ -30,8 +30,7 @@ Ext.define('amdaPlotObj.PlotRequestObject', {
30 30 {name: 'one-file-per-interval', type: 'boolean'},
31 31 {name: 'last-plotted-tab', type: 'int', defaultValue: 0},
32 32 {name: 'last-tab-id', type: 'int', defaultValue: 0},
33   - {name: 'active-tab-id', type: 'int', defaultValue: 1},
34   - {name: 'all-in-one', type: 'boolean', defaultValue: false}
  33 + {name: 'active-tab-id', type: 'int', defaultValue: 1}
35 34 ],
36 35  
37 36 hasMany: {
... ... @@ -77,7 +76,7 @@ Ext.define('amdaPlotObj.PlotRequestObject', {
77 76 var recs = this.tabs().add({id : this.get('last-tab-id')});
78 77 recs[0].setDefaultValues();
79 78 this.dirty = true;
80   - return recs[0];
  79 + return recs[0];
81 80 },
82 81  
83 82 removeTabById: function(tabId) {
... ... @@ -124,7 +123,6 @@ Ext.define('amdaPlotObj.PlotRequestObject', {
124 123 requestValues['one-file-per-interval'] = this.get('one-file-per-interval');
125 124 requestValues['last-plotted-tab'] = this.get('last-plotted-tab');
126 125 requestValues['name'] = this.get('name');
127   - requestValues['all-in-one'] = this.get('all-in-one');
128 126  
129 127 requestValues['timesrc'] = this.get('timesrc');
130 128  
... ... @@ -153,26 +151,15 @@ Ext.define('amdaPlotObj.PlotRequestObject', {
153 151 requestValues['durationSec'] = this.get('durationSec');
154 152 }
155 153  
156   - requestValues['tabs'] = [];
  154 + requestValues['tabs'] = [];
157 155  
158   - if (this.get('all-in-one')) {
159   - this.tabs().each(function (tab, index) {
160   - requestValues['tabs'][index] = tab.getJsonValues();
161   - });
  156 + this.tabs().each(function (tab, index) {
  157 + requestValues['tabs'][index] = tab.getJsonValues();
  158 + });
162 159  
163   - requestValues['active-tab-id'] = this.get('active-tab-id');
164   - requestValues['last-tab-id'] = this.get('last-tab-id');
165   - }
166   - else {
167   - var tab = this.tabs().getAt(this.get('active-tab-id')-1);
168   - requestValues['tabs'][0] = tab.getJsonValues();
169   -
170   - requestValues['tabs'][0]['id'] = "1";
171   - requestValues['active-tab-id'] = "1";
172   - requestValues['last-tab-id'] = "1";
173   - requestValues['last-plotted-tab'] = "0";
174   - }
  160 + requestValues['active-tab-id'] = this.get('active-tab-id');
  161 + requestValues['last-tab-id'] = this.get('last-tab-id');
175 162  
176   - return requestValues;
  163 + return requestValues;
177 164 }
178   -});
179 165 \ No newline at end of file
  166 +});
... ...
js/app/models/PlotTabNode.js
... ... @@ -78,6 +78,15 @@ Ext.define('amdaModel.PlotTabNode', {
78 78 default:
79 79 break;
80 80 }
  81 + },
  82 +
  83 + editPlotTab : function() {
  84 + var me = this;
  85 + this.parentNode.editLeaf(function () {
  86 + myDesktopApp.getLoadedModule(me.get('moduleId'), true, function (module) {
  87 + module.forceTabSelection(me.get('tabid'));
  88 + });
  89 + });
81 90 }
82 91  
83 92 });
... ...
js/app/views/ExplorerUI.js
... ... @@ -576,13 +576,13 @@ Ext.define('amdaUI.ExplorerUI', {
576 576 });
577 577 }
578 578  
579   - if (record.isLeaf() || record.data.isParameter)
  579 + if (record.isLeaf() || record.data.isParameter || (record.data.tabs && (record.data.tabs.length > 0)))
580 580 switch (record.get('nodeType'))
581 581 {
582 582 case 'myData' :
583 583 case 'myDataParam' :
584 584 case 'derivedParam' :
585   - case 'timeTable' :
  585 + case 'timeTable' :
586 586 case 'sharedtimeTable' :
587 587 case 'sharedcatalog' :
588 588 case 'catalog' :
... ... @@ -590,6 +590,9 @@ Ext.define('amdaUI.ExplorerUI', {
590 590 case 'condition' :
591 591 record.editLeaf();
592 592 break;
  593 + case 'plottab' :
  594 + record.editPlotTab();
  595 + break;
593 596 case 'localParam' :
594 597 case 'remoteParam':
595 598 case 'remoteSimuParam':
... ...
js/app/views/PlotComponents/PlotTabPanel.js
... ... @@ -31,16 +31,20 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
31 31  
32 32 setRequestObject: function(object)
33 33 {
  34 + var me = this;
34 35 this.removeAll();
35 36 this.object = object;
36   - var selectedTab = this.object.get('active-tab-id');
37 37  
  38 + var haveSelectedTab = false;
38 39 this.object.tabs().each(function (rec, index) {
39   - var isSelected = false;
40   - if (index+1 == selectedTab)
41   - isSelected = true;
  40 + if (rec.get('id') == me.object.get('active-tab-id')) {
  41 + haveSelectedTab = true;
  42 + }
  43 + });
42 44  
43   - this.addPlotTab(rec, isSelected);
  45 + this.object.tabs().each(function (rec, index) {
  46 + var isSelectedTab = haveSelectedTab ? (rec.get('id') == me.object.get('active-tab-id')) : (index == 0);
  47 + this.addPlotTab(rec, isSelectedTab);
44 48 }, this);
45 49 },
46 50  
... ...
js/app/views/PlotUI.js
... ... @@ -111,7 +111,6 @@ Ext.define('amdaUI.PlotUI', {
111 111 doPlot : function(){
112 112  
113 113 this.updateObject();
114   - this.object.set('all-in-one', true);
115 114 this.object.set('last-plotted-tab', this.plotTabs.getSelectedTabId());
116 115 var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
117 116 if (plotModule)
... ... @@ -172,6 +171,16 @@ Ext.define('amdaUI.PlotUI', {
172 171  
173 172 this.timeSelector.intervalSel.setInterval(dateStart, dateStop);
174 173 },
  174 +
  175 + forceActiveTab : function(tabId) {
  176 + for (var i = 0; i < this.plotTabs.items.getCount(); ++i) {
  177 + var plotTab = this.plotTabs.items.getAt(i).items.getAt(0);
  178 + if (plotTab.tabId == tabId) {
  179 + this.plotTabs.setActiveTab(i);
  180 + return;
  181 + }
  182 + }
  183 + },
175 184  
176 185 updateLinkedToMultiPlotMode : function(isLinkedToMultiPlotMode) {
177 186 this.timeSelector.setVisible(isLinkedToMultiPlotMode);
... ... @@ -183,7 +192,6 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
183 192 return;
184 193 this.updateObject();
185 194 this.object.set('active-tab-id', this.plotTabs.getSelectedTabId());
186   - this.object.set('all-in-one', allTabs);
187 195  
188 196 if ((this.object.get('id') != '') && (plotModule.linkedNode.get('text') == this.object.get('name'))) {
189 197 //update existing request
... ...