From 3ca3b0bba65c71843f385df92b019654ae3097d9 Mon Sep 17 00:00:00 2001 From: "s.malakhov" Date: Thu, 27 Apr 2023 10:43:40 +0300 Subject: [PATCH] [MPQEditor] Implement 'dispose' and 'onViewMessage' This commit implements 'dispose' and 'onViewMessage' for manual mixed precision quantization task. ONE-vscode-DCO-1.0-Signed-off-by: s.malakhov --- src/MPQEditor/MPQCircleSelector.ts | 42 +++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/src/MPQEditor/MPQCircleSelector.ts b/src/MPQEditor/MPQCircleSelector.ts index a9752962..97eb78d4 100644 --- a/src/MPQEditor/MPQCircleSelector.ts +++ b/src/MPQEditor/MPQCircleSelector.ts @@ -20,6 +20,7 @@ import * as vscode from "vscode"; import { CircleGraphCtrl, CircleGraphEvent, + MessageDefs, } from "../CircleGraph/CircleGraphCtrl"; export interface MPQSelectionEvent { @@ -213,14 +214,49 @@ export class MPQSelectionPanel } public dispose() { - //TODO + if (!this._closedByOwner && this._mpqEventHandler) { + this._mpqEventHandler.onClosed(this._ownerPanel); + } + + this.disposeGraphCtrl(); + + MPQSelectionPanel.panels.forEach((selPan, index) => { + if ( + this._ownerId === selPan._ownerId && + this._modelPath === selPan._modelPath + ) { + MPQSelectionPanel.panels.splice(index, 1); + } + }); + + // Clean up our resources + this._panel.dispose(); + + while (this._disposables.length) { + const x = this._disposables.pop(); + if (x) { + x.dispose(); + } + } } /** * CircleGraphEvent interface implementations */ - public onViewMessage(_message: any) { - // TODO + public onViewMessage(message: any) { + switch (message.command) { + case MessageDefs.selection: + this._lastSelected = message.names; + // we need to update the document, but not save to file. + // pass to owner to handle this. + if (this._mpqEventHandler) { + this._mpqEventHandler.onSelection(message.names, this._document); + } + break; + case MessageDefs.finishload: + this.onForwardSelection(this._lastSelected); + break; + } } public onForwardSelection(selection: any) {