UNPKG

dadou-json-editor

Version:

Angular 8 with Electron (Typescript + SASS + Hot Reload)

63 lines (58 loc) 2.05 kB
import { ConfigArbre , Arbre , Objet , Tableau , TypeService, Chemin, ValeurString, Feuille, Propriete} from 'dadou-tree'; export class ConfigTypes extends ConfigArbre { afficher(noeud: Arbre): string { if (noeud instanceof Objet) { if (noeud.estOuvert) { return null; } const prop:Propriete =noeud.proprietes.find( (c)=>{return c.nom ==='nom'}); if (prop) { if (prop.valeur instanceof ValeurString) { return prop.valeur.contenu; } } return noeud.type; } return null; } estTable(tableau: Tableau, typeService: TypeService): boolean { if (tableau.typeBase === 'TypeDef') { return false; } return true; } nomTypes( racine: Arbre , noms: string[]) { if (racine instanceof Objet) { racine.proprietes.forEach( prop => { if (prop.nom === 'types') { if (prop.valeur instanceof Tableau) { prop.valeur.valeurs.forEach (element => { this.nomTypes(element, noms); }); } } if (prop.nom === 'nom') { if (prop.valeur instanceof ValeurString) { noms.push(prop.valeur.contenu); } } if (prop.nom === 'sousTypes') { if (prop.valeur instanceof Tableau) { prop.valeur.valeurs.forEach( arbre => { this.nomTypes(arbre, noms); } ); } } }); } } choix(racine: Arbre, chemin: Chemin): string[] { if (chemin.parent) { if (chemin.parent.arbre instanceof Objet) { if (chemin.parent.arbre.type === 'TypeRef' ) { const ls: string [] = []; this.nomTypes(racine , ls); return ls; } } } } }