From dbd058bd211915dbcd22cd9a118fcf8dc1123d6a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Jan 2020 12:25:49 +0100 Subject: [PATCH] Several Bug Fixes and Mantainance --- ChartsSpace/PlottersManager.js | 4 +- Container.js | 4 +- Panels/LayersPanel.js | 1 + Panels/PanelTabButton.js | 69 +++++++++++++++++++--------------- Panels/PlotterPanel.js | 26 +++++++++---- Spaces/PanelsSpace.js | 6 +-- 6 files changed, 65 insertions(+), 45 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index 46cdccd33..5e5b40f56 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -201,9 +201,7 @@ function newPlottersManager () { dataMine: dataMine.code.codeName, plotterCodeName: plotterModule.parentNode.code.codeName, moduleCodeName: plotterModule.code.codeName, - panelCodeName: panel.code.codeName, - panelId: panel.id, - isLegacy: panel.code.isLegacy + panelNode: panel } let owner = thisObject.payload.node.payload.parentNode.id // Panels are owned by the time machine. diff --git a/Container.js b/Container.js index 0816953fd..81f6ab874 100644 --- a/Container.js +++ b/Container.js @@ -70,7 +70,9 @@ function newContainer () { thisObject.frame = newFrame() thisObject.frame.initialize(pType) - thisObject.frame.containerName = pName + if (pName !== undefined) { + thisObject.frame.containerName = pName + } thisObject.frame.container = thisObject thisObject.eventHandler = newEventHandler() diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 5bb86653c..894909c7a 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -33,6 +33,7 @@ function newProductsPanel () { function finalize () { thisObject.container.eventHandler.stopListening(onMouseWheelEventSuscriptionId) + panelTabButton.finalize() panelTabButton = undefined layersMap = undefined visibleLayers = undefined diff --git a/Panels/PanelTabButton.js b/Panels/PanelTabButton.js index fe41ecbf6..dc389b7e8 100644 --- a/Panels/PanelTabButton.js +++ b/Panels/PanelTabButton.js @@ -5,35 +5,41 @@ function newPanelTabButton () { parentContainer: undefined, draw: draw, getContainer: getContainer, // returns the inner most container that holds the point received by parameter. - initialize: initialize + initialize: initialize, + finalize: finalize } let isInitialized = false /* Cointainer stuff */ - var container = newContainer() - - container.name = 'Panel Tab Button' - container.initialize() - - container.isClickeable = true - - thisObject.container = container + thisObject.container = newContainer() + thisObject.container.name = 'Panel Tab Button' + thisObject.container.initialize() + thisObject.container.isClickeable = true thisObject.container.frame.containerName = 'Panel Tab Button' - /* Lets listen to our own events to react when we have a Mouse Click */ - - thisObject.container.eventHandler.listenToEvent('onMouseClick', buttonPressed) - /* Animation to hide the pannel */ - let tabStatus = 'visible' let visiblePosition = {} let hiddenPosition = {} let transitionPosition = {} + let onMouseClickEventSuscriptionId return thisObject + function finalize () { + thisObject.container.eventHandler.stopListening(onMouseClickEventSuscriptionId) + thisObject.container.finalize() + thisObject.container = undefined + thisObject.fitFunction = undefined + thisObject.parentContainer = undefined + + tabStatus = undefined + visiblePosition = undefined + hiddenPosition = undefined + transitionPosition = undefined + } + function initialize () { thisObject.container.frame.width = 10 thisObject.container.frame.height = 10 @@ -54,10 +60,13 @@ function newPanelTabButton () { transitionPosition.x = visiblePosition.x transitionPosition.y = visiblePosition.y + /* Lets listen to our own events to react when we have a Mouse Click */ + onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) + isInitialized = true } - function buttonPressed (event) { + function onMouseClick (event) { if (tabStatus === 'visible') { visiblePosition.x = thisObject.parentContainer.frame.position.x visiblePosition.y = thisObject.parentContainer.frame.position.y @@ -104,7 +113,7 @@ function newPanelTabButton () { } function getContainer (point) { - var container + let container /* First we check if thisObject point is inside thisObject space. */ @@ -132,13 +141,13 @@ function newPanelTabButton () { } point2 = { - x: container.frame.width - 3, + x: thisObject.container.frame.width - 3, y: 3 } point3 = { - x: container.frame.width / 2, - y: container.frame.height - 3 + x: thisObject.container.frame.width / 2, + y: thisObject.container.frame.height - 3 } break } @@ -150,13 +159,13 @@ function newPanelTabButton () { } point2 = { - x: container.frame.width - 4, + x: thisObject.container.frame.width - 4, y: 4 } point3 = { - x: container.frame.width / 2, - y: container.frame.height - 4 + x: thisObject.container.frame.width / 2, + y: thisObject.container.frame.height - 4 } break } @@ -164,16 +173,16 @@ function newPanelTabButton () { case 'going up': { point1 = { x: 4, - y: container.frame.height - 4 + y: thisObject.container.frame.height - 4 } point2 = { - x: container.frame.width - 4, - y: container.frame.height - 4 + x: thisObject.container.frame.width - 4, + y: thisObject.container.frame.height - 4 } point3 = { - x: container.frame.width / 2, + x: thisObject.container.frame.width / 2, y: 4 } break @@ -182,16 +191,16 @@ function newPanelTabButton () { case 'hidden': { point1 = { x: 3, - y: container.frame.height - 3 + y: thisObject.container.frame.height - 3 } point2 = { - x: container.frame.width - 3, - y: container.frame.height - 3 + x: thisObject.container.frame.width - 3, + y: thisObject.container.frame.height - 3 } point3 = { - x: container.frame.width / 2, + x: thisObject.container.frame.width / 2, y: 3 } break diff --git a/Panels/PlotterPanel.js b/Panels/PlotterPanel.js index b2d33194b..a704be207 100644 --- a/Panels/PlotterPanel.js +++ b/Panels/PlotterPanel.js @@ -8,18 +8,16 @@ function newPlotterPanel () { let thisObject = { fitFunction: undefined, - onRecordChange: onRecordChange, container: undefined, + onRecordChange: onRecordChange, draw: draw, getContainer: getContainer, - initialize: initialize + initialize: initialize, + finalize: finalize } - let container = newContainer() - container.initialize() - thisObject.container = container - - container.frame.containerName = 'Plotter Panel' + thisObject.container = newContainer() + thisObject.container.initialize('Plotter Panel') let heightFactor = 1 let currentRecord @@ -28,9 +26,21 @@ function newPlotterPanel () { return thisObject + function finalize () { + thisObject.container.finalize() + thisObject.container = undefined + thisObject.fitFunction = undefined + + heightFactor = undefined + currentRecord = undefined + panelTabButton.finalize() + panelTabButton = undefined + panelNode = undefined + } + function initialize (pPanelNode) { panelNode = pPanelNode - container.frame.containerName = panelNode.name + thisObject.container.frame.containerName = panelNode.name thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index 1dc46530d..43442c705 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -47,14 +47,14 @@ function newPanelsSpace () { } case 'Plotter Panel': { - if (pParameters.isLegacy !== true) { + if (pParameters.panelNode.code.isLegacy !== true) { panel = newPlotterPanel() panel.fitFunction = canvas.chartSpace.fitFunction panel.container.isVisibleFunction = canvas.chartSpace.isThisPointVisible panel.session = pSession - panel.initialize(pParameters.panelId) + panel.initialize(pParameters.panelNode) } else { - panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelCodeName) + panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelNode.code.codeName) panel.fitFunction = canvas.chartSpace.fitFunction panel.container.isVisibleFunction = canvas.chartSpace.isThisPointVisible panel.session = pSession