mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-27 17:23:21 -05:00
* save not yet tested work * Merge from master. * Screeens Shared for Feeedback * Code complete * remove unneeded changes * remove unnecessary comma * remov wss * remove dead code * PR feedback * checkpoint fixes * PR & minor fixes * minor fix for feature of resourceType options being optional. * reverting experimental change * separating out changes for future featurework. * revert unneeded change * review feedback fixes * review feedback * rename InputFieldComponent to InputComponent * working version of custom summary page * add option to align items in a flex- container. * changes to support labelColor * save work , still pending issue with labelCSSStyles * Summary page and setting variabless in notebook. * minor fixes. * pr feedbck * fix formatting issues * pr feedback * pr feedback * pr feedback * fixing docs * summary page value setting fix * rename children of RowInfo to items * rename a method * rename summary_text to evaluated_text * rename properties of fieldInfo * revert inadvertent change * rename linked_texttext to hyperlinked_text and removing linking facility from readonly_text * pr feedback * fix setting tools variables in env and notebook * removing saving of originalValues for EvaluatedText * await on launchNotebookWithEdits * await on launchNotebookWithContent * merge RadioOptions & Options into 1 * merge ReadOnlyText, links & evaluatedText * Samples for new generic wizard features * fix comment * fix assertions * return type and comment for getClusterContext * fix inadvertent change * increase minimum required azdata version * remove unneeded environment variable settings * not leaking passwords in notebooks
91 lines
2.6 KiB
TypeScript
91 lines
2.6 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';
|
|
import * as nls from 'vscode-nls';
|
|
import { WizardPageBase } from './wizardPageBase';
|
|
import { Model } from './model';
|
|
const localize = nls.loadMessageBundle();
|
|
|
|
export abstract class WizardBase<T, P extends WizardPageBase<T>, M extends Model> {
|
|
private customButtons: azdata.window.Button[] = [];
|
|
public pages: P[] = [];
|
|
|
|
public wizardObject: azdata.window.Wizard;
|
|
public toDispose: vscode.Disposable[] = [];
|
|
public get model(): M {
|
|
return this._model;
|
|
}
|
|
|
|
constructor(private title: string, private _model: M) {
|
|
this.wizardObject = azdata.window.createWizard(title);
|
|
}
|
|
|
|
public open(): Thenable<void> {
|
|
this.initialize();
|
|
this.wizardObject.customButtons = this.customButtons;
|
|
this.toDispose.push(this.wizardObject.onPageChanged((e) => {
|
|
let previousPage = this.pages[e.lastPage];
|
|
let newPage = this.pages[e.newPage];
|
|
previousPage.onLeave();
|
|
newPage.onEnter();
|
|
}));
|
|
|
|
this.toDispose.push(this.wizardObject.doneButton.onClick(async () => {
|
|
await this.onOk();
|
|
this.dispose();
|
|
}));
|
|
this.toDispose.push(this.wizardObject.cancelButton.onClick(() => {
|
|
this.onCancel();
|
|
this.dispose();
|
|
}));
|
|
|
|
return this.wizardObject.open().then(() => {
|
|
if (this.pages && this.pages.length > 0) {
|
|
this.pages[0].onEnter();
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
protected abstract initialize(): void;
|
|
protected abstract async onOk(): Promise<void>;
|
|
protected abstract onCancel(): void;
|
|
|
|
public addButton(button: azdata.window.Button) {
|
|
this.customButtons.push(button);
|
|
}
|
|
|
|
protected setPages(pages: P[]) {
|
|
this.wizardObject!.pages = pages.map(p => p.pageObject);
|
|
this.pages = pages;
|
|
this.pages.forEach((page) => {
|
|
page.initialize();
|
|
});
|
|
}
|
|
|
|
private dispose() {
|
|
let errorOccurred = false;
|
|
this.toDispose.forEach((disposable: vscode.Disposable) => {
|
|
try {
|
|
disposable.dispose();
|
|
}
|
|
catch (error) {
|
|
errorOccurred = true;
|
|
console.error(error);
|
|
}
|
|
});
|
|
|
|
if (errorOccurred) {
|
|
vscode.window.showErrorMessage(localize('resourceDeployment.DisposableError', "Error occurred while closing the wizard: {0}, open 'Debugger Console' for more information."), this.title);
|
|
}
|
|
}
|
|
|
|
public registerDisposable(disposable: vscode.Disposable): void {
|
|
this.toDispose.push(disposable);
|
|
}
|
|
}
|