From 24dbff3e345bf74a779c5e3a41c36c5360ebfe23 Mon Sep 17 00:00:00 2001 From: glopesdev Date: Tue, 3 Sep 2024 18:45:52 +0100 Subject: [PATCH] Clear workflow error highlight --- Bonsai.Editor/EditorForm.cs | 19 ++++++++++++++----- Bonsai.Editor/GraphView/WorkflowGraphView.cs | 12 +++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Bonsai.Editor/EditorForm.cs b/Bonsai.Editor/EditorForm.cs index fe05d454..9c1a0c3d 100644 --- a/Bonsai.Editor/EditorForm.cs +++ b/Bonsai.Editor/EditorForm.cs @@ -1355,10 +1355,7 @@ void ClearWorkflowError() { if (workflowError != null) { - statusStrip.ContextMenuStrip = null; - statusTextLabel.Text = Resources.ReadyStatus; - statusImageLabel.Image = Resources.StatusReadyImage; - explorerTreeView.SetNodeStatus(ExplorerNodeStatus.Ready); + ClearExceptionBuilderNode(workflowError); } exceptionCache.Clear(); @@ -1373,6 +1370,18 @@ void HighlightWorkflowError() } } + void ClearExceptionBuilderNode(WorkflowException ex) + { + var workflowPath = WorkflowEditorPath.GetExceptionPath(workflowBuilder, ex); + var selectedView = selectionModel.SelectedView; + selectedView.ClearGraphNode(workflowPath); + + statusStrip.ContextMenuStrip = null; + statusTextLabel.Text = Resources.ReadyStatus; + statusImageLabel.Image = Resources.StatusReadyImage; + explorerTreeView.SetNodeStatus(ExplorerNodeStatus.Ready); + } + void HighlightExceptionBuilderNode(WorkflowException ex, bool showMessageBox) { var workflowPath = WorkflowEditorPath.GetExceptionPath(workflowBuilder, ex); @@ -1381,13 +1390,13 @@ void HighlightExceptionBuilderNode(WorkflowException ex, bool showMessageBox) selectedView.HighlightGraphNode(workflowPath, showMessageBox); var buildException = ex is WorkflowBuildException; - var errorCaption = buildException ? Resources.BuildError_Caption : Resources.RuntimeError_Caption; statusTextLabel.Text = ex.Message; statusStrip.ContextMenuStrip = statusContextMenuStrip; statusImageLabel.Image = buildException ? Resources.StatusBlockedImage : Resources.StatusCriticalImage; explorerTreeView.SetNodeStatus(pathElements, ExplorerNodeStatus.Blocked); if (showMessageBox) { + var errorCaption = buildException ? Resources.BuildError_Caption : Resources.RuntimeError_Caption; editorSite.ShowError(ex.Message, errorCaption); } } diff --git a/Bonsai.Editor/GraphView/WorkflowGraphView.cs b/Bonsai.Editor/GraphView/WorkflowGraphView.cs index 9784d159..75fe805a 100644 --- a/Bonsai.Editor/GraphView/WorkflowGraphView.cs +++ b/Bonsai.Editor/GraphView/WorkflowGraphView.cs @@ -273,7 +273,17 @@ internal void SelectGraphNode(GraphNode node) UpdateSelection(); } + internal void ClearGraphNode(WorkflowEditorPath path) + { + SetGraphNodeHighlight(path, false, false); + } + internal void HighlightGraphNode(WorkflowEditorPath path, bool selectNode) + { + SetGraphNodeHighlight(path, selectNode, true); + } + + private void SetGraphNodeHighlight(WorkflowEditorPath path, bool selectNode, bool highlight) { if (selectNode) WorkflowPath = path?.Parent; @@ -291,7 +301,7 @@ internal void HighlightGraphNode(WorkflowEditorPath path, bool selectNode) GraphView.Invalidate(graphNode); if (selectNode) GraphView.SelectedNode = graphNode; - graphNode.Highlight = true; + graphNode.Highlight = highlight; break; }