diff --git a/js/app/controllers/PlotModule.js b/js/app/controllers/PlotModule.js index 723fd6e..429bf64 100644 --- a/js/app/controllers/PlotModule.js +++ b/js/app/controllers/PlotModule.js @@ -61,7 +61,7 @@ Ext.define('amdaDesktop.PlotModule', { return size; }, - startInteractiveSession : function(session) { + updateInteractiveSession : function(session) { var me = this; Ext.each(session.result, function (tabResult, index) { var winResultId = tabResult.id+"-win"; @@ -120,14 +120,9 @@ Ext.define('amdaDesktop.PlotModule', { var me = this; this.plotResultWindowsManager.each(function (key, value, length) { value.close(); - me.plotResultWindowsManager.unregister(value); }); }, - updateInteractiveSession : function(interactiveResult) { - - }, - getWindowResult: function(winResultId){ if (!this.plotResultWindowsManager.get(winResultId)) return null; return this.plotResultWindowsManager.get(winResultId); diff --git a/js/app/models/ExecutableNode.js b/js/app/models/ExecutableNode.js index 9cac40f..c746583 100644 --- a/js/app/models/ExecutableNode.js +++ b/js/app/models/ExecutableNode.js @@ -80,7 +80,7 @@ Ext.define('amdaModel.ExecutableNode', { if (isInteractivePlot) { myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) { - module.startInteractiveSession(res); + module.updateInteractiveSession(res); }); } else diff --git a/js/app/models/PlotObjects/PlotAxisObject.js b/js/app/models/PlotObjects/PlotAxisObject.js index 0b3abd0..39d14c1 100644 --- a/js/app/models/PlotObjects/PlotAxisObject.js +++ b/js/app/models/PlotObjects/PlotAxisObject.js @@ -61,6 +61,22 @@ Ext.define('amdaPlotObj.PlotAxisObject', { } ], + constructor: function(){ + var me = this; + me.callParent(arguments); + if ((arguments.length > 0) && arguments[0]) + { + + } + else + { + //new object, set default fields values + me.setDefaultValues(); + } + + this.dirty = false; + }, + setDefaultValues: function(type) { this.set('axis-type', type); @@ -90,6 +106,11 @@ Ext.define('amdaPlotObj.PlotAxisObject', { this.set('axis-color-maxval', 'none'); }, + isDirty : function() + { + return this.dirty; + }, + getJsonValues : function() { var axisValues = new Object(); diff --git a/js/app/models/PlotObjects/PlotConstantObject.js b/js/app/models/PlotObjects/PlotConstantObject.js index f087028..17d8ad1 100644 --- a/js/app/models/PlotObjects/PlotConstantObject.js +++ b/js/app/models/PlotObjects/PlotConstantObject.js @@ -41,6 +41,20 @@ Ext.define('amdaPlotObj.PlotConstantObject', { {name: 'constant-line-color', type: 'string'} ], + constructor: function(){ + var me = this; + me.callParent(arguments); + if ((arguments.length > 0) && arguments[0]) + { + } + else + { + //new object, set default fields values + me.setDefaultValues(); + } + this.dirty = false; + }, + setDefaultValues: function() { this.set('constant-axis-id', amdaPlotObj.PlotObjectConfig.defaultValues.constants.axisId); diff --git a/js/app/models/PlotObjects/PlotCurveObject.js b/js/app/models/PlotObjects/PlotCurveObject.js index d8804dc..07bb0d2 100644 --- a/js/app/models/PlotObjects/PlotCurveObject.js +++ b/js/app/models/PlotObjects/PlotCurveObject.js @@ -51,6 +51,7 @@ Ext.define('amdaPlotObj.PlotCurveObject', { //new object, set default fields values me.setDefaultValues(); } + this.dirty = false; }, getCurvesDefStore: function(onCurvesDefGet) @@ -116,6 +117,20 @@ Ext.define('amdaPlotObj.PlotCurveObject', { this.set('curve-line-color', amdaPlotObj.PlotObjectConfig.defaultValues.curves.line.color); }, + isDirty : function() + { + if (this.dirty) + return true; + + var d = false; + this.params().each(function (param, index) { + if (param.dirty) + d = true; + }); + + return d; + }, + getJsonValues : function() { var curveValues = new Object(); diff --git a/js/app/models/PlotObjects/PlotFillObject.js b/js/app/models/PlotObjects/PlotFillObject.js index 0681823..802f1d7 100644 --- a/js/app/models/PlotObjects/PlotFillObject.js +++ b/js/app/models/PlotObjects/PlotFillObject.js @@ -31,6 +31,20 @@ Ext.define('amdaPlotObj.PlotFillObject', { {name: 'fill-less-color', type: 'string'} ], + constructor: function(){ + var me = this; + me.callParent(arguments); + if ((arguments.length > 0) && arguments[0]) + { + } + else + { + //new object, set default fields values + me.setDefaultValues(); + } + this.dirty = false; + }, + setDefaultValues: function() { this.set('fill-type', amdaPlotObj.PlotObjectConfig.defaultValues.fills.type); diff --git a/js/app/models/PlotObjects/PlotInstantSerieObject.js b/js/app/models/PlotObjects/PlotInstantSerieObject.js index d3aa9ea..4fca875 100644 --- a/js/app/models/PlotObjects/PlotInstantSerieObject.js +++ b/js/app/models/PlotObjects/PlotInstantSerieObject.js @@ -32,6 +32,20 @@ Ext.define('amdaPlotObj.PlotInstantSerieObject', { {name: 'iserie-symbols-color', type: 'string'} ], + constructor: function(){ + var me = this; + me.callParent(arguments); + if ((arguments.length > 0) && arguments[0]) + { + } + else + { + //new object, set default fields values + me.setDefaultValues(); + } + this.dirty = false; + }, + setDefaultValues: function() { this.set('iserie-tableonx', false); diff --git a/js/app/models/PlotObjects/PlotInstantSpectroObject.js b/js/app/models/PlotObjects/PlotInstantSpectroObject.js index c1cd615..6389402 100644 --- a/js/app/models/PlotObjects/PlotInstantSpectroObject.js +++ b/js/app/models/PlotObjects/PlotInstantSpectroObject.js @@ -24,6 +24,20 @@ Ext.define('amdaPlotObj.PlotInstantSpectroObject', { {name: 'ispectro-dimonxaxis', type: 'int'} ], + constructor: function(){ + var me = this; + me.callParent(arguments); + if ((arguments.length > 0) && arguments[0]) + { + } + else + { + //new object, set default fields values + me.setDefaultValues(); + } + this.dirty = false; + }, + setDefaultValues: function() { this.set('ispectro-dimonxaxis', 0); diff --git a/js/app/models/PlotObjects/PlotLayoutAutoObject.js b/js/app/models/PlotObjects/PlotLayoutAutoObject.js index f0c30e4..709231a 100644 --- a/js/app/models/PlotObjects/PlotLayoutAutoObject.js +++ b/js/app/models/PlotObjects/PlotLayoutAutoObject.js @@ -21,18 +21,11 @@ Ext.define('amdaPlotObj.PlotLayoutAutoObject', { ], fields : [ - {name: 'layout-panel-height', type: 'float'}, - {name: 'layout-panel-spacing', type: 'float'}, - {name: 'layout-expand', type: 'boolean'} + {name: 'layout-panel-height', type: 'float', defaultValue: amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.panelHeight}, + {name: 'layout-panel-spacing', type: 'float', defaultValue: amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.panelSpacing}, + {name: 'layout-expand', type: 'boolean', defaultValue: amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.expand} ], - setDefaultValues: function() - { - this.set('layout-panel-height', amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.panelHeight); - this.set('layout-panel-spacing', amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.panelSpacing); - this.set('layout-expand', amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.expand); - }, - getJsonValues : function() { var layoutValues = new Object(); diff --git a/js/app/models/PlotObjects/PlotLayoutManualObject.js b/js/app/models/PlotObjects/PlotLayoutManualObject.js index ac3ceaf..7ee1b94 100644 --- a/js/app/models/PlotObjects/PlotLayoutManualObject.js +++ b/js/app/models/PlotObjects/PlotLayoutManualObject.js @@ -27,14 +27,6 @@ Ext.define('amdaPlotObj.PlotLayoutManualObject', { {name: 'layout-xyplot-margin-right', type: 'float', useNull:true} ], - setDefaultValues: function() - { - this.set('layout-timeplot-margin-left', null); - this.set('layout-timeplot-margin-right', null); - this.set('layout-xyplot-margin-left', null); - this.set('layout-xyplot-margin-right', null); - }, - getJsonValues : function() { var layoutValues = new Object(); diff --git a/js/app/models/PlotObjects/PlotLayoutVerticalObject.js b/js/app/models/PlotObjects/PlotLayoutVerticalObject.js index c4f5cf8..3f36e65 100644 --- a/js/app/models/PlotObjects/PlotLayoutVerticalObject.js +++ b/js/app/models/PlotObjects/PlotLayoutVerticalObject.js @@ -21,26 +21,15 @@ Ext.define('amdaPlotObj.PlotLayoutVerticalObject', { ], fields : [ - {name: 'layout-panel-height', type: 'float'}, - {name: 'layout-panel-spacing', type: 'float'}, - {name: 'layout-expand', type: 'boolean'}, + {name: 'layout-panel-height', type: 'float', defaultValue: amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.panelHeight}, + {name: 'layout-panel-spacing', type: 'float', defaultValue: amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.panelSpacing}, + {name: 'layout-expand', type: 'boolean', defaultValue: amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.expand}, //{name: 'layout-timeplot-width', type: 'float', useNull:true}, {name: 'layout-timeplot-height', type: 'float', useNull:true}, {name: 'layout-xyplot-width', type: 'float', useNull:true}, {name: 'layout-xyplot-height', type: 'float', useNull:true} ], - setDefaultValues: function() - { - this.set('layout-panel-height', amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.panelHeight); - this.set('layout-panel-spacing', amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.panelSpacing); - this.set('layout-expand', amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.expand); - //this.set('layout-timeplot-width', null); - this.set('layout-timeplot-height', null); - this.set('layout-xyplot-width', null); - this.set('layout-xyplot-height', null); - }, - getJsonValues : function() { var layoutValues = new Object(); diff --git a/js/app/models/PlotObjects/PlotLegendSeriesObject.js b/js/app/models/PlotObjects/PlotLegendSeriesObject.js index cdce36a..31d6f36 100644 --- a/js/app/models/PlotObjects/PlotLegendSeriesObject.js +++ b/js/app/models/PlotObjects/PlotLegendSeriesObject.js @@ -21,25 +21,25 @@ Ext.define('amdaPlotObj.PlotLegendSeriesObject', { ], fields : [ - {name: 'legend-series-activated', type: 'boolean'}, - {name: 'legend-series-type', type: 'string'}, - {name: 'legend-series-position', type: 'string'}, - {name: 'legend-series-showparaminfo', type: 'boolean'}, - {name: 'legend-series-defaulttextcolor', type: 'string'}, - {name: 'legend-series-border-activated', type: 'boolean'}, - {name: 'legend-series-border-color', type: 'string'}, - {name: 'legend-series-intervalinfo-activated', type: 'boolean'}, - {name: 'legend-series-intervalinfo-type', type: 'string'}, - {name: 'legend-series-font-activated', type: 'boolean'}, - {name: 'legend-series-font-name', type: 'string'}, - {name: 'legend-series-font-size', type: 'int'}, - {name: 'legend-series-font-bold', type: 'boolean'}, - {name: 'legend-series-font-italic', type: 'boolean'} + {name: 'legend-series-activated', type: 'boolean', defaultValue: false}, + {name: 'legend-series-type', type: 'string', defaultValue: amdaPlotObj.PlotObjectConfig.defaultValues.legends.series.type}, + {name: 'legend-series-position', type: 'string', defaultValue: amdaPlotObj.PlotObjectConfig.defaultValues.legends.series.position}, + {name: 'legend-series-showparaminfo', type: 'boolean', defaultValue: true}, + {name: 'legend-series-defaulttextcolor', type: 'string', defaultValue: amdaPlotObj.PlotObjectConfig.defaultValues.legends.series.text.color}, + {name: 'legend-series-border-activated', type: 'boolean', defaultValue: false}, + {name: 'legend-series-border-color', type: 'string', defaultValue: amdaPlotObj.PlotObjectConfig.defaultValues.legends.series.border.color}, + {name: 'legend-series-intervalinfo-activated', type: 'boolean', defaultValue: false}, + {name: 'legend-series-intervalinfo-type', type: 'string', defaultValue: amdaPlotObj.PlotObjectConfig.defaultValues.legends.series.intervalinfo.type}, + {name: 'legend-series-font-activated', type: 'boolean', defaultValue: false}, + {name: 'legend-series-font-name', type: 'string', defaultValue: amdaPlotObj.PlotObjectConfig.defaultValues.legends.series.font.name}, + {name: 'legend-series-font-size', type: 'int', defaultValue: amdaPlotObj.PlotObjectConfig.defaultValues.legends.series.font.size}, + {name: 'legend-series-font-bold', type: 'boolean', defaultValue: false}, + {name: 'legend-series-font-italic', type: 'boolean', defaultValue: false} ], setDefaultValues: function() { - this.set('legend-series-activated', false); + /*this.set('legend-series-activated', false); this.set('legend-series-type', amdaPlotObj.PlotObjectConfig.defaultValues.legends.series.type); this.set('legend-series-position', amdaPlotObj.PlotObjectConfig.defaultValues.legends.series.position); this.set('legend-series-showparaminfo', true); @@ -52,7 +52,7 @@ Ext.define('amdaPlotObj.PlotLegendSeriesObject', { this.set('legend-series-font-name', amdaPlotObj.PlotObjectConfig.defaultValues.legends.series.font.name); this.set('legend-series-font-size', amdaPlotObj.PlotObjectConfig.defaultValues.legends.series.font.size); this.set('legend-series-font-bold', false); - this.set('legend-series-font-italic', false); + this.set('legend-series-font-italic', false);*/ }, getShortInfo : function() diff --git a/js/app/models/PlotObjects/PlotLegendTextObject.js b/js/app/models/PlotObjects/PlotLegendTextObject.js index be61ba9..f4724f2 100644 --- a/js/app/models/PlotObjects/PlotLegendTextObject.js +++ b/js/app/models/PlotObjects/PlotLegendTextObject.js @@ -33,6 +33,20 @@ Ext.define('amdaPlotObj.PlotLegendTextObject', { {name: 'legend-text-font-italic', type: 'boolean'} ], + constructor: function(){ + var me = this; + me.callParent(arguments); + if ((arguments.length > 0) && arguments[0]) + { + } + else + { + //new object, set default fields values + me.setDefaultValues(); + } + this.dirty = false; + }, + setDefaultValues: function() { this.set('legend-text-value', ''); diff --git a/js/app/models/PlotObjects/PlotPanelObject.js b/js/app/models/PlotObjects/PlotPanelObject.js index 7e61d79..5662cc5 100644 --- a/js/app/models/PlotObjects/PlotPanelObject.js +++ b/js/app/models/PlotObjects/PlotPanelObject.js @@ -140,8 +140,8 @@ Ext.define('amdaPlotObj.PlotPanelObject', { me.loadAxes(arguments[0].axes); if (arguments[0].params) me.loadParams(arguments[0].params); - if (arguments[0].textLegends) - me.loadTextLegends(arguments[0].textLegends); + if (arguments[0]['text-legends']) + me.loadTextLegends(arguments[0]['text-legends']); if (arguments[0].constants) me.loadConstants(arguments[0].constants); if (arguments[0].textObjs) @@ -150,12 +150,15 @@ Ext.define('amdaPlotObj.PlotPanelObject', { me.loadCurves(arguments[0].curves); if (arguments[0].fills) me.loadFills(arguments[0].fills); + if (arguments[0]['panel-series-legend']) + me.loadSeriesLegend(arguments[0]['panel-series-legend']); } else { //new object, set default fields values me.setDefaultValues(); } + this.dirty = false; }, loadAxes: function(axes) @@ -193,6 +196,12 @@ Ext.define('amdaPlotObj.PlotPanelObject', { this.fills().loadData(fills); }, + loadSeriesLegend: function(seriesLegend) + { + this.set('panel-legend-series', new amdaPlotObj.PlotLegendSeriesObject(seriesLegend)); + this.get('panel-legend-series').dirty = false; + }, + initAxes : function() { this.axes().removeAll(); @@ -264,7 +273,8 @@ Ext.define('amdaPlotObj.PlotPanelObject', { this.set('last-param-id', this.get('last-param-id') + 1); var recs = this.params().add({id : this.get('last-param-id')}); var availableDrawingObjects = recs[0].getAvailableDrawingObjectByPlotType(this.get('panel-plot-type')); - recs[0].updateDrawingType(availableDrawingObjects[0].key, true); + recs[0].changeDrawingType(availableDrawingObjects[0].key); + this.dirty = true; return recs[0]; }, @@ -274,6 +284,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { if (paramRecord == null) return false; this.params().remove(paramRecord); + this.dirty = true; return true; }, @@ -281,6 +292,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { this.set('last-textlegend-id', this.get('last-textlegend-id') + 1); var recs = this.textLegends().add({id : this.get('last-textlegend-id')}); recs[0].setDefaultValues(); + this.dirty = true; return recs[0]; }, @@ -290,6 +302,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { if (textLegendRecord == null) return false; this.textLegends().remove(textLegendRecord); + this.dirty = true; return true; }, @@ -297,6 +310,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { this.set('last-constant-id', this.get('last-constant-id') + 1); var recs = this.constants().add({id : this.get('last-constant-id')}); recs[0].setDefaultValues(); + this.dirty = true; return recs[0]; }, @@ -306,6 +320,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { if (constantRecord == null) return false; this.constants().remove(constantRecord); + this.dirty = true; return true; }, @@ -313,6 +328,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { this.set('last-textobj-id', this.get('last-textobj-id') + 1); var recs = this.textObjs().add({id : this.get('last-textobj-id')}); recs[0].setDefaultValues(); + this.dirty = true; return recs[0]; }, @@ -322,6 +338,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { if (textObjRecord == null) return false; this.textObjs().remove(textObjRecord); + this.dirty = true; return true; }, @@ -329,6 +346,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { this.set('last-curve-id', this.get('last-curve-id') + 1); var recs = this.curves().add({id : this.get('last-curve-id')}); recs[0].setDefaultValues(); + this.dirty = true; return recs[0]; }, @@ -338,6 +356,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { if (curveRecord == null) return false; this.curves().remove(curveRecord); + this.dirty = true; return true; }, @@ -345,6 +364,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { this.set('last-fill-id', this.get('last-fill-id') + 1); var recs = this.fills().add({id : this.get('last-fill-id')}); recs[0].setDefaultValues(); + this.dirty = true; return recs[0]; }, @@ -354,13 +374,12 @@ Ext.define('amdaPlotObj.PlotPanelObject', { if (fillRecord == null) return false; this.fills().remove(fillRecord); + this.dirty = true; return true; }, - updatePlotType: function(plotType, forceUpdate) { - forceUpdate = (typeof forceUpdate !== 'undefined') ? forceUpdate : false; - - if (!forceUpdate && (plotType == this.get('panel-plot-type'))) + changePlotType: function(plotType) { + if (plotType == this.get('panel-plot-type')) return; this.set('panel-plot-type', plotType); @@ -375,7 +394,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { }); if (!compatibleDrawingType) { - param.updateDrawingType(availableDrawingObjects[0].key, forceUpdate); + param.changeDrawingType(availableDrawingObjects[0].key); } }); this.initAxes(); @@ -385,7 +404,6 @@ Ext.define('amdaPlotObj.PlotPanelObject', { if (this.get('panel-legend-series') == null) { this.set('panel-legend-series', new amdaPlotObj.PlotLegendSeriesObject()); - this.get('panel-legend-series').setDefaultValues(); } } else @@ -445,7 +463,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { this.set('panel-epoch-centertimeid', ""); - this.updatePlotType(amdaPlotObj.PlotObjectConfig.defaultValues.panel.plotType); + this.changePlotType(amdaPlotObj.PlotObjectConfig.defaultValues.panel.plotType); }, getPanelShortInfo : function() @@ -468,6 +486,68 @@ Ext.define('amdaPlotObj.PlotPanelObject', { return info; }, + isDirty : function() + { + if (this.dirty) + return true; + var d = false; + + this.axes().each(function (axe, index) { + if (axe.isDirty()) + d = true; + }); + if (d) + return d; + + this.params().each(function (param, index) { + if (param.isDirty()) + d = true; + }); + if (d) + return d; + + this.textLegends().each(function (text, index) { + if (text.dirty) + d = true; + }); + if (d) + return d; + + this.constants().each(function (constant, index) { + if (constant.dirty) + d = true; + }); + if (d) + return d; + + this.textObjs().each(function (textObj, index) { + if (textObj.dirty) + d = true; + }); + if (d) + return d; + + this.curves().each(function (curve, index) { + if (curve.isDirty()) + d = true; + }); + if (d) + return d; + + this.fills().each(function (fill, index) { + if (fill.dirty) + d = true; + }); + if (d) + return d; + + if (this.get('panel-legend-series') != null) + if (this.get('panel-legend-series').dirty) + return true; + + return false; + }, + getJsonValues : function() { var panelValues = new Object(); @@ -522,7 +602,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { if (this.get('panel-plot-type') == 'instantPlot') panelValues['panel-instant-time'] = this.get('panel-instant-time'); - if ((this.get('panel-legend-series') != null) && this.get('panel-legend-series').get('legend-series-activated')) + if (this.get('panel-legend-series') != null) panelValues['panel-series-legend'] = this.get('panel-legend-series').getJsonValues(); panelValues['text-legends'] = []; diff --git a/js/app/models/PlotObjects/PlotParamObject.js b/js/app/models/PlotObjects/PlotParamObject.js index 459bd08..aa4994a 100644 --- a/js/app/models/PlotObjects/PlotParamObject.js +++ b/js/app/models/PlotObjects/PlotParamObject.js @@ -45,12 +45,12 @@ Ext.define('amdaPlotObj.PlotParamObject', { constructor: function(){ var me = this; me.callParent(arguments); - me.updateDrawingType(this.get('param-drawing-type'), true); if ((arguments.length > 0) && arguments[0]) { if (arguments[0]['param-drawing-object']) me.loadDrawingObject(arguments[0]['param-drawing-object']); } + this.dirty = false; }, loadDrawingObject: function(drawing) @@ -58,44 +58,40 @@ Ext.define('amdaPlotObj.PlotParamObject', { var drawingObject = this.get('param-drawing-object'); if (drawingObject == null) return; - Ext.Object.each(drawing, function(key,value) { - drawingObject.set(key,value); - }); + this.set('param-drawing-object', this.createDrawingObjectByType(this.get('param-drawing-type'), drawing)); + drawingObject.dirty = false; }, - updateDrawingType: function(type, forceUpdate) + createDrawingObjectByType : function(type, data) { - forceUpdate = (typeof forceUpdate !== 'undefined') ? forceUpdate : false; - - if (!forceUpdate && (type == this.get('param-drawing-type'))) - return; - - this.set('param-drawing-type', type); - //Create drawing object in relation with the type switch (type) { case 'serie' : - this.set('param-drawing-object', new amdaPlotObj.PlotSerieObject()); - break; + return new amdaPlotObj.PlotSerieObject(data); case 'spectro' : - this.set('param-drawing-object', new amdaPlotObj.PlotSpectroObject()); - break; + return new amdaPlotObj.PlotSpectroObject(data); case 'status-bar' : - this.set('param-drawing-object', new amdaPlotObj.PlotStatusBarObject()); - break; + return new amdaPlotObj.PlotStatusBarObject(data); case 'tick-bar' : - this.set('param-drawing-object', new amdaPlotObj.PlotTickBarObject()); - break; + return new amdaPlotObj.PlotTickBarObject(data); case 'iserie' : - this.set('param-drawing-object', new amdaPlotObj.PlotInstantSerieObject()); - break; + return new amdaPlotObj.PlotInstantSerieObject(data); case 'ispectro' : - this.set('param-drawing-object', new amdaPlotObj.PlotInstantSpectroObject()); - break; + return new amdaPlotObj.PlotInstantSpectroObject(data); default : - this.set('param-drawing-object', null); + return null; } + }, + + changeDrawingType: function(type) + { + if (type == this.get('param-drawing-type')) + return; + + this.set('param-drawing-type', type); + + this.set('param-drawing-object', this.createDrawingObjectByType(type)); //Set drawing object to default status if (this.get('param-drawing-object') != null) @@ -137,7 +133,7 @@ Ext.define('amdaPlotObj.PlotParamObject', { setDefaultValues: function(type) { - this.updateDrawingType(type, true); + this.changeDrawingType(type); }, getShortInfo : function(plotType) @@ -175,6 +171,16 @@ Ext.define('amdaPlotObj.PlotParamObject', { return info; }, + isDirty : function() + { + if (this.dirty) + return true; + if (this.get('param-drawing-object') != null) + return this.get('param-drawing-object').dirty; + + return false; + }, + getJsonValues : function() { var paramValues = new Object(); diff --git a/js/app/models/PlotObjects/PlotRequestObject.js b/js/app/models/PlotObjects/PlotRequestObject.js index ee9e07d..4dec947 100644 --- a/js/app/models/PlotObjects/PlotRequestObject.js +++ b/js/app/models/PlotObjects/PlotRequestObject.js @@ -72,6 +72,7 @@ Ext.define('amdaPlotObj.PlotRequestObject', { this.set('last-tab-id', this.get('last-tab-id') + 1); var recs = this.tabs().add({id : this.get('last-tab-id')}); recs[0].setDefaultValues(); + this.dirty = true; return recs[0]; }, @@ -81,9 +82,26 @@ Ext.define('amdaPlotObj.PlotRequestObject', { if (tabRecord == null) return false; this.tabs().remove(tabRecord); + this.dirty = true; return true; }, + isDirty : function() + { + if (this.get('id') == '') + return false; + + if (this.dirty) + return true; + + var d = false; + this.tabs().each(function (tab, index) { + if (tab.isDirty()) + d = true; + }); + return d; + }, + getJsonValues : function(hasId) { var requestValues = new Object(); diff --git a/js/app/models/PlotObjects/PlotSerieObject.js b/js/app/models/PlotObjects/PlotSerieObject.js index b92cbeb..43dcee2 100644 --- a/js/app/models/PlotObjects/PlotSerieObject.js +++ b/js/app/models/PlotObjects/PlotSerieObject.js @@ -56,6 +56,20 @@ Ext.define('amdaPlotObj.PlotSerieObject', { {name: 'serie-timetick-font-italic', type: 'boolean'} ], + constructor: function(){ + var me = this; + me.callParent(arguments); + if ((arguments.length > 0) && arguments[0]) + { + } + else + { + //new object, set default fields values + me.setDefaultValues(); + } + this.dirty = false; + }, + setDefaultValues: function() { this.set('serie-yaxis', amdaPlotObj.PlotObjectConfig.defaultValues.serie.yAxis); diff --git a/js/app/models/PlotObjects/PlotSpectroObject.js b/js/app/models/PlotObjects/PlotSpectroObject.js index 9b88470..3cb7445 100644 --- a/js/app/models/PlotObjects/PlotSpectroObject.js +++ b/js/app/models/PlotObjects/PlotSpectroObject.js @@ -24,6 +24,20 @@ Ext.define('amdaPlotObj.PlotSpectroObject', { {name: 'spectro-yaxis', type: 'string'} ], + constructor: function(){ + var me = this; + me.callParent(arguments); + if ((arguments.length > 0) && arguments[0]) + { + } + else + { + //new object, set default fields values + me.setDefaultValues(); + } + this.dirty = false; + }, + setDefaultValues: function() { this.set('spectro-yaxis', amdaPlotObj.PlotObjectConfig.defaultValues.spectro.yAxis); diff --git a/js/app/models/PlotObjects/PlotStatusBarObject.js b/js/app/models/PlotObjects/PlotStatusBarObject.js index 9ce9fb6..9e58b4d 100644 --- a/js/app/models/PlotObjects/PlotStatusBarObject.js +++ b/js/app/models/PlotObjects/PlotStatusBarObject.js @@ -23,6 +23,20 @@ Ext.define('amdaPlotObj.PlotTickBarObject', { fields : [ ], + constructor: function(){ + var me = this; + me.callParent(arguments); + if ((arguments.length > 0) && arguments[0]) + { + } + else + { + //new object, set default fields values + me.setDefaultValues(); + } + this.dirty = false; + }, + setDefaultValues: function() { }, diff --git a/js/app/models/PlotObjects/PlotTabObject.js b/js/app/models/PlotObjects/PlotTabObject.js index 5d0ae0d..425aa5a 100644 --- a/js/app/models/PlotObjects/PlotTabObject.js +++ b/js/app/models/PlotObjects/PlotTabObject.js @@ -70,7 +70,6 @@ Ext.define('amdaPlotObj.PlotTabObject', { constructor: function(){ var me = this; me.callParent(arguments); - me.setLayout(this.get('page-layout-type'), true); if ((arguments.length > 0) && arguments[0]) { if (arguments[0].panels) @@ -83,6 +82,7 @@ Ext.define('amdaPlotObj.PlotTabObject', { //new object, set default fields values me.setDefaultValues(); } + this.dirty = false; }, loadPanels: function(panels) @@ -92,18 +92,16 @@ Ext.define('amdaPlotObj.PlotTabObject', { loadLayoutObject: function(layout) { - var layoutObject = this.get('page-layout-object'); - if (layoutObject == null) - return; - Ext.Object.each(layout, function(key,value) { - layoutObject.set(key,value); - }); + this.set('page-layout-object', this.createLayoutByType(this.get('page-layout-type'), layout)); + if (this.get('page-layout-object') != null) + this.get('page-layout-object').dirty = false; }, createNewPanel: function() { this.set('last-panel-id', this.get('last-panel-id') + 1); var recs = this.panels().add({id : this.get('last-panel-id')}); recs[0].setDefaultValues(); + this.dirty = true; return recs[0]; }, @@ -113,37 +111,33 @@ Ext.define('amdaPlotObj.PlotTabObject', { if (panelRecord == null) return false; this.panels().remove(panelRecord); + this.dirty = true; return true; }, - setLayout: function(layoutType, forceUpdate) + createLayoutByType : function(layoutType, data) { - forceUpdate = (typeof forceUpdate !== 'undefined') ? forceUpdate : false; - - if (!forceUpdate && (layoutType == this.get('page-layout-type'))) - return; - - this.set('page-layout-type', layoutType); - //Create layout object in relation with the type switch (layoutType) { case 'vertical' : - this.set('page-layout-object', new amdaPlotObj.PlotLayoutVerticalObject()); - break; + return new amdaPlotObj.PlotLayoutVerticalObject(data); case 'auto' : - this.set('page-layout-object', new amdaPlotObj.PlotLayoutAutoObject()); - break; + return new amdaPlotObj.PlotLayoutAutoObject(data); case 'manual' : - this.set('page-layout-object', new amdaPlotObj.PlotLayoutManualObject()); - break; + return new amdaPlotObj.PlotLayoutManualObject(data); default : - this.set('page-layout-object', null); + return null; } + }, + + setLayout: function(layoutType) + { + if (layoutType == this.get('page-layout-type')) + return; - //Set layout object to default status - if (this.get('page-layout-object') != null) - this.get('page-layout-object').setDefaultValues(); + this.set('page-layout-type', layoutType); + this.set('page-layout-object', this.createLayoutByType(layoutType)); }, setDefaultValues: function() @@ -176,8 +170,7 @@ Ext.define('amdaPlotObj.PlotTabObject', { this.set('page-font-bold', false); this.set('page-font-italic', false); - this.set('page-layout-type', amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.type); - this.setLayout(amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.type, true); + this.setLayout(amdaPlotObj.PlotObjectConfig.defaultValues.page.layout.type); }, getPageShortInfo : function() @@ -197,6 +190,23 @@ Ext.define('amdaPlotObj.PlotTabObject', { return type; }, + isDirty : function() + { + if (this.dirty) + return true; + + if (this.get('page-layout-object') != null) + if (this.get('page-layout-object').dirty) + return true; + + var d = false; + this.panels().each(function (panel, index) { + if (panel.isDirty()) + d = true; + }); + return d; + }, + getJsonValues : function() { var tabValues = new Object(); diff --git a/js/app/models/PlotObjects/PlotTextObject.js b/js/app/models/PlotObjects/PlotTextObject.js index b3ad962..5947456 100644 --- a/js/app/models/PlotObjects/PlotTextObject.js +++ b/js/app/models/PlotObjects/PlotTextObject.js @@ -50,6 +50,20 @@ Ext.define('amdaPlotObj.PlotTextObject', { {name: 'text-font-italic', type: 'boolean'} ], + constructor: function(){ + var me = this; + me.callParent(arguments); + if ((arguments.length > 0) && arguments[0]) + { + } + else + { + //new object, set default fields values + me.setDefaultValues(); + } + this.dirty = false; + }, + setDefaultValues: function() { this.set('text-value', ''); diff --git a/js/app/models/PlotObjects/PlotTickBarObject.js b/js/app/models/PlotObjects/PlotTickBarObject.js index c4c6135..2e4079d 100644 --- a/js/app/models/PlotObjects/PlotTickBarObject.js +++ b/js/app/models/PlotObjects/PlotTickBarObject.js @@ -23,6 +23,20 @@ Ext.define('amdaPlotObj.PlotStatusBarObject', { fields : [ ], + constructor: function(){ + var me = this; + me.callParent(arguments); + if ((arguments.length > 0) && arguments[0]) + { + } + else + { + //new object, set default fields values + me.setDefaultValues(); + } + this.dirty = false; + }, + setDefaultValues: function() { }, diff --git a/js/app/views/PlotComponents/PlotConstantForm.js b/js/app/views/PlotComponents/PlotConstantForm.js index 88abb07..73dc2a8 100644 --- a/js/app/views/PlotComponents/PlotConstantForm.js +++ b/js/app/views/PlotComponents/PlotConstantForm.js @@ -15,6 +15,7 @@ Ext.define('amdaPlotComp.PlotConstantForm', { this.object = object; if (this.object != null) this.loadRecord(this.object); + this.updateOptions(this.object.get('constant-axis-id'), this.crtTree.getSelectedPlotType()); }, updateOptions: function(axisId, plotType) { @@ -29,8 +30,11 @@ Ext.define('amdaPlotComp.PlotConstantForm', { var me = this; return [ this.addStandardCombo('constant-axis-id', 'Axis attachment', amdaPlotObj.PlotObjectConfig.availableConstantAxes, function (name, value, oldValue) { - me.updateOptions(value, me.crtTree.getSelectedPlotType()); - me.crtTree.getView().refresh(); + if (me.object.get('constant-axis-id') != value) + { + me.updateOptions(value, me.crtTree.getSelectedPlotType()); + me.crtTree.getView().refresh(); + } }), this.addStandardDate('constant-time-value', 'Value'), this.addStandardText('constant-float-value', 'Value'), diff --git a/js/app/views/PlotComponents/PlotCurveForm.js b/js/app/views/PlotComponents/PlotCurveForm.js index 1c2dc0d..ce901f5 100644 --- a/js/app/views/PlotComponents/PlotCurveForm.js +++ b/js/app/views/PlotComponents/PlotCurveForm.js @@ -50,7 +50,7 @@ Ext.define('amdaPlotComp.PlotCurveForm', { value: param.get('curve-param-value'), listeners: { change: function(field, newValue, oldValue, eOpts) { - param.set(param.get('curve-param-name'), newValue); + param.set('curve-param-value', newValue); }, scope: me } @@ -120,9 +120,10 @@ Ext.define('amdaPlotComp.PlotCurveForm', { return [ this.addStandardCombo('curve-name', 'Curve name', [], function(name, value, oldValue) { - me.object.setCurveName(value, function (){ - me.updateParamsContainer(); - }); + if (me.object.get('curve-name') != value) + me.object.setCurveName(value, function (){ + me.updateParamsContainer(); + }); }), this.addStandardCombo('curve-serie-id', 'Attached serie', []), this.addStandardFieldSet('Lines', '', this.addStandardLineItems('curve-line')), diff --git a/js/app/views/PlotComponents/PlotElementPanel.js b/js/app/views/PlotComponents/PlotElementPanel.js index 4734c66..3b7d61d 100644 --- a/js/app/views/PlotComponents/PlotElementPanel.js +++ b/js/app/views/PlotComponents/PlotElementPanel.js @@ -40,6 +40,13 @@ Ext.define('amdaPlotComp.PlotElementPanel', { this.callParent(arguments); }, + destroy: function() { + this.elementFormsManager.each(function (key, value, length) { + this.elementFormsManager.unregister(value); + }, this); + this.callParent(); + }, + setElement: function(type, object, tree) { this.removeAll(false); diff --git a/js/app/views/PlotComponents/PlotFillForm.js b/js/app/views/PlotComponents/PlotFillForm.js index f6acfd5..0622174 100644 --- a/js/app/views/PlotComponents/PlotFillForm.js +++ b/js/app/views/PlotComponents/PlotFillForm.js @@ -22,6 +22,7 @@ Ext.define('amdaPlotComp.PlotFillForm', { this.updateSerieIdLists(); this.updateConstantIdList(); this.loadRecord(this.object); + this.updateOptions(); } }, @@ -77,8 +78,11 @@ Ext.define('amdaPlotComp.PlotFillForm', { return [ this.addStandardCombo('fill-type', 'Fill type', amdaPlotObj.PlotObjectConfig.availableFillTypes, function(name, value, oldValue) { - me.updateOptions(); - me.crtTree.getView().refresh(); + if (me.object.get('fill-type') != value) + { + me.updateOptions(); + me.crtTree.getView().refresh(); + } }), this.addStandardCombo('fill-firstserie-id', 'First serie Id', []), this.addStandardCombo('fill-secondserie-id', 'Second serie Id', []), diff --git a/js/app/views/PlotComponents/PlotLayoutForm.js b/js/app/views/PlotComponents/PlotLayoutForm.js index 43fd15f..0670825 100644 --- a/js/app/views/PlotComponents/PlotLayoutForm.js +++ b/js/app/views/PlotComponents/PlotLayoutForm.js @@ -21,6 +21,13 @@ Ext.define('amdaPlotComp.PlotLayoutForm', { layoutOptionsFormsManager : new Ext.AbstractManager(), + destroy: function() { + this.layoutOptionsFormsManager.each(function (key, value, length) { + this.layoutOptionsFormsManager.unregister(value); + }, this); + this.callParent(); + }, + setObject : function(object) { this.object = object; this.loadRecord(this.object); @@ -59,10 +66,10 @@ Ext.define('amdaPlotComp.PlotLayoutForm', { }, - updateLayoutOptions: function(forceUpdate) { + updateLayoutOptions: function() { var typeField = this.getForm().findField('page-layout-type'); var layoutType = typeField.getValue(); - this.object.setLayout(layoutType, forceUpdate); + this.object.setLayout(layoutType); this.layoutOptionsContainer.removeAll(false); @@ -82,8 +89,11 @@ Ext.define('amdaPlotComp.PlotLayoutForm', { return [ this.addStandardCombo('page-layout-type', 'Layout type', amdaPlotObj.PlotObjectConfig.availablePageLayouts, function(name, value, oldValue) { - me.updateLayoutOptions(value != oldValue); - me.crtTree.getView().refresh(); + if (me.object.get('page-layout-type') != value) + { + me.updateLayoutOptions(); + me.crtTree.getView().refresh(); + } }), this.layoutOptionsContainer ]; diff --git a/js/app/views/PlotComponents/PlotLegendSeriesForm.js b/js/app/views/PlotComponents/PlotLegendSeriesForm.js index f65c5a4..bd075df 100644 --- a/js/app/views/PlotComponents/PlotLegendSeriesForm.js +++ b/js/app/views/PlotComponents/PlotLegendSeriesForm.js @@ -13,6 +13,7 @@ Ext.define('amdaPlotComp.PlotLegendSeriesForm', { setObject : function(object) { this.object = object.get('panel-legend-series'); + console.log(this.object); if (this.object != null) this.loadRecord(this.object); var legendTypeField = this.getForm().findField('legend-series-type'); diff --git a/js/app/views/PlotComponents/PlotOutputForm.js b/js/app/views/PlotComponents/PlotOutputForm.js index d143a5e..babee9a 100644 --- a/js/app/views/PlotComponents/PlotOutputForm.js +++ b/js/app/views/PlotComponents/PlotOutputForm.js @@ -13,27 +13,32 @@ Ext.define('amdaPlotComp.PlotOutputForm', { title: 'Output options', - updateOneFilePerIntOption : function() { - var formatField = this.getForm().findField('file-format'); + setObject : function(object) { + this.object = object; + this.loadRecord(this.object); + this.updateOutputOption(this.object.get('file-format')); + this.updateOneFilePerIntOption(this.object.get('file-format')); + this.updateFilePrefixOption(this.object.get('file-output')); + }, + + updateOneFilePerIntOption : function(format) { var oneFilePerIntField = this.getForm().findField('one-file-per-interval'); - oneFilePerIntField.setDisabled((formatField.getValue() == 'PNG') || (formatField.getValue() == 'SVG')); + oneFilePerIntField.setDisabled((format == 'PNG') || (format == 'SVG')); }, - updateFilePrefixOption : function() { + updateFilePrefixOption : function(output) { var prefixField = this.getForm().findField('file-prefix'); - var outputField = this.getForm().findField('file-output'); - if (outputField.getValue() == 'INTERACTIVE') + if (output == 'INTERACTIVE') prefixField.setValue(""); - prefixField.setDisabled(outputField.getValue() == 'INTERACTIVE'); + prefixField.setDisabled(output == 'INTERACTIVE'); }, - updateOutputOption : function() { - var formatField = this.getForm().findField('file-format'); + updateOutputOption : function(format) { var outputField = this.getForm().findField('file-output'); - if (formatField.getValue() == 'PNG') + if (format == 'PNG') { outputField.getStore().loadData(amdaPlotObj.PlotObjectConfig.availableFileOutputsForPng); outputField.setValue('INTERACTIVE'); @@ -43,6 +48,8 @@ Ext.define('amdaPlotComp.PlotOutputForm', { outputField.getStore().loadData(amdaPlotObj.PlotObjectConfig.availableFileOutputsForOtherFormats); if (outputField.getValue() == 'INTERACTIVE') outputField.setValue('TGZ'); + else + outputField.setValue('TGZ'); } }, @@ -51,11 +58,15 @@ Ext.define('amdaPlotComp.PlotOutputForm', { return [ this.addStandardCombo('file-format', 'File format', amdaPlotObj.PlotObjectConfig.availableFileFormats, function(name, value, oldValue) { - me.updateOutputOption(); - me.updateOneFilePerIntOption(); + if (me.object.get('file-format') != value) + { + me.updateOutputOption(value); + me.updateOneFilePerIntOption(value); + } }), this.addStandardCombo('file-output', 'File output', amdaPlotObj.PlotObjectConfig.availableFileOutputs, function(name, value, oldValue) { - me.updateFilePrefixOption(); + if (me.object.get('file-output') != value) + me.updateFilePrefixOption(value); }), this.addStandardText('file-prefix', 'File prefix'), this.addStandardCheck('one-file-per-interval', 'One file per interval'), diff --git a/js/app/views/PlotComponents/PlotPanelForm.js b/js/app/views/PlotComponents/PlotPanelForm.js index 1ad5cfd..122dc8c 100644 --- a/js/app/views/PlotComponents/PlotPanelForm.js +++ b/js/app/views/PlotComponents/PlotPanelForm.js @@ -117,9 +117,9 @@ Ext.define('amdaPlotComp.PlotPanelForm', { var me = this; return [ this.addStandardCombo('panel-plot-type', 'Plot type', amdaPlotObj.PlotObjectConfig.availablePlotTypes, function(name, value, oldValue) { - if (value != oldValue) + if (value != me.object.get('panel-plot-type')) { - me.object.updatePlotType(value, true); + me.object.changePlotType(value); if (!me.crtTree.tabObject.get('tree-simplified-view')) { me.crtTree.buildPanelAxesNode(me.object); diff --git a/js/app/views/PlotComponents/PlotParamForm.js b/js/app/views/PlotComponents/PlotParamForm.js index ad1a3ec..94ca60b 100644 --- a/js/app/views/PlotComponents/PlotParamForm.js +++ b/js/app/views/PlotComponents/PlotParamForm.js @@ -24,10 +24,17 @@ Ext.define('amdaPlotComp.PlotParamForm', { drawingOptionsFormsManager : new Ext.AbstractManager(), + destroy: function() { + this.drawingOptionsFormsManager.each(function (key, value, length) { + this.drawingOptionsFormsManager.unregister(value); + }, this); + this.callParent(); + }, + setObject : function(object) { this.object = object; this.loadRecord(this.object); - this.updateDrawingOptions(); + this.updateDrawingOptions(this.object.get('param-drawing-type')); }, getDrawingOptionsForm: function(type) { @@ -71,15 +78,14 @@ Ext.define('amdaPlotComp.PlotParamForm', { }, - updateDrawingOptions: function(forceUpdate) { + updateDrawingOptions: function(drawingType) { var typeField = this.getForm().findField('param-drawing-type'); var availableDrawingObjects = this.object.getAvailableDrawingObjectByPlotType(this.crtTree.getSelectedPlotType()); typeField.getStore().loadData(availableDrawingObjects); - - var drawingType = typeField.getValue(); - - this.object.updateDrawingType(drawingType, forceUpdate); + typeField.suspendEvents(); + typeField.setValue(drawingType); + typeField.resumeEvents(false); this.drawingOptionsContainer.removeAll(false); @@ -99,8 +105,12 @@ Ext.define('amdaPlotComp.PlotParamForm', { return [ this.addStandardCombo('param-drawing-type', 'Drawing type', [{'key' : '', 'value' : 'None'}], function(name, value, oldValue) { - me.updateDrawingOptions(value != oldValue); - me.crtTree.getView().refresh(); + if (me.object.get('param-drawing-type') != value) + { + me.object.changeDrawingType(value); + me.crtTree.getView().refresh(); + me.updateDrawingOptions(value); + } }), this.drawingOptionsContainer ]; diff --git a/js/app/views/PlotComponents/PlotStandardForm.js b/js/app/views/PlotComponents/PlotStandardForm.js index dd3de6b..49075e6 100644 --- a/js/app/views/PlotComponents/PlotStandardForm.js +++ b/js/app/views/PlotComponents/PlotStandardForm.js @@ -91,9 +91,9 @@ Ext.define('amdaPlotComp.PlotStandardForm', { editable: false, listeners: { change: function(combo, newValue, oldValue, eOpts) { - this.object.set(name, newValue); if (onChange != null) onChange(name, newValue, oldValue); + this.object.set(name, newValue); }, scope: this } diff --git a/js/app/views/PlotTabResultUI.js b/js/app/views/PlotTabResultUI.js index bcf3c18..59de4d6 100644 --- a/js/app/views/PlotTabResultUI.js +++ b/js/app/views/PlotTabResultUI.js @@ -314,7 +314,7 @@ Ext.define('amdaUI.PlotTabResultUI', { if (result.success) { myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) { - module.startInteractiveSession(result); + module.updateInteractiveSession(result); }); } else @@ -331,6 +331,131 @@ Ext.define('amdaUI.PlotTabResultUI', { },this); }, + createToolBar : function(isTimeTable) { + var interoperItemCfg = { + text: 'Get HST Data', + scope: this, + menu: [ + { + text: 'Giant Planet Auroral Emissions', + scope: this, + handler: function() + { + var me = this; + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.astro.id, true, function (module) { + //module.createWindow(me.object.get('startDate'),me.object.get('stopDate')); + }); + } + } + ] + }; + + if (isTimeTable) { + var toolConfig = { + dock: 'top', + items: [ + { + text: 'Previous', + scope: this, + handler: function(){ + } + }, + '-', + { + text: 'Next', + scope: this, + handler: function(){ + } + }, + '-', + { + text: 'Go to Interval #', + scope: this, + handler: function(bt){ + } + }, + { + xtype: 'numberfield', + hideTrigger: true, + width: 40, + minValue: 1 + }, + ' ', + ' ', + ' ', + { + xtype: 'textfield', + labelAlign: 'right', + labelWidth: 30, + fieldLabel: 'Table', + width: 130, + disabled : true + }, + { + xtype: 'textfield', + labelAlign: 'right', + labelWidth: 30, + fieldLabel: 'Int #', + width: 70, + disabled : true + }, + { + xtype: 'textfield', + labelAlign: 'right', + labelWidth: 30, + fieldLabel: 'Total', + width: 70, + disabled : true + }, + '->', + interoperItemCfg + ] + }; + } + else { + var toolConfig = { + dock: 'top', + items: [ { + text: 'Backward', + scope: this, + handler: function(){ + this.callInteractivePlot({'action' : 'backward', 'tabId' : this.tabId}); + } + }, + '-' , + { + text: '1/2 Backward', + scope: this, + handler: function(){ + this.callInteractivePlot({'action' : 'halfbackward', 'tabId' : this.tabId}); + } + }, + '-', + { + text: '1/2 Forward', + scope: this, + handler: function(){ + this.callInteractivePlot({'action' : 'halfforward', 'tabId' : this.tabId}); + } + }, + '-', + { + text: 'Forward', + scope: this, + handler: function(){ + this.callInteractivePlot({'action' : 'forward', 'tabId' : this.tabId}); + } + }, + '->', + interoperItemCfg + ] + }; + } + + var toolBar = Ext.create('Ext.toolbar.Toolbar', toolConfig); + return toolBar; + }, + init: function(configResult){ this.crtContext = configResult.context; this.tabId = configResult.tabId; @@ -363,8 +488,6 @@ Ext.define('amdaUI.PlotTabResultUI', { } }); - - var mouseToolbar = { xtype: 'toolbar', height: 25, @@ -382,13 +505,15 @@ Ext.define('amdaUI.PlotTabResultUI', { items: [] }); + var navToolBar = this.createToolBar(false); + var plotResultTabPanelConfig = { preventHeader : true, autoScroll: true, items: [ this.createPlotImage(configResult.folder, configResult.plotFile) ], - dockedItems: [mouseToolbar], + dockedItems: [navToolBar, mouseToolbar], plugins: [ { ptype: 'plotZoomPlugin', pluginId : 'plot-zoom-plugin-id' diff --git a/js/app/views/PlotUI.js b/js/app/views/PlotUI.js index 50bcc3b..2e7bd93 100644 --- a/js/app/views/PlotUI.js +++ b/js/app/views/PlotUI.js @@ -46,14 +46,49 @@ Ext.define('amdaUI.PlotUI', { this.timeSelector.intervalSel.setInterval(this.object.get('startDate'), this.object.get('stopDate')); }, - /** - * save method called by Save button to launch the save process - */ - saveProcess : function(){ - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); - if (plotModule) - plotModule.linkedNode.create(); - }, + saveProcess : function() { + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); + if (!plotModule) + return; + + if ((this.object.get('id') != '') && (plotModule.linkedNode.get('text') == this.object.get('name'))) + //update existing request + plotModule.linkedNode.update(); + else + { + var me = this; + //Request Name validation + plotModule.linkedNode.isValidName(this.object.get('name'), function (res) { + if (!res) + { + myDesktopApp.errorMsg('Error during object validation'); + return; + } + + if (!res.valid) + { + if (res.error) + myDesktopApp.errorMsg(res.error); + else + myDesktopApp.errorMsg('Invalid object name'); + return; + } + + //Save + if (me.object.get('id') != '') + { + //Duplicate request + plotModule.createLinkedNode(); + plotModule.linkedNode.set('object',me.object); + } + else + { + //Create new request + } + plotModule.linkedNode.create(); + }); + } + }, resetProcess : function(){ var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); @@ -77,15 +112,7 @@ Ext.define('amdaUI.PlotUI', { * plot method called by 'Do Plot' button to launch the plot process */ doPlot : function(){ - var timeSource = this.timeSelector.getActiveTimeSource(); - var multiPlotForm = this.multiPlotIntervalPanel.getForm(); - multiPlotForm.updateRecord(this.object); - this.object.set('timesrc', timeSource); - if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) - this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items); - this.plotTabs.updateTimeObject(); - - // fire execution + this.updateObject(); var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); if (plotModule) plotModule.linkedNode.execute(); @@ -96,13 +123,26 @@ Ext.define('amdaUI.PlotUI', { * @return false */ fclose : function() { - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) { + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); + if (module) module.closeInteractiveSession(); - }); - return false; + return this.object.isDirty(); }, + /** + * update this.object from form + */ + updateObject : function(){ + var timeSource = this.timeSelector.getActiveTimeSource(); + var multiPlotForm = this.multiPlotIntervalPanel.getForm(); + multiPlotForm.updateRecord(this.object); + this.object.set('timesrc', timeSource); + if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) + this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items); + this.plotTabs.updateTimeObject(); + }, + addTT : function(newTTName,newTTid) { this.timeSelector.addTT(newTTName,newTTid); -- libgit2 0.21.2