@@ -44,7 +44,7 @@ import { SIDE_BAR_BACKGROUND, PANEL_BACKGROUND } from 'vs/workbench/common/theme
4444import { IOpenerService } from 'vs/platform/opener/common/opener' ;
4545import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
4646
47- export class CustomTreeViewPane extends ViewPane {
47+ export class TreeViewPane extends ViewPane {
4848
4949 private treeView : ITreeView ;
5050
@@ -79,7 +79,7 @@ export class CustomTreeViewPane extends ViewPane {
7979 renderBody ( container : HTMLElement ) : void {
8080 super . renderBody ( container ) ;
8181
82- if ( this . treeView instanceof CustomTreeView ) {
82+ if ( this . treeView instanceof TreeView ) {
8383 this . treeView . show ( container ) ;
8484 }
8585 }
@@ -119,12 +119,11 @@ class Root implements ITreeItem {
119119
120120const noDataProviderMessage = localize ( 'no-dataprovider' , "There is no data provider registered that can provide view data." ) ;
121121
122- class CustomTree extends WorkbenchAsyncDataTree < ITreeItem , ITreeItem , FuzzyScore > { }
122+ class Tree extends WorkbenchAsyncDataTree < ITreeItem , ITreeItem , FuzzyScore > { }
123123
124- export class CustomTreeView extends Disposable implements ITreeView {
124+ export class TreeView extends Disposable implements ITreeView {
125125
126126 private isVisible : boolean = false ;
127- private activated : boolean = false ;
128127 private _hasIconForParentNode = false ;
129128 private _hasIconForLeafNode = false ;
130129 private _showCollapseAllAction = false ;
@@ -135,7 +134,7 @@ export class CustomTreeView extends Disposable implements ITreeView {
135134 private _messageValue : string | undefined ;
136135 private _canSelectMany : boolean = false ;
137136 private messageElement ! : HTMLDivElement ;
138- private tree : CustomTree | undefined ;
137+ private tree : Tree | undefined ;
139138 private treeLabels : ResourceLabels | undefined ;
140139
141140 private root : ITreeItem ;
@@ -165,14 +164,13 @@ export class CustomTreeView extends Disposable implements ITreeView {
165164 private readonly _onDidCompleteRefresh : Emitter < void > = this . _register ( new Emitter < void > ( ) ) ;
166165
167166 constructor (
168- private id : string ,
167+ protected readonly id : string ,
169168 private _title : string ,
170- @IExtensionService private readonly extensionService : IExtensionService ,
171169 @IThemeService private readonly themeService : IThemeService ,
172170 @IInstantiationService private readonly instantiationService : IInstantiationService ,
173171 @ICommandService private readonly commandService : ICommandService ,
174172 @IConfigurationService private readonly configurationService : IConfigurationService ,
175- @IProgressService private readonly progressService : IProgressService ,
173+ @IProgressService protected readonly progressService : IProgressService ,
176174 @IContextMenuService private readonly contextMenuService : IContextMenuService ,
177175 @IKeybindingService private readonly keybindingService : IKeybindingService ,
178176 @INotificationService private readonly notificationService : INotificationService ,
@@ -305,9 +303,6 @@ export class CustomTreeView extends Disposable implements ITreeView {
305303 }
306304
307305 this . isVisible = isVisible ;
308- if ( this . isVisible ) {
309- this . activate ( ) ;
310- }
311306
312307 if ( this . tree ) {
313308 if ( this . isVisible ) {
@@ -365,9 +360,9 @@ export class CustomTreeView extends Disposable implements ITreeView {
365360 const aligner = new Aligner ( this . themeService ) ;
366361 const renderer = this . instantiationService . createInstance ( TreeRenderer , this . id , treeMenus , this . treeLabels , actionViewItemProvider , aligner ) ;
367362
368- this . tree = this . _register ( this . instantiationService . createInstance ( CustomTree , 'CustomView' , this . treeContainer , new CustomTreeDelegate ( ) , [ renderer ] ,
363+ this . tree = this . _register ( this . instantiationService . createInstance ( Tree , this . id , this . treeContainer , new TreeViewDelegate ( ) , [ renderer ] ,
369364 dataSource , {
370- identityProvider : new CustomViewIdentityProvider ( ) ,
365+ identityProvider : new TreeViewIdentityProvider ( ) ,
371366 accessibilityProvider : {
372367 getAriaLabel ( element : ITreeItem ) : string {
373368 return element . tooltip ? element . tooltip : element . label ? element . label . label : '' ;
@@ -409,9 +404,9 @@ export class CustomTreeView extends Disposable implements ITreeView {
409404 } ) ) ;
410405 this . tree . setInput ( this . root ) . then ( ( ) => this . updateContentAreas ( ) ) ;
411406
412- const customTreeNavigator = ResourceNavigator . createTreeResourceNavigator ( this . tree , { openOnFocus : false , openOnSelection : false } ) ;
413- this . _register ( customTreeNavigator ) ;
414- this . _register ( customTreeNavigator . onDidOpenResource ( e => {
407+ const treeNavigator = ResourceNavigator . createTreeResourceNavigator ( this . tree , { openOnFocus : false , openOnSelection : false } ) ;
408+ this . _register ( treeNavigator ) ;
409+ this . _register ( treeNavigator . onDidOpenResource ( e => {
415410 if ( ! e . browserEvent ) {
416411 return ;
417412 }
@@ -462,7 +457,7 @@ export class CustomTreeView extends Disposable implements ITreeView {
462457 } ) ;
463458 }
464459
465- private updateMessage ( ) : void {
460+ protected updateMessage ( ) : void {
466461 if ( this . _message ) {
467462 this . showMessage ( this . _message ) ;
468463 } else if ( ! this . dataProvider ) {
@@ -579,17 +574,6 @@ export class CustomTreeView extends Disposable implements ITreeView {
579574 return Promise . resolve ( ) ;
580575 }
581576
582- private activate ( ) {
583- if ( ! this . activated ) {
584- this . progressService . withProgress ( { location : this . viewContainer . id } , ( ) => this . extensionService . activateByEvent ( `onView:${ this . id } ` ) )
585- . then ( ( ) => timeout ( 2000 ) )
586- . then ( ( ) => {
587- this . updateMessage ( ) ;
588- } ) ;
589- this . activated = true ;
590- }
591- }
592-
593577 private refreshing : boolean = false ;
594578 private async doRefresh ( elements : ITreeItem [ ] ) : Promise < void > {
595579 const tree = this . tree ;
@@ -618,13 +602,13 @@ export class CustomTreeView extends Disposable implements ITreeView {
618602 }
619603}
620604
621- class CustomViewIdentityProvider implements IIdentityProvider < ITreeItem > {
605+ class TreeViewIdentityProvider implements IIdentityProvider < ITreeItem > {
622606 getId ( element : ITreeItem ) : { toString ( ) : string ; } {
623607 return element . handle ;
624608 }
625609}
626610
627- class CustomTreeDelegate implements IListVirtualDelegate < ITreeItem > {
611+ class TreeViewDelegate implements IListVirtualDelegate < ITreeItem > {
628612
629613 getHeight ( element : ITreeItem ) : number {
630614 return TreeRenderer . ITEM_HEIGHT ;
@@ -943,3 +927,43 @@ class TreeMenus extends Disposable implements IDisposable {
943927 return result ;
944928 }
945929}
930+
931+ export class CustomTreeView extends TreeView {
932+
933+ private activated : boolean = false ;
934+
935+ constructor (
936+ id : string ,
937+ title : string ,
938+ @IThemeService themeService : IThemeService ,
939+ @IInstantiationService instantiationService : IInstantiationService ,
940+ @ICommandService commandService : ICommandService ,
941+ @IConfigurationService configurationService : IConfigurationService ,
942+ @IProgressService progressService : IProgressService ,
943+ @IContextMenuService contextMenuService : IContextMenuService ,
944+ @IKeybindingService keybindingService : IKeybindingService ,
945+ @INotificationService notificationService : INotificationService ,
946+ @IViewDescriptorService viewDescriptorService : IViewDescriptorService ,
947+ @IExtensionService private readonly extensionService : IExtensionService ,
948+ ) {
949+ super ( id , title , themeService , instantiationService , commandService , configurationService , progressService , contextMenuService , keybindingService , notificationService , viewDescriptorService ) ;
950+ }
951+
952+ setVisibility ( isVisible : boolean ) : void {
953+ super . setVisibility ( isVisible ) ;
954+ if ( this . visible ) {
955+ this . activate ( ) ;
956+ }
957+ }
958+
959+ private activate ( ) {
960+ if ( ! this . activated ) {
961+ this . progressService . withProgress ( { location : this . viewContainer . id } , ( ) => this . extensionService . activateByEvent ( `onView:${ this . id } ` ) )
962+ . then ( ( ) => timeout ( 2000 ) )
963+ . then ( ( ) => {
964+ this . updateMessage ( ) ;
965+ } ) ;
966+ this . activated = true ;
967+ }
968+ }
969+ }
0 commit comments