Commit 1baabd91af57c7f8d0665a35a76baa2a82fa1ffd

Authored by Elena.Budnik
2 parents a55dc57a 4078a635

Merge branch 'master' into webservices

js/app/models/BkgJobNode.js
... ... @@ -328,7 +328,7 @@ Ext.define('amdaModel.BkgJobNode', {
328 328 case 'condition' : var type = 'Data Mining '; break;
329 329 case 'request' : var type = 'Plot '; break;
330 330 case 'download' : var type = 'Download '; break;
331   - case 'statistics' : var type = 'Statistics '; break;
  331 + case 'statistics' : var type = 'Statistics '; break;
332 332 default: var type = 'unknown';
333 333 }
334 334 myDesktopApp.infoMsg('Your request is still running and has been assigned the name '+this.get('text')+' -- Check Jobs in Progress');
... ... @@ -424,8 +424,8 @@ Ext.define('amdaModel.BkgJobNode', {
424 424 var isNewTab = false;
425 425  
426 426 loadMask.show(this.get('object').get('tabId'));
427   - AmdaAction.execute({nodeType : this.get('nodeType')}, jsonObj, function(res,e){
428   -
  427 + AmdaAction.execute({nodeType : this.get('nodeType')}, jsonObj, function(res,e)
  428 + {
429 429 loadMask.hide();
430 430 //AKKA - Rework of the result treatment for the integration with the new kernel
431 431 if (!e.status)
... ...
js/app/models/ExecutableNode.js
... ... @@ -6,142 +6,134 @@
6 6 * @brief Generic Model of Executable Node
7 7 * @author elena
8 8 * @version $Id: ExecutableNode.js 1662 2013-07-02 15:10:22Z benjamin $
9   - * @todo
10   - *******************************************************************************
11   - * FT Id : Date : Name - Description
12   - *******************************************************************************
13   - * : :12/07/2011: elena - creation
14   - *
15 9 */
16 10  
17 11 Ext.define('amdaModel.ExecutableNode', {
18   - extend: 'amdaModel.InteractiveNode',
  12 + extend: 'amdaModel.InteractiveNode',
19 13  
20   -//TODO use resultModel in execute method Is it needed???
21   -
22   - fields: [ 'jobNode', 'resultModel'],
  14 + fields: [ 'jobNode', 'resultModel'],
23 15  
24   - statics: { jobTreeLoaded : false },
  16 + statics: { jobTreeLoaded : false },
25 17  
26   - constructor : function(config) {
27   - this.callParent(arguments);
28   - this.set('ownerTreeId',amdaUI.ExplorerUI.OPE_TAB.TREE_ID);
29   - this.set('jobNode', 'amdaModel.BkgJobNode');
30   - },
  18 + constructor : function(config)
  19 + {
  20 + this.callParent(arguments);
  21 + this.set('ownerTreeId',amdaUI.ExplorerUI.OPE_TAB.TREE_ID);
  22 + this.set('jobNode', 'amdaModel.BkgJobNode');
  23 + },
31 24  
32   - loadJobTree : function() {
33   - var rootNode = Ext.getCmp(amdaUI.ExplorerUI.JOB_TAB.TREE_ID).getRootNode();
34   - var me = this;
35   - amdaModel.InteractiveNode.preloadNodes(rootNode,
36   - function()
37   - {
38   - amdaModel.ExecutableNode.jobTreeLoaded = true;
39   - me.realExecute();
40   - });
41   - },
42   -
43   - execute : function(isDirty) {
44   -
45   - if (!amdaModel.ExecutableNode.jobTreeLoaded) this.loadJobTree();
46   - else this.realExecute();
47   -
48   - },
  25 + loadJobTree : function()
  26 + {
  27 + var rootNode = Ext.getCmp(amdaUI.ExplorerUI.JOB_TAB.TREE_ID).getRootNode();
  28 + var me = this;
  29 + amdaModel.InteractiveNode.preloadNodes(rootNode, function(){
  30 + amdaModel.ExecutableNode.jobTreeLoaded = true;
  31 + me.realExecute();
  32 + });
  33 + },
49 34  
50   - /**
51   - * Method to execute this node
52   - */
53   - realExecute : function() {
54   -
55   - var isInteractivePlot = (this.get('nodeType') == 'request') && (this.get('object').get('file-output') == 'INTERACTIVE');
  35 + execute : function(isDirty)
  36 + {
  37 + if (!amdaModel.ExecutableNode.jobTreeLoaded)
  38 + this.loadJobTree();
  39 + else
  40 + this.realExecute();
  41 + },
  42 +
  43 + /**
  44 + * Method to execute this node
  45 + */
  46 + realExecute : function()
  47 + {
  48 + var isInteractivePlot = (this.get('nodeType') == 'request') && (this.get('object').get('file-output') == 'INTERACTIVE');
56 49  
57   - if (!loadMask.isMasked())
58   - loadMask.show(isInteractivePlot);
  50 + if (!loadMask.isMasked())
  51 + loadMask.show(isInteractivePlot);
59 52  
60   - AmdaAction.execute({nodeType : this.get('nodeType')}, this.get('object').getJsonValues(true), function(res,e){
61   -
62   - loadMask.hide();
  53 + AmdaAction.execute({nodeType : this.get('nodeType')}, this.get('object').getJsonValues(true),
  54 + function(res,e)
  55 + {
  56 + loadMask.hide();
63 57  
64   - //AKKA - Rework of the result treatment for the integration with the new kernel
65   - if (!e.status)
66   - {
67   - myDesktopApp.errorMsg('Internal error during request');
68   - return;
69   - }
  58 + //AKKA - Rework of the result treatment for the integration with the new kernel
  59 + if (!e.status){
  60 + myDesktopApp.errorMsg('Internal error during request');
  61 + return;
  62 + }
70 63  
71   - if (!res.success)
72   - {
73   - myDesktopApp.errorMsg(res.message);
74   - return;
75   - }
76   -
77   - if (res.killed)
78   - return;
  64 + if (!res.success){
  65 + myDesktopApp.errorMsg(res.message);
  66 + return;
  67 + }
  68 +
  69 + if (res.killed)
  70 + return;
79 71  
80   - if (isInteractivePlot)
81   - {
82   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) {
83   - module.updateInteractiveSession(res, true);
84   - });
85   - }
86   - else
87   - {
88   - var newobj = this.createJobObject(res);
89   - var newNode = Ext.create(this.get('jobNode'),
90   - {
91   - info : res.info,
92   - jobType : this.get('nodeType'),
93   - processId : res.id,
94   - id : res.id,
95   - text : res.name,
96   - status : res.status,
97   - start : res.start,
98   - stop : res.stop,
99   - tabId : res.tabId,
100   - leaf : true,
101   - object : newobj});
  72 + if (isInteractivePlot){
  73 + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) {
  74 + module.updateInteractiveSession(res, true);
  75 + });
  76 + }
  77 + else {
  78 + var newobj = this.createJobObject(res);
  79 + var newNode = Ext.create(this.get('jobNode'), {
  80 + info : res.info,
  81 + jobType : this.get('nodeType'),
  82 + processId : res.id,
  83 + id : res.id,
  84 + text : res.name,
  85 + status : res.status,
  86 + start : res.start,
  87 + stop : res.stop,
  88 + tabId : res.tabId,
  89 + leaf : true,
  90 + object : newobj
  91 + });
102 92  
103   - newNode.get('object').on('execute', function() {
104   - // Then call the node creation method
105   - this.execute(arguments);
106   - }, newNode);
  93 + newNode.get('object').on('execute', function() {
  94 + // Then call the node creation method
  95 + this.execute(arguments);
  96 + }, newNode);
107 97  
108   - switch (res.status)
109   - {
110   - case amdaModel.BkgJobNode.STATUS_LIST.DONE :
111   - newNode.createJobNode(true);
112   - newNode.editNode(true, false);
113   - break;
114   - case amdaModel.BkgJobNode.STATUS_LIST.IN_PROGRESS :
115   - newNode.createJobNode(false);
116   - break;
117   - default:
118   - newNode.createJobNode(true);
119   - }
120   - }
121   - }, this );
122   - },
  98 + switch (res.status)
  99 + {
  100 + case amdaModel.BkgJobNode.STATUS_LIST.DONE :
  101 + newNode.createJobNode(true);
  102 + newNode.editNode(true, false);
  103 + break;
  104 + case amdaModel.BkgJobNode.STATUS_LIST.IN_PROGRESS :
  105 + newNode.createJobNode(false);
  106 + break;
  107 + default:
  108 + newNode.createJobNode(true);
  109 + }
  110 + }
  111 + }, this );
  112 + },
123 113  
124   - createJobObject: function(res) {
125   -
126   - var obj = this.get('object').getJsonValues();
127   -//TODO text, name, outputName - if all is needed
128   - //new object to attach to new bkgJobNode
129   -//TODO Ext.clone()
130   - var newobj = Ext.copyTo({}, obj, this.get('object').propertiesToCopy);
131   - newobj.resultId = res.result;
132   - newobj.folderId = res.folder;
133   - newobj.processId= res.id;
134   - newobj.tabId = res.tabId;
135   - newobj.name = res.name;
136   - newobj = Ext.create(this.get('object').$className, newobj);
137   - return newobj;
  114 + createJobObject: function(res)
  115 + {
  116 + var obj = this.get('object').getJsonValues();
  117 + //TODO text, name, outputName - if all is needed
  118 +
  119 + //new object to attach to new bkgJobNode
  120 + //TODO Ext.clone()
  121 + var newobj = Ext.copyTo({}, obj, this.get('object').propertiesToCopy);
  122 + newobj.resultId = res.result;
  123 + newobj.folderId = res.folder;
  124 + newobj.processId= res.id;
  125 + newobj.tabId = res.tabId;
  126 + newobj.name = res.name;
  127 + newobj = Ext.create(this.get('object').$className, newobj);
  128 +
  129 + return newobj;
138 130 },
139   - /**
140   - * override isExecutable to return true
141   - */
142   - isExecutable: function(){
143   - return true;
144   - }
145   -
  131 +
  132 + /**
  133 + * override isExecutable to return true
  134 + */
  135 + isExecutable: function()
  136 + {
  137 + return true;
  138 + }
146 139 });
147   -
... ...
js/app/models/PlotObjects/PlotObjectConfig.js
... ... @@ -328,6 +328,7 @@ Ext.define('amdaPlotObj.PlotObjectConfig', {
328 328 ],
329 329  
330 330 availableColors : [
  331 + {'key' : 'auto', 'color' : 'auto', 'value' : 'auto'},
331 332 {'key' : '[0,0,0]', 'color' : '#000000', 'value' : 'Black'},
332 333 {'key' : '[0,0,255]', 'color' : '#0000ff', 'value' : 'Blue'},
333 334 {'key' : '[255,0,0]', 'color' : '#ff0000', 'value' : 'Red'},
... ...
js/app/views/ParameterUI.js
... ... @@ -286,7 +286,6 @@ Ext.define('amdaUI.ParameterUI',
286 286 validateOnChange: false,
287 287 validateOnBlur: false,
288 288 validator : this.isBalanced,
289   - // ToDo - BRE - Wait the fix for drag&drop issue
290 289 listeners :
291 290 {
292 291 render : function(o,op)
... ...
js/app/views/PlotComponents/PlotZoomPlug.js
1 1 /**
2   - * Project  : AMDA-NG
3   - * Name : PlotZoomPlug.js
4   - * @plugin amdaPlotComp.PlotZoomPlug
5   - * @extends Ext.util.Observable
6   - * @ptype plotZoomPlugin
7   - * @brief Plot Zoom UI (View)
8   - * @author Benjamin
9   - * @version $Id: PlotZoomPlug.js
10   - ********************************************************************************
11   - * FT Id : Date : Name - Description
12   - *******************************************************************************
13   - * :
14   - */
  2 + * Project  : AMDA-NG
  3 + * Name : PlotZoomPlug.js
  4 + * @plugin amdaPlotComp.PlotZoomPlug
  5 + * @extends Ext.util.Observable
  6 + * @ptype plotZoomPlugin
  7 + * @brief Plot Zoom UI (View)
  8 + * @author Benjamin
  9 + * @version $Id: PlotZoomPlug.js
  10 + ********************************************************************************
  11 + * FT Id : Date : Name - Description
  12 + *******************************************************************************
  13 + * :
  14 + */
15 15  
16 16  
17 17 Ext.define('amdaPlotComp.PlotZoomPlug', {
18   - extend: 'Ext.util.Observable',
19   - alias: 'plugin.plotZoomPlugin',
20   -
21   - id: 'plot-zoom-plug',
22   -
23   - ttModuleId : 'timetab-win',
24   -
25   - win : null,
26   - form : null,
27   - zoomType : '',
28   - tabId : '',
29   - panelId : -1,
30   -
31   - linkedTTNode : null,
32   -
33   - constructor: function(config) {
34   - Ext.apply(this, config);
35   - this.callParent(arguments);
36   - },
37   -
38   - onDestroy : function() {
39   - this.win = null;
40   - },
41   -
42   - init: function(cmp) {
43   - this.hostCmp = cmp;
44   - },
45   -
46   - setMinValue : function(min) {
47   - if (!this.form)
48   - return;
49   -
50   - if (this.zoomType == 'timeAxis')
51   - this.form.getForm().findField('zoom-min-time').setValue(min);
52   - else
53   - this.form.getForm().findField('zoom-min-float').setValue(min);
54   - },
55   -
56   - setMaxValue : function(max) {
57   - if (!this.form)
58   - return;
59   -
60   - if (this.zoomType == 'timeAxis')
61   - {
62   - var minValue = this.form.getForm().findField('zoom-min-time').getValue();
63   - if (minValue <= max)
64   - this.form.getForm().findField('zoom-max-time').setValue(max);
65   - else
66   - {
67   - this.form.getForm().findField('zoom-min-time').setValue(max);
68   - this.form.getForm().findField('zoom-max-time').setValue(minValue);
69   - }
70   - }
71   - else
72   - {
73   - var minValue = this.form.getForm().findField('zoom-min-float').getValue();
74   - if (minValue <= max)
75   - this.form.getForm().findField('zoom-max-float').setValue(max);
76   - else
77   - {
78   - this.form.getForm().findField('zoom-min-float').setValue(max);
79   - this.form.getForm().findField('zoom-max-float').setValue(minValue);
80   - }
81   - }
82   - },
83   -
84   -/**
85   - * add Interval to Time table
86   - **/
87   - insertInterval: function() {
88   - if (this.zoomType != 'timeAxis')
89   - return;
90   -
91   - var start = this.form.getForm().findField('zoom-min-time').getValue();
92   - var stop = this.form.getForm().findField('zoom-max-time').getValue();
93   -
94   - myDesktopApp.getLoadedModule(this.ttModuleId, true, function(module){
95   - var targetModuleUI = module.getUiContent();
96   - if (targetModuleUI)
97   - targetModuleUI.addInterval(start,stop);
98   - });
99   - },
  18 + extend: 'Ext.util.Observable',
  19 + alias: 'plugin.plotZoomPlugin',
100 20  
101   -/**
102   - * creation of the window
103   - */
104   - show : function(tabId, zoomType, panelId) {
105   - if (!this.win)
106   - {
107   - this.win = new Ext.Window({
108   - id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(), // Plot window ID
109   - width: 250,
110   - height: 250,
111   - x: 0, y: 0,
112   - baseCls:'x-panel',
113   - title: 'Zoom',
114   - layout: 'fit',
115   - constrain: true,
116   - collapsible: true,
117   - resizable: false,
118   - ghost: false,
119   - renderTo: this.hostCmp.ownerCt.body,
120   - items: this.getFormConfig(),
121   - listeners: {
122   - scope: this,
123   - beforeclose: function() {
124   - this.hostCmp.panelImage.stopZoom();
125   - Ext.PluginManager.unregister(this);
126   - }
127   - },
128   - getConstrainVector: function(constrainTo){
129   - var me = this;
130   - if (me.constrain || me.constrainHeader) {
131   - constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent();
132   - return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo);
133   - }
134   - }
135   - });
136   -
137   - this.win.on('destroy', this.onDestroy, this);
138   -
139   - Ext.PluginManager.register(this);
140   - }
141   -
142   - this.tabId = tabId;
143   - this.updateWinByType(zoomType, panelId);
144   - this.win.show();
145   - this.win.setPosition(0,0);
146   - },
147   -
148   - close : function() {
149   - if (this.win == null)
150   - return;
151   - this.win.close();
152   - },
153   -
154   - updateWinByType : function(zoomType, panelId) {
155   - if (this.win == null)
156   - return;
157   -
158   - this.zoomType = zoomType;
159   - this.panelId = panelId;
160   -
161   - switch (zoomType)
162   - {
163   - case 'timeAxis':
164   - this.win.setTitle('Zoom on time axis & Interval selection - Panel Id : '+panelId);
165   - break;
166   - case 'y-left' :
167   - this.win.setTitle('Zoom on Y Left axis - Panel Id : '+panelId);
168   - break;
169   - case 'y-right' :
170   - this.win.setTitle('Zoom on Y Right axis - Panel Id : '+panelId);
171   - break;
172   - case 'xaxis_id' :
173   - this.win.setTitle('Zoom on X axis - Panel Id : '+panelId);
174   - break;
175   - }
176   -
177   - this.form.getForm().findField('zoom-min-time').setVisible(this.zoomType == 'timeAxis');
178   - this.form.getForm().findField('zoom-max-time').setVisible(this.zoomType == 'timeAxis');
179   -
180   - this.form.getForm().findField('zoom-min-float').setVisible(this.zoomType != 'timeAxis');
181   - this.form.getForm().findField('zoom-max-float').setVisible(this.zoomType != 'timeAxis');
182   -
183   - var ttNameField = this.form.getForm().findField('tt-name');
184   - if (ttNameField)
185   - ttNameField.findParentByType('fieldset').setVisible(this.zoomType == 'timeAxis');
186   -
187   - this.win.setHeight((this.zoomType == 'timeAxis') ? 250 : 160);
188   - },
189   -
190   - resetMinMaxValue: function() {
191   - if (this.zoomType == 'timeAxis')
192   - {
193   - this.form.getForm().findField('zoom-min-time').setValue('');
194   - this.form.getForm().findField('zoom-max-time').setValue('');
195   - }
196   - else
197   - {
198   - this.form.getForm().findField('zoom-min-float').setValue(null);
199   - this.form.getForm().findField('zoom-max-float').setValue(null);
200   - }
201   -
202   - this.hostCmp.panelImage.resetZoom();
203   - },
  21 + id: 'plot-zoom-plug',
204 22  
205   -/**
206   - * Main form
207   - */
208   - getFormConfig: function(){
209   -
210   - var intervalFieldSet = {
211   - xtype: 'fieldset',
212   - title: 'Interval Selection',
213   - name: 'interval-selection-fieldset',
214   - collapsible: false,
215   - layout: {
216   - type: 'vbox',
217   - pack: 'start',
218   - align: 'stretch'
219   - },
220   - items : [
221   - {
222   - xtype:'datefield', name:'zoom-min-time', fieldLabel: 'Start Time',
223   - format : 'Y-m-d\\TH:i:s'
224   - },
225   - {
226   - xtype:'datefield', name:'zoom-max-time', fieldLabel: 'Stop Time',
227   - format : 'Y-m-d\\TH:i:s'
228   - },
229   - {
230   - xtype:'numberfield', name:'zoom-min-float', fieldLabel: 'Min Value'
231   - },
232   - {
233   - xtype:'numberfield', name:'zoom-max-float', fieldLabel: 'Max Value'
234   - },
235   - {
236   - xtype: 'button',
237   - width: 100,
238   - text: 'Reset interval',
239   - scope: this,
240   - handler: function() {
241   - this.resetMinMaxValue();
242   - }
243   - }
244   - ]
245   - };
246   -
247   - var insertTTFieldSet = {
248   - xtype: 'fieldset',
249   - title: 'TimeTable Insertion',
250   - name: 'tt-insertion-fieldset',
251   - collapsible: false,
252   - layout: {
253   - type: 'vbox',
254   - pack: 'start',
255   - align: 'stretch'
256   - },
257   - items : [
258   - {
259   - xtype: 'textfield',
260   - fieldLabel: 'TimeTable Name',
261   - name: 'tt-name',
262   - listeners :
263   - {
264   - render : function(o,op)
265   - {
266   - var me = this;
267   - var el = me.el;
268   - var dropTarget = Ext.create('Ext.dd.DropTarget', el, {
269   - ddGroup: 'explorerTree',
270   - notifyOver : function(ddSource, e, data)
271   - {
272   - if ((data.records[0].data.nodeType == 'timeTable') && (data.records[0].data.leaf))
273   - {
274   - this.valid = true;
275   - return this.dropAllowed;
276   - }
277   - this.valid = false;
278   - return this.dropNotAllowed;
279   - },
280   - notifyDrop : function(ddSource, e, data)
281   - {
282   - if (!this.valid)
283   - return false;
284   - me.setValue(data.records[0].get('text'));
285   - return true;
286   - }
287   - });
288   - }
289   - }
290   - },
291   - {
292   - xtype: 'button',
293   - width: 100,
294   - text: 'Insert Interval',
295   - scope: this,
296   - handler: function(){
297   - var me = this;
298   -
299   - var TTname = this.form.getForm().findField('tt-name').getValue();
300   -
301   - myDesktopApp.getLoadedModule(this.ttModuleId, true, function(module){
302   - var targetModuleUI = module.getUiContent();
303   - if (me.linkedTTNode && (me.linkedTTNode.get('text') == TTname))
304   - {
305   - if (targetModuleUI)
306   - me.insertInterval();
307   - else
308   - {
309   - me.linkedTTNode.editLeaf(function () {
310   - me.insertInterval();
311   - });
312   - }
313   - }
314   - else
315   - {
316   - if (TTname == '')
317   - {
318   - me.linkedTTNode.editLeaf(function () {
319   - me.insertInterval();
320   - });
321   - }
322   -
323   - var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);
324   - var ttRootNode = explorerTree.getRootNode().findChild('id','timeTable-treeRootNode',true);
325   - amdaModel.InteractiveNode.preloadNodes(ttRootNode, function() {
326   - var nodeWithSameName = null;
327   -
328   - if (TTname != '')
329   - nodeWithSameName = ttRootNode.findChild('text', TTname, true);
330   -
331   - if (nodeWithSameName !== null)
332   - me.linkedTTNode = nodeWithSameName;
333   - else
334   - {
335   - var obj = Ext.create('amdaModel.TimeTable', {name : TTname, fromPlugin : true});
336   - me.linkedTTNode = Ext.create('amdaModel.TimeTableNode', {
337   - leaf : true,
338   - text : TTname,
339   - nodeType : 'timeTable',
340   - object : obj
341   - });
342   - }
343   -
344   - me.linkedTTNode.editLeaf(function () {
345   - me.insertInterval();
346   - });
347   - });
348   - }
349   - });
350   - }
351   - }
352   - ]
353   - };
354   -
355   - this.form = new Ext.form.FormPanel( {
356   - frame: true,
357   - width: 250,
358   - height: 250,
359   - layout: {
360   - type: 'vbox',
361   - pack: 'start',
362   - align: 'stretch'
363   - },
364   - fieldDefaults: {
365   - labelWidth: 60
366   - },
367   - items: [
368   - intervalFieldSet,
369   - insertTTFieldSet
370   - ],
371   - fbar : [
372   - {
373   - text: 'Apply Zoom',
374   - width: 100,
375   - scope: this,
376   - handler: function(){
377   - if (this.zoomType == 'timeAxis')
378   - {
379   - var minZoom = this.form.getForm().findField('zoom-min-time').getValue();
380   - var maxZoom = this.form.getForm().findField('zoom-max-time').getValue();
381   - }
382   - else
383   - {
384   - var minZoom = this.form.getForm().findField('zoom-min-float').getValue();
385   - var maxZoom = this.form.getForm().findField('zoom-max-float').getValue();
386   - }
387   -
388   - if(!maxZoom || !minZoom || !this.form.getForm().isValid()) {
389   - myDesktopApp.warningMsg('Error in values definition');
390   - return;
391   - }
392   -
393   - this.hostCmp.callInteractivePlot({'action' : 'zoom', 'tabId' : this.tabId, 'panelId' : this.panelId, 'axeId' : this.zoomType, 'min' : minZoom, 'max' : maxZoom});
394   - this.hostCmp.panelImage.resetZoom();
395   - }
396   - },
397   - {
398   - text: 'Undo Zoom',
399   - width: 100,
400   - scope : this,
401   - handler: function(){
402   - this.hostCmp.callInteractivePlot({'action' : 'undozoom', 'tabId' : this.tabId, 'panelId' : this.panelId, 'axeId' : this.zoomType});
403   - this.hostCmp.panelImage.resetZoom();
404   - }
405   - }
406   - ]
407   - });
408   - return this.form;
409   - }
  23 + ttModuleId: 'timetab-win',
  24 +
  25 + win: null,
  26 + form: null,
  27 + zoomType: '',
  28 + tabId: '',
  29 + panelId: -1,
  30 +
  31 + linkedTTNode: null,
  32 +
  33 + constructor: function (config) {
  34 + Ext.apply(this, config);
  35 + this.callParent(arguments);
  36 + },
  37 +
  38 + onDestroy: function () {
  39 + this.win = null;
  40 + },
  41 +
  42 + init: function (cmp) {
  43 + this.hostCmp = cmp;
  44 + },
  45 +
  46 + setMinValue: function (min) {
  47 + if (!this.form)
  48 + return;
  49 +
  50 + if (this.zoomType == 'timeAxis')
  51 + this.form.getForm().findField('zoom-min-time').setValue(min);
  52 + else
  53 + this.form.getForm().findField('zoom-min-float').setValue(min);
  54 + },
  55 +
  56 + setMaxValue: function (max) {
  57 + if (!this.form)
  58 + return;
  59 +
  60 + if (this.zoomType == 'timeAxis') {
  61 + var minValue = this.form.getForm().findField('zoom-min-time').getValue();
  62 + if (minValue <= max)
  63 + this.form.getForm().findField('zoom-max-time').setValue(max);
  64 + else {
  65 + this.form.getForm().findField('zoom-min-time').setValue(max);
  66 + this.form.getForm().findField('zoom-max-time').setValue(minValue);
  67 + }
  68 + }
  69 + else {
  70 + var minValue = this.form.getForm().findField('zoom-min-float').getValue();
  71 + if (minValue <= max)
  72 + this.form.getForm().findField('zoom-max-float').setValue(max);
  73 + else {
  74 + this.form.getForm().findField('zoom-min-float').setValue(max);
  75 + this.form.getForm().findField('zoom-max-float').setValue(minValue);
  76 + }
  77 + }
  78 + },
  79 +
  80 + /**
  81 + * add Interval to Time table
  82 + **/
  83 + insertInterval: function () {
  84 + if (this.zoomType != 'timeAxis')
  85 + return;
  86 +
  87 + var start = this.form.getForm().findField('zoom-min-time').getValue();
  88 + var stop = this.form.getForm().findField('zoom-max-time').getValue();
  89 +
  90 + myDesktopApp.getLoadedModule(this.ttModuleId, true, function (module) {
  91 + var targetModuleUI = module.getUiContent();
  92 + if (targetModuleUI)
  93 + targetModuleUI.addInterval(start, stop);
  94 + });
  95 + },
  96 +
  97 + /**
  98 + * creation of the window
  99 + */
  100 + show: function (tabId, zoomType, panelId) {
  101 + if (!this.win) {
  102 + this.win = new Ext.Window({
  103 + id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(), // Plot window ID
  104 + width: 250,
  105 + x: 0, y: 0,
  106 + baseCls: 'x-panel',
  107 + title: 'Zoom',
  108 + constrain: true,
  109 + collapsible: true,
  110 + resizable: false,
  111 + ghost: false,
  112 + renderTo: this.hostCmp.ownerCt.body,
  113 + items: this.getFormConfig(),
  114 + listeners: {
  115 + scope: this,
  116 + beforeclose: function () {
  117 + this.hostCmp.panelImage.stopZoom();
  118 + Ext.PluginManager.unregister(this);
  119 + }
  120 + },
  121 + getConstrainVector: function (constrainTo) {
  122 + var me = this;
  123 + if (me.constrain || me.constrainHeader) {
  124 + constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent();
  125 + return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo);
  126 + }
  127 + }
  128 + });
  129 +
  130 + this.win.on('destroy', this.onDestroy, this);
  131 +
  132 + Ext.PluginManager.register(this);
  133 + }
  134 +
  135 + this.tabId = tabId;
  136 + this.updateWinByType(zoomType, panelId);
  137 + this.win.show();
  138 + this.win.setPosition(0, 0);
  139 + },
  140 +
  141 + close: function () {
  142 + if (this.win == null)
  143 + return;
  144 + this.win.close();
  145 + },
  146 +
  147 + updateWinByType: function (zoomType, panelId) {
  148 + if (this.win == null)
  149 + return;
  150 +
  151 + this.zoomType = zoomType;
  152 + this.panelId = panelId;
  153 +
  154 + switch (zoomType) {
  155 + case 'timeAxis':
  156 + this.win.setTitle('Zoom on time axis & Interval selection - Panel Id : ' + panelId);
  157 + break;
  158 + case 'y-left' :
  159 + this.win.setTitle('Zoom on Y Left axis - Panel Id : ' + panelId);
  160 + break;
  161 + case 'y-right' :
  162 + this.win.setTitle('Zoom on Y Right axis - Panel Id : ' + panelId);
  163 + break;
  164 + case 'xaxis_id' :
  165 + this.win.setTitle('Zoom on X axis - Panel Id : ' + panelId);
  166 + break;
  167 + }
  168 +
  169 + this.form.getForm().findField('zoom-min-time').setVisible(this.zoomType == 'timeAxis');
  170 + this.form.getForm().findField('zoom-max-time').setVisible(this.zoomType == 'timeAxis');
  171 +
  172 + this.form.getForm().findField('zoom-min-float').setVisible(this.zoomType != 'timeAxis');
  173 + this.form.getForm().findField('zoom-max-float').setVisible(this.zoomType != 'timeAxis');
  174 +
  175 + var ttNameField = this.form.getForm().findField('tt-name');
  176 + if (ttNameField)
  177 + ttNameField.findParentByType('fieldset').setVisible(this.zoomType == 'timeAxis');
  178 + },
  179 +
  180 + resetMinMaxValue: function () {
  181 + if (this.zoomType == 'timeAxis') {
  182 + this.form.getForm().findField('zoom-min-time').setValue('');
  183 + this.form.getForm().findField('zoom-max-time').setValue('');
  184 + }
  185 + else {
  186 + this.form.getForm().findField('zoom-min-float').setValue(null);
  187 + this.form.getForm().findField('zoom-max-float').setValue(null);
  188 + }
  189 +
  190 + this.hostCmp.panelImage.resetZoom();
  191 + },
  192 +
  193 + /**
  194 + * Main form
  195 + */
  196 + getFormConfig: function () {
  197 +
  198 + var intervalFieldSet = {
  199 + xtype: 'fieldset',
  200 + title: 'Interval Selection',
  201 + name: 'interval-selection-fieldset',
  202 + collapsible: false,
  203 + layout: {
  204 + type: 'vbox',
  205 + pack: 'start',
  206 + align: 'stretch'
  207 + },
  208 + items: [
  209 + {
  210 + xtype: 'datefield', name: 'zoom-min-time', fieldLabel: 'Start Time',
  211 + format: 'Y-m-d\\TH:i:s'
  212 + },
  213 + {
  214 + xtype: 'datefield', name: 'zoom-max-time', fieldLabel: 'Stop Time',
  215 + format: 'Y-m-d\\TH:i:s'
  216 + },
  217 + {
  218 + xtype: 'numberfield', name: 'zoom-min-float', fieldLabel: 'Min Value'
  219 + },
  220 + {
  221 + xtype: 'numberfield', name: 'zoom-max-float', fieldLabel: 'Max Value'
  222 + },
  223 + {
  224 + xtype: 'button',
  225 + width: 100,
  226 + text: 'Reset interval',
  227 + scope: this,
  228 + handler: function () {
  229 + this.resetMinMaxValue();
  230 + }
  231 + }
  232 + ]
  233 + };
  234 +
  235 + var insertTTFieldSet = {
  236 + xtype: 'fieldset',
  237 + title: 'TimeTable Insertion',
  238 + name: 'tt-insertion-fieldset',
  239 + collapsible: false,
  240 + layout: {
  241 + type: 'vbox',
  242 + pack: 'start',
  243 + align: 'stretch'
  244 + },
  245 + items: [
  246 + {
  247 + xtype: 'textfield',
  248 + fieldLabel: 'TimeTable Name',
  249 + name: 'tt-name',
  250 + listeners:
  251 + {
  252 + render: function (o, op) {
  253 + var me = this;
  254 + var el = me.el;
  255 + var dropTarget = Ext.create('Ext.dd.DropTarget', el, {
  256 + ddGroup: 'explorerTree',
  257 + 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;
  261 + }
  262 + this.valid = false;
  263 + return this.dropNotAllowed;
  264 + },
  265 + notifyDrop: function (ddSource, e, data) {
  266 + if (!this.valid)
  267 + return false;
  268 + me.setValue(data.records[0].get('text'));
  269 + return true;
  270 + }
  271 + });
  272 + }
  273 + }
  274 + },
  275 + {
  276 + xtype: 'button',
  277 + width: 100,
  278 + text: 'Insert Interval',
  279 + scope: this,
  280 + handler: function () {
  281 + var me = this;
  282 +
  283 + var TTname = this.form.getForm().findField('tt-name').getValue();
  284 +
  285 + myDesktopApp.getLoadedModule(this.ttModuleId, true, function (module) {
  286 + var targetModuleUI = module.getUiContent();
  287 + if (me.linkedTTNode && (me.linkedTTNode.get('text') == TTname)) {
  288 + if (targetModuleUI)
  289 + me.insertInterval();
  290 + else {
  291 + me.linkedTTNode.editLeaf(function () {
  292 + me.insertInterval();
  293 + });
  294 + }
  295 + }
  296 + else {
  297 + if (TTname == '') {
  298 + me.linkedTTNode.editLeaf(function () {
  299 + me.insertInterval();
  300 + });
  301 + }
  302 +
  303 + 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 () {
  306 + var nodeWithSameName = null;
  307 +
  308 + if (TTname != '')
  309 + nodeWithSameName = ttRootNode.findChild('text', TTname, true);
  310 +
  311 + if (nodeWithSameName !== null)
  312 + me.linkedTTNode = nodeWithSameName;
  313 + 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 + });
  321 + }
  322 +
  323 + me.linkedTTNode.editLeaf(function () {
  324 + me.insertInterval();
  325 + });
  326 + });
  327 + }
  328 + });
  329 + }
  330 + }
  331 + ]
  332 + };
  333 +
  334 + this.form = new Ext.form.FormPanel({
  335 + frame: true,
  336 + width: 250,
  337 + layout: {
  338 + type: 'vbox',
  339 + pack: 'start',
  340 + align: 'stretch'
  341 + },
  342 + fieldDefaults: {
  343 + labelWidth: 60
  344 + },
  345 + items: [
  346 + intervalFieldSet,
  347 + insertTTFieldSet
  348 + ],
  349 + fbar: [
  350 + {
  351 + text: 'Apply Zoom',
  352 + width: 100,
  353 + scope: this,
  354 + handler: function () {
  355 + if (this.zoomType == 'timeAxis') {
  356 + var minZoom = this.form.getForm().findField('zoom-min-time').getValue();
  357 + var maxZoom = this.form.getForm().findField('zoom-max-time').getValue();
  358 + }
  359 + else {
  360 + var minZoom = this.form.getForm().findField('zoom-min-float').getValue();
  361 + var maxZoom = this.form.getForm().findField('zoom-max-float').getValue();
  362 + }
  363 +
  364 + if (!maxZoom || !minZoom || !this.form.getForm().isValid()) {
  365 + myDesktopApp.warningMsg('Error in values definition');
  366 + return;
  367 + }
  368 +
  369 + this.hostCmp.callInteractivePlot({
  370 + 'action': 'zoom',
  371 + 'tabId': this.tabId,
  372 + 'panelId': this.panelId,
  373 + 'axeId': this.zoomType,
  374 + 'min': minZoom,
  375 + 'max': maxZoom
  376 + });
  377 + this.hostCmp.panelImage.resetZoom();
  378 + }
  379 + },
  380 + {
  381 + text: 'Undo Zoom',
  382 + width: 100,
  383 + scope: this,
  384 + handler: function () {
  385 + this.hostCmp.callInteractivePlot({
  386 + 'action': 'undozoom',
  387 + 'tabId': this.tabId,
  388 + 'panelId': this.panelId,
  389 + 'axeId': this.zoomType
  390 + });
  391 + this.hostCmp.panelImage.resetZoom();
  392 + }
  393 + }
  394 + ]
  395 + });
  396 + return this.form;
  397 + }
410 398 });
411 399 \ No newline at end of file
... ...