<commit_before>import { DragAndDropService, DraggingEvent, DragSourceType, DropTarget } from "../dragAndDrop/dragAndDropService";
import { Autowired, Context, PostConstruct } from "../context/context";
import { MoveColumnController } from "./moveColumnController";
import { Column } from "../entities/column";
import { GridPanel } from "../gridPanel/gridPanel";
import { BodyDropPivotTarget } from "./bodyDropPivotTarget";
import { ColumnController } from "../columnController/columnController";
import {Constants} from "../constants";

export interface DropListener {
    getIconName(): string;
    onDragEnter(params: DraggingEvent): void;
    onDragLeave(params: DraggingEvent): void;
    onDragging(params: DraggingEvent): void;
    onDragStop(params: DraggingEvent): void;
}

enum DropType { ColumnMove, Pivot }

export class BodyDropTarget implements DropTarget {

    @Autowired('context') private context: Context;
    @Autowired('dragAndDropService') private dragAndDropService: DragAndDropService;
    @Autowired('columnController') private columnController: ColumnController;

    private gridPanel: GridPanel;

    private pinned: string;

    // public because it's part of the DropTarget interface
    private eContainer: HTMLElement;

    // public because it's part of the DropTarget interface
    private eSecondaryContainers: HTMLElement[];

    private dropListeners: {[type: number]: DropListener} = {};

    private currentDropListener: DropListener;

    private moveColumnController: MoveColumnController;

    constructor(pinned: string, eContainer: HTMLElement) {
        this.pinned = pinned;
        this.eContainer = eContainer;
    }

    public registerGridComp(gridPanel: GridPanel): void {
        this.gridPanel = gridPanel;

        this.moveColumnController.registerGridComp(gridPanel);

        switch (this.pinned) {
            case Constants.PINNED_LEFT: this.eSecondaryContainers = this.gridPanel.getDropTargetLeftContainers(); break;
            case Constants.PINNED_RIGHT: this.eSecondaryContainers = this.gridPanel.getDropTargetRightContainers(); break;
            default: this.eSecondaryContainers = this.gridPanel.getDropTargetBodyContainers(); break;
        }
    }

    public isInterestedIn(type: DragSourceType): boolean {
        // not interested in row drags
        return type === DragSourceType.HeaderCell || type === DragSourceType.ToolPanel;
    }

    public getSecondaryContainers(): HTMLElement[] {
        return this.eSecondaryContainers;
    }

    public getContainer(): HTMLElement {
        return this.eContainer;
    }

    @PostConstruct
    private init(): void {

        this.moveColumnController = new MoveColumnController(this.pinned, this.eContainer);
        this.context.wireBean(this.moveColumnController);<commit_msg>AG-2764 - prevent dragging columns from toolpanel to grid<commit_after>import { DragAndDropService, DraggingEvent, DragSourceType, DropTarget } from "../dragAndDrop/dragAndDropService";
import { Autowired, Context, PostConstruct } from "../context/context";
import { MoveColumnController } from "./moveColumnController";
import { Column } from "../entities/column";
import { GridPanel } from "../gridPanel/gridPanel";
import { BodyDropPivotTarget } from "./bodyDropPivotTarget";
import { ColumnController } from "../columnController/columnController";
import {Constants} from "../constants";

export interface DropListener {
    getIconName(): string;
    onDragEnter(params: DraggingEvent): void;
    onDragLeave(params: DraggingEvent): void;
    onDragging(params: DraggingEvent): void;
    onDragStop(params: DraggingEvent): void;
}

enum DropType { ColumnMove, Pivot }

export class BodyDropTarget implements DropTarget {

    @Autowired('context') private context: Context;
    @Autowired('dragAndDropService') private dragAndDropService: DragAndDropService;
    @Autowired('columnController') private columnController: ColumnController;

    private gridPanel: GridPanel;

    private pinned: string;

    // public because it's part of the DropTarget interface
    private eContainer: HTMLElement;

    // public because it's part of the DropTarget interface
    private eSecondaryContainers: HTMLElement[];

    private dropListeners: {[type: number]: DropListener} = {};

    private currentDropListener: DropListener;

    private moveColumnController: MoveColumnController;

    constructor(pinned: string, eContainer: HTMLElement) {
        this.pinned = pinned;
        this.eContainer = eContainer;
    }

    public registerGridComp(gridPanel: GridPanel): void {
        this.gridPanel = gridPanel;

        this.moveColumnController.registerGridComp(gridPanel);

        switch (this.pinned) {
            case Constants.PINNED_LEFT: this.eSecondaryContainers = this.gridPanel.getDropTargetLeftContainers(); break;
            case Constants.PINNED_RIGHT: this.eSecondaryContainers = this.gridPanel.getDropTargetRightContainers(); break;
            default: this.eSecondaryContainers = this.gridPanel.getDropTargetBodyContainers(); break;
        }
    }

    public isInterestedIn(type: DragSourceType): boolean {
        // not interested in row or toolpanel column drags
        return type === DragSourceType.HeaderCell;
    }

    public getSecondaryContainers(): HTMLElement[] {
        return this.eSecondaryContainers;
    }

    public getContainer(): HTMLElement {
        return this.eContainer;
    }

    @PostConstruct
    private init(): void {

        this.moveColumnController = new MoveColumnController(this.pinned, this.eContainer);
        this.context.wireBean(this.moveColumnController);
{'fraction_non_alphanumeric': 0.09596587879864937, 'fraction_numerical': 0.0007108583614714769, 'mean_word_length': 4.056603773584905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4333566', 'n_tokens_mistral': 1487, 'n_tokens_neox': 1459, 'n_words': 363}