Commit b74e48d42b60c37a0370012b9640872533d30060

Authored by Benjamin Renard
1 parent 444a796a

Add Extend/Shift for plot

js/app/views/PlotComponents/PlotExtendShiftPlug.js 0 → 100644
... ... @@ -0,0 +1,192 @@
  1 +/**
  2 + * Project  : AMDA-NG
  3 + * Name : PlotExtendShiftPlug.js
  4 + * @plugin amdaPlotComp.PlotZoomPlug
  5 + * @extends Ext.util.Observable
  6 + * @ptype plotExtendShiftPlugin
  7 + * @brief Plot Extend/Shift UI (View)
  8 + * @author Benjamin
  9 + * @version $Id: PlotExtendShiftPlug.js
  10 + ********************************************************************************
  11 + * FT Id : Date : Name - Description
  12 + *******************************************************************************
  13 + * :
  14 + */
  15 +
  16 +
  17 +Ext.define('amdaPlotComp.PlotExtendShiftPlug', {
  18 + extend: 'Ext.util.Observable',
  19 + alias: 'plugin.plotExtendShiftPlugin',
  20 +
  21 + win : null,
  22 + form : null,
  23 + tabId : '',
  24 +
  25 + constructor: function(config) {
  26 + Ext.apply(this, config);
  27 + this.callParent(arguments);
  28 + },
  29 +
  30 + onDestroy : function() {
  31 + this.win = null;
  32 + },
  33 +
  34 + init: function(cmp) {
  35 + this.hostCmp = cmp;
  36 + },
  37 +
  38 +/**
  39 + * creation of the window
  40 + */
  41 + show : function(tabId) {
  42 + if (!this.win)
  43 + {
  44 + this.win = new Ext.Window({
  45 + id: 'plot-extendshift-win-' + this.hostCmp.ownerCt.getId(), // Plot window ID
  46 + width: 230,
  47 + height: 120,
  48 + x: 0, y: 0,
  49 + baseCls:'x-panel',
  50 + title: 'Extend / Shift',
  51 + layout: 'fit',
  52 + constrain: true,
  53 + collapsible: true,
  54 + resizable: false,
  55 + ghost: false,
  56 + renderTo: this.hostCmp.ownerCt.body,
  57 + items: this.getFormConfig(),
  58 + listeners: {
  59 + scope: this,
  60 + beforeclose: function() {
  61 + this.hostCmp.panelImage.stopZoom();
  62 + Ext.PluginManager.unregister(this);
  63 + }
  64 + },
  65 + getConstrainVector: function(constrainTo){
  66 + var me = this;
  67 + if (me.constrain || me.constrainHeader) {
  68 + constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent();
  69 + return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo);
  70 + }
  71 + }
  72 + });
  73 +
  74 + this.win.on('destroy', this.onDestroy, this);
  75 +
  76 + Ext.PluginManager.register(this);
  77 + }
  78 +
  79 + this.tabId = tabId;
  80 + this.win.show();
  81 + this.win.setPosition(0,0);
  82 + },
  83 +
  84 + close : function() {
  85 + if (this.win == null)
  86 + return;
  87 + this.win.close();
  88 + },
  89 +
  90 + toSec: function(value, unit) {
  91 + if (value == "")
  92 + return 0;
  93 +
  94 + switch (unit) {
  95 + case "sec":
  96 + return value;
  97 + case "min":
  98 + return value * 60;
  99 + case "hour":
  100 + return value * 3600;
  101 + case "day":
  102 + return value * 86400;
  103 + default:
  104 + return 0;
  105 + }
  106 + },
  107 +
  108 + executeAction : function(actionType) {
  109 + var durationField = this.form.getForm().findField('duration');
  110 + var durationUnitField = this.form.getForm().findField('durationUnit');
  111 + var duration = this.toSec(durationField.getValue(), durationUnitField.getValue());
  112 + if (duration) {
  113 + this.hostCmp.callInteractivePlot({'action' : actionType, 'tabId' : this.tabId, 'duration' : duration});
  114 + }
  115 + else
  116 + myDesktopApp.errorMsg('No duration defined');
  117 + },
  118 +
  119 +/**
  120 + * Main form
  121 + */
  122 + getFormConfig: function(){
  123 + this.form = new Ext.form.FormPanel( {
  124 + frame: true,
  125 + width: 230,
  126 + height: 120,
  127 + layout: {
  128 + type: 'vbox',
  129 + pack: 'start',
  130 + align: 'stretch'
  131 + },
  132 + fieldDefaults: {
  133 + labelWidth: 60
  134 + },
  135 + items: [
  136 + {
  137 + xtype: 'fieldcontainer',
  138 + layout: 'hbox',
  139 + fieldLabel: 'Duration to apply to the interval',
  140 + labelAlign: 'top',
  141 + bodyStyle: {background : '#dfe8f6'},
  142 + border: false,
  143 + items: [
  144 + {
  145 + xtype: 'numberfield',
  146 + hideTrigger: true,
  147 + name: 'duration',
  148 + // minValue: 0,
  149 + width: 150
  150 + },
  151 + {
  152 + xtype: 'splitter',
  153 + width: 5
  154 + },
  155 + {
  156 + xtype:'combo',
  157 + name: 'durationUnit',
  158 + store:[
  159 + 'sec',
  160 + 'min',
  161 + 'hour',
  162 + 'day'
  163 + ],
  164 + editable: false,
  165 + width: 60,
  166 + value: 'sec',
  167 + triggerAction: 'all'
  168 + }
  169 + ]
  170 + }
  171 + ],
  172 + buttons: [
  173 + {
  174 + text: 'Extend/Shrink',
  175 + scope : this,
  176 + handler: function(bt,event) {
  177 + this.executeAction('extend');
  178 + }
  179 + },
  180 + '->',
  181 + {
  182 + text: 'Shift',
  183 + scope : this,
  184 + handler: function(bt,event) {
  185 + this.executeAction('shift');
  186 + }
  187 + }
  188 + ]
  189 + });
  190 + return this.form;
  191 + }
  192 +});
0 193 \ No newline at end of file
... ...
js/app/views/PlotTabResultUI.js
... ... @@ -19,6 +19,7 @@ Ext.define('amdaUI.PlotTabResultUI', {
19 19  
20 20 requires: [
21 21 'amdaPlotComp.PlotZoomPlug',
  22 + 'amdaPlotComp.PlotExtendShiftPlug',
22 23 'amdaPlotComp.PlotContextManager'
23 24 ],
24 25  
... ... @@ -281,7 +282,13 @@ Ext.define('amdaUI.PlotTabResultUI', {
281 282 me.contextualMenu.add('-');
282 283  
283 284 me.contextualMenu.add({
284   - text:'Extend/Shift Time request'
  285 + text:'Extend/Shift Time request',
  286 + handler : function ()
  287 + {
  288 + var extendShiftPlugin = this.getPlugin('plot-extendshift-plugin-id');
  289 + extendShiftPlugin.show(me.tabId);
  290 + },
  291 + scope: me
285 292 });
286 293  
287 294 me.contextualMenu.showAt(absoluteX, absoluteY);
... ... @@ -514,10 +521,16 @@ Ext.define('amdaUI.PlotTabResultUI', {
514 521 this.createPlotImage(configResult.folder, configResult.plotFile)
515 522 ],
516 523 dockedItems: [navToolBar, mouseToolbar],
517   - plugins: [ {
518   - ptype: 'plotZoomPlugin',
519   - pluginId : 'plot-zoom-plugin-id'
520   - }]
  524 + plugins: [
  525 + {
  526 + ptype: 'plotZoomPlugin',
  527 + pluginId : 'plot-zoom-plugin-id'
  528 + },
  529 + {
  530 + ptype: 'plotExtendShiftPlugin',
  531 + pluginId : 'plot-extendshift-plugin-id'
  532 + }
  533 + ]
521 534 };
522 535  
523 536 Ext.apply(this , plotResultTabPanelConfig);
... ...