import * as vscode from 'vscode' ; import { ALXmlPortWizardData } from "../wizards/alXmlPortWizardData" ; import { ALSyntaxWriter } from "../../allanguage/alSyntaxWriter" ; import { ALSyntaxHelper } from '../../allanguage/alSyntaxHelper' ; export class ALXmlPortSyntaxBuilder { constructor ( ) { } buildFromXmlPortWizardData ( destUri , data ) { let writer = new ALSyntaxWriter ( destUri ) ; writer . writeStartObject ( "xmlport" , data . objectId , data . objectName ) ; writer . addProperty ( "Caption" , writer . encodeString ( ALSyntaxHelper . removePrefixSuffix ( data . objectName , data . projectSettings ) ) ) ; writer . writeProperties ( ) ; this . writeSchema ( writer , data ) ; if ( data . createRequestPage ) this . writeRequestPage ( writer ) ; writer . writeEndObject ( ) ; return writer . toWizardGeneratedString ( ) ; } private writeSchema ( writer , data ) { let tableElementName = writer . createName ( data . selectedTable ) ; let fieldNodeName ; if ( data . fieldNodeType == "element" ) fieldNodeName = "fieldelement" ; else fieldNodeName = "fieldattribute" ; writer . writeStartNamedBlock ( "schema" ) ; writer . writeStartGroup ( "textelement" , "RootNodeName" ) ; writer . writeStartNameSourceBlock ( "tableelement" , tableElementName , writer . encodeName ( data . selectedTable ) ) ; if ( data . selectedFieldList ) { for ( let i = 0 ; i < data . selectedFieldList . length ; i ++ ) { writer . writeNameSourceBlock ( fieldNodeName , writer . createName ( data . selectedFieldList [ i ] . name ! ) , tableElementName + "." + writer . encodeName ( data . selectedFieldList [ i ] . name ! ) ) ; } } writer . writeEndBlock ( ) ; writer . writeEndBlock ( ) ; writer . writeEndBlock ( ) ; } private writeRequestPage ( writer ) { writer . writeStartNamedBlock ( "requestpage" ) ; writer . writeStartLayout ( ) ; writer . writeStartGroup ( "area" , "content" ) ; writer . writeStartGroup ( "group" , "GroupName" ) ; writer . writeEndBlock ( ) ; writer . writeEndBlock ( ) ; writer . writeEndLayout ( ) ; writer . writeStartNamedBlock ( "actions" ) ; writer . writeStartGroup ( "area" , "processing" ) ; writer . writeEndBlock ( ) ; writer . writeEndBlock ( ) ; writer . writeEndBlock ( ) ; } }