import * as path from 'path' ; import { DevToolsExtensionContext } from "../../devToolsExtensionContext" ; import { ALObjectWizardSettings } from "./alObjectWizardSettings" ; import { ALPageExtWizardData } from './alPageExtWizardData' ; import { ALPageExtSyntaxBuilder } from '../syntaxbuilders/alPageExtSyntaxBuilder' ; import { ProjectItemWizardPage } from './projectItemWizardPage' ; import { ToolsSymbolInformationRequest } from '../../langserver/symbolsinformation/toolsSymbolInformationRequest' ; import { SymbolWithNameInformation } from '../../symbolsinformation/smbolWithNameInformation' ; export class ALPageExtWizardPage extends ProjectItemWizardPage { protected _pageExtWizardData : ALPageExtWizardData ; constructor ( toolsExtensionContext , settings , data ) { super ( toolsExtensionContext , "AL Page Extension Wizard" , settings ) ; this . _pageExtWizardData = data ; } protected onDocumentLoaded ( ) { this . sendMessage ( { command : 'setData' , data : this . _pageExtWizardData } ) ; this . loadPages ( ) ; } protected getHtmlContentPath ( ) { return path . join ( 'htmlresources' , 'alpageextwizard' , 'alpageextwizard.html' ) ; } protected getViewType ( ) { return "azALDevTools.ALPageExtWizard" ; } protected processWebViewMessage ( message ) { if ( super . processWebViewMessage ( message ) ) { return true ; } switch ( message . command ) { case 'loadPages' : this . loadPages ( ) ; return true ; } return false ; } protected async finishWizard ( data ) { this . _pageExtWizardData . objectId = data . objectId ; this . _pageExtWizardData . objectName = data . objectName ; this . _pageExtWizardData . basePage = data . basePage ; let builder = new ALPageExtSyntaxBuilder ( ) ; let source = await builder . buildFromPageExtWizardData ( this . _settings . getDestDirectoryUri ( ) , this . _pageExtWizardData ) ; this . createObjectExtensionFile ( 'PageExtension' , this . _pageExtWizardData . objectId , this . _pageExtWizardData . objectName , this . _pageExtWizardData . basePage , source ) ; return true ; } protected async loadPages ( ) { let response = await this . _toolsExtensionContext . toolsLangServerClient . getPagesList ( new ToolsSymbolInformationRequest ( this . _settings . getDestDirectoryPath ( ) , false ) ) ; if ( response ) this . _pageExtWizardData . pageList = SymbolWithNameInformation . toNamesList ( response . symbols ) ; if ( ( this . _pageExtWizardData . pageList ) && ( this . _pageExtWizardData . pageList . length > 0 ) ) { this . sendMessage ( { command : "setPages" , data : this . _pageExtWizardData . pageList } ) ; } } }