Commit 4efeb4592c76f6a1cc4e4d58431ddf799697e4b6

Authored by Benjamin Renard
1 parent 580cdf42

First version for multiplot UI

js/app/controllers/PlotModule.js
... ... @@ -16,7 +16,8 @@ Ext.define('amdaDesktop.PlotModule', {
16 16 'amdaPlotObj.MultiplotRequestObject',
17 17 'amdaModel.MultiplotNode',
18 18 'amdaUI.PlotTabResultUI',
19   - 'amdaPlotComp.PlotPreviewUI'
  19 + 'amdaPlotComp.PlotPreviewUI',
  20 + 'amdaUI.MultiPlotUI'
20 21 ],
21 22  
22 23 contentId : 'plotUI',
... ... @@ -39,7 +40,9 @@ Ext.define('amdaDesktop.PlotModule', {
39 40 helpFile : 'plotHelp',
40 41  
41 42 plotResultWindowsManager : new Ext.AbstractManager(),
42   -
  43 +
  44 + multiPlotWin: null,
  45 +
43 46 computeResultWindowSize : function(panelResult) {
44 47 var size = panelResult.getImageSize();
45 48 size.width += 30;
... ... @@ -139,6 +142,9 @@ Ext.define('amdaDesktop.PlotModule', {
139 142 this.plotResultWindowsManager.each(function (key, value, length) {
140 143 value.close();
141 144 });
  145 + if (this.multiPlotWin) {
  146 + this.multiPlotWin.close();
  147 + }
142 148 },
143 149  
144 150 updatePreview : function(plotPreviewConfig) {
... ... @@ -232,5 +238,53 @@ Ext.define('amdaDesktop.PlotModule', {
232 238 me.getUiContent().updateTabs();
233 239 me.getUiContent().updateRequestName(renamedNode);
234 240 }
  241 + },
  242 +
  243 + showMultiplotWin: function() {
  244 + var me = this;
  245 + var desktop = this.app.getDesktop();
  246 + var win = desktop.getWindow(this.id);
  247 +
  248 + if (!win) {
  249 + return;
  250 + }
  251 +
  252 + if (!this.multiPlotWin) {
  253 + var multiPlotPanel = Ext.create('amdaUI.MultiPlotUI',
  254 + {
  255 + plotWin: me.getUiContent()
  256 + }
  257 + );
  258 + this.multiPlotWin = myDesktopApp.getDesktop().createWindow({
  259 + id : "multiplot-win",
  260 + title : "Multi Plot Manager",
  261 + width : 320,
  262 + height: 320,
  263 + minHeight: 300,
  264 + minWidth: 320,
  265 + layout: 'fit',
  266 + items : [
  267 + multiPlotPanel
  268 + ],
  269 + listeners: {
  270 + beforeclose: function(win,opt) {
  271 + me.multiPlotWin = null;
  272 + }
  273 + }
  274 + });
  275 + }
  276 +
  277 + this.multiPlotWin.show();
  278 +
  279 + },
  280 +
  281 + refreshMultiPlot: function() {
  282 + if (this.multiPlotWin) {
  283 + this.multiPlotWin.items.items[0].refreshMultiPlot();
  284 + }
  285 + },
  286 +
  287 + isMultiPlot : function() {
  288 + return this.multiPlotWin && !this.multiPlotWin.isHidden();
235 289 }
236 290 });
... ...
js/app/models/PlotObjects/MultiplotRequestObject.js
... ... @@ -101,6 +101,46 @@ Ext.define('amdaPlotObj.MultiplotRequestObject', {
101 101 this.plots().remove(plotNode);
102 102 },
103 103  
104   - addPlot: function(plotNode) {
  104 + getJsonValues : function()
  105 + {
  106 + var requestValues = new Object();
  107 +
  108 + requestValues['nodeType'] = 'request';
  109 + requestValues['leaf'] = true;
  110 +
  111 + requestValues['timesrc'] = this.get('timesrc');
  112 + // if there's at least one timeTable name into 'timeTables' collection
  113 + if (this.get('timesrc') == amdaModel.AmdaTimeObject.inputTimeSrc[0] && this.get('timeTables') && this.get('timeTables').length){
  114 + // get complete timeTables collection
  115 + var timeTables = this.get('timeTables');
  116 + // init an empty array for timeTables
  117 + requestValues['timeTables'] = [];
  118 + // for each interval record
  119 + Ext.Array.each(timeTables, function(item, index, all){
  120 + if (!item.$className) {
  121 + requestValues['timeTables'][index] = {timeTableName : item.timeTableName, id : item.id};
  122 + }
  123 + // get Json simplified value
  124 + else {
  125 + requestValues['timeTables'][index] = item.getJsonValues();
  126 + }
  127 + });
  128 + } else {
  129 + requestValues['startDate'] = this.get('startDate');
  130 + requestValues['stopDate'] = this.get('stopDate');
  131 + requestValues['durationDay'] = this.get('durationDay');
  132 + requestValues['durationHour'] = this.get('durationHour');
  133 + requestValues['durationMin'] = this.get('durationMin');
  134 + requestValues['durationSec'] = this.get('durationSec');
  135 + }
  136 +
  137 + requestValues['plots'] = [];
  138 + this.plots().each(function(plotNode) {
  139 + if (plotNode.get('object').get('multi-selected')) {
  140 + requestValues['plots'].push(plotNode.get('object').getJsonValues());
  141 + }
  142 + });
  143 +
  144 + return requestValues;
105 145 }
106 146 });
... ...
js/app/models/PlotObjects/PlotRequestObject.js
... ... @@ -29,6 +29,7 @@ Ext.define('amdaPlotObj.PlotRequestObject', {
29 29 fields : [
30 30 {name: 'tab-index', type: 'int', defaultValue: 0, persist: false},
31 31 {name: 'tab-title', type: 'string', defaultValue: '', persist: false},
  32 + {name: 'multi-selected', type: 'boolean', defaultValue: false, persist: false},
32 33  
33 34 {name: 'file-format', type: 'string'},
34 35 {name: 'file-output', type: 'string'},
... ...
js/app/views/MultiPlotUI.js 0 โ†’ 100644
... ... @@ -0,0 +1,111 @@
  1 +/**
  2 + * Projectย  : AMDA-NG
  3 + * Name : MultiPlotUI.js
  4 + * @class amdaUI.MultiPlotUI
  5 + * @extends Ext. panel.Panel
  6 + * @brief MultiPlot UI definition (View)
  7 + * @author
  8 + * @version $Id: MultiPlotUI.js benjamin
  9 + */
  10 +
  11 +Ext.define('amdaUI.MultiPlotUI', {
  12 + extend: 'Ext.panel.Panel',
  13 +
  14 + plotWin: null,
  15 +
  16 + timeSelector: null,
  17 + newInteractiveSessionCheck: null,
  18 + plotSelector: null,
  19 +
  20 + constructor: function(config) {
  21 + this.init(config);
  22 + this.callParent(arguments);
  23 + },
  24 +
  25 + refreshMultiPlot: function() {
  26 + var me = this;
  27 + var tabsInfo = this.plotWin.plotTabs.getTabsInfo();
  28 + this.plotSelector.removeAll();
  29 + Ext.Array.each(tabsInfo, function(tabInfo) {
  30 + me.plotSelector.add(
  31 + {
  32 + boxLabel: tabInfo.name,
  33 + checked: tabInfo.object.get('multi-selected'),
  34 + listeners: {
  35 + change: function(field, newValue, oldValue, eOpts) {
  36 + tabInfo.object.set('multi-selected', newValue);
  37 + }
  38 + }
  39 + }
  40 + );
  41 + });
  42 + },
  43 +
  44 + doMultiPlot: function() {
  45 + // Update time definition
  46 + var timeSource = this.timeSelector.getActiveTimeSource();
  47 + this.plotWin.object.set('timesrc', timeSource);
  48 + if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
  49 + this.plotWin.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
  50 +
  51 + // Time validation
  52 + if (!this.timeSelector.isValid(false)) {
  53 + myDesktopApp.errorMsg('Error in Time definition');
  54 + return false;
  55 + }
  56 +
  57 + // Execute multiplot request
  58 + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
  59 + plotModule.linkedNode.execute();
  60 + },
  61 +
  62 + init : function(config) {
  63 + var me = this;
  64 +
  65 + this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'multiplot-time-selector', border : false, collapsible: false, height: 180} );
  66 + this.newInteractiveSessionCheck = Ext.create('Ext.form.Checkbox', {
  67 + xtype: 'checkbox',
  68 + boxLabel: 'New Interactive Session for Selected Plot Requests'
  69 + });
  70 + this.plotSelector = Ext.create('Ext.form.CheckboxGroup', {
  71 + xtype: 'checkboxgroup',
  72 + flex: 1,
  73 + columns: 3,
  74 + minHeight: 40,
  75 + autoScroll: true
  76 + });
  77 + var myConf = {
  78 + layout: {
  79 + type: 'vbox',
  80 + pack: 'start',
  81 + align: 'stretch'
  82 + },
  83 + items: [
  84 + this.plotSelector,
  85 + this.newInteractiveSessionCheck,
  86 + this.timeSelector
  87 + ],
  88 + listeners: {
  89 + afterrender: function() {
  90 + me.refreshMultiPlot();
  91 + me.timeSelector.intervalSel.setInterval(me.plotWin.object.get('startDate'), me.plotWin.object.get('stopDate'));
  92 + me.timeSelector.intervalSel.updateStop();
  93 + me.timeSelector.setTTTab(me.plotWin.object.get('timeTables'));
  94 + me.timeSelector.timeSrc.setActiveTab(me.plotWin.object.get('timesrc'));
  95 + }
  96 + },
  97 + fbar: [
  98 + '->',
  99 + {
  100 + xtype: 'button',
  101 + text: 'Plot',
  102 + scope: this,
  103 + handler: function(button) {
  104 + this.doMultiPlot();
  105 + }
  106 + }
  107 + ]
  108 + };
  109 + Ext.apply(this, Ext.apply(arguments, myConf));
  110 + }
  111 +});
... ...
js/app/views/PlotComponents/PlotTabContent.js
... ... @@ -54,6 +54,9 @@ Ext.define('amdaPlotComp.PlotTabContent', {
54 54 doPlot : function() {
55 55 this.plotNode.get('object').set('tab-index', this.tabIndex);
56 56 this.plotNode.get('object').set('tab-title', this.getPlotTitle());
  57 + this.plotNode.get('object').set('multi-selected', false);
  58 + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
  59 + plotModule.refreshMultiPlot();
57 60 this.plotNode.execute();
58 61 },
59 62  
... ...
js/app/views/PlotComponents/PlotTabPanel.js
... ... @@ -34,8 +34,9 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
34 34 this.multiplot_object = multiplot_object;
35 35  
36 36 this.multiplot_object.plots().each(function (rec, index) {
37   - this.addPlotNode(rec, index == 0);
  37 + this.addPlotNode(rec, index == 0, false);
38 38 }, this);
  39 + this.refreshMultiPlot();
39 40 },
40 41  
41 42 reloadPlot : function(plotNode) {
... ... @@ -49,7 +50,7 @@ Ext.define('amdaPlotComp.PlotTabPanel', {
49 50 }
50 51 },
51 52  
52   - addPlotNode: function(plotNode, selectTab)
  53 + addPlotNode: function(plotNode, selectTab, refreshMultiPlot)
53 54 {
54 55 for (i = 0; i < this.items.getCount(); ++i)
55 56 {
... ... @@ -104,6 +105,9 @@ Ext.define(&#39;amdaPlotComp.PlotTabPanel&#39;, {
104 105  
105 106 if (selectTab)
106 107 this.setActiveTab(tabComp);
  108 +
  109 + if (refreshMultiPlot)
  110 + this.refreshMultiPlot();
107 111  
108 112 return tabContent;
109 113 },
... ... @@ -129,6 +133,7 @@ Ext.define(&#39;amdaPlotComp.PlotTabPanel&#39;, {
129 133 if (!this.getActiveTab())
130 134 this.setActiveTab(tabItem);
131 135 }
  136 + this.refreshMultiPlot();
132 137 },
133 138  
134 139 closePlotTabIfOpened: function(plotNodeToClose) {
... ... @@ -139,6 +144,7 @@ Ext.define(&#39;amdaPlotComp.PlotTabPanel&#39;, {
139 144 var plotNode = tabContent.plotNode;
140 145 if (plotNode == renamedNode) {
141 146 this.remove(tabItem.getId());
  147 + this.refreshMultiPlot();
142 148 }
143 149 }
144 150 },
... ... @@ -153,6 +159,7 @@ Ext.define(&#39;amdaPlotComp.PlotTabPanel&#39;, {
153 159 if (plotNode == renamedNode) {
154 160 plotNode.get('object').set('name', renamedNode.get('text'));
155 161 tabContent.updateUI();
  162 + this.refreshMultiPlot();
156 163 }
157 164 }
158 165 },
... ... @@ -174,6 +181,28 @@ Ext.define(&#39;amdaPlotComp.PlotTabPanel&#39;, {
174 181 {
175 182 return plotTab.child().treePlot;
176 183 },
  184 +
  185 + getTabsInfo: function()
  186 + {
  187 + var tabsInfo = [];
  188 + for (i = 0; i < this.items.getCount(); ++i) {
  189 + var tabItem = this.items.getAt(i);
  190 + var tabContent = tabItem.items.getAt(0);
  191 + var plotNode = tabContent.plotNode;
  192 + tabsInfo.push({
  193 + name: tabContent.getPlotTitle(),
  194 + object: plotNode.get('object'),
  195 + selected: (tabItem == this.getActiveTab())
  196 + });
  197 + }
  198 + return tabsInfo;
  199 + },
  200 +
  201 + refreshMultiPlot: function()
  202 + {
  203 + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
  204 + plotModule.refreshMultiPlot();
  205 + },
177 206  
178 207 init : function(config) {
179 208 var me = this;
... ... @@ -193,7 +222,7 @@ Ext.define(&#39;amdaPlotComp.PlotTabPanel&#39;, {
193 222 text:'+',
194 223 closable: false,
195 224 handler:function(btn,e){
196   - var tabContent = me.addPlotNode(me.multiplot_object.createNewPlot(), true);
  225 + var tabContent = me.addPlotNode(me.multiplot_object.createNewPlot(), true, true);
197 226 }
198 227 }
199 228 ],
... ...
js/app/views/PlotUI.js
... ... @@ -70,7 +70,7 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
70 70 },
71 71  
72 72 editPlot : function(plotNode) {
73   - this.plotTabs.addPlotNode(plotNode, true);
  73 + this.plotTabs.addPlotNode(plotNode, true, true);
74 74 },
75 75  
76 76 reloadPlot : function(plotNode) {
... ... @@ -81,10 +81,12 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
81 81 * plot method called by 'Do Plot' button to launch the plot process
82 82 */
83 83 doPlot : function(){
  84 + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
84 85 if ( this.updateObject(false) ) {
85 86 var plotTab = this.plotTabs.getCurrentPlotTabContent();
86   - if (plotTab)
  87 + if (plotTab) {
87 88 plotTab.doPlot();
  89 + }
88 90 }
89 91 },
90 92  
... ... @@ -181,7 +183,17 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
181 183 handler: function(button) {
182 184 this.resetProcess();
183 185 }
184   - },'->', '-', {
  186 + },
  187 + '-', {
  188 + xtype: 'button',
  189 + text: 'Multiplot',
  190 + scope: this,
  191 + handler: function(button) {
  192 + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
  193 + plotModule.showMultiplotWin();
  194 + }
  195 + },
  196 + '->', '-', {
185 197 xtype: 'button',
186 198 text: 'Save',
187 199 scope: this,
... ...