Skip to content

Commit 8f3d0b9

Browse files
committed
1 parent 3158543 commit 8f3d0b9

File tree

2 files changed

+97
-50
lines changed

2 files changed

+97
-50
lines changed

packages/eez-studio-ui/_stylesheets/project-editor.less

+15
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,21 @@
242242
}
243243
}
244244

245+
.EezStudio_DebuggerPanel_WatchBody {
246+
display: flex;
247+
flex-direction: column;
248+
height: 100%;
249+
250+
& > .EezStudio_SearchInput_Container {
251+
flex: 0;
252+
border-bottom: 1px solid @borderColor;
253+
}
254+
255+
& > .EezStudio_DebuggerVariablesTable {
256+
flex: 1;
257+
}
258+
}
259+
245260
.EezStudio_ComponentsPalette_Enclosure {
246261
height: 100%;
247262

packages/project-editor/flow/debugger/WatchPanel.tsx

+82-50
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { stringCompare } from "eez-studio-shared/string";
3737
import { isArray } from "eez-studio-shared/util";
3838
import type { UserProperty } from "project-editor/flow/user-property";
3939
import { IObjectVariableValueFieldDescription } from "eez-studio-types";
40+
import { SearchInput } from "eez-studio-ui/search-input";
4041

4142
////////////////////////////////////////////////////////////////////////////////
4243

@@ -189,6 +190,7 @@ const WatchTable = observer(
189190
super(props);
190191

191192
makeObservable(this, {
193+
searchText: observable,
192194
columns: computed,
193195
watchExpressions: computed,
194196
globalVariables: computed,
@@ -201,6 +203,19 @@ const WatchTable = observer(
201203
}
202204

203205
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+
}
204219

205220
expanded(id: string, defaultValue: boolean) {
206221
const expandedMap = this.expandedMap;
@@ -456,8 +471,11 @@ const WatchTable = observer(
456471
value: undefined,
457472
type: "",
458473
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) => {
461479
let watchExpressionLabel;
462480
let value;
463481
let type: any;
@@ -514,8 +532,7 @@ const WatchTable = observer(
514532
className,
515533
data: i
516534
});
517-
}
518-
),
535+
}),
519536
selected: false,
520537
expanded: this.expanded("expressions", true)
521538
});
@@ -527,47 +544,50 @@ const WatchTable = observer(
527544
) => {
528545
variables = variables.slice();
529546
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+
}
539559

540-
const name = variable.fullName;
560+
const name = variable.fullName;
541561

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,
547584
value,
548585
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+
});
569590
});
570-
});
571591
};
572592

573593
get globalVariables() {
@@ -702,7 +722,9 @@ const WatchTable = observer(
702722
const { flowState, component } = result;
703723

704724
const inputs = component.inputs.filter(
705-
input => input.name != "@seqin"
725+
input =>
726+
input.name != "@seqin" &&
727+
this.filterBySearchText(input.name)
706728
);
707729
if (inputs.length == 0) {
708730
return undefined;
@@ -783,15 +805,25 @@ const WatchTable = observer(
783805

784806
render() {
785807
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>
795827
</div>
796828
);
797829
}

0 commit comments

Comments
 (0)