Files
azuredatastudio/src/sql/workbench/services/dialog/browser/customDialogService.ts
Anthony Dresser ade68b184d Move code around for more linting (#8190)
* testing

* moving around all the code

* fix strict nulls
2019-11-04 10:41:28 -08:00

50 lines
2.1 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 { DialogModal } from 'sql/workbench/services/dialog/browser/dialogModal';
import { WizardModal } from 'sql/workbench/services/dialog/browser/wizardModal';
import { Dialog, Wizard } from 'sql/workbench/services/dialog/common/dialogTypes';
import { IModalOptions } from 'sql/workbench/browser/modal/modal';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
const defaultOptions: IModalOptions = { hasBackButton: false, isWide: false, hasErrors: true };
const defaultWizardOptions: IModalOptions = { hasBackButton: false, isWide: true, hasErrors: true };
export class CustomDialogService {
private _dialogModals = new Map<Dialog, DialogModal>();
private _wizardModals = new Map<Wizard, WizardModal>();
constructor(@IInstantiationService private _instantiationService: IInstantiationService) { }
public showDialog(dialog: Dialog, dialogName?: string, options?: IModalOptions): void {
let name = dialogName ? dialogName : 'CustomDialog';
let dialogModal = this._instantiationService.createInstance(DialogModal, dialog, name, options || defaultOptions);
this._dialogModals.set(dialog, dialogModal);
dialogModal.render();
dialogModal.open();
}
public showWizard(wizard: Wizard, options?: IModalOptions): void {
let wizardModal = this._instantiationService.createInstance(WizardModal, wizard, 'WizardPage', options || defaultWizardOptions);
this._wizardModals.set(wizard, wizardModal);
wizardModal.render();
wizardModal.open();
}
public closeDialog(dialog: Dialog): void {
let dialogModal = this._dialogModals.get(dialog);
if (dialogModal) {
dialogModal.cancel();
}
}
public closeWizard(wizard: Wizard): void {
let wizardModal = this._wizardModals.get(wizard);
if (wizardModal) {
wizardModal.cancel();
}
}
}