import * as vscode from 'vscode' ; import { FileBuilder } from '../fileBuilder' ; import { AZSymbolInformation } from '../../symbollibraries/azSymbolInformation' ; import { AZSymbolKind } from '../../symbollibraries/azSymbolKind' ; import { ALSymbolsBasedWizard } from './alSymbolsBasedWizard' ; import { ALSyntaxWriter } from '../../allanguage/alSyntaxWriter' ; import { DevToolsExtensionContext } from '../../devToolsExtensionContext' ; export class ALSymbolsBasedPageExtWizard extends ALSymbolsBasedWizard { constructor ( context ) { super ( context ) ; } async showWizard ( symbols ) { if ( symbols . length == 1 ) await this . showPageExtWizard ( symbols [ 0 ] ) ; else await this . showMultiPageExtWizard ( symbols ) ; } async showMultiPageExtWizard ( pageSymbols ) { if ( ! FileBuilder . checkCrsExtensionFileNamePatternRequired ( ) || ! FileBuilder . checkCrsExtensionObjectNamePatternRequired ( true ) ) return ; const extObjType = AZSymbolKind . PageExtensionObject ; let relativeFileDir = await this . getRelativeFileDir ( extObjType ) ; let startObjectId = await this . getObjectId ( relativeFileDir , "pageextension" , "Please enter a starting ID for the page extensions." , 0 ) ; if ( startObjectId < 0 ) { return ; } for ( let i = 0 ; i < pageSymbols . length ; i ++ ) { let pageSymbol = pageSymbols [ i ] ; let extObjectId = startObjectId + i ; let extObjectName = await FileBuilder . getPatternGeneratedExtensionObjectName ( extObjType , extObjectId , pageSymbol ) ; await this . createAndShowNewPageExtension ( pageSymbol , extObjType , extObjectId , extObjectName , relativeFileDir ) ; } } async showPageExtWizard ( pageSymbol ) { if ( ! FileBuilder . checkCrsExtensionFileNamePatternRequired ( ) || ! FileBuilder . checkCrsExtensionObjectNamePatternRequired ( false ) ) return ; const extObjType = AZSymbolKind . PageExtensionObject ; let relativeFileDir = await this . getRelativeFileDir ( extObjType ) ; let extObjectId = await this . getObjectId ( relativeFileDir , "pageextension" , "Please enter an ID for the page extension." , 0 ) ; if ( extObjectId < 0 ) { return ; } let extObjectName = await FileBuilder . getPatternGeneratedExtensionObjectName ( extObjType , extObjectId , pageSymbol ) ; if ( ! extObjectName ) extObjectName = pageSymbol . name + ' Extension' ; extObjectName = await this . getObjectName ( "Please enter a name for the page extension." , extObjectName ) ; if ( ! extObjectName ) { return ; } await this . createAndShowNewPageExtension ( pageSymbol , extObjType , extObjectId , extObjectName , relativeFileDir ) ; } private async createAndShowNewPageExtension ( pageSymbol , extObjType , extObjectId , extObjectName , relativeFileDir ) { let fileName = await FileBuilder . getPatternGeneratedExtensionObjectFileName ( extObjType , extObjectId , extObjectName , pageSymbol ) ; this . showNewDocument ( this . buildPageExtForPage ( pageSymbol , extObjectId , extObjectName ) , fileName , relativeFileDir ) ; } private buildPageExtForPage ( pageSymbol , objectId , extObjectName ) { let writer = new ALSyntaxWriter ( undefined ) ; writer . writeStartExtensionObject ( "pageextension" , objectId . toString ( ) , extObjectName , pageSymbol . name ) ; writer . writeStartLayout ( ) ; writer . writeLine ( "" ) ; writer . writeEndLayout ( ) ; writer . writeLine ( "" ) ; writer . writeStartActions ( ) ; writer . writeLine ( "" ) ; writer . writeEndActions ( ) ; writer . writeEndObject ( ) ; return writer . toWizardGeneratedString ( ) ; } }