<commit_before>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import * as nls from 'vs/nls';
import { Action, IAction } from 'vs/base/common/actions';
import { illegalArgument } from 'vs/base/common/errors';
import * as arrays from 'vs/base/common/arrays';
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { IBadge } from 'vs/workbench/services/activity/common/activity';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ActionBar, ActionsOrientation, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { CompositeActionViewItem, CompositeOverflowActivityAction, ICompositeActivity, CompositeOverflowActivityActionViewItem, ActivityAction, ICompositeBar, ICompositeBarColors, DraggedCompositeIdentifier } from 'vs/workbench/browser/parts/compositeBarActions';
import { Dimension, $, addDisposableListener, EventType, EventHelper } from 'vs/base/browser/dom';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { Widget } from 'vs/base/browser/ui/widget';
import { isUndefinedOrNull } from 'vs/base/common/types';
import { LocalSelectionTransfer } from 'vs/workbench/browser/dnd';
import { ITheme } from 'vs/platform/theme/common/themeService';
import { Emitter } from 'vs/base/common/event';
import { DraggedViewIdentifier } from 'vs/workbench/browser/parts/views/viewPaneContainer';
import { Registry } from 'vs/platform/registry/common/platform';
import { IViewContainersRegistry, Extensions as ViewContainerExtensions, ViewContainerLocation, IViewDescriptorService } from 'vs/workbench/common/views';
import { ICompositeDragAndDrop, CompositeDragAndDropData } from 'vs/base/parts/composite/browser/compositeDnd';
import { IPaneComposite } from 'vs/workbench/common/panecomposite';

export interface ICompositeBarItem {
	id: string;
	name?: string;
	pinned: boolean;
	order?: number;
	visible: boolean;
}

export class CompositeDragAndDrop implements ICompositeDragAndDrop {

	constructor(
		private viewDescriptorService: IViewDescriptorService,
		private targetContainerLocation: ViewContainerLocation,
		private openComposite: (id: string, focus?: boolean) => Promise<IPaneComposite | undefined>,
		private moveComposite: (from: string, to: string) => void,
		private getVisibleCompositeIds: () => string[]
	) { }
	drop(data: CompositeDragAndDropData, targetCompositeId: string | undefined, originalEvent: DragEvent): void {
		const dragData = data.getData();
		const viewContainerRegistry = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry);

		if (dragData.type === 'composite') {
			const currentContainer = viewContainerRegistry.get(dragData.id)!;
			const currentLocation = viewContainerRegistry.getViewContainerLocation(currentContainer);
			if (targetCompositeId) {
				if (currentLocation !== this.targetContainerLocation && this.targetContainerLocation !== ViewContainerLocation.Panel) {
					const destinationContainer = viewContainerRegistry.get(targetCompositeId);
					if (destinationContainer && !destinationContainer.rejectAddedViews) {
						this.viewDescriptorService.moveViewsToContainer(this.viewDescriptorService.getViewDescriptors(currentContainer)!.allViewDescriptors.filter(vd => vd.canMoveView), destinationContainer);
						this.openComposite(targetCompositeId, true);
					}
				} else {
					this.moveComposite(dragData.id, targetCompositeId);
				}
			} else {
				const draggedViews = this.viewDescriptorService.getViewDescriptors(currentContainer).allViewDescriptors;
				if (draggedViews.length === 1 && draggedViews[0].canMoveView) {
					dragData.type = 'view';
					dragData.id = draggedViews[0].id;
				}
			}
		}

		if (dragData.type === 'view') {
			const viewDescriptor = this.viewDescriptorService.getViewDescriptor(dragData.id);
			if (viewDescriptor && viewDescriptor.canMoveView) {
				if (targetCompositeId) {
					const destinationContainer = viewContainerRegistry.get(targetCompositeId);
					if (destinationContainer && !destinationContainer.rejectAddedViews) {
						if (this.targetContainerLocation === ViewContainerLocation.Sidebar) {
							this.viewDescriptorService.moveViewsToContainer([viewDescriptor], destinationContainer);
							this.openComposite(targetCompositeId, true).then(composite => {
								if (composite) {<commit_msg>refs #91630<commit_after>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import * as nls from 'vs/nls';
import { Action, IAction } from 'vs/base/common/actions';
import { illegalArgument } from 'vs/base/common/errors';
import * as arrays from 'vs/base/common/arrays';
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { IBadge } from 'vs/workbench/services/activity/common/activity';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ActionBar, ActionsOrientation, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { CompositeActionViewItem, CompositeOverflowActivityAction, ICompositeActivity, CompositeOverflowActivityActionViewItem, ActivityAction, ICompositeBar, ICompositeBarColors, DraggedCompositeIdentifier } from 'vs/workbench/browser/parts/compositeBarActions';
import { Dimension, $, addDisposableListener, EventType, EventHelper } from 'vs/base/browser/dom';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { Widget } from 'vs/base/browser/ui/widget';
import { isUndefinedOrNull } from 'vs/base/common/types';
import { LocalSelectionTransfer } from 'vs/workbench/browser/dnd';
import { ITheme } from 'vs/platform/theme/common/themeService';
import { Emitter } from 'vs/base/common/event';
import { DraggedViewIdentifier } from 'vs/workbench/browser/parts/views/viewPaneContainer';
import { Registry } from 'vs/platform/registry/common/platform';
import { IViewContainersRegistry, Extensions as ViewContainerExtensions, ViewContainerLocation, IViewDescriptorService } from 'vs/workbench/common/views';
import { ICompositeDragAndDrop, CompositeDragAndDropData } from 'vs/base/parts/composite/browser/compositeDnd';
import { IPaneComposite } from 'vs/workbench/common/panecomposite';

export interface ICompositeBarItem {
	id: string;
	name?: string;
	pinned: boolean;
	order?: number;
	visible: boolean;
}

export class CompositeDragAndDrop implements ICompositeDragAndDrop {

	constructor(
		private viewDescriptorService: IViewDescriptorService,
		private targetContainerLocation: ViewContainerLocation,
		private openComposite: (id: string, focus?: boolean) => Promise<IPaneComposite | undefined>,
		private moveComposite: (from: string, to: string) => void,
		private getVisibleCompositeIds: () => string[]
	) { }
	drop(data: CompositeDragAndDropData, targetCompositeId: string | undefined, originalEvent: DragEvent): void {
		const dragData = data.getData();
		const viewContainerRegistry = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry);

		if (dragData.type === 'composite') {
			const currentContainer = viewContainerRegistry.get(dragData.id)!;
			const currentLocation = viewContainerRegistry.getViewContainerLocation(currentContainer);
			if (targetCompositeId) {
				if (currentLocation !== this.targetContainerLocation && this.targetContainerLocation !== ViewContainerLocation.Panel) {
					const destinationContainer = viewContainerRegistry.get(targetCompositeId);
					if (destinationContainer && !destinationContainer.rejectAddedViews) {
						const viewsToMove = this.viewDescriptorService.getViewDescriptors(currentContainer)!.allViewDescriptors.filter(vd => vd.canMoveView);
						this.viewDescriptorService.moveViewsToContainer(viewsToMove, destinationContainer);
						this.openComposite(targetCompositeId, true).then(composite => {
							if (composite && viewsToMove.length === 1) {
								composite.openView(viewsToMove[0].id, true);
							}
						});
					}
				} else {
					this.moveComposite(dragData.id, targetCompositeId);
				}
			} else {
				const draggedViews = this.viewDescriptorService.getViewDescriptors(currentContainer).allViewDescriptors;
				if (draggedViews.length === 1 && draggedViews[0].canMoveView) {
					dragData.type = 'view';
					dragData.id = draggedViews[0].id;
				}
			}
		}

		if (dragData.type === 'view') {
			const viewDescriptor = this.viewDescriptorService.getViewDescriptor(dragData.id);
			if (viewDescriptor && viewDescriptor.canMoveView) {
				if (targetCompositeId) {
					const destinationContainer = viewContainerRegistry.get(targetCompositeId);
					if (destinationContainer && !destinationContainer.rejectAddedViews) {
						if (this.targetContainerLocation === ViewContainerLocation.Sidebar) {
							this.viewDescriptorService.moveViewsToContainer([viewDescriptor], destinationContainer);
							this.openComposite(targetCompositeId, true).then(composite => {
								if (composite) {
{'fraction_non_alphanumeric': 0.141137401411374, 'fraction_numerical': 0.0013491075134910752, 'mean_word_length': 4.5480713874496255, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5620692', 'n_tokens_mistral': 2817, 'n_tokens_neox': 2545, 'n_words': 524}