2
2
// MIT License, see LICENSE file for full terms.
3
3
4
4
import * as pd from 'polymer-ts-decorators' ;
5
- import { Disposable } from 'event-kit' ;
5
+ import { CompositeDisposable , Disposable } from 'event-kit' ;
6
6
import addDisposableListener from '../lib/disposable-dom-event-listener' ;
7
7
import * as debugWorkbench from '../lib/debug-workbench' ;
8
8
import { IDebugSession } from '../lib/debug-engine'
@@ -27,10 +27,18 @@ const START_DEBUGGING_EVENT = 'start-debugging';
27
27
const STOP_DEBUGGING_EVENT = 'stop-debugging' ;
28
28
const OPEN_SETTINGS_EVENT = 'open-settings' ;
29
29
30
+ function getDebugConfigNames ( ) : string [ ] {
31
+ return debugWorkbench . debugConfigs . getAll ( ) . map ( ( debugConfig ) => debugConfig . name ) ;
32
+ }
33
+
30
34
@pd . is ( 'debug-workbench-debug-toolbar' )
31
35
export default class DebugToolbarElement {
36
+ private subscriptions : CompositeDisposable ;
32
37
private debugSession : IDebugSession ;
33
38
39
+ @pd . property ( { type : Array , value : getDebugConfigNames } )
40
+ private debugConfigs : string [ ] ;
41
+
34
42
static create ( ) : Promise < IDebugToolbarElement > {
35
43
return debugWorkbench . createElement ( ( < any > DebugToolbarElement . prototype ) . is ) ;
36
44
}
@@ -50,6 +58,41 @@ export default class DebugToolbarElement {
50
58
return addDisposableListener ( < any > this , OPEN_SETTINGS_EVENT , callback ) ;
51
59
}
52
60
61
+ created ( ) : void {
62
+ this . subscriptions = new CompositeDisposable ( ) ;
63
+ }
64
+
65
+ ready ( ) : void {
66
+ this . subscriptions . add ( debugWorkbench . debugConfigs . onDidAddConfig (
67
+ ( addedConfig ) => {
68
+ base ( this ) . push ( 'debugConfigs' , addedConfig . name ) ;
69
+ }
70
+ ) ) ;
71
+ this . subscriptions . add ( debugWorkbench . debugConfigs . onDidRemoveConfig (
72
+ ( removedConfig ) => {
73
+ const idx = this . debugConfigs . indexOf ( removedConfig . name ) ;
74
+ if ( idx > - 1 ) {
75
+ base ( this ) . splice ( 'debugConfigs' , idx , 1 ) ;
76
+ }
77
+ }
78
+ ) ) ;
79
+ this . subscriptions . add ( debugWorkbench . debugConfigs . onDidRenameConfig (
80
+ ( { newName, oldName } ) => {
81
+ const idx = this . debugConfigs . indexOf ( oldName ) ;
82
+ if ( idx > - 1 ) {
83
+ base ( this ) . set ( [ 'debugConfigs' , idx ] , newName ) ;
84
+ }
85
+ }
86
+ ) ) ;
87
+ }
88
+
89
+ destroy ( ) : void {
90
+ if ( this . subscriptions ) {
91
+ this . subscriptions . dispose ( ) ;
92
+ this . subscriptions = null ;
93
+ }
94
+ }
95
+
53
96
@pd . listener ( 'startButton.tap' )
54
97
private startDebugging ( ) : void {
55
98
base ( this ) . fire ( START_DEBUGGING_EVENT ) ;
0 commit comments