|
@@ -5,12 +5,13 @@ import { IDebugger } from '../tokens';
|
|
|
|
|
|
import { Panel, Widget } from '@lumino/widgets';
|
|
|
|
|
|
-// import { VariablesBody } from './body';
|
|
|
+import { VariablesBody } from './body';
|
|
|
|
|
|
import { VariablesBodyTable } from './table';
|
|
|
|
|
|
import { VariablesHeader } from './header';
|
|
|
|
|
|
+import { ToolbarButton } from '@jupyterlab/apputils';
|
|
|
import { VariablesModel } from './model';
|
|
|
|
|
|
/**
|
|
@@ -27,16 +28,42 @@ export class Variables extends Panel {
|
|
|
const { model, service } = options;
|
|
|
|
|
|
this._header = new VariablesHeader();
|
|
|
- this._body = new VariablesBodyTable({ model, service });
|
|
|
+ this._tree = new VariablesBody(model);
|
|
|
+ this._table = new VariablesBodyTable({ model, service });
|
|
|
+ this._table.hide();
|
|
|
|
|
|
- this.addWidget(this._header);
|
|
|
- this.addWidget(this._body);
|
|
|
+ const onClick = () => {
|
|
|
+ if (this._table.isHidden) {
|
|
|
+ this._tree.hide();
|
|
|
+ this._table.show();
|
|
|
+ this.node.setAttribute('data-jp-table', 'true');
|
|
|
+ } else {
|
|
|
+ this._tree.show();
|
|
|
+ this._table.hide();
|
|
|
+ this.node.removeAttribute('data-jp-table');
|
|
|
+ }
|
|
|
+ this.update();
|
|
|
+ };
|
|
|
+
|
|
|
+ this._header.toolbar.addItem(
|
|
|
+ 'view-VariableSwitch',
|
|
|
+ new ToolbarButton({
|
|
|
+ className: 'jp-SwitchButton',
|
|
|
+ iconClass: 'jp-ToggleSwitch',
|
|
|
+ onClick,
|
|
|
+ tooltip: 'Table / Tree View'
|
|
|
+ })
|
|
|
+ );
|
|
|
|
|
|
+ this.addWidget(this._header);
|
|
|
+ this.addWidget(this._tree);
|
|
|
+ this.addWidget(this._table);
|
|
|
this.addClass('jp-DebuggerVariables');
|
|
|
}
|
|
|
|
|
|
private _header: VariablesHeader;
|
|
|
- private _body: Widget;
|
|
|
+ private _tree: Widget;
|
|
|
+ private _table: Widget;
|
|
|
|
|
|
/**
|
|
|
* A message handler invoked on a `'resize'` message.
|
|
@@ -52,7 +79,7 @@ export class Variables extends Panel {
|
|
|
*/
|
|
|
private _resizeBody(msg: Widget.ResizeMessage) {
|
|
|
const height = msg.height - this._header.node.offsetHeight;
|
|
|
- this._body.node.style.height = `${height}px`;
|
|
|
+ this._table.node.style.height = `${height}px`;
|
|
|
}
|
|
|
}
|
|
|
|