From b9842857291c2cd62efec2bfb0efef76771c6806 Mon Sep 17 00:00:00 2001 From: Maxime Jacquemin <maxime.jacquemin@cea.fr> Date: Tue, 5 Apr 2022 10:08:03 +0200 Subject: [PATCH] [ivette] Keep the Eva state when changing view --- ivette/src/frama-c/plugins/eva/valuetable.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ivette/src/frama-c/plugins/eva/valuetable.tsx b/ivette/src/frama-c/plugins/eva/valuetable.tsx index 8a7191399bd..7f139652537 100644 --- a/ivette/src/frama-c/plugins/eva/valuetable.tsx +++ b/ivette/src/frama-c/plugins/eva/valuetable.tsx @@ -28,6 +28,7 @@ import * as States from 'frama-c/states'; import * as Server from 'frama-c/server'; import * as Ast from 'frama-c/kernel/api/ast'; import * as Values from 'frama-c/plugins/eva/api/values'; +import { GlobalState, useGlobalState } from 'dome/data/states'; import { classes } from 'dome/misc/utils'; import { Icon } from 'dome/controls/icons'; @@ -913,13 +914,19 @@ class FunctionsManager { /* --- Eva Table Complet Component --- */ /* -------------------------------------------------------------------------- */ +/* Table's state. It is global for when the user changes the view. */ +const CallstackState = new GlobalState<callstack>('Summary'); +const FunctionsManagerState = new GlobalState(new FunctionsManager()); +const FocusState = new GlobalState<Probe | undefined>(undefined); + +/* Component */ function EvaTable(): JSX.Element { /* Component state */ const [ selection, select ] = States.useSelection(); - const [ cs, setCS ] = React.useState<callstack>('Summary'); - const [ fcts ] = React.useState(new FunctionsManager()); - const [ focus, setFocus ] = React.useState<Probe | undefined>(undefined); + const [ cs, setCS ] = useGlobalState(CallstackState); + const [ fcts ] = useGlobalState(FunctionsManagerState); + const [ focus, setFocus ] = useGlobalState(FocusState); /* Used to force the component update. We cannot use the `forceUpdate` hook * proposed by Dome as we need to be able to add dependencies on a changing -- GitLab