@jupyterlab/debugger 4.0.0-alpha.2 → 4.0.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/lib/debugger.d.ts +4 -0
  2. package/lib/debugger.js +5 -1
  3. package/lib/debugger.js.map +1 -1
  4. package/lib/dialogs/evaluate.d.ts +5 -0
  5. package/lib/dialogs/evaluate.js +16 -6
  6. package/lib/dialogs/evaluate.js.map +1 -1
  7. package/lib/factory.d.ts +1 -1
  8. package/lib/factory.js +15 -9
  9. package/lib/factory.js.map +1 -1
  10. package/lib/handler.js +24 -9
  11. package/lib/handler.js.map +1 -1
  12. package/lib/handlers/console.js +9 -3
  13. package/lib/handlers/console.js.map +1 -1
  14. package/lib/handlers/editor.d.ts +33 -11
  15. package/lib/handlers/editor.js +177 -88
  16. package/lib/handlers/editor.js.map +1 -1
  17. package/lib/handlers/file.d.ts +1 -0
  18. package/lib/handlers/file.js +11 -2
  19. package/lib/handlers/file.js.map +1 -1
  20. package/lib/handlers/notebook.d.ts +0 -7
  21. package/lib/handlers/notebook.js +22 -18
  22. package/lib/handlers/notebook.js.map +1 -1
  23. package/lib/icons.d.ts +3 -0
  24. package/lib/icons.js +15 -0
  25. package/lib/icons.js.map +1 -1
  26. package/lib/model.d.ts +5 -0
  27. package/lib/model.js +4 -0
  28. package/lib/model.js.map +1 -1
  29. package/lib/panels/breakpoints/index.d.ts +18 -0
  30. package/lib/panels/breakpoints/index.js +10 -3
  31. package/lib/panels/breakpoints/index.js.map +1 -1
  32. package/lib/panels/breakpoints/pauseonexceptions.d.ts +53 -0
  33. package/lib/panels/breakpoints/pauseonexceptions.js +98 -0
  34. package/lib/panels/breakpoints/pauseonexceptions.js.map +1 -0
  35. package/lib/panels/callstack/index.d.ts +1 -1
  36. package/lib/panels/kernelSources/body.d.ts +45 -0
  37. package/lib/panels/kernelSources/body.js +76 -0
  38. package/lib/panels/kernelSources/body.js.map +1 -0
  39. package/lib/panels/kernelSources/filter.d.ts +11 -0
  40. package/lib/panels/kernelSources/filter.js +18 -0
  41. package/lib/panels/kernelSources/filter.js.map +1 -0
  42. package/lib/panels/kernelSources/index.d.ts +39 -0
  43. package/lib/panels/kernelSources/index.js +54 -0
  44. package/lib/panels/kernelSources/index.js.map +1 -0
  45. package/lib/panels/kernelSources/model.d.ts +73 -0
  46. package/lib/panels/kernelSources/model.js +120 -0
  47. package/lib/panels/kernelSources/model.js.map +1 -0
  48. package/lib/panels/sources/body.js +5 -3
  49. package/lib/panels/sources/body.js.map +1 -1
  50. package/lib/panels/variables/grid.d.ts +8 -2
  51. package/lib/panels/variables/grid.js +29 -364
  52. package/lib/panels/variables/grid.js.map +1 -1
  53. package/lib/panels/variables/gridpanel.d.ts +140 -0
  54. package/lib/panels/variables/gridpanel.js +363 -0
  55. package/lib/panels/variables/gridpanel.js.map +1 -0
  56. package/lib/panels/variables/index.d.ts +1 -9
  57. package/lib/panels/variables/index.js +1 -15
  58. package/lib/panels/variables/index.js.map +1 -1
  59. package/lib/panels/variables/mimerenderer.d.ts +15 -2
  60. package/lib/panels/variables/mimerenderer.js +56 -17
  61. package/lib/panels/variables/mimerenderer.js.map +1 -1
  62. package/lib/panels/variables/model.d.ts +3 -0
  63. package/lib/panels/variables/model.js +7 -0
  64. package/lib/panels/variables/model.js.map +1 -1
  65. package/lib/panels/variables/scope.js +4 -0
  66. package/lib/panels/variables/scope.js.map +1 -1
  67. package/lib/panels/variables/tree.d.ts +2 -5
  68. package/lib/panels/variables/tree.js +137 -47
  69. package/lib/panels/variables/tree.js.map +1 -1
  70. package/lib/service.d.ts +32 -2
  71. package/lib/service.js +122 -9
  72. package/lib/service.js.map +1 -1
  73. package/lib/session.d.ts +37 -1
  74. package/lib/session.js +89 -6
  75. package/lib/session.js.map +1 -1
  76. package/lib/sidebar.d.ts +7 -1
  77. package/lib/sidebar.js +10 -2
  78. package/lib/sidebar.js.map +1 -1
  79. package/lib/sources.d.ts +2 -2
  80. package/lib/sources.js +32 -17
  81. package/lib/sources.js.map +1 -1
  82. package/lib/tokens.d.ts +139 -24
  83. package/lib/tokens.js.map +1 -1
  84. package/package.json +39 -47
  85. package/src/config.ts +78 -0
  86. package/src/debugger.ts +154 -0
  87. package/src/dialogs/evaluate.ts +144 -0
  88. package/src/factory.ts +72 -0
  89. package/src/handler.ts +528 -0
  90. package/src/handlers/console.ts +118 -0
  91. package/src/handlers/editor.ts +469 -0
  92. package/src/handlers/file.ts +86 -0
  93. package/src/handlers/notebook.ts +128 -0
  94. package/src/hash.ts +69 -0
  95. package/src/icons.ts +64 -0
  96. package/src/index.ts +16 -0
  97. package/src/model.ts +155 -0
  98. package/src/panels/breakpoints/body.tsx +145 -0
  99. package/src/panels/breakpoints/index.ts +116 -0
  100. package/src/panels/breakpoints/model.ts +74 -0
  101. package/src/panels/breakpoints/pauseonexceptions.tsx +141 -0
  102. package/src/panels/callstack/body.tsx +96 -0
  103. package/src/panels/callstack/index.ts +152 -0
  104. package/src/panels/callstack/model.ts +86 -0
  105. package/src/panels/kernelSources/body.tsx +139 -0
  106. package/src/panels/kernelSources/filter.tsx +44 -0
  107. package/src/panels/kernelSources/index.tsx +106 -0
  108. package/src/panels/kernelSources/model.ts +160 -0
  109. package/src/panels/sources/body.ts +161 -0
  110. package/src/panels/sources/index.tsx +85 -0
  111. package/src/panels/sources/model.ts +94 -0
  112. package/src/panels/sources/sourcepath.tsx +28 -0
  113. package/src/panels/variables/grid.ts +144 -0
  114. package/src/panels/variables/gridpanel.ts +455 -0
  115. package/src/panels/variables/index.ts +199 -0
  116. package/src/panels/variables/mimerenderer.ts +125 -0
  117. package/src/panels/variables/model.ts +61 -0
  118. package/src/panels/variables/scope.tsx +132 -0
  119. package/src/panels/variables/tree.tsx +521 -0
  120. package/src/service.ts +1009 -0
  121. package/src/session.ts +342 -0
  122. package/src/sidebar.ts +194 -0
  123. package/src/sources.ts +327 -0
  124. package/src/svg.d.ts +9 -0
  125. package/src/tokens.ts +1071 -0
  126. package/style/base.css +2 -1
  127. package/style/breakpoints.css +21 -12
  128. package/style/icons/arrow-collapse.svg +1 -1
  129. package/style/icons/arrow-expand.svg +1 -1
  130. package/style/icons/exceptions.svg +10 -0
  131. package/style/icons/open-kernel-source.svg +6 -0
  132. package/style/icons/pause.svg +6 -0
  133. package/style/icons.css +9 -8
  134. package/style/index.css +1 -1
  135. package/style/index.js +1 -1
  136. package/style/kernelSources.css +45 -0
  137. package/style/sidebar.css +1 -1
  138. package/style/variables.css +82 -21
@@ -0,0 +1,144 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { IThemeManager } from '@jupyterlab/apputils';
5
+
6
+ import { CommandRegistry } from '@lumino/commands';
7
+
8
+ import { Panel } from '@lumino/widgets';
9
+
10
+ import { IDebugger } from '../../tokens';
11
+
12
+ import { VariablesModel } from './model';
13
+ import { ITranslator } from '@jupyterlab/translation';
14
+
15
+ import type * as GridPanelModule from './gridpanel';
16
+ import { PromiseDelegate } from '@lumino/coreutils';
17
+ import { Message } from '@lumino/messaging';
18
+
19
+ /**
20
+ * A data grid that displays variables in a debugger session.
21
+ */
22
+ export class VariablesBodyGrid extends Panel {
23
+ /**
24
+ * Instantiate a new VariablesBodyGrid.
25
+ *
26
+ * @param options The instantiation options for a VariablesBodyGrid.
27
+ */
28
+ constructor(options: VariablesBodyGrid.IOptions) {
29
+ super();
30
+
31
+ this._model = options.model;
32
+ this._options = options;
33
+
34
+ this.addClass('jp-DebuggerVariables-body');
35
+ }
36
+
37
+ /**
38
+ * Wait until actually displaying the grid to trigger initialization.
39
+ */
40
+ protected onBeforeShow(msg: Message): void {
41
+ if (!this._grid) {
42
+ void this.initialize();
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Load the grid panel implementation.
48
+ */
49
+ protected async initialize(): Promise<void> {
50
+ const { model, commands, themeManager, scopes, translator } = this._options;
51
+ const { Grid } = await Private.ensureGridPanel();
52
+ this._grid = new Grid({ commands, model, themeManager, translator });
53
+ this._grid.addClass('jp-DebuggerVariables-grid');
54
+ this._model.changed.connect((model: VariablesModel): void => {
55
+ this._update();
56
+ }, this);
57
+ this._grid.dataModel.setData(scopes ?? []);
58
+ this.addWidget(this._grid);
59
+ }
60
+
61
+ /**
62
+ * Set the variable filter list.
63
+ *
64
+ * @param filter The variable filter to apply.
65
+ */
66
+ set filter(filter: Set<string>) {
67
+ (this._grid.dataModel as GridPanelModule.GridModel).filter = filter;
68
+ this._update();
69
+ }
70
+
71
+ /**
72
+ * Set the current scope.
73
+ *
74
+ * @param scope The current scope for the variables.
75
+ */
76
+ set scope(scope: string) {
77
+ (this._grid.dataModel as GridPanelModule.GridModel).scope = scope;
78
+ this._update();
79
+ }
80
+
81
+ /**
82
+ * Update the underlying data model
83
+ */
84
+ private _update(): void {
85
+ this._grid.dataModel.setData(this._model.scopes ?? []);
86
+ }
87
+
88
+ private _grid: GridPanelModule.Grid;
89
+ private _model: IDebugger.Model.IVariables;
90
+ private _options: VariablesBodyGrid.IOptions;
91
+ }
92
+
93
+ /**
94
+ * A namespace for `VariablesBodyGrid` statics.
95
+ */
96
+ export namespace VariablesBodyGrid {
97
+ /**
98
+ * Instantiation options for `VariablesBodyGrid`.
99
+ */
100
+ export interface IOptions {
101
+ /**
102
+ * The variables model.
103
+ */
104
+ model: IDebugger.Model.IVariables;
105
+
106
+ /**
107
+ * The commands registry.
108
+ */
109
+ commands: CommandRegistry;
110
+
111
+ /**
112
+ * The optional initial scopes data.
113
+ */
114
+ scopes?: IDebugger.IScope[];
115
+
116
+ /**
117
+ * An optional application theme manager to detect theme changes.
118
+ */
119
+ themeManager?: IThemeManager | null;
120
+
121
+ /**
122
+ * The application language translator.
123
+ */
124
+ translator?: ITranslator;
125
+ }
126
+ }
127
+
128
+ /**
129
+ * A private namespace for managing lazy loading of the underlying grid panel.
130
+ */
131
+ namespace Private {
132
+ let gridPanelLoaded: PromiseDelegate<typeof GridPanelModule> | null = null;
133
+
134
+ /**
135
+ * Lazily load the datagrid module when the first grid is requested.
136
+ */
137
+ export async function ensureGridPanel(): Promise<typeof GridPanelModule> {
138
+ if (gridPanelLoaded == null) {
139
+ gridPanelLoaded = new PromiseDelegate();
140
+ gridPanelLoaded.resolve(await import('./gridpanel'));
141
+ }
142
+ return gridPanelLoaded.promise;
143
+ }
144
+ }
@@ -0,0 +1,455 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ import { CommandRegistry } from '@lumino/commands';
5
+ import {
6
+ BasicKeyHandler,
7
+ BasicMouseHandler,
8
+ BasicSelectionModel,
9
+ DataGrid,
10
+ DataModel,
11
+ TextRenderer
12
+ } from '@lumino/datagrid';
13
+ import { ISignal, Signal } from '@lumino/signaling';
14
+ import { Panel } from '@lumino/widgets';
15
+
16
+ import { IThemeManager } from '@jupyterlab/apputils';
17
+ import {
18
+ ITranslator,
19
+ nullTranslator,
20
+ TranslationBundle
21
+ } from '@jupyterlab/translation';
22
+
23
+ import { IDebugger } from '../../tokens';
24
+ import { Debugger } from '../../';
25
+
26
+ /**
27
+ * A class wrapping the underlying variables datagrid.
28
+ */
29
+ export class Grid extends Panel {
30
+ /**
31
+ * Instantiate a new VariablesGrid.
32
+ *
33
+ * @param options The instantiation options for a VariablesGrid.
34
+ */
35
+ constructor(options: Grid.IOptions) {
36
+ super();
37
+ const { commands, model, themeManager } = options;
38
+ this.model = model;
39
+ const dataModel = new GridModel(options.translator);
40
+ const grid = new DataGrid();
41
+ const mouseHandler = new Private.MouseHandler();
42
+ mouseHandler.doubleClicked.connect((_, hit) =>
43
+ commands.execute(Debugger.CommandIDs.inspectVariable, {
44
+ variableReference: dataModel.getVariableReference(hit.row),
45
+ name: dataModel.getVariableName(hit.row)
46
+ })
47
+ );
48
+ mouseHandler.selected.connect((_, hit) => {
49
+ const { row } = hit;
50
+ this.model.selectedVariable = {
51
+ name: dataModel.getVariableName(row),
52
+ value: dataModel.data('body', row, 1),
53
+ type: dataModel.data('body', row, 2),
54
+ variablesReference: dataModel.getVariableReference(row)
55
+ };
56
+ });
57
+ grid.dataModel = dataModel;
58
+ grid.keyHandler = new BasicKeyHandler();
59
+ grid.mouseHandler = mouseHandler;
60
+ grid.selectionModel = new BasicSelectionModel({
61
+ dataModel
62
+ });
63
+ grid.stretchLastColumn = true;
64
+ grid.node.style.height = '100%';
65
+ this._grid = grid;
66
+
67
+ // Compute the grid's styles based on the current theme.
68
+ if (themeManager) {
69
+ themeManager.themeChanged.connect(this._updateStyles, this);
70
+ }
71
+ this.addWidget(grid);
72
+ }
73
+
74
+ /**
75
+ * Set the variable filter list.
76
+ *
77
+ * @param filter The variable filter to apply.
78
+ */
79
+ set filter(filter: Set<string>) {
80
+ (this._grid.dataModel as GridModel).filter = filter;
81
+ this.update();
82
+ }
83
+
84
+ /**
85
+ * Set the scope for the variables data model.
86
+ *
87
+ * @param scope The scopes for the variables
88
+ */
89
+ set scope(scope: string) {
90
+ (this._grid.dataModel as GridModel).scope = scope;
91
+ this.update();
92
+ }
93
+
94
+ /**
95
+ * Get the data model for the data grid.
96
+ */
97
+ get dataModel(): GridModel {
98
+ return this._grid.dataModel as GridModel;
99
+ }
100
+
101
+ /**
102
+ * Handle `after-attach` messages.
103
+ *
104
+ * @param message - The `after-attach` message.
105
+ */
106
+ protected onAfterAttach(message: any): void {
107
+ super.onAfterAttach(message);
108
+ this._updateStyles();
109
+ }
110
+
111
+ /**
112
+ * Update the computed style for the data grid on theme change.
113
+ */
114
+ private _updateStyles(): void {
115
+ const { style, textRenderer } = Private.computeStyle();
116
+ this._grid.cellRenderers.update({}, textRenderer);
117
+ this._grid.style = style;
118
+ }
119
+
120
+ private _grid: DataGrid;
121
+ protected model: IDebugger.Model.IVariables;
122
+ }
123
+
124
+ /**
125
+ * A namespace for VariablesGrid `statics`.
126
+ */
127
+ namespace Grid {
128
+ /**
129
+ * Instantiation options for `VariablesGrid`.
130
+ */
131
+ export interface IOptions {
132
+ /**
133
+ * The commands registry.
134
+ */
135
+ commands: CommandRegistry;
136
+
137
+ /**
138
+ * The variables model.
139
+ */
140
+ model: IDebugger.Model.IVariables;
141
+
142
+ /**
143
+ * An optional application theme manager to detect theme changes.
144
+ */
145
+ themeManager?: IThemeManager | null;
146
+
147
+ /**
148
+ * The application language translator.
149
+ */
150
+ translator?: ITranslator;
151
+ }
152
+ }
153
+
154
+ /**
155
+ * A data grid model for variables.
156
+ */
157
+ export class GridModel extends DataModel {
158
+ /**
159
+ * Create gird model
160
+ * @param translator optional translator
161
+ */
162
+ constructor(translator?: ITranslator) {
163
+ super();
164
+ translator = translator || nullTranslator;
165
+ this._trans = translator.load('jupyterlab');
166
+ }
167
+
168
+ /**
169
+ * Set the variable filter list.
170
+ */
171
+ set filter(filter: Set<string>) {
172
+ this._filter = filter;
173
+ }
174
+
175
+ /**
176
+ * Get the current scope for the variables.
177
+ */
178
+ get scope(): string {
179
+ return this._scope;
180
+ }
181
+
182
+ /**
183
+ * Set the variable scope
184
+ */
185
+ set scope(scope: string) {
186
+ this._scope = scope;
187
+ }
188
+
189
+ /**
190
+ * Get the row count for a particular region in the data grid.
191
+ *
192
+ * @param region The datagrid region.
193
+ */
194
+ rowCount(region: DataModel.RowRegion): number {
195
+ return region === 'body' ? this._data.name.length : 1;
196
+ }
197
+
198
+ /**
199
+ * Get the column count for a particular region in the data grid.
200
+ *
201
+ * @param region The datagrid region.
202
+ */
203
+ columnCount(region: DataModel.ColumnRegion): number {
204
+ return region === 'body' ? 2 : 1;
205
+ }
206
+
207
+ /**
208
+ * Get the data count for a particular region, row and column in the data grid.
209
+ *
210
+ * @param region The datagrid region.
211
+ * @param row The datagrid row
212
+ * @param column The datagrid column
213
+ */
214
+ data(region: DataModel.CellRegion, row: number, column: number): any {
215
+ if (region === 'row-header') {
216
+ return this._data.name[row];
217
+ }
218
+
219
+ if (region === 'column-header') {
220
+ return column === 1 ? this._trans.__('Value') : this._trans.__('Type');
221
+ }
222
+ if (region === 'corner-header') {
223
+ return this._trans.__('Name');
224
+ }
225
+
226
+ return column === 1 ? this._data.value[row] : this._data.type[row];
227
+ }
228
+
229
+ /**
230
+ * Get the variable reference for a given row
231
+ *
232
+ * @param row The row in the datagrid.
233
+ */
234
+ getVariableReference(row: number): number {
235
+ return this._data.variablesReference[row];
236
+ }
237
+
238
+ /**
239
+ * Get the variable name for a given row
240
+ *
241
+ * @param row The row in the datagrid.
242
+ */
243
+ getVariableName(row: number): string {
244
+ return this._data.name[row];
245
+ }
246
+
247
+ /**
248
+ * Set the datagrid model data from the list of variables.
249
+ *
250
+ * @param scopes The list of variables.
251
+ */
252
+ setData(scopes: IDebugger.IScope[]): void {
253
+ this._clearData();
254
+ this.emitChanged({
255
+ type: 'model-reset',
256
+ region: 'body'
257
+ });
258
+ const scope = scopes.find(scope => scope.name === this._scope) ?? scopes[0];
259
+ const variables = scope?.variables ?? [];
260
+ const filtered = variables.filter(
261
+ variable => variable.name && !this._filter.has(variable.name)
262
+ );
263
+ filtered.forEach((variable, index) => {
264
+ this._data.name[index] = variable.name;
265
+ this._data.type[index] = variable.type ?? '';
266
+ this._data.value[index] = variable.value;
267
+ this._data.variablesReference[index] = variable.variablesReference;
268
+ });
269
+ this.emitChanged({
270
+ type: 'rows-inserted',
271
+ region: 'body',
272
+ index: 1,
273
+ span: filtered.length
274
+ });
275
+ }
276
+
277
+ /**
278
+ * Clear all the data in the datagrid.
279
+ */
280
+ private _clearData(): void {
281
+ this._data = {
282
+ name: [],
283
+ type: [],
284
+ value: [],
285
+ variablesReference: []
286
+ };
287
+ }
288
+
289
+ private _filter = new Set<string>();
290
+ private _scope = '';
291
+ private _trans: TranslationBundle;
292
+ private _data: {
293
+ name: string[];
294
+ type: string[];
295
+ value: string[];
296
+ variablesReference: number[];
297
+ } = {
298
+ name: [],
299
+ type: [],
300
+ value: [],
301
+ variablesReference: []
302
+ };
303
+ }
304
+
305
+ /**
306
+ * A namespace for private data.
307
+ */
308
+ namespace Private {
309
+ /**
310
+ * Create a color palette element.
311
+ */
312
+ function createPalette(): HTMLDivElement {
313
+ const div = document.createElement('div');
314
+ div.className = 'jp-DebuggerVariables-colorPalette';
315
+ div.innerHTML = `
316
+ <div class="jp-mod-void"></div>
317
+ <div class="jp-mod-background"></div>
318
+ <div class="jp-mod-header-background"></div>
319
+ <div class="jp-mod-grid-line"></div>
320
+ <div class="jp-mod-header-grid-line"></div>
321
+ <div class="jp-mod-selection"></div>
322
+ <div class="jp-mod-text"></div>
323
+ `;
324
+ return div;
325
+ }
326
+
327
+ /**
328
+ * Compute the style and renderer for a data grid.
329
+ */
330
+ export function computeStyle(): {
331
+ style: DataGrid.Style;
332
+ textRenderer: TextRenderer;
333
+ } {
334
+ const palette = createPalette();
335
+ document.body.appendChild(palette);
336
+ let node: HTMLDivElement | null;
337
+ node = palette.querySelector('.jp-mod-void');
338
+ const voidColor = getComputedStyle(node!).color;
339
+ node = palette.querySelector('.jp-mod-background');
340
+ const backgroundColor = getComputedStyle(node!).color;
341
+ node = palette.querySelector('.jp-mod-header-background');
342
+ const headerBackgroundColor = getComputedStyle(node!).color;
343
+ node = palette.querySelector('.jp-mod-grid-line');
344
+ const gridLineColor = getComputedStyle(node!).color;
345
+ node = palette.querySelector('.jp-mod-header-grid-line');
346
+ const headerGridLineColor = getComputedStyle(node!).color;
347
+ node = palette.querySelector('.jp-mod-selection');
348
+ const selectionFillColor = getComputedStyle(node!).color;
349
+ node = palette.querySelector('.jp-mod-text');
350
+ const textColor = getComputedStyle(node!).color;
351
+ document.body.removeChild(palette);
352
+ return {
353
+ style: {
354
+ voidColor,
355
+ backgroundColor,
356
+ headerBackgroundColor,
357
+ gridLineColor,
358
+ headerGridLineColor,
359
+ rowBackgroundColor: (i: number): string =>
360
+ i % 2 === 0 ? voidColor : backgroundColor,
361
+ selectionFillColor
362
+ },
363
+ textRenderer: new TextRenderer({
364
+ font: '12px sans-serif',
365
+ textColor,
366
+ backgroundColor: '',
367
+ verticalAlignment: 'center',
368
+ horizontalAlignment: 'left'
369
+ })
370
+ };
371
+ }
372
+
373
+ /**
374
+ * A custom click handler to handle clicks on the variables grid.
375
+ */
376
+ export class MouseHandler extends BasicMouseHandler {
377
+ /**
378
+ * A signal emitted when the variables grid is double clicked.
379
+ */
380
+ get doubleClicked(): ISignal<this, DataGrid.HitTestResult> {
381
+ return this._doubleClicked;
382
+ }
383
+
384
+ /**
385
+ * A signal emitted when the variables grid received mouse down or context menu event.
386
+ */
387
+ get selected(): ISignal<this, DataGrid.HitTestResult> {
388
+ return this._selected;
389
+ }
390
+
391
+ /**
392
+ * Dispose of the resources held by the mouse handler.
393
+ */
394
+ dispose(): void {
395
+ if (this.isDisposed) {
396
+ return;
397
+ }
398
+
399
+ Signal.disconnectSender(this);
400
+
401
+ super.dispose();
402
+ }
403
+
404
+ /**
405
+ * Handle a mouse double-click event.
406
+ *
407
+ * @param grid The datagrid clicked.
408
+ * @param event The mouse event.
409
+ */
410
+ onMouseDoubleClick(grid: DataGrid, event: MouseEvent): void {
411
+ const hit = grid.hitTest(event.clientX, event.clientY);
412
+ this._doubleClicked.emit(hit);
413
+ }
414
+
415
+ /**
416
+ * Handle the mouse down event for the data grid.
417
+ *
418
+ * @param grid - The data grid of interest.
419
+ *
420
+ * @param event - The mouse down event of interest.
421
+ */
422
+ onMouseDown(grid: DataGrid, event: MouseEvent): void {
423
+ // Unpack the event.
424
+ let { clientX, clientY } = event;
425
+
426
+ // Hit test the grid.
427
+ let hit = grid.hitTest(clientX, clientY);
428
+
429
+ this._selected.emit(hit);
430
+
431
+ // Propagate event to Lumino DataGrid BasicMouseHandler.
432
+ super.onMouseDown(grid, event);
433
+ }
434
+
435
+ /**
436
+ * Handle the context menu event for the data grid.
437
+ *
438
+ * @param grid - The data grid of interest.
439
+ *
440
+ * @param event - The context menu event of interest.
441
+ */
442
+ onContextMenu(grid: DataGrid, event: MouseEvent): void {
443
+ // Unpack the event.
444
+ let { clientX, clientY } = event;
445
+
446
+ // Hit test the grid.
447
+ let hit = grid.hitTest(clientX, clientY);
448
+
449
+ this._selected.emit(hit);
450
+ }
451
+
452
+ private _doubleClicked = new Signal<this, DataGrid.HitTestResult>(this);
453
+ private _selected = new Signal<this, DataGrid.HitTestResult>(this);
454
+ }
455
+ }