From 7cbb821601f6daeaa9de159068bf8b74612159ed Mon Sep 17 00:00:00 2001 From: Alexandru Stefan Date: Sat, 13 Nov 2021 02:35:59 +0200 Subject: [PATCH] reset code editor space while changing workspaces. forbid designer shortcuts while editing code --- Platform/UI/Canvas.js | 6 +++++ Platform/WebServer/index.html | 2 +- .../CodeEditor-Space/CodeEditorSpace.js | 27 ++++++++++++++----- .../UI/Spaces/CodeEditor-Space/EditorPage.js | 2 +- .../UI/Spaces/Design-Space/Workspace.js | 3 ++- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Platform/UI/Canvas.js b/Platform/UI/Canvas.js index 7a2d09b74..459e3e675 100644 --- a/Platform/UI/Canvas.js +++ b/Platform/UI/Canvas.js @@ -56,6 +56,7 @@ function newCanvas() { UI.projects.foundations.spaces.sideSpace.finalize() UI.projects.foundations.spaces.chartingSpace.finalize() UI.projects.foundations.spaces.floatingSpace.finalize() + UI.projects.foundations.spaces.codeEditorSpace.finalize() thisObject.shorcutNumbers = undefined if (browserCanvas.removeEventListener) { @@ -385,6 +386,11 @@ function newCanvas() { if (UI.projects.education !== undefined && UI.projects.education.spaces.docsSpace.isVisible === true) { return } + /* When the Code Editor is Visible, we do not process key down events of the Designer Space. */ + if (UI.projects.foundations.spaces.codeEditorSpace.isVisible === true) { + return + } + thisObject.mouse.event = event thisObject.mouse.action = 'key down' diff --git a/Platform/WebServer/index.html b/Platform/WebServer/index.html index 0925c901c..8eeeb113a 100644 --- a/Platform/WebServer/index.html +++ b/Platform/WebServer/index.html @@ -140,7 +140,7 @@
-
+
diff --git a/Projects/Foundations/UI/Spaces/CodeEditor-Space/CodeEditorSpace.js b/Projects/Foundations/UI/Spaces/CodeEditor-Space/CodeEditorSpace.js index 71362e847..88e678a51 100644 --- a/Projects/Foundations/UI/Spaces/CodeEditor-Space/CodeEditorSpace.js +++ b/Projects/Foundations/UI/Spaces/CodeEditor-Space/CodeEditorSpace.js @@ -5,6 +5,8 @@ function newFoundationsCodeEditorSpace() { sidePanelTab: undefined, container: undefined, editorPage: undefined, + isVisible: undefined, + reset: reset, openSpaceArea: openSpaceArea, physics: physics, draw: draw, @@ -23,15 +25,24 @@ function newFoundationsCodeEditorSpace() { return thisObject function finalize() { - thisObject.sidePanelTab = undefined + if (isInitialized === false) { return } + + thisObject.container.finalize() + thisObject.container = undefined + canvas.eventHandler.stopListening(browserResizedEventSubscriptionId) thisObject.sidePanelTab.container.eventHandler.stopListening(openingEventSubscriptionId) thisObject.sidePanelTab.container.eventHandler.stopListening(closingEventSubscriptionId) + UI.projects.foundations.spaces.sideSpace.deleteSidePanelTab('Foundations', 'javascript-code', 'Code', 'right') + + thisObject.editorPage.finalize() + thisObject.editorPage = undefined + + isInitialized = false } function initialize() { - thisObject.container = newContainer() thisObject.container.name = MODULE_NAME thisObject.container.initialize() @@ -43,10 +54,7 @@ function newFoundationsCodeEditorSpace() { resize() thisObject.editorPage = newFoundationsCodeEditorEditorPage() - thisObject.footer = newGovernanceReportsFooter() // Reuse simple footer - thisObject.editorPage.initialize() - thisObject.footer.initialize() thisObject.sidePanelTab = UI.projects.foundations.spaces.sideSpace.createSidePanelTab(thisObject.container, 'Foundations', 'javascript-code', 'Code', 'right') @@ -66,6 +74,11 @@ function newFoundationsCodeEditorSpace() { thisObject.editorPage.render(originatingNode, codeEditorType) } + function reset() { + finalize() + initialize() + } + function physics() { if (isInitialized === false) { return @@ -92,11 +105,11 @@ function newFoundationsCodeEditorSpace() { } function onOpening() { - + thisObject.isVisible = true } function onClosing() { - + thisObject.isVisible = false } function draw() { diff --git a/Projects/Foundations/UI/Spaces/CodeEditor-Space/EditorPage.js b/Projects/Foundations/UI/Spaces/CodeEditor-Space/EditorPage.js index e6f048fac..689765313 100644 --- a/Projects/Foundations/UI/Spaces/CodeEditor-Space/EditorPage.js +++ b/Projects/Foundations/UI/Spaces/CodeEditor-Space/EditorPage.js @@ -211,7 +211,7 @@ function newFoundationsCodeEditorEditorPage() { /** * The autocomplete models will be based on: * 1. Existing code in the data mines -> we will create models for each code node (it's like opening multiple files in vscode) - * 2. Formulas from data mines by creating an object representation of all formulas see implementation below than passing it to the monaco registerCompletionItemProvider + * 2. Formulas from data mines by creating an object representation of all formulas see implementation below then passing it to the monaco registerCompletionItemProvider * 2. Trading engine loaded into the workspace - we create an obj. representation using getProtocolNode and we are using monaco registerCompletionItemProvider * */ diff --git a/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js b/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js index a0eaed8f6..b26180407 100644 --- a/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js +++ b/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js @@ -343,6 +343,7 @@ function newWorkspace() { UI.projects.education.spaces.docsSpace.sidePanelTab.close() UI.projects.foundations.spaces.workspaceSpace.sidePanelTab.close() + UI.projects.foundations.spaces.codeEditorSpace.sidePanelTab.close() UI.projects.foundations.spaces.floatingSpace.inMapMode = true workingAtTask = 2 break @@ -446,7 +447,7 @@ function newWorkspace() { UI.projects.governance.spaces.reportsSpace.reset() UI.projects.governance.spaces.userProfileSpace.reset() - + UI.projects.foundations.spaces.codeEditorSpace.reset() await UI.projects.education.spaces.docsSpace.reset() await UI.projects.education.spaces.tutorialSpace.reset()