Commit 5c74462588325315ca493b619f0665d4076b015b

Authored by Benjamin Renard
1 parent 48bbaed6

Synchronize request name

js/app/controllers/PlotModule.js
... ... @@ -40,158 +40,148 @@ Ext.define('amdaDesktop.PlotModule', {
40 40  
41 41 plotResultWindowsManager : new Ext.AbstractManager(),
42 42  
43   - computeResultWindowSize : function(panelResult)
44   - {
45   - var size = panelResult.getImageSize();
46   - size.width += 30;
47   - size.height += 95;
48   -
49   - return size;
50   - },
  43 + computeResultWindowSize : function(panelResult) {
  44 + var size = panelResult.getImageSize();
  45 + size.width += 30;
  46 + size.height += 95;
  47 + return size;
  48 + },
51 49  
52   - computePreviewWindowSize : function(previewContent)
53   - {
54   - var size = previewContent.getImageSize();
55   - size.width += 30;
56   - size.height += 65;
57   -
58   - return size;
59   - },
  50 + computePreviewWindowSize : function(previewContent) {
  51 + var size = previewContent.getImageSize();
  52 + size.width += 30;
  53 + size.height += 65;
  54 + return size;
  55 + },
60 56  
61 57 updateInteractiveSession : function(session, newplot) {
62   - var me = this;
63   -
64   -
65   - Ext.each(session.result, function (tabResult, index) {
66   - if (logExecTime && tabResult.exectime)
67   - {
68   - console.log("CMD EXEC TIME FOR "+tabResult.plot+" = "+tabResult.exectime+"ms");
69   - }
  58 + var me = this;
70 59  
71   - if (tabResult.preview)
72   - {
73   - var plotPreviewConfig = {
74   - folder : session.folder,
75   - plotFile : tabResult.plot,
76   - context : tabResult.context,
77   - interactiveId : tabResult.id
78   - };
79   - me.updatePreview(plotPreviewConfig);
80   - return;
81   - }
82   -
83   - var winResultId = tabResult.id+"-win";
84   -
85   - var winResult = me.getWindowResult(winResultId);
86   -
87   - var plotTabConfig = {
88   - folder : session.folder,
89   - plotFile : tabResult.plot,
90   - context : tabResult.context,
91   - interactiveId : tabResult.id,
92   - isInterval: tabResult.isInterval,
93   - ttName : tabResult.ttName,
94   - ttIndex : tabResult.ttIndex,
95   - ttNbIntervals : tabResult.ttNbIntervals,
96   - ttFileIndex : tabResult.ttFileIndex
97   - };
  60 +
  61 + Ext.each(session.result, function (tabResult, index) {
  62 + if (logExecTime && tabResult.exectime) {
  63 + console.log("CMD EXEC TIME FOR "+tabResult.plot+" = "+tabResult.exectime+"ms");
  64 + }
  65 +
  66 + if (tabResult.preview) {
  67 + var plotPreviewConfig = {
  68 + folder : session.folder,
  69 + plotFile : tabResult.plot,
  70 + context : tabResult.context,
  71 + interactiveId : tabResult.id
  72 + };
  73 + me.updatePreview(plotPreviewConfig);
  74 + return;
  75 + }
  76 +
  77 + var winResultId = tabResult.id+"-win";
98 78  
99   - if (winResult == null) {
100   -
101   - var x = 50 + tabResult.index * 50;
102   - var y = 100 + tabResult.index * 20;
103   -
104   - //create new result win
105   - var panelResult = new amdaUI.PlotTabResultUI(plotTabConfig);
  79 + var winResult = me.getWindowResult(winResultId);
106 80  
107   - var size = me.computeResultWindowSize(panelResult);
  81 + var plotTabConfig = {
  82 + folder : session.folder,
  83 + plotFile : tabResult.plot,
  84 + context : tabResult.context,
  85 + interactiveId : tabResult.id,
  86 + isInterval: tabResult.isInterval,
  87 + ttName : tabResult.ttName,
  88 + ttIndex : tabResult.ttIndex,
  89 + ttNbIntervals : tabResult.ttNbIntervals,
  90 + ttFileIndex : tabResult.ttFileIndex
  91 + };
108 92  
109   - var win = myDesktopApp.getDesktop().createWindow({
110   - id : tabResult.id+"-win",
111   - title : tabResult.title,
112   - width : size.width,
113   - height: size.height,
114   - x : x,
115   - y : y,
116   - layout: 'fit',
117   - items : [
118   - panelResult
119   - ],
120   - listeners: {
121   - scope: me,
122   - beforeclose: function(win,opt) {
123   - me.plotResultWindowsManager.unregister(win);
124   - }
125   - },
126   - getPanelResult: function() {
127   - return panelResult;
128   - }
129   - });
130   - win.show();
131   - me.plotResultWindowsManager.register(win);
132   - }
133   - else
134   - {
135   - //update result
136   - winResult.getPanelResult().updatePlotImage(plotTabConfig, newplot);
137   - //update window size
138   - var size = me.computeResultWindowSize(winResult.getPanelResult());
139   - winResult.setSize(size.width, size.height);
140   -
141   - winResult.toFront();
142   - }
143   - });
  93 + if (winResult == null) {
  94 + var x = 50 + tabResult.index * 50;
  95 + var y = 100 + tabResult.index * 20;
  96 + //create new result win
  97 + var panelResult = new amdaUI.PlotTabResultUI(plotTabConfig);
  98 +
  99 + var size = me.computeResultWindowSize(panelResult);
  100 +
  101 + var win = myDesktopApp.getDesktop().createWindow({
  102 + id : tabResult.id+"-win",
  103 + title : tabResult.title,
  104 + width : size.width,
  105 + height: size.height,
  106 + x : x,
  107 + y : y,
  108 + layout: 'fit',
  109 + items : [
  110 + panelResult
  111 + ],
  112 + listeners: {
  113 + scope: me,
  114 + beforeclose: function(win,opt) {
  115 + me.plotResultWindowsManager.unregister(win);
  116 + }
  117 + },
  118 + getPanelResult: function() {
  119 + return panelResult;
  120 + }
  121 + });
  122 + win.show();
  123 + me.plotResultWindowsManager.register(win);
  124 + }
  125 + else {
  126 + //update result
  127 + winResult.getPanelResult().updatePlotImage(plotTabConfig, newplot);
  128 + //update window size
  129 + var size = me.computeResultWindowSize(winResult.getPanelResult());
  130 + winResult.setTitle(tabResult.title);
  131 + winResult.setSize(size.width, size.height);
  132 + winResult.toFront();
  133 + }
  134 + });
144 135 },
145 136  
146 137 closeInteractiveSession : function() {
147   - var me = this;
148   - this.plotResultWindowsManager.each(function (key, value, length) {
149   - value.close();
150   - });
  138 + var me = this;
  139 + this.plotResultWindowsManager.each(function (key, value, length) {
  140 + value.close();
  141 + });
151 142 },
152   -
  143 +
153 144 updatePreview : function(plotPreviewConfig) {
154   - var winPreviewId = "plot-preview-win";
155   -
156   - var winPreview = this.getWindowResult(winPreviewId);
157   -
158   - if (winPreview == null) {
159   - //create new preview win
160   - var previewContent = new amdaPlotComp.PlotPreviewUI(plotPreviewConfig);
161   -
162   - var size = this.computePreviewWindowSize(previewContent);
163   -
164   - var win = myDesktopApp.getDesktop().createWindow({
165   - id : winPreviewId,
166   - title : 'Plot Preview',
167   - width : size.width,
168   - height: size.height,
169   - layout: 'fit',
170   - items : [
171   - previewContent
172   - ],
173   - listeners: {
174   - scope: this,
175   - beforeclose: function(win,opt) {
176   - this.plotResultWindowsManager.unregister(win);
177   - }
178   - },
179   - getPreviewContent: function() {
180   - return previewContent;
181   - }
182   - });
183   - win.show();
184   - this.plotResultWindowsManager.register(win);
185   - }
186   - else
187   - {
188   - //update result
189   - winPreview.getPreviewContent().updatePlotImage(plotPreviewConfig);
190   - //update window size
191   - var size = this.computePreviewWindowSize(winPreview.getPreviewContent());
192   - winPreview.setSize(size.width, size.height);
193   - winPreview.toFront();
194   - }
  145 + var winPreviewId = "plot-preview-win";
  146 +
  147 + var winPreview = this.getWindowResult(winPreviewId);
  148 +
  149 + if (winPreview == null) {
  150 + //create new preview win
  151 + var previewContent = new amdaPlotComp.PlotPreviewUI(plotPreviewConfig);
  152 +
  153 + var size = this.computePreviewWindowSize(previewContent);
  154 +
  155 + var win = myDesktopApp.getDesktop().createWindow({
  156 + id : winPreviewId,
  157 + title : 'Plot Preview',
  158 + width : size.width,
  159 + height: size.height,
  160 + layout: 'fit',
  161 + items : [
  162 + previewContent
  163 + ],
  164 + listeners: {
  165 + scope: this,
  166 + beforeclose: function(win,opt) {
  167 + this.plotResultWindowsManager.unregister(win);
  168 + }
  169 + },
  170 + getPreviewContent: function() {
  171 + return previewContent;
  172 + }
  173 + });
  174 + win.show();
  175 + this.plotResultWindowsManager.register(win);
  176 + }
  177 + else {
  178 + //update result
  179 + winPreview.getPreviewContent().updatePlotImage(plotPreviewConfig);
  180 + //update window size
  181 + var size = this.computePreviewWindowSize(winPreview.getPreviewContent());
  182 + winPreview.setSize(size.width, size.height);
  183 + winPreview.toFront();
  184 + }
195 185 },
196 186  
197 187 getWindowResult: function(winResultId){
... ... @@ -234,12 +224,13 @@ Ext.define('amdaDesktop.PlotModule', {
234 224 }
235 225 },
236 226  
237   - updateTabs: function() {
  227 + syncAfterRename: function(renamedNode) {
238 228 var me = this;
239 229 var desktop = this.app.getDesktop();
240 230 var win = desktop.getWindow(this.id);
241 231 if (win) {
242 232 me.getUiContent().updateTabs();
  233 + me.getUiContent().updateRequestName(renamedNode);
243 234 }
244 235 }
245 236 });
... ...
js/app/models/PlotNode.js
... ... @@ -117,7 +117,7 @@ Ext.define('amdaModel.PlotNode', {
117 117 AmdaAction.renameObject(dataToSend, function(result) {
118 118 callBackFn(result);
119 119 myDesktopApp.getLoadedModule(me.get('moduleId'),true, function (module) {
120   - module.updateTabs();
  120 + module.syncAfterRename(me);
121 121 });
122 122 });
123 123 }
... ...
js/app/models/PlotObjects/MultiplotRequestObject.js
... ... @@ -58,6 +58,8 @@ Ext.define('amdaPlotObj.MultiplotRequestObject', {
58 58 leaf : true
59 59 });
60 60 newPlotNode.set('object', plotNode.get('object'));
  61 + me.plots().remove(plotNode);
  62 + me.plots().insert(index, [newPlotNode]);
61 63 return false;
62 64 }
63 65 });
... ...
js/app/views/PlotComponents/PlotTabContent.js
... ... @@ -145,7 +145,7 @@ Ext.define('amdaPlotComp.PlotTabContent', {
145 145 this.tabIndex = config.tabIndex;
146 146 this.plotTabPanel = config.plotTabPanel;
147 147  
148   - this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelectorTab' + this.plotNode.id, border : false, flex: 6, collapsible: true, collapseDirection : 'bottom'} );
  148 + this.timeSelector = new amdaUI.TimeSelectorUI( { id: Ext.id()/*'plotTimeSelectorTab' + this.plotNode.id*/, border : false, flex: 6, collapsible: true, collapseDirection : 'bottom'} );
149 149 this.plotElement = new amdaPlotComp.PlotElementPanel({flex: 11});
150 150 this.treePlot = new amdaPlotComp.PlotTree({flex: 11, plotElementPanel: this.plotElement});
151 151 this.plotOutput = new amdaPlotComp.PlotOutputForm({flex: 6, collapseDirection : 'bottom', collapsible : true });
... ...
js/app/views/PlotComponents/PlotTabPanel.js
... ... @@ -87,8 +87,9 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
87 87 return true;
88 88 },
89 89 close: function( tab, eOpts ) {
90   - if (tab.items.getAt(0).plotNode)
  90 + if (tab.items.getAt(0).plotNode) {
91 91 this.multiplot_object.removePlotByInternalId(tab.items.getAt(0).plotNode.internalId);
  92 + }
92 93 },
93 94 destroy: function(tab, eOpts) {
94 95 if (!this.tabbar_destroy)
... ... @@ -118,6 +119,20 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
118 119 }
119 120 },
120 121  
  122 + updateRequestName: function(renamedNode)
  123 + {
  124 + for (i = 0; i < this.items.getCount(); ++i)
  125 + {
  126 + var tabItem = this.items.getAt(i);
  127 + var tabContent = tabItem.items.getAt(0);
  128 + var plotNode = tabContent.plotNode;
  129 + if (plotNode == renamedNode) {
  130 + plotNode.get('object').set('name', renamedNode.get('text'));
  131 + tabContent.updateUI();
  132 + }
  133 + }
  134 + },
  135 +
121 136 getCurrentPlotTabContent : function() {
122 137 if (this.getActiveTab())
123 138 return this.getActiveTab().child();
... ...
js/app/views/PlotUI.js
... ... @@ -110,6 +110,10 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
110 110 updateTabs : function() {
111 111 this.plotTabs.updatePlotTabs();
112 112 },
  113 +
  114 + updateRequestName : function(renamedNode) {
  115 + this.plotTabs.updateRequestName(renamedNode);
  116 + },
113 117  
114 118 addTT : function(newTTName,newTTid,timeSelectorId) {
115 119 var crtTimeSelector = Ext.getCmp(timeSelectorId);
... ...