license import { BaseTreeControl } from './base-tree-control' ; /** Flat tree control. Able to expand/collapse a subtree recursively for flattened tree. */ export class FlatTreeControl < T > extends BaseTreeControl < T > { /** Construct with flat tree data node functions getLevel and isExpandable. */ constructor ( public getLevel , public isExpandable ) { super ( ) ; } /**
     * Gets a list of the data node's subtree of descendent data nodes.
     *
     * To make this working, the `dataNodes` of the TreeControl must be flattened tree nodes
     * with correct levels.
     */ getDescendants ( dataNode ) { const startIndex = this . dataNodes . indexOf ( dataNode ) ; const results = [ ] ; for ( let i = startIndex + 1 ; i < this . dataNodes . length && this . getLevel ( dataNode ) < this . getLevel ( this . dataNodes [ i ] ) ; i ++ ) { results . push ( this . dataNodes [ i ] ) ; } return results ; } /**
     * Expands all data nodes in the tree.
     *
     * To make this working, the `dataNodes` variable of the TreeControl must be set to all flattened
     * data nodes of the tree.
     */ expandAll ( ) { this . expansionModel . select ( ... this . dataNodes ) ; } }