Commit eac92219676ad28c922ade098fe982208e322a0e

Authored by Benjamin Renard
1 parent b1a45580

Do not call onChange callback during rebuild + Move a specific message for plot in the plot module

js/app/views/ParamArgumentsUI.js
... ... @@ -19,7 +19,7 @@ Ext.define('amdaUI.ParamArgumentsUI', {
19 19 onChange: null,
20 20 onModifyHeight: null,
21 21 pluginOwner: null,
22   - isFirstMsg : true,
  22 + inRebuild : false,
23 23  
24 24 constructor: function(config) {
25 25 this.init(config);
... ... @@ -66,8 +66,8 @@ Ext.define('amdaUI.ParamArgumentsUI', {
66 66 paramRequestObject.set('dim2-index', 0);
67 67 }
68 68 }
69   - paramRequestObject.set('is-init', true);
70 69 }
  70 + paramRequestObject.set('is-init', true);
71 71 }
72 72 me.rebuildAll(paramInfo, uiScope);
73 73 }
... ... @@ -153,6 +153,7 @@ Ext.define('amdaUI.ParamArgumentsUI', {
153 153 },
154 154  
155 155 rebuildAll: function(paramInfoResult , uiScope) {
  156 + this.inRebuild = true;
156 157 //Rebuild arguments selection
157 158 this.rebuildArguments(paramInfoResult, uiScope);
158 159 //Add default template args values
... ... @@ -199,6 +200,7 @@ Ext.define('amdaUI.ParamArgumentsUI', {
199 200 }
200 201 else
201 202 item.setValue(this.paramRequestObject.get(item.argId));
  203 + this.inRebuild = false;
202 204 }, this);
203 205 },
204 206  
... ... @@ -310,26 +312,10 @@ Ext.define('amdaUI.ParamArgumentsUI', {
310 312 hidden: (relatedTable ? relatedTable.variable : false),
311 313 listeners: {
312 314 change: function(field, newValue, oldValue, eOpts) {
313   - if (this.paramRequestObject.get('type') == '2' && this.isFirstMsg)
314   - {
315   - if (relatedDim == 'dim2' && newValue == '*') {
316   - var previousCombo = field.previousSibling();
317   -
318   - if (previousCombo instanceof Ext.form.FieldSet)
319   - previousCombo = previousCombo.previousSibling();
320   -
321   - if (previousCombo instanceof Ext.form.ComboBox && previousCombo.argId == 'dim1' && previousCombo.getValue() == '*' && !previousCombo.isDisabled()) {
322   - myDesktopApp.warningMsg('If argument <i>All</i> is set for both dimensions output will be the total sum <b>(not spectra!)</b>');
323   - this.isFirstMsg = false;
324   - }
325   -
326   - }
327   - }
328   -
329   - this.paramRequestObject.set(relatedDim+'-index', newValue);
330   - if (this.onChange != null)
331   - this.onChange(uiScope, relatedDim, newValue, oldValue, false);
332   - },
  315 + this.paramRequestObject.set(relatedDim+'-index', newValue);
  316 + if (!this.inRebuild && (this.onChange != null))
  317 + this.onChange(uiScope, relatedDim, newValue, oldValue, false);
  318 + },
333 319 scope: this
334 320 }
335 321  
... ... @@ -363,7 +349,7 @@ Ext.define(&#39;amdaUI.ParamArgumentsUI&#39;, {
363 349 field.up().down('[name=value_max_'+relatedDim+']').setVisible(newValue == 1);
364 350 field.up().down('[name=index_min_'+relatedDim+']').setVisible(newValue == 2);
365 351 field.up().down('[name=index_max_'+relatedDim+']').setVisible(newValue == 2);
366   - if (this.onChange != null)
  352 + if (!this.inRebuild && (this.onChange != null))
367 353 this.onChange(uiScope, relatedDim, newValue, oldValue, false);
368 354 },
369 355 scope: this
... ... @@ -378,7 +364,7 @@ Ext.define(&#39;amdaUI.ParamArgumentsUI&#39;, {
378 364 listeners: {
379 365 change: function(field, newValue, oldValue, eOpts) {
380 366 this.paramRequestObject.set(relatedDim+'-min-value', newValue);
381   - if (this.onChange != null)
  367 + if (!this.inRebuild && (this.onChange != null))
382 368 this.onChange(uiScope, relatedDim, newValue, oldValue, false);
383 369 },
384 370 scope: this
... ... @@ -393,7 +379,7 @@ Ext.define(&#39;amdaUI.ParamArgumentsUI&#39;, {
393 379 listeners: {
394 380 change: function(field, newValue, oldValue, eOpts) {
395 381 this.paramRequestObject.set(relatedDim+'-max-value', newValue);
396   - if (this.onChange != null)
  382 + if (!this.inRebuild && (this.onChange != null))
397 383 this.onChange(uiScope, relatedDim, newValue, oldValue, false);
398 384 },
399 385 scope: this
... ... @@ -410,7 +396,7 @@ Ext.define(&#39;amdaUI.ParamArgumentsUI&#39;, {
410 396 listeners: {
411 397 change: function(field, newValue, oldValue, eOpts) {
412 398 this.paramRequestObject.set(relatedDim+'-min-index', newValue);
413   - if (this.onChange != null)
  399 + if (!this.inRebuild && (this.onChange != null))
414 400 this.onChange(uiScope, relatedDim, newValue, oldValue, false);
415 401 },
416 402 scope: this
... ... @@ -427,7 +413,7 @@ Ext.define(&#39;amdaUI.ParamArgumentsUI&#39;, {
427 413 listeners: {
428 414 change: function(field, newValue, oldValue, eOpts) {
429 415 this.paramRequestObject.set(relatedDim+'-max-index', newValue);
430   - if (this.onChange != null)
  416 + if (!this.inRebuild && (this.onChange != null))
431 417 this.onChange(uiScope, relatedDim, newValue, oldValue, false);
432 418 },
433 419 scope: this
... ... @@ -454,7 +440,7 @@ Ext.define(&#39;amdaUI.ParamArgumentsUI&#39;, {
454 440 }
455 441 fieldset.down('[name=sum_type_'+relatedDim+']').setValue(this.paramRequestObject.get(relatedDim+'-sum-type'));
456 442 indexesCombo.setDisabled(true);
457   - if (this.onChange != null)
  443 + if (!this.inRebuild && (this.onChange != null))
458 444 this.onChange(uiScope, relatedDim, true, false, false);
459 445 if (this.onModifyHeight)
460 446 this.onModifyHeight(this.pluginOwner);
... ... @@ -462,7 +448,7 @@ Ext.define(&#39;amdaUI.ParamArgumentsUI&#39;, {
462 448 collapse: function(fieldset, eOpts) {
463 449 indexesCombo.setDisabled(false);
464 450 this.paramRequestObject.set(relatedDim+'-sum-type', 0);
465   - if (this.onChange != null)
  451 + if (!this.inRebuild && (this.onChange != null))
466 452 this.onChange(uiScope, relatedDim, false, true, false);
467 453 if (this.onModifyHeight)
468 454 this.onModifyHeight(this.pluginOwner);
... ... @@ -493,7 +479,7 @@ Ext.define(&#39;amdaUI.ParamArgumentsUI&#39;, {
493 479 template_args = {};
494 480 template_args[key] = newValue;
495 481 me.paramRequestObject.set('template_args', template_args);
496   - if (me.onChange != null)
  482 + if (!this.inRebuild && (me.onChange != null))
497 483 me.onChange(uiScope, key, newValue, oldValue, true);
498 484 },
499 485 scope: me
... ... @@ -529,7 +515,7 @@ Ext.define(&#39;amdaUI.ParamArgumentsUI&#39;, {
529 515 template_args = {};
530 516 template_args[key] = newValue;
531 517 me.paramRequestObject.set('template_args', template_args);
532   - if (me.onChange != null)
  518 + if (!this.inRebuild && (me.onChange != null))
533 519 me.onChange(uiScope, key, newValue, oldValue, true);
534 520 },
535 521 scope: me
... ... @@ -551,7 +537,7 @@ Ext.define(&#39;amdaUI.ParamArgumentsUI&#39;, {
551 537 template_args = {};
552 538 template_args[key] = newValue;
553 539 me.paramRequestObject.set('template_args', template_args);
554   - if (me.onChange != null)
  540 + if (!this.inRebuild && (me.onChange != null))
555 541 me.onChange(uiScope, key, newValue, oldValue, true);
556 542 },
557 543 scope: me
... ...
js/app/views/PlotComponents/PlotParamForm.js
... ... @@ -27,6 +27,8 @@ Ext.define(&#39;amdaPlotComp.PlotParamForm&#39;, {
27 27 drawingOptionsFormsManager : new Ext.AbstractManager(),
28 28  
29 29 paramArgs : null,
  30 +
  31 + isFirstMsg: true,
30 32  
31 33 destroy: function() {
32 34 this.drawingOptionsFormsManager.each(function (key, value, length) {
... ... @@ -108,6 +110,11 @@ Ext.define(&#39;amdaPlotComp.PlotParamForm&#39;, {
108 110 },
109 111  
110 112 onChangeParamArgs: function(uiScope, args_key, newValue, oldValue, isTemplateArg) {
  113 + if ((uiScope.isFirstMsg) && (uiScope.object.get('type') == 2) && (uiScope.object.get('dim1-sum-type') == 0) && (uiScope.object.get('dim2-sum-type') == 0) &&
  114 + (uiScope.object.get('dim1-index') == '*') && (uiScope.object.get('dim2-index') == '*')) {
  115 + uiScope.isFirstMsg = false;
  116 + myDesktopApp.warningMsg('If argument <i>All</i> is set for both dimensions output will be the total sum <b>(not spectra!)</b>');
  117 + }
111 118 uiScope.crtTree.refresh();
112 119 },
113 120  
... ...