4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import * as nls from 'vs/nls' ;
7
- import * as errors from 'vs/base/common/errors' ;
8
- import * as DOM from 'vs/base/browser/dom' ;
9
- import { Button } from 'vs/base/browser/ui/button/button' ;
10
7
import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet' ;
11
8
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
12
- import { OpenFolderAction , AddRootFolderAction } from 'vs/workbench/browser/actions/workspaceActions' ;
13
- import { attachButtonStyler } from 'vs/platform/theme/common/styler' ;
14
9
import { IThemeService } from 'vs/platform/theme/common/themeService' ;
15
10
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
16
11
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView' ;
@@ -20,23 +15,16 @@ import { ViewPane, IViewPaneOptions } from 'vs/workbench/browser/parts/views/vie
20
15
import { ResourcesDropHandler , DragAndDropObserver } from 'vs/workbench/browser/dnd' ;
21
16
import { listDropBackground } from 'vs/platform/theme/common/colorRegistry' ;
22
17
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme' ;
23
- import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService' ;
24
18
import { ILabelService } from 'vs/platform/label/common/label' ;
25
- import { Schemas } from 'vs/base/common/network' ;
26
- import { isWeb } from 'vs/base/common/platform' ;
27
19
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
28
20
import { IViewDescriptorService } from 'vs/workbench/common/views' ;
29
21
import { IOpenerService } from 'vs/platform/opener/common/opener' ;
30
- import { ActionRunner } from 'vs/base/common/actions' ;
31
22
32
23
export class EmptyView extends ViewPane {
33
24
34
25
static readonly ID : string = 'workbench.explorer.emptyView' ;
35
26
static readonly NAME = nls . localize ( 'noWorkspace' , "No Folder Opened" ) ;
36
27
37
- private button ! : Button ;
38
- private messageElement ! : HTMLElement ;
39
-
40
28
constructor (
41
29
options : IViewletViewOptions ,
42
30
@IThemeService themeService : IThemeService ,
@@ -46,53 +34,31 @@ export class EmptyView extends ViewPane {
46
34
@IContextMenuService contextMenuService : IContextMenuService ,
47
35
@IWorkspaceContextService private readonly contextService : IWorkspaceContextService ,
48
36
@IConfigurationService configurationService : IConfigurationService ,
49
- @IWorkbenchEnvironmentService private environmentService : IWorkbenchEnvironmentService ,
50
37
@ILabelService private labelService : ILabelService ,
51
38
@IContextKeyService contextKeyService : IContextKeyService ,
52
39
@IOpenerService openerService : IOpenerService
53
40
) {
54
41
super ( { ...( options as IViewPaneOptions ) , ariaHeaderLabel : nls . localize ( 'explorerSection' , "Explorer Section: No Folder Opened" ) } , keybindingService , contextMenuService , configurationService , contextKeyService , viewDescriptorService , instantiationService , openerService , themeService ) ;
55
- this . _register ( this . contextService . onDidChangeWorkbenchState ( ( ) => this . setLabels ( ) ) ) ;
56
- this . _register ( this . labelService . onDidChangeFormatters ( ( ) => this . setLabels ( ) ) ) ;
42
+
43
+ this . _register ( this . contextService . onDidChangeWorkbenchState ( ( ) => this . refreshTitle ( ) ) ) ;
44
+ this . _register ( this . labelService . onDidChangeFormatters ( ( ) => this . refreshTitle ( ) ) ) ;
45
+ }
46
+
47
+ shouldShowWelcome ( ) : boolean {
48
+ return true ;
57
49
}
58
50
59
51
protected renderBody ( container : HTMLElement ) : void {
60
52
super . renderBody ( container ) ;
61
53
62
- DOM . addClass ( container , 'explorer-empty-view' ) ;
63
- container . tabIndex = 0 ;
64
-
65
- const messageContainer = document . createElement ( 'div' ) ;
66
- DOM . addClass ( messageContainer , 'section' ) ;
67
- container . appendChild ( messageContainer ) ;
68
-
69
- this . messageElement = document . createElement ( 'p' ) ;
70
- messageContainer . appendChild ( this . messageElement ) ;
71
-
72
- this . button = new Button ( messageContainer ) ;
73
- attachButtonStyler ( this . button , this . themeService ) ;
74
-
75
- const actionRunner = new ActionRunner ( ) ;
76
- this . _register ( this . button . onDidClick ( ( ) => {
77
- const action = this . contextService . getWorkbenchState ( ) === WorkbenchState . WORKSPACE
78
- ? this . instantiationService . createInstance ( AddRootFolderAction , AddRootFolderAction . ID , AddRootFolderAction . LABEL )
79
- : this . instantiationService . createInstance ( OpenFolderAction , OpenFolderAction . ID , OpenFolderAction . LABEL ) ;
80
- actionRunner . run ( action ) . then ( ( ) => {
81
- action . dispose ( ) ;
82
- } , err => {
83
- action . dispose ( ) ;
84
- errors . onUnexpectedError ( err ) ;
85
- } ) ;
86
- } ) ) ;
87
-
88
54
this . _register ( new DragAndDropObserver ( container , {
89
55
onDrop : e => {
90
56
const color = this . themeService . getTheme ( ) . getColor ( SIDE_BAR_BACKGROUND ) ;
91
57
container . style . backgroundColor = color ? color . toString ( ) : '' ;
92
58
const dropHandler = this . instantiationService . createInstance ( ResourcesDropHandler , { allowWorkspaceOpen : true } ) ;
93
- dropHandler . handleDrop ( e , ( ) => undefined , targetGroup => undefined ) ;
59
+ dropHandler . handleDrop ( e , ( ) => undefined , ( ) => undefined ) ;
94
60
} ,
95
- onDragEnter : ( e ) => {
61
+ onDragEnter : ( ) => {
96
62
const color = this . themeService . getTheme ( ) . getColor ( listDropBackground ) ;
97
63
container . style . backgroundColor = color ? color . toString ( ) : '' ;
98
64
} ,
@@ -111,36 +77,18 @@ export class EmptyView extends ViewPane {
111
77
}
112
78
} ) ) ;
113
79
114
- this . setLabels ( ) ;
80
+ this . refreshTitle ( ) ;
115
81
}
116
82
117
- private setLabels ( ) : void {
83
+ private refreshTitle ( ) : void {
118
84
if ( this . contextService . getWorkbenchState ( ) === WorkbenchState . WORKSPACE ) {
119
- this . messageElement . textContent = nls . localize ( 'noWorkspaceHelp' , "You have not yet added a folder to the workspace." ) ;
120
- if ( this . button ) {
121
- this . button . label = nls . localize ( 'addFolder' , "Add Folder" ) ;
122
- }
123
85
this . updateTitle ( EmptyView . NAME ) ;
124
86
} else {
125
- if ( this . environmentService . configuration . remoteAuthority && ! isWeb ) {
126
- const hostLabel = this . labelService . getHostLabel ( Schemas . vscodeRemote , this . environmentService . configuration . remoteAuthority ) ;
127
- this . messageElement . textContent = hostLabel ? nls . localize ( 'remoteNoFolderHelp' , "Connected to {0}" , hostLabel ) : nls . localize ( 'connecting' , "Connecting..." ) ;
128
- } else {
129
- this . messageElement . textContent = nls . localize ( 'noFolderHelp' , "You have not yet opened a folder." ) ;
130
- }
131
- if ( this . button ) {
132
- this . button . label = nls . localize ( 'openFolder' , "Open Folder" ) ;
133
- }
134
87
this . updateTitle ( this . title ) ;
135
88
}
136
89
}
137
90
138
91
layoutBody ( _size : number ) : void {
139
92
// no-op
140
93
}
141
-
142
- focus ( ) : void {
143
- this . button . element . focus ( ) ;
144
- }
145
-
146
94
}
0 commit comments