4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import 'vs/css!./media/editordroptarget' ;
7
- import { LocalSelectionTransfer , DraggedEditorIdentifier , ResourcesDropHandler , DraggedEditorGroupIdentifier , DragAndDropObserver , containsDragType , CodeDataTransfers , extractFilesDropData } from 'vs/workbench/browser/dnd' ;
7
+ import { LocalSelectionTransfer , DraggedEditorIdentifier , ResourcesDropHandler , DraggedEditorGroupIdentifier , DragAndDropObserver , containsDragType , CodeDataTransfers , extractFilesDropData , DraggedExtensionTreeItemsIdentifier } from 'vs/workbench/browser/dnd' ;
8
8
import { addDisposableListener , EventType , EventHelper , isAncestor } from 'vs/base/browser/dom' ;
9
9
import { IEditorGroupsAccessor , IEditorGroupView , fillActiveEditorViewState } from 'vs/workbench/browser/parts/editor/editor' ;
10
10
import { EDITOR_DRAG_AND_DROP_BACKGROUND } from 'vs/workbench/common/theme' ;
@@ -21,6 +21,8 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
21
21
import { assertIsDefined , assertAllDefined } from 'vs/base/common/types' ;
22
22
import { Schemas } from 'vs/base/common/network' ;
23
23
import { URI } from 'vs/base/common/uri' ;
24
+ import { ITreeViewsDragAndDropService } from 'vs/workbench/services/views/common/treeViewsDragAndDropService' ;
25
+ import { ITreeDataTransfer } from 'vs/workbench/common/views' ;
24
26
25
27
interface IDropOperation {
26
28
splitDirection ?: GroupDirection ;
@@ -40,14 +42,16 @@ class DropOverlay extends Themable {
40
42
41
43
private readonly editorTransfer = LocalSelectionTransfer . getInstance < DraggedEditorIdentifier > ( ) ;
42
44
private readonly groupTransfer = LocalSelectionTransfer . getInstance < DraggedEditorGroupIdentifier > ( ) ;
45
+ private readonly treeItemsTransfer = LocalSelectionTransfer . getInstance < DraggedExtensionTreeItemsIdentifier > ( ) ;
43
46
44
47
constructor (
45
48
private accessor : IEditorGroupsAccessor ,
46
49
private groupView : IEditorGroupView ,
47
50
@IThemeService themeService : IThemeService ,
48
51
@IInstantiationService private instantiationService : IInstantiationService ,
49
52
@IEditorService private readonly editorService : IEditorService ,
50
- @IEditorGroupsService private readonly editorGroupService : IEditorGroupsService
53
+ @IEditorGroupsService private readonly editorGroupService : IEditorGroupsService ,
54
+ @ITreeViewsDragAndDropService private readonly treeViewsDragAndDropService : ITreeViewsDragAndDropService < ITreeDataTransfer >
51
55
) {
52
56
super ( themeService ) ;
53
57
@@ -292,6 +296,24 @@ class DropOverlay extends Themable {
292
296
}
293
297
}
294
298
299
+ // Check for tree items
300
+ else if ( this . treeItemsTransfer . hasData ( DraggedExtensionTreeItemsIdentifier . prototype ) ) {
301
+ const data = this . treeItemsTransfer . getData ( DraggedExtensionTreeItemsIdentifier . prototype ) ;
302
+ if ( Array . isArray ( data ) ) {
303
+ const treeData = Promise . all (
304
+ data . map ( id => this . treeViewsDragAndDropService . removeDragOperationTransfer ( id . identifier ) ) ) ;
305
+ treeData . then ( dataTransferItems => {
306
+ const dropHandler = this . instantiationService . createInstance ( ResourcesDropHandler , { allowWorkspaceOpen : true /* open workspace instead of file if dropped */ } ) ;
307
+ dataTransferItems . forEach ( dataTransferItem => {
308
+ if ( dataTransferItem ) {
309
+ dropHandler . handleDrop ( dataTransferItem , ( ) => ensureTargetGroup ( ) , targetGroup => targetGroup ?. focus ( ) ) ;
310
+ }
311
+ } ) ;
312
+ } ) ;
313
+ }
314
+ this . treeItemsTransfer . clearData ( DraggedExtensionTreeItemsIdentifier . prototype ) ;
315
+ }
316
+
295
317
// Web: check for file transfer
296
318
else if ( isWeb && containsDragType ( event , DataTransfers . FILES ) ) {
297
319
let targetGroup : IEditorGroupView | undefined = undefined ;
0 commit comments