<commit_before>import {Input, OnDestroy, AfterViewInit, Output, EventEmitter, NgModule, Component} from '@angular/core';
import {AbstractJigsawComponent} from "../common";
import {InternalUtils} from "../../core/utils/internal-utils";
import {CommonUtils} from "../../core/utils/common-utils";
import {ZTreeSettingSetting} from "./ztree-types";
import {TreeData} from "../../core/data/tree-data";
import {CallbackRemoval} from "../../core/utils/common-utils";

export class TreeEventData {
    treeId: string;
    treeNode: object;
    event?: Event;
    extraInfo?: object;
}


@Component({
    selector: 'jigsaw-tree-ext, j-tree-ext',
    template: `
        <div [id]="_$uniqueId" class="ztree"></div>`
})
export class JigsawTreeExt extends AbstractJigsawComponent implements AfterViewInit, OnDestroy {
    constructor() {
        super();
    }

    /**
     * @internal
     */
    public _$uniqueId: string = InternalUtils.createUniqueId();

    /**
     * @internal
     */
    private _setting: ZTreeSettingSetting = this._defaultSetting();

    @Input()
    public get setting(): ZTreeSettingSetting {
        return this._setting;
    }

    public set setting(setting: ZTreeSettingSetting) {
        this._setting = setting == null || CommonUtils.isEmptyObject(setting) ? this._defaultSetting() : setting;
        this._updateTree();
    }

    private _removeRefreshCallback: CallbackRemoval;

    private _data: TreeData;

    @Input()
    public get data(): TreeData {
        return this._data;
    }

    public set data(data: TreeData) {
        this._data = data;
        if (this._removeRefreshCallback) {
            this._removeRefreshCallback();
        }
        this._removeRefreshCallback = data.onRefresh(() => {
            this._updateTree();
        });
    }

    @Output()
    public onClick = new EventEmitter<TreeEventData>();<commit_msg>修复：#500 异步new TreeData在tree组件中会报错<commit_after>import {Input, OnDestroy, AfterViewInit, Output, EventEmitter, NgModule, Component} from '@angular/core';
import {AbstractJigsawComponent} from "../common";
import {InternalUtils} from "../../core/utils/internal-utils";
import {CommonUtils} from "../../core/utils/common-utils";
import {ZTreeSettingSetting} from "./ztree-types";
import {TreeData} from "../../core/data/tree-data";
import {CallbackRemoval} from "../../core/utils/common-utils";

export class TreeEventData {
    treeId: string;
    treeNode: object;
    event?: Event;
    extraInfo?: object;
}


@Component({
    selector: 'jigsaw-tree-ext, j-tree-ext',
    template: `
        <div [id]="_$uniqueId" class="ztree"></div>`
})
export class JigsawTreeExt extends AbstractJigsawComponent implements AfterViewInit, OnDestroy {
    constructor() {
        super();
    }

    /**
     * @internal
     */
    public _$uniqueId: string = InternalUtils.createUniqueId();

    /**
     * @internal
     */
    private _setting: ZTreeSettingSetting = this._defaultSetting();

    @Input()
    public get setting(): ZTreeSettingSetting {
        return this._setting;
    }

    public set setting(setting: ZTreeSettingSetting) {
        this._setting = setting == null || CommonUtils.isEmptyObject(setting) ? this._defaultSetting() : setting;
        this._updateTree();
    }

    private _removeRefreshCallback: CallbackRemoval;

    private _data: TreeData;

    @Input()
    public get data(): TreeData {
        return this._data;
    }

    public set data(data: TreeData) {
        if(!(data instanceof TreeData)) return;
        this._data = data;
        if (this._removeRefreshCallback) {
            this._removeRefreshCallback();
        }
        this._removeRefreshCallback = data.onRefresh(() => {
            this._updateTree();
        });
    }

    @Output()
    public onClick = new EventEmitter<TreeEventData>();
{'fraction_non_alphanumeric': 0.13700787401574804, 'fraction_numerical': 0.0007874015748031496, 'mean_word_length': 2.9905759162303664, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1197591', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1078, 'n_words': 247}