public void RebuildSections(Blackboard blackboard)
        {
            Dictionary <IVariableDeclarationModel, bool> expandedState = new Dictionary <IVariableDeclarationModel, bool>();

            foreach (var blackboardSection in blackboard.Sections)
            {
                var rows = blackboardSection.Query <BlackboardRow>().ToList();
                foreach (var row in rows)
                {
                    var field = row.Q <BlackboardVariableField>();
                    expandedState[field.VariableDeclarationModel] = row.expanded;
                }
            }

            m_Blackboard = blackboard;
            m_Store      = blackboard.Store;
            var currentGraphModel = (VSGraphModel)blackboard.Store.GetState().CurrentGraphModel;

            blackboard.ClearContents();

            if (blackboard.Sections != null && blackboard.Sections.Count > 1)
            {
                blackboard.Sections[k_GraphDeclarationsSection].title     = k_GraphDeclarationsSectionTitle;
                blackboard.Sections[k_InputPortDeclarationsSection].title = k_InputPortDeclarationsSectionTitle;
            }

            foreach (VariableDeclarationModel declaration in currentGraphModel.VariableDeclarations)
            {
                var blackboardField = new BlackboardVariableField(blackboard.Store, declaration, blackboard.GraphView);
                var blackboardVariablePropertyView = new DotsVariablePropertyView(blackboard.Store, declaration, blackboard.Rebuild, m_Stencil);
                if (declaration.DataType != TypeHandle.ExecutionFlow)
                {
                    blackboardVariablePropertyView = (DotsVariablePropertyView)blackboardVariablePropertyView.WithLocalInputOutputToggle().WithTypeSelector(new SearcherFilter(SearcherContext.Type).WithValueTypes());
                    blackboardVariablePropertyView = (DotsVariablePropertyView)blackboardVariablePropertyView.WithInitializationField();
                }
                blackboardVariablePropertyView = (DotsVariablePropertyView)blackboardVariablePropertyView.WithTooltipField();

                bool expanded;
                if (!expandedState.TryGetValue(declaration, out expanded))
                {
                    expanded = true;
                }

                var blackboardRow = new BlackboardRow(
                    blackboardField,
                    blackboardVariablePropertyView)
                {
                    Model    = declaration,
                    expanded = expanded
                };
                if (blackboard.Sections != null)
                {
                    if (declaration.IsInputOrOutputTrigger())
                    {
                        blackboard.Sections[k_InputPortDeclarationsSection].Add(blackboardRow);
                    }
                    else
                    {
                        blackboard.Sections[k_GraphDeclarationsSection].Add(blackboardRow);
                    }
                }
                blackboard.GraphVariables.Add(blackboardField);
            }
        }
 public void DisplayAppropriateSearcher(Vector2 mousePosition, Blackboard blackboard)
 {
     throw new NotImplementedException();
 }
        public void RebuildSections(Blackboard blackboard)
        {
            VSGraphModel currentGraphModel = (VSGraphModel)blackboard.Store.GetState().CurrentGraphModel;

            Dictionary <IVariableDeclarationModel, bool> expandedRows = new Dictionary <IVariableDeclarationModel, bool>();

            foreach (BlackboardSection blackBoardSection in blackboard.Sections)
            {
                foreach (VisualElement visualElement in blackBoardSection.Children())
                {
                    if (visualElement is BlackboardRow row)
                    {
                        if (row.Model is IVariableDeclarationModel model)
                        {
                            expandedRows[model] = row.expanded;
                        }
                    }
                }
            }

            blackboard.ClearContents();

            if (CanDisplayThisToken)
            {
                var thisNodeModel = currentGraphModel.NodeModels.OfType <ThisNodeModel>().FirstOrDefault();
                var thisField     = new BlackboardThisField(blackboard.GraphView, thisNodeModel, currentGraphModel);
                blackboard.Sections[k_MainSection].Add(thisField);
                blackboard.GraphVariables.Add(thisField);
                blackboard.RestoreSelectionForElement(thisField);
            }

            // Fetch all fields from the GraphModel in the main section
            foreach (IVariableDeclarationModel variableDeclarationModel in ((IVSGraphModel)currentGraphModel).GraphVariableModels)
            {
                var blackboardField = new BlackboardVariableField(blackboard.Store, variableDeclarationModel, blackboard.GraphView);
                var blackboardRow   = new BlackboardRow(
                    blackboardField,
                    CreateExtendedFieldView(blackboard.Store, variableDeclarationModel, blackboard.Rebuild))
                {
                    Model    = variableDeclarationModel,
                    expanded = expandedRows.TryGetValue(variableDeclarationModel, out var expandedValue) && expandedValue
                };
                blackboard.Sections[k_MainSection].Add(blackboardRow);
                blackboard.GraphVariables.Add(blackboardField);
                blackboard.RestoreSelectionForElement(blackboardField);
            }

            if (blackboard.selection != null)
            {
                // Fill local scope section
                foreach (Tuple <IVariableDeclarationModel, bool> variableDeclarationModelTuple in blackboard.GraphView.UIController
                         .GetAllVariableDeclarationsFromSelection(blackboard.selection))
                {
                    var blackboardField = new BlackboardVariableField(blackboard.Store, variableDeclarationModelTuple.Item1, blackboard.GraphView);

                    if (variableDeclarationModelTuple.Item2)
                    {
                        var blackboardRow = new BlackboardRow(
                            blackboardField,
                            CreateExtendedFieldView(blackboard.Store, variableDeclarationModelTuple.Item1, blackboard.Rebuild))
                        {
                            userData = variableDeclarationModelTuple,
                            expanded = expandedRows.TryGetValue(variableDeclarationModelTuple.Item1, out var expandedValue) && expandedValue
                        };
                        blackboard.Sections[k_CurrentScopeVariableDeclarationsSection].Add(blackboardRow);
                    }
                    else
                    {
                        blackboardField.AddToClassList("readonly");
                        blackboard.Sections[k_CurrentScopeVariableDeclarationsSection].Add(blackboardField);
                    }

                    blackboard.GraphVariables.Add(blackboardField);

                    blackboard.RestoreSelectionForElement(blackboardField);
                }
            }
        }