Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/files/browser/views/emptyView.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import * as nls from '../../../../../nls.js';
7
import { IViewletViewOptions } from '../../../../browser/parts/views/viewsViewlet.js';
8
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
9
import { IThemeService } from '../../../../../platform/theme/common/themeService.js';
10
import { IKeybindingService } from '../../../../../platform/keybinding/common/keybinding.js';
11
import { IContextMenuService } from '../../../../../platform/contextview/browser/contextView.js';
12
import { isTemporaryWorkspace, IWorkspaceContextService, WorkbenchState } from '../../../../../platform/workspace/common/workspace.js';
13
import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js';
14
import { ViewPane } from '../../../../browser/parts/views/viewPane.js';
15
import { ResourcesDropHandler } from '../../../../browser/dnd.js';
16
import { listDropOverBackground } from '../../../../../platform/theme/common/colorRegistry.js';
17
import { ILabelService } from '../../../../../platform/label/common/label.js';
18
import { IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js';
19
import { IViewDescriptorService } from '../../../../common/views.js';
20
import { IOpenerService } from '../../../../../platform/opener/common/opener.js';
21
import { isWeb } from '../../../../../base/common/platform.js';
22
import { DragAndDropObserver, getWindow } from '../../../../../base/browser/dom.js';
23
import { ILocalizedString } from '../../../../../platform/action/common/action.js';
24
import { IHoverService } from '../../../../../platform/hover/browser/hover.js';
25
26
export class EmptyView extends ViewPane {
27
28
static readonly ID: string = 'workbench.explorer.emptyView';
29
static readonly NAME: ILocalizedString = nls.localize2('noWorkspace', "No Folder Opened");
30
private _disposed: boolean = false;
31
32
constructor(
33
options: IViewletViewOptions,
34
@IThemeService themeService: IThemeService,
35
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
36
@IInstantiationService instantiationService: IInstantiationService,
37
@IKeybindingService keybindingService: IKeybindingService,
38
@IContextMenuService contextMenuService: IContextMenuService,
39
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
40
@IConfigurationService configurationService: IConfigurationService,
41
@ILabelService private labelService: ILabelService,
42
@IContextKeyService contextKeyService: IContextKeyService,
43
@IOpenerService openerService: IOpenerService,
44
@IHoverService hoverService: IHoverService,
45
) {
46
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, hoverService);
47
48
this._register(this.contextService.onDidChangeWorkbenchState(() => this.refreshTitle()));
49
this._register(this.labelService.onDidChangeFormatters(() => this.refreshTitle()));
50
}
51
52
override shouldShowWelcome(): boolean {
53
return true;
54
}
55
56
protected override renderBody(container: HTMLElement): void {
57
super.renderBody(container);
58
59
this._register(new DragAndDropObserver(container, {
60
onDrop: e => {
61
container.style.backgroundColor = '';
62
const dropHandler = this.instantiationService.createInstance(ResourcesDropHandler, { allowWorkspaceOpen: !isWeb || isTemporaryWorkspace(this.contextService.getWorkspace()) });
63
dropHandler.handleDrop(e, getWindow(container));
64
},
65
onDragEnter: () => {
66
const color = this.themeService.getColorTheme().getColor(listDropOverBackground);
67
container.style.backgroundColor = color ? color.toString() : '';
68
},
69
onDragEnd: () => {
70
container.style.backgroundColor = '';
71
},
72
onDragLeave: () => {
73
container.style.backgroundColor = '';
74
},
75
onDragOver: e => {
76
if (e.dataTransfer) {
77
e.dataTransfer.dropEffect = 'copy';
78
}
79
}
80
}));
81
82
this.refreshTitle();
83
}
84
85
private refreshTitle(): void {
86
if (this._disposed) {
87
return;
88
}
89
90
if (this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE) {
91
this.updateTitle(EmptyView.NAME.value);
92
} else {
93
this.updateTitle(this.title);
94
}
95
}
96
97
override dispose(): void {
98
this._disposed = true;
99
super.dispose();
100
}
101
}
102
103