@@ -11,22 +11,25 @@ import { CollapseAllAction } from 'vs/base/browser/ui/tree/treeDefaults';
1111import { isCodeEditor } from 'vs/editor/browser/editorBrowser' ;
1212import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
1313import { TreeResourceNavigator } from 'vs/platform/list/browser/listService' ;
14- import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
1514import { IThemeService } from 'vs/platform/theme/common/themeService' ;
16- import { Panel } from 'vs/workbench/browser/panel' ;
1715import { CommentNode , CommentsModel , ResourceWithCommentThreads , ICommentThreadChangedEvent } from 'vs/workbench/contrib/comments/common/commentModel' ;
1816import { CommentController } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution' ;
19- import { ICommentService , IWorkspaceCommentThreadsEvent } from 'vs/workbench/contrib/comments/browser/commentService' ;
17+ import { IWorkspaceCommentThreadsEvent , ICommentService } from 'vs/workbench/contrib/comments/browser/commentService' ;
2018import { IEditorService , ACTIVE_GROUP , SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService' ;
2119import { CommandsRegistry } from 'vs/platform/commands/common/commands' ;
2220import { textLinkForeground , textLinkActiveForeground , focusBorder , textPreformatForeground } from 'vs/platform/theme/common/colorRegistry' ;
23- import { IStorageService } from 'vs/platform/storage/common/storage' ;
2421import { ResourceLabels } from 'vs/workbench/browser/labels' ;
25- import { IPanelService } from 'vs/workbench/services/panel/common/panelService' ;
26- import { CommentsList , COMMENTS_PANEL_ID , COMMENTS_PANEL_TITLE } from 'vs/workbench/contrib/comments/browser/commentsTreeViewer' ;
22+ import { CommentsList , COMMENTS_VIEW_ID , COMMENTS_VIEW_TITLE } from 'vs/workbench/contrib/comments/browser/commentsTreeViewer' ;
23+ import { ViewPane , IViewPaneOptions } from 'vs/workbench/browser/parts/views/viewPaneContainer' ;
24+ import { IViewDescriptorService , IViewsService } from 'vs/workbench/common/views' ;
25+ import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
26+ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
27+ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView' ;
28+ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
29+ import { IOpenerService } from 'vs/platform/opener/common/opener' ;
2730
2831
29- export class CommentsPanel extends Panel {
32+ export class CommentsPanel extends ViewPane {
3033 private treeLabels ! : ResourceLabels ;
3134 private tree ! : CommentsList ;
3235 private treeContainer ! : HTMLElement ;
@@ -35,43 +38,50 @@ export class CommentsPanel extends Panel {
3538 private commentsModel ! : CommentsModel ;
3639 private collapseAllAction ?: IAction ;
3740
41+ readonly onDidChangeVisibility = this . onDidChangeBodyVisibility ;
42+
3843 constructor (
39- @IInstantiationService private readonly instantiationService : IInstantiationService ,
40- @ICommentService private readonly commentService : ICommentService ,
44+ options : IViewPaneOptions ,
45+ @IInstantiationService readonly instantiationService : IInstantiationService ,
46+ @IViewDescriptorService viewDescriptorService : IViewDescriptorService ,
4147 @IEditorService private readonly editorService : IEditorService ,
42- @ITelemetryService telemetryService : ITelemetryService ,
48+ @IConfigurationService configurationService : IConfigurationService ,
49+ @IContextKeyService contextKeyService : IContextKeyService ,
50+ @IContextMenuService contextMenuService : IContextMenuService ,
51+ @IKeybindingService keybindingService : IKeybindingService ,
52+ @IOpenerService openerService : IOpenerService ,
4353 @IThemeService themeService : IThemeService ,
44- @IStorageService storageService : IStorageService
54+ @ICommentService private readonly commentService : ICommentService
4555 ) {
46- super ( COMMENTS_PANEL_ID , telemetryService , themeService , storageService ) ;
56+ super ( { ... ( options as IViewPaneOptions ) , id : COMMENTS_VIEW_ID , ariaHeaderLabel : COMMENTS_VIEW_TITLE } , keybindingService , contextMenuService , configurationService , contextKeyService , viewDescriptorService , instantiationService , openerService , themeService ) ;
4757 }
4858
49- public create ( parent : HTMLElement ) : void {
50- super . create ( parent ) ;
59+ public renderBody ( container : HTMLElement ) : void {
60+ super . renderBody ( container ) ;
5161
52- dom . addClass ( parent , 'comments-panel' ) ;
62+ dom . addClass ( container , 'comments-panel' ) ;
5363
54- let container = dom . append ( parent , dom . $ ( '.comments-panel-container' ) ) ;
55- this . treeContainer = dom . append ( container , dom . $ ( '.tree-container' ) ) ;
64+ let domContainer = dom . append ( container , dom . $ ( '.comments-panel-container' ) ) ;
65+ this . treeContainer = dom . append ( domContainer , dom . $ ( '.tree-container' ) ) ;
5666 this . commentsModel = new CommentsModel ( ) ;
5767
5868 this . createTree ( ) ;
59- this . createMessageBox ( container ) ;
69+ this . createMessageBox ( domContainer ) ;
6070
6171 this . _register ( this . commentService . onDidSetAllCommentThreads ( this . onAllCommentsChanged , this ) ) ;
6272 this . _register ( this . commentService . onDidUpdateCommentThreads ( this . onCommentsUpdated , this ) ) ;
6373
64- const styleElement = dom . createStyleSheet ( parent ) ;
74+ const styleElement = dom . createStyleSheet ( container ) ;
6575 this . applyStyles ( styleElement ) ;
6676 this . _register ( this . themeService . onThemeChange ( _ => this . applyStyles ( styleElement ) ) ) ;
6777
68- this . _register ( this . onDidChangeVisibility ( visible => {
78+ this . _register ( this . onDidChangeBodyVisibility ( visible => {
6979 if ( visible ) {
7080 this . refresh ( ) ;
7181 }
7282 } ) ) ;
7383
74- this . render ( ) ;
84+ this . renderComments ( ) ;
7585 }
7686
7787 private applyStyles ( styleElement : HTMLStyleElement ) {
@@ -101,7 +111,7 @@ export class CommentsPanel extends Panel {
101111 styleElement . innerHTML = content . join ( '\n' ) ;
102112 }
103113
104- private async render ( ) : Promise < void > {
114+ private async renderComments ( ) : Promise < void > {
105115 dom . toggleClass ( this . treeContainer , 'hidden' , ! this . commentsModel . hasCommentThreads ( ) ) ;
106116 await this . tree . setInput ( this . commentsModel ) ;
107117 this . renderMessage ( ) ;
@@ -116,12 +126,12 @@ export class CommentsPanel extends Panel {
116126 return [ this . collapseAllAction ] ;
117127 }
118128
119- public layout ( dimensions : dom . Dimension ) : void {
120- this . tree . layout ( dimensions . height , dimensions . width ) ;
129+ public layoutBody ( height : number , width : number ) : void {
130+ this . tree . layout ( height , width ) ;
121131 }
122132
123133 public getTitle ( ) : string {
124- return COMMENTS_PANEL_TITLE ;
134+ return COMMENTS_VIEW_TITLE ;
125135 }
126136
127137 private createMessageBox ( parent : HTMLElement ) : void {
@@ -224,10 +234,7 @@ export class CommentsPanel extends Panel {
224234CommandsRegistry . registerCommand ( {
225235 id : 'workbench.action.focusCommentsPanel' ,
226236 handler : async ( accessor ) => {
227- const panelService = accessor . get ( IPanelService ) ;
228- const panels = panelService . getPanels ( ) ;
229- if ( panels . some ( panelIdentifier => panelIdentifier . id === COMMENTS_PANEL_ID ) ) {
230- await panelService . openPanel ( COMMENTS_PANEL_ID , true ) ;
231- }
237+ const viewsService = accessor . get ( IViewsService ) ;
238+ viewsService . openView ( COMMENTS_VIEW_ID , true ) ;
232239 }
233240} ) ;
0 commit comments