'use strict' ; import * as path from 'path' ; import { ProjectItemWizardPage } from './projectItemWizardPage' ; import { ALEnumExtWizardData } from './alEnumExtWizardData' ; import { ALEnumExtSyntaxBuilder } from '../syntaxbuilders/alEnumExtSyntaxBuilder' ; import { DevToolsExtensionContext } from '../../devToolsExtensionContext' ; import { ALObjectWizardSettings } from './alObjectWizardSettings' ; import { SymbolWithNameInformation } from '../../symbolsinformation/smbolWithNameInformation' ; export class ALEnumExtWizardPage extends ProjectItemWizardPage { private _enumExtWizardData : ALEnumExtWizardData ; constructor ( toolsExtensionContext , settings , data ) { super ( toolsExtensionContext , "AL Enum Extension Wizard" , settings ) ; this . _enumExtWizardData = data ; } protected onDocumentLoaded ( ) { this . sendMessage ( { command : 'setData' , data : this . _enumExtWizardData } ) ; if ( ( this . _enumExtWizardData . baseEnumList == null ) || ( this . _enumExtWizardData . baseEnumList . length == 0 ) ) this . loadBaseEnums ( ) ; } protected async loadBaseEnums ( ) { let response = await this . _toolsExtensionContext . toolsLangServerClient . getEnumsList ( { path : this . _settings . getDestDirectoryPath ( ) , includeNonAccessible : false } ) ; if ( response ) this . _enumExtWizardData . baseEnumList = SymbolWithNameInformation . toNamesList ( response . symbols ) ; else this . _enumExtWizardData . baseEnumList = [ ] ; this . sendMessage ( { command : "setEnums" , data : this . _enumExtWizardData . baseEnumList } ) ; } protected getHtmlContentPath ( ) { return path . join ( 'htmlresources' , 'alenumextwizard' , 'alenumextwizard.html' ) ; } protected getViewType ( ) { return "azALDevTools.ALEnumExtWizard" ; } protected async finishWizard ( data ) { this . _enumExtWizardData . objectId = data . objectId ; this . _enumExtWizardData . objectName = data . objectName ; this . _enumExtWizardData . baseEnum = data . baseEnum ; this . _enumExtWizardData . valueList = data . valueList ; this . _enumExtWizardData . captionList = data . captionList ; let firstValueId = Number . parseInt ( data . firstValueId ) ; if ( Number . isNaN ( firstValueId ) ) this . _enumExtWizardData . firstValueId = 0 ; else this . _enumExtWizardData . firstValueId = firstValueId ; let builder = new ALEnumExtSyntaxBuilder ( ) ; let source = builder . buildFromEnumExtWizardData ( this . _settings . getDestDirectoryUri ( ) , this . _enumExtWizardData ) ; this . createObjectExtensionFile ( 'EnumExtension' , this . _enumExtWizardData . objectId , this . _enumExtWizardData . objectName , this . _enumExtWizardData . baseEnum , source ) ; return true ; } }