import * as parseXml from '../parser/types' ; import { WidgetModel , ExtraDataModel , AttributeModel , PropertyModel , AttributeInfo } from '../models/models' ; export abstract class CustomPropertyHandler { priority : number = 100 ; isElement = false ; elementAttributes : AttributeInfo [ ] ; valueSnippet : string ; documentation : string ; getRelatedProperties ( element , handlerProperty , widget ) { return [ ] ; } canResolvePropertyElement ( ) { return false ; } resolvePropertyElement ( element , widgetResolveResult , parent , parentChildren , resolveWidget ) { return null ; } canResolve ( element , handlerProperty , widget ) { return false ; } resolve ( element , attr , widget ) { return { wrapperWidget : null , value : attr . value , handled : false , extraData : null } ; } canGenerate ( widget ) { return false ; } generate ( widget , tabsLevel , generateChildWidgetCode , generatePropertyCode ) { return '' ; } } export class PropertyHandlerProvider { private readonly handlers : { [ name ] : CustomPropertyHandler ; } = { } ; register ( name , handler ) { if ( name instanceof Array ) { name . forEach ( n => this . handlers [ n ] = handler ) ; } else { this . handlers [ name ] = handler ; } } getAll ( ) { return this . handlers ; } get ( name ) { return this . handlers [ name ] ; } remove ( name ) { if ( name instanceof Array ) { name . forEach ( n => delete this . handlers [ n ] ) ; } else { delete this . handlers [ name ] ; } } } export interface PropertyResolveResult { wrapperWidget : WidgetModel | null ; extraData : ExtraDataModel | null ; value : string ; handled : boolean ; } export interface WidgetResolveResult { widget : WidgetModel ; isPropertyElement : boolean ; propertyElement : string ; propertyElementProperties : any [ ] ; }