diff --git a/extensions/sql-migration/src/models/migrationWizardPage.ts b/extensions/sql-migration/src/models/migrationWizardPage.ts new file mode 100644 index 0000000000..626baa9a41 --- /dev/null +++ b/extensions/sql-migration/src/models/migrationWizardPage.ts @@ -0,0 +1,17 @@ +/*--------------------------------------------------------------------------------------------- + * 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 { MigrationStateModel } from './stateMachine'; +export abstract class MigrationWizardPage { + constructor(protected readonly wizardPage: azdata.window.WizardPage, protected readonly migrationStateModel: MigrationStateModel) { } + + public abstract async registerWizardContent(): Promise; + + public getwizardPage(): azdata.window.WizardPage { + return this.wizardPage; + } +} + diff --git a/extensions/sql-migration/src/models/stateMachine.ts b/extensions/sql-migration/src/models/stateMachine.ts index 8f710be096..70d3449f2a 100644 --- a/extensions/sql-migration/src/models/stateMachine.ts +++ b/extensions/sql-migration/src/models/stateMachine.ts @@ -3,7 +3,11 @@ * 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 enum State { + INIT, COLLECTING_SOURCE_INFO, COLLECTION_SOURCE_INFO_ERROR, TARGET_SELECTION, @@ -20,3 +24,45 @@ export enum State { EXIT, } +export interface Model { + readonly sourceConnection: azdata.IConnectionProfile; + readonly currentState: State; +} + +export interface StateChangeEvent { + oldState: State; + newState: State; +} + +export class MigrationStateModel implements Model, vscode.Disposable { + private _stateChangeEventEmitter = new vscode.EventEmitter(); + private _currentState: State; + + constructor(private readonly _sourceConnection: azdata.IConnectionProfile) { + this._currentState = State.INIT; + } + + public get sourceConnection(): azdata.IConnectionProfile { + return this._sourceConnection; + } + + public get currentState(): State { + return this._currentState; + } + + public set currentState(newState: State) { + const oldState = this.currentState; + + this._currentState = newState; + + this._stateChangeEventEmitter.fire({ oldState, newState: this.currentState }); + } + + public get stateChangeEvent(): vscode.Event { + return this._stateChangeEventEmitter.event; + } + + dispose() { + this._stateChangeEventEmitter.dispose(); + } +} diff --git a/extensions/sql-migration/src/models/strings.ts b/extensions/sql-migration/src/models/strings.ts new file mode 100644 index 0000000000..d23c00f6f2 --- /dev/null +++ b/extensions/sql-migration/src/models/strings.ts @@ -0,0 +1,11 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as nls from 'vscode-nls'; +const localize = nls.loadMessageBundle(); + + +export const WIZARD_TITLE = localize('sql-migration.wizard.title', "SQL Migration Wizard"); +export const SOURCE_CONFIGURATION_PAGE_TITLE = localize('sql.migration.wizard.source_configuration.title', "SQL Source Configuration"); diff --git a/extensions/sql-migration/src/wizard/sourceConfigurationPage.ts b/extensions/sql-migration/src/wizard/sourceConfigurationPage.ts new file mode 100644 index 0000000000..222eff286a --- /dev/null +++ b/extensions/sql-migration/src/wizard/sourceConfigurationPage.ts @@ -0,0 +1,34 @@ +/*--------------------------------------------------------------------------------------------- + * 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 { MigrationWizardPage } from '../models/migrationWizardPage'; +import { SOURCE_CONFIGURATION_PAGE_TITLE } from '../models/strings'; +import { MigrationStateModel } from '../models/stateMachine'; + +export class SourceConfigurationPage extends MigrationWizardPage { + constructor(migrationStateModel: MigrationStateModel) { + super(azdata.window.createWizardPage(SOURCE_CONFIGURATION_PAGE_TITLE), migrationStateModel); + } + + public async registerWizardContent(): Promise { + return new Promise(async (resolve, reject) => { + this.wizardPage.registerContent(async (view) => { + try { + await this.registerContent(view); + resolve(); + } catch (ex) { + reject(ex); + } finally { + reject(new Error()); + } + }); + }); + } + + private async registerContent(view: azdata.ModelView) { + + } +} diff --git a/extensions/sql-migration/src/wizard/wizardController.ts b/extensions/sql-migration/src/wizard/wizardController.ts index f4af019e72..308305820c 100644 --- a/extensions/sql-migration/src/wizard/wizardController.ts +++ b/extensions/sql-migration/src/wizard/wizardController.ts @@ -2,6 +2,10 @@ * 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 { WIZARD_TITLE } from '../models/strings'; +import { SourceConfigurationPage } from './sourceConfigurationPage'; +import { MigrationStateModel } from '../models/stateMachine'; export class WizardController { constructor() { @@ -9,6 +13,12 @@ export class WizardController { } public async openWizard(): Promise { + } + + public async createWizard(): Promise { + azdata.window.createWizard(WIZARD_TITLE, 'wide'); + const stateModel = new MigrationStateModel({} as azdata.IConnectionProfile); + new SourceConfigurationPage(stateModel); } }