mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 17:22:59 -05:00
* saving first draft * throw if no controllers * cleanup * bug fixes * bug fixes and caching controller access * pr comments and bug fixes. * fixes * fixes * comment fix * remove debug prints * comment fixes * remove debug logs * inputValueTransformer returns string|Promise * PR feedback * pr fixes * remove _ from protected fields * anonymous to full methods * small fixes
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import * as azdata from 'azdata';
|
|
import * as vscode from 'vscode';
|
|
|
|
export abstract class DialogBase {
|
|
protected _toDispose: vscode.Disposable[] = [];
|
|
protected _dialogObject: azdata.window.Dialog;
|
|
|
|
constructor(dialogTitle: string, dialogName: string, isWide: boolean = false) {
|
|
this._dialogObject = azdata.window.createModelViewDialog(dialogTitle, dialogName, isWide);
|
|
this._toDispose.push(this._dialogObject.cancelButton.onClick(() => this.onCancelButtonClicked()));
|
|
this._toDispose.push(this._dialogObject.okButton.onClick(() => this.onOkButtonClicked()));
|
|
}
|
|
|
|
protected abstract initialize(): void;
|
|
|
|
public open(): void {
|
|
this.initialize();
|
|
azdata.window.openDialog(this._dialogObject);
|
|
}
|
|
|
|
private onCancelButtonClicked(): void {
|
|
this.dispose();
|
|
}
|
|
|
|
private async onOkButtonClicked(): Promise<void> {
|
|
await this.onComplete();
|
|
this.dispose();
|
|
}
|
|
|
|
protected async onComplete(): Promise<void> {
|
|
}
|
|
|
|
protected dispose(): void {
|
|
this._toDispose.forEach(disposable => disposable.dispose());
|
|
}
|
|
}
|