@jupyterlab/debugger
Version:
JupyterLab - Debugger Extension
90 lines • 2.71 kB
JavaScript
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import { Panel } from '@lumino/widgets';
/**
* A data grid that displays variables in a debugger session.
*/
export class VariablesBodyGrid extends Panel {
/**
* Instantiate a new VariablesBodyGrid.
*
* @param options The instantiation options for a VariablesBodyGrid.
*/
constructor(options) {
super();
this._filter = new Set();
this._grid = null;
this._pending = null;
this.commands = options.commands;
this.model = options.model;
this.themeManager = options.themeManager;
this.translator = options.translator;
this.model.changed.connect(() => this.update(), this);
this.addClass('jp-DebuggerVariables-body');
}
/**
* The variable filter list.
*/
get filter() {
return this._filter;
}
set filter(filter) {
this._filter = filter;
this.update();
}
/**
* The current scope of the variables.
*/
get scope() {
return this._scope;
}
set scope(scope) {
this._scope = scope;
if (scope !== 'Globals') {
this.addClass('jp-debuggerVariables-local');
}
else {
this.removeClass('jp-debuggerVariables-local');
}
this.update();
}
/**
* Load the grid panel implementation and instantiate a grid.
*/
async initialize() {
if (this._grid || this._pending) {
return;
}
// Lazily load the datagrid module when the first grid is requested.
const { Grid } = await (this._pending = import('./gridpanel'));
const { commands, model, themeManager, translator } = this;
this._grid = new Grid({ commands, model, themeManager, translator });
this._grid.addClass('jp-DebuggerVariables-grid');
this._pending = null;
this.addWidget(this._grid);
this.update();
}
/**
* Wait until actually displaying the grid to trigger initialization.
*/
onBeforeShow(msg) {
if (!this._grid && !this._pending) {
void this.initialize();
}
super.onBeforeShow(msg);
}
/**
* Handle `update-request` messages.
*/
onUpdateRequest(msg) {
var _a;
if (this._grid) {
const { dataModel } = this._grid;
dataModel.filter = this._filter;
dataModel.scope = this._scope;
dataModel.setData((_a = this.model.scopes) !== null && _a !== void 0 ? _a : []);
}
super.onUpdateRequest(msg);
}
}
//# sourceMappingURL=grid.js.map