44 *--------------------------------------------------------------------------------------------*/
55
66import 'vs/css!./media/debugViewlet' ;
7- import { Builder , Dimension } from 'vs/base/browser/builder' ;
7+ import { Builder } from 'vs/base/browser/builder' ;
8+ import * as DOM from 'vs/base/browser/dom' ;
89import { TPromise } from 'vs/base/common/winjs.base' ;
9- import * as lifecycle from 'vs/base/common/lifecycle' ;
1010import { IAction } from 'vs/base/common/actions' ;
1111import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar' ;
12- import { SplitView , HeaderView } from 'vs/base/browser/ui/splitview/splitview' ;
13- import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle' ;
14- import { Scope } from 'vs/workbench/common/memento' ;
15- import { Viewlet } from 'vs/workbench/browser/viewlet' ;
16- import { IViewletView } from 'vs/workbench/parts/views/browser/views' ;
12+ import { ComposedViewsViewlet } from 'vs/workbench/parts/views/browser/views' ;
1713import { IDebugService , VIEWLET_ID , State } from 'vs/workbench/parts/debug/common/debug' ;
18- import { DebugViewRegistry } from 'vs/workbench/parts/debug/browser/debugViewRegistry' ;
1914import { StartAction , ToggleReplAction , ConfigureAction } from 'vs/workbench/parts/debug/browser/debugActions' ;
2015import { StartDebugActionItem } from 'vs/workbench/parts/debug/browser/debugActionItems' ;
2116import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
2217import { IProgressService , IProgressRunner } from 'vs/platform/progress/common/progress' ;
2318import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace' ;
2419import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
25- import { IStorageService , StorageScope } from 'vs/platform/storage/common/storage' ;
20+ import { IStorageService } from 'vs/platform/storage/common/storage' ;
2621import { IThemeService } from 'vs/platform/theme/common/themeService' ;
27- import { attachHeaderViewStyler } from 'vs/platform/theme/common/styler' ;
22+ import { ViewLocation } from 'vs/workbench/parts/views/browser/viewsRegistry' ;
23+ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
2824
29- const DEBUG_VIEWS_WEIGHTS = 'debug.viewsweights' ;
25+ export class DebugViewlet extends ComposedViewsViewlet {
3026
31- export class DebugViewlet extends Viewlet {
32-
33- private toDispose : lifecycle . IDisposable [ ] ;
3427 private actions : IAction [ ] ;
3528 private startDebugActionItem : StartDebugActionItem ;
3629 private progressRunner : IProgressRunner ;
37- private viewletSettings : any ;
38-
39- private $el : Builder ;
40- private splitView : SplitView ;
41- private views : IViewletView [ ] ;
4230
4331 constructor (
4432 @ITelemetryService telemetryService : ITelemetryService ,
4533 @IProgressService private progressService : IProgressService ,
4634 @IDebugService private debugService : IDebugService ,
47- @IInstantiationService private instantiationService : IInstantiationService ,
48- @IWorkspaceContextService private contextService : IWorkspaceContextService ,
49- @IStorageService private storageService : IStorageService ,
50- @ILifecycleService lifecycleService : ILifecycleService ,
51- @IThemeService themeService : IThemeService
35+ @IInstantiationService instantiationService : IInstantiationService ,
36+ @IWorkspaceContextService contextService : IWorkspaceContextService ,
37+ @IStorageService storageService : IStorageService ,
38+ @IThemeService themeService : IThemeService ,
39+ @IContextKeyService contextKeyService : IContextKeyService
5240 ) {
53- super ( VIEWLET_ID , telemetryService , themeService ) ;
41+ super ( VIEWLET_ID , ViewLocation . Debug , ` ${ VIEWLET_ID } .state` , telemetryService , storageService , instantiationService , themeService , contextService , contextKeyService ) ;
5442
5543 this . progressRunner = null ;
56- this . viewletSettings = this . getMemento ( storageService , Scope . WORKSPACE ) ;
57- this . toDispose = [ ] ;
58- this . views = [ ] ;
59- this . toDispose . push ( this . debugService . onDidChangeState ( state => {
60- this . onDebugServiceStateChange ( state ) ;
61- } ) ) ;
62- lifecycleService . onShutdown ( this . store , this ) ;
63- }
64-
65- // viewlet
66-
67- public create ( parent : Builder ) : TPromise < void > {
68- super . create ( parent ) ;
69- this . $el = parent . div ( ) . addClass ( 'debug-viewlet' ) ;
70-
71- const actionRunner = this . getActionRunner ( ) ;
72- const registeredViews = DebugViewRegistry . getDebugViews ( ) ;
73- this . views = registeredViews . map ( viewConstructor => this . instantiationService . createInstance (
74- viewConstructor . view ,
75- actionRunner ,
76- this . viewletSettings )
77- ) ;
78-
79- this . views . forEach ( ( view , index ) => {
80- if ( view instanceof HeaderView ) {
81- attachHeaderViewStyler ( view , this . themeService , { noContrastBorder : index === 0 } ) ;
82- }
83- } ) ;
84-
85- this . splitView = new SplitView ( this . $el . getHTMLElement ( ) ) ;
86- this . toDispose . push ( this . splitView ) ;
87- let weights : number [ ] = JSON . parse ( this . storageService . get ( DEBUG_VIEWS_WEIGHTS , StorageScope . WORKSPACE , '[]' ) ) ;
88- if ( ! weights . length ) {
89- weights = registeredViews . map ( v => v . weight ) ;
90- }
91-
92- for ( let i = 0 ; i < this . views . length ; i ++ ) {
93- this . splitView . addView ( this . views [ i ] , Math . max ( weights [ i ] , 1 ) ) ;
94- }
95-
96- return TPromise . as ( null ) ;
97- }
9844
99- public setVisible ( visible : boolean ) : TPromise < any > {
100- return super . setVisible ( visible ) . then ( ( ) => {
101- return TPromise . join ( this . views . map ( view => view . setVisible ( visible ) ) ) ;
102- } ) ;
45+ this . _register ( this . debugService . onDidChangeState ( state => this . onDebugServiceStateChange ( state ) ) ) ;
10346 }
10447
105- public layout ( dimension : Dimension ) : void {
106- if ( this . splitView ) {
107- this . splitView . layout ( dimension . height ) ;
108- }
48+ public create ( parent : Builder ) : TPromise < void > {
49+ return super . create ( parent ) . then ( ( ) => DOM . addClass ( this . viewletContainer , 'debug-viewlet' ) ) ;
10950 }
11051
11152 public focus ( ) : void {
@@ -127,16 +68,16 @@ export class DebugViewlet extends Viewlet {
12768 if ( this . contextService . hasWorkspace ( ) ) {
12869 this . actions . push ( this . instantiationService . createInstance ( ConfigureAction , ConfigureAction . ID , ConfigureAction . LABEL ) ) ;
12970 }
130- this . actions . push ( this . instantiationService . createInstance ( ToggleReplAction , ToggleReplAction . ID , ToggleReplAction . LABEL ) ) ;
131-
132- this . actions . forEach ( a => {
133- this . toDispose . push ( a ) ;
134- } ) ;
71+ this . actions . push ( this . _register ( this . instantiationService . createInstance ( ToggleReplAction , ToggleReplAction . ID , ToggleReplAction . LABEL ) ) ) ;
13572 }
13673
13774 return this . actions ;
13875 }
13976
77+ public getSecondaryActions ( ) : IAction [ ] {
78+ return [ ] ;
79+ }
80+
14081 public getActionItem ( action : IAction ) : IActionItem {
14182 if ( action . id === StartAction . ID && this . contextService . hasWorkspace ( ) ) {
14283 this . startDebugActionItem = this . instantiationService . createInstance ( StartDebugActionItem , null , action ) ;
@@ -157,19 +98,4 @@ export class DebugViewlet extends Viewlet {
15798 this . progressRunner = null ;
15899 }
159100 }
160-
161- private store ( ) : void {
162- this . storageService . store ( DEBUG_VIEWS_WEIGHTS , JSON . stringify ( this . views . map ( view => view . size ) ) , StorageScope . WORKSPACE ) ;
163- }
164-
165- public dispose ( ) : void {
166- this . toDispose = lifecycle . dispose ( this . toDispose ) ;
167-
168- super . dispose ( ) ;
169- }
170-
171- public shutdown ( ) : void {
172- this . views . forEach ( v => v . shutdown ( ) ) ;
173- super . shutdown ( ) ;
174- }
175101}
0 commit comments