@@ -37,6 +37,7 @@ import { stringCompare } from "eez-studio-shared/string";
37
37
import { isArray } from "eez-studio-shared/util" ;
38
38
import type { UserProperty } from "project-editor/flow/user-property" ;
39
39
import { IObjectVariableValueFieldDescription } from "eez-studio-types" ;
40
+ import { SearchInput } from "eez-studio-ui/search-input" ;
40
41
41
42
////////////////////////////////////////////////////////////////////////////////
42
43
@@ -189,6 +190,7 @@ const WatchTable = observer(
189
190
super ( props ) ;
190
191
191
192
makeObservable ( this , {
193
+ searchText : observable ,
192
194
columns : computed ,
193
195
watchExpressions : computed ,
194
196
globalVariables : computed ,
@@ -201,6 +203,19 @@ const WatchTable = observer(
201
203
}
202
204
203
205
expandedMap = new Map < string , boolean > ( ) ;
206
+ searchText = "" ;
207
+
208
+ onSearchChange = ( event : any ) => {
209
+ this . searchText = event . target . value ;
210
+ } ;
211
+
212
+ filterBySearchText ( text : string ) {
213
+ const searchText = this . searchText . trim ( ) . toLowerCase ( ) ;
214
+ if ( ! searchText ) {
215
+ return true ;
216
+ }
217
+ return text . toLowerCase ( ) . indexOf ( searchText ) != - 1 ;
218
+ }
204
219
205
220
expanded ( id : string , defaultValue : boolean ) {
206
221
const expandedMap = this . expandedMap ;
@@ -456,8 +471,11 @@ const WatchTable = observer(
456
471
value : undefined ,
457
472
type : "" ,
458
473
children : ( ) =>
459
- this . props . runtime . projectStore . uiStateStore . watchExpressions . map (
460
- ( expression , i ) => {
474
+ this . props . runtime . projectStore . uiStateStore . watchExpressions
475
+ . filter ( expression =>
476
+ this . filterBySearchText ( expression )
477
+ )
478
+ . map ( ( expression , i ) => {
461
479
let watchExpressionLabel ;
462
480
let value ;
463
481
let type : any ;
@@ -514,8 +532,7 @@ const WatchTable = observer(
514
532
className,
515
533
data : i
516
534
} ) ;
517
- }
518
- ) ,
535
+ } ) ,
519
536
selected : false ,
520
537
expanded : this . expanded ( "expressions" , true )
521
538
} ) ;
@@ -527,47 +544,50 @@ const WatchTable = observer(
527
544
) => {
528
545
variables = variables . slice ( ) ;
529
546
variables . sort ( ( a , b ) => stringCompare ( a . fullName , b . fullName ) ) ;
530
- return variables . map ( variable => {
531
- const flowState = this . props . runtime . selectedFlowState ;
532
-
533
- let dataContext : IDataContext ;
534
- if ( flowState ) {
535
- dataContext = flowState . dataContext ;
536
- } else {
537
- dataContext = this . props . runtime . projectStore . dataContext ;
538
- }
547
+ return variables
548
+ . filter ( variable => this . filterBySearchText ( variable . fullName ) )
549
+ . map ( variable => {
550
+ const flowState = this . props . runtime . selectedFlowState ;
551
+
552
+ let dataContext : IDataContext ;
553
+ if ( flowState ) {
554
+ dataContext = flowState . dataContext ;
555
+ } else {
556
+ dataContext =
557
+ this . props . runtime . projectStore . dataContext ;
558
+ }
539
559
540
- const name = variable . fullName ;
560
+ const name = variable . fullName ;
541
561
542
- const value = dataContext . get ( name ) ;
543
- const valueLabel = (
544
- < span >
545
- { getValueLabel (
546
- this . props . runtime . projectStore . project ,
562
+ const value = dataContext . get ( name ) ;
563
+ const valueLabel = (
564
+ < span >
565
+ { getValueLabel (
566
+ this . props . runtime . projectStore . project ,
567
+ value ,
568
+ variable . type
569
+ ) }
570
+ </ span >
571
+ ) ;
572
+
573
+ return observable ( {
574
+ id : id + name ,
575
+
576
+ name : name ,
577
+ nameTitle : name ,
578
+ value : valueLabel ,
579
+ valueTitle : valueLabel ,
580
+ type : variable . type ,
581
+
582
+ children : this . getValueChildren (
583
+ id + name ,
547
584
value ,
548
585
variable . type
549
- ) }
550
- </ span >
551
- ) ;
552
-
553
- return observable ( {
554
- id : id + name ,
555
-
556
- name : name ,
557
- nameTitle : name ,
558
- value : valueLabel ,
559
- valueTitle : valueLabel ,
560
- type : variable . type ,
561
-
562
- children : this . getValueChildren (
563
- id + name ,
564
- value ,
565
- variable . type
566
- ) ,
567
- selected : false ,
568
- expanded : this . expanded ( id + name , false )
586
+ ) ,
587
+ selected : false ,
588
+ expanded : this . expanded ( id + name , false )
589
+ } ) ;
569
590
} ) ;
570
- } ) ;
571
591
} ;
572
592
573
593
get globalVariables ( ) {
@@ -702,7 +722,9 @@ const WatchTable = observer(
702
722
const { flowState, component } = result ;
703
723
704
724
const inputs = component . inputs . filter (
705
- input => input . name != "@seqin"
725
+ input =>
726
+ input . name != "@seqin" &&
727
+ this . filterBySearchText ( input . name )
706
728
) ;
707
729
if ( inputs . length == 0 ) {
708
730
return undefined ;
@@ -783,15 +805,25 @@ const WatchTable = observer(
783
805
784
806
render ( ) {
785
807
return (
786
- < div className = "EezStudio_DebuggerVariablesTable" >
787
- {
788
- < TreeTable
789
- columns = { this . columns }
790
- showOnlyChildren = { true }
791
- rootNode = { this . rootNode }
792
- selectNode = { this . selectNode }
793
- />
794
- }
808
+ < div className = "EezStudio_DebuggerPanel_WatchBody" >
809
+ < SearchInput
810
+ searchText = { this . searchText }
811
+ onClear = { action ( ( ) => {
812
+ this . searchText = "" ;
813
+ } ) }
814
+ onChange = { this . onSearchChange }
815
+ onKeyDown = { this . onSearchChange }
816
+ > </ SearchInput >
817
+ < div className = "EezStudio_DebuggerVariablesTable" >
818
+ {
819
+ < TreeTable
820
+ columns = { this . columns }
821
+ showOnlyChildren = { true }
822
+ rootNode = { this . rootNode }
823
+ selectNode = { this . selectNode }
824
+ />
825
+ }
826
+ </ div >
795
827
</ div >
796
828
) ;
797
829
}
0 commit comments