import { IThemeManager , ToolbarButton } from '@jupyterlab/apputils' ; import { CommandRegistry } from '@lumino/commands' ; import { Panel , Widget } from '@lumino/widgets' ; import { IDebugger } from '../../tokens' ; import { VariablesBodyGrid } from './grid' ; import { VariablesHeader } from './header' ; import { ScopeSwitcher } from './scope' ; import { VariablesBodyTree } from './tree' ; /**
 * A Panel to show a variable explorer.
 */ export class Variables extends Panel { param options constructor ( options ) { super ( ) ; const { model , service , commands , themeManager } = options ; this . _header = new VariablesHeader ( ) ; this . _tree = new VariablesBodyTree ( { model , service } ) ; this . _table = new VariablesBodyGrid ( { model , commands , themeManager } ) ; this . _table . hide ( ) ; const onViewChange = ( ) : void => { 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 ( 'scope-switcher' , new ScopeSwitcher ( { model , tree : this . _tree , grid : this . _table } ) ) ; this . _header . toolbar . addItem ( 'view-VariableSwitch' , new ToolbarButton ( { iconClass : 'jp-ToggleSwitch' , onClick : onViewChange , tooltip : 'Table / Tree View' } ) ) ; this . addWidget ( this . _header ) ; this . addWidget ( this . _tree ) ; this . addWidget ( this . _table ) ; this . addClass ( 'jp-DebuggerVariables' ) ; } /**
     * Set the variable filter for both the tree and table views.
     */ set filter ( filter ) { this . _tree . filter = filter ; this . _table . filter = filter ; } param msg protected onResize ( msg ) { super . onResize ( msg ) ; this . _resizeBody ( msg ) ; } param msg private _resizeBody ( msg ) { const height = msg . height - this . _header . node . offsetHeight ; this . _tree . node . style . height = `${ height }px` ; } private _header : VariablesHeader ; private _tree : VariablesBodyTree ; private _table : VariablesBodyGrid ; } param variable export const convertType = ( variable ) : string | number => { const { type , value } = variable ; switch ( type ) { case 'int' : return parseInt ( value , 10 ) ; case 'float' : return parseFloat ( value ) ; case 'bool' : return value ; case 'str' : return value . slice ( 1 , value . length - 1 ) ; default : return type ?? value ; } } ; /**
 * A namespace for Variables `statics`.
 */ export namespace Variables { /**
     * Instantiation options for `Variables`.
     */ export interface IOptions extends Panel . IOptions { /**
         * The variables model.
         */ model : IDebugger . Model . IVariables ; /**
         * The debugger service.
         */ service : IDebugger ; /**
         * The commands registry.
         */ commands : CommandRegistry ; /**
         * An optional application theme manager to detect theme changes.
         */ themeManager ? : IThemeManager | null ; } }