import { RhamtConfiguration, rhamtEvents } from 'raas-core'; import { WebviewPanel, window, ViewColumn, Uri, ExtensionContext, Disposable } from 'vscode'; import * as path from 'path'; import { Endpoint } from '../server/endpoint'; export class ConfigurationEditor implements Disposable { onEditorClosed = new rhamtEvents.TypedEvent(); private configuration: RhamtConfiguration; private view: WebviewPanel | undefined = undefined; private endpoint: Endpoint; private context: ExtensionContext; constructor(configuration: RhamtConfiguration, endpoint: Endpoint, context: ExtensionContext) { this.configuration = configuration; this.endpoint = endpoint; this.context = context; this.context.subscriptions.push(this); // TODO: Move this to an area for setting default values when configuration created. this.configuration.server.host = endpoint.raasHost; this.configuration.server.port = Number(endpoint.raasPort); } open(): void { if (!this.view) { this.view = window.createWebviewPanel('rhamtEditor', this.configuration.name, ViewColumn.Active, { enableScripts: true, retainContextWhenHidden: true, localResourceRoots: [Uri.file(path.join(this.context.extensionPath, 'out'))] }); this.view.onDidDispose(() => { this.view = undefined; this.onEditorClosed.emit(undefined); }); this.view.webview.html = this.render(); } this.view.reveal(); } dispose(): void { } render(): string { return this.renderBody(); } private renderBody(): string { const html = ` `; return html; } }