<commit_before>import {ComponentRef, ViewContainerRef, Injectable, ComponentFactoryResolver} from "@angular/core";
import {IComponent, Bean}  from "ag-grid/main";
import {FrameworkComponentWrapper}  from 'ag-grid';
import {AgFrameworkComponent} from "./interfaces";

@Injectable()
@Bean("frameworkComponentWrapper")
export class Ng2FrameworkComponentWrapper implements FrameworkComponentWrapper {
    private viewContainerRef: ViewContainerRef;
    private componentFactoryResolver: ComponentFactoryResolver;

    public setViewContainerRef(viewContainerRef: ViewContainerRef) {
        this.viewContainerRef = viewContainerRef;
    }

    public setComponentFactoryResolver(componentFactoryResolver: ComponentFactoryResolver) {
        this.componentFactoryResolver = componentFactoryResolver;
    }

    wrap <A extends IComponent<any>>(Ng2Component: {new (): any}, mandatoryMethodList: string[], optionalMethodList?: string[]): A {
        let that = this;
        class DynamicAgNg2Component extends BaseGuiComponent<any, AgFrameworkComponent<any>> {
            init(params: any): void {
                super.init(params);
                this._componentRef.changeDetectorRef.detectChanges();
            }

            protected createComponent(): ComponentRef<AgFrameworkComponent<any>> {
                return that.createComponent(Ng2Component,
                    that.viewContainerRef);
            }

        }

        function addMethod(wrapper: DynamicAgNg2Component, methodName:string, mandatory:boolean) {
            let methodProxy: Function = function () {
                if (wrapper.getFrameworkComponentInstance()[methodName]) {
                    var componentRef = this.getFrameworkComponentInstance();
                    return wrapper.getFrameworkComponentInstance()[methodName].apply(componentRef, arguments)
                } else {
                    if (mandatory){
                        console.warn('ag-Grid: Angular component is missing the method ' + methodName + '()');
                    }
                    return null;
                }
            };

            wrapper[methodName] = methodProxy
        }
        let wrapper: DynamicAgNg2Component = new DynamicAgNg2Component();
        mandatoryMethodList.forEach((methodName => {
            addMethod(wrapper, methodName, true);
        }));

        if (optionalMethodList){
            optionalMethodList.forEach((methodName => {
                addMethod(wrapper, methodName, false);
            }));
        }


        return <A><any>wrapper;

    }

<commit_msg>AG-618 Fixing floating filter issue. Also allowing for gulp watch of Angular and React<commit_after>import {ComponentRef, ViewContainerRef, Injectable, ComponentFactoryResolver} from "@angular/core";
import {IComponent, Bean}  from "ag-grid/main";
import {FrameworkComponentWrapper, BaseComponentWrapper, WrapableInterface}  from 'ag-grid';
import {AgFrameworkComponent} from "./interfaces";

@Injectable()
@Bean("frameworkComponentWrapper")
export class Ng2FrameworkComponentWrapper extends BaseComponentWrapper<WrapableInterface> implements FrameworkComponentWrapper {
    private viewContainerRef: ViewContainerRef;
    private componentFactoryResolver: ComponentFactoryResolver;

    public setViewContainerRef(viewContainerRef: ViewContainerRef) {
        this.viewContainerRef = viewContainerRef;
    }

    public setComponentFactoryResolver(componentFactoryResolver: ComponentFactoryResolver) {
        this.componentFactoryResolver = componentFactoryResolver;
    }

    createWrapper(OriginalConstructor: { new (): any }): WrapableInterface{
        let that = this;
        class DynamicAgNg2Component extends BaseGuiComponent<any, AgFrameworkComponent<any>> implements WrapableInterface{
            init(params: any): void {
                super.init(params);
                this._componentRef.changeDetectorRef.detectChanges();
            }

            protected createComponent(): ComponentRef<AgFrameworkComponent<any>> {
                return that.createComponent(OriginalConstructor,
                    that.viewContainerRef);
            }

            hasMethod(name: string): boolean{
                return wrapper.getFrameworkComponentInstance()[name] != null;
            }

            callMethod(name: string, args: IArguments): void{
                var componentRef = this.getFrameworkComponentInstance();
                return wrapper.getFrameworkComponentInstance()[name].apply(componentRef, args)

            }
            addMethod(name:string, callback:Function): void {
                wrapper[name] = callback
            }
        }

        let wrapper: DynamicAgNg2Component = new DynamicAgNg2Component();
        return wrapper;

    }


{'fraction_non_alphanumeric': 0.08555812486861468, 'fraction_numerical': 0.00294303132226193, 'mean_word_length': 2.8809135399673735, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 18, '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': '3934877', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1079, 'n_words': 236}