From 513d565057fe28cae6e143803513300f4b88df0f Mon Sep 17 00:00:00 2001 From: John T Maxwell III Date: Fri, 6 Dec 2024 11:54:06 -0800 Subject: [PATCH] Fix LT-21999: Improve saving of parser test reports (#224) * Fix LT-21999: Improve saving of parser test reports * Fix button position * Move button to bottom of window --------- Co-authored-by: Jake Oliver --- Src/LexText/ParserUI/ParserListener.cs | 21 +- Src/LexText/ParserUI/ParserReportDialog.xaml | 250 +++++++++--------- .../ParserUI/ParserReportDialog.xaml.cs | 46 +++- Src/LexText/ParserUI/ParserReportViewModel.cs | 17 ++ Src/LexText/ParserUI/ParserReportsDialog.xaml | 4 +- .../ParserUI/ParserReportsDialog.xaml.cs | 11 +- .../ParserUI/ParserReportsViewModel.cs | 13 +- .../ParserUI/ParserUIStrings.Designer.cs | 9 + Src/LexText/ParserUI/ParserUIStrings.resx | 3 + 9 files changed, 230 insertions(+), 144 deletions(-) diff --git a/Src/LexText/ParserUI/ParserListener.cs b/Src/LexText/ParserUI/ParserListener.cs index 4ec98804bf..f95c9f6fd3 100644 --- a/Src/LexText/ParserUI/ParserListener.cs +++ b/Src/LexText/ParserUI/ParserListener.cs @@ -619,8 +619,8 @@ private void UpdateWordforms(IEnumerable wordforms, ParserPriority ReadParserReports(); // Write an empty parser report. var parserReport = CreateParserReport(); - AddParserReport(parserReport); - ShowParserReport(parserReport, m_mediator, m_cache); + ParserReportViewModel viewModel = AddParserReport(parserReport); + ShowParserReport(viewModel, m_mediator, m_cache); } } m_parserConnection.UpdateWordforms(wordforms, priority, checkParser); @@ -670,8 +670,8 @@ private void WordformUpdatedEventHandler(object sender, WordformUpdatedEventArgs ReadParserReports(); // Convert parse results into ParserReport. var parserReport = CreateParserReport(); - AddParserReport(parserReport); - ShowParserReport(parserReport, m_mediator, m_cache); + ParserReportViewModel viewModel = AddParserReport(parserReport); + ShowParserReport(viewModel, m_mediator, m_cache); } } @@ -701,15 +701,18 @@ ParserReport CreateParserReport() return parserReport; } - public static void SaveParserReport(ParserReport report, LcmCache cache, string defaultComment) + public static void SaveParserReport(ParserReportViewModel reportViewModel, LcmCache cache, string defaultComment) { Form inputBox = CreateInputBox(ParserUIStrings.ksEnterComment, ref defaultComment); DialogResult result = inputBox.ShowDialog(); if (result == DialogResult.OK) { + ParserReport report = reportViewModel.ParserReport; Control textBox = inputBox.Controls["input"]; report.Comment = textBox.Text; + report.DeleteJsonFile(); report.WriteJsonFile(cache); + reportViewModel.UpdateDisplayComment(); } } @@ -850,12 +853,14 @@ private void ReadParserReports() /// /// Add parserReport to the list of parser reports. /// - private void AddParserReport(ParserReport parserReport) + private ParserReportViewModel AddParserReport(ParserReport parserReport) { - m_parserReports.Insert(0, new ParserReportViewModel { ParserReport = parserReport }); + ParserReportViewModel viewModel = new ParserReportViewModel { ParserReport = parserReport }; + m_parserReports.Insert(0, viewModel); if (m_parserReportsDialog != null) // Reset ParserReports so that the window gets notified when the new report is selected. ((ParserReportsViewModel)m_parserReportsDialog.DataContext).ParserReports = m_parserReports; + return viewModel; } /// @@ -863,7 +868,7 @@ private void AddParserReport(ParserReport parserReport) /// /// /// the mediator is used to call TryAWord - public static void ShowParserReport(ParserReport parserReport, Mediator mediator, LcmCache cache) + public static void ShowParserReport(ParserReportViewModel parserReport, Mediator mediator, LcmCache cache) { ParserReportDialog dialog = new ParserReportDialog(parserReport, mediator, cache); dialog.Show(); diff --git a/Src/LexText/ParserUI/ParserReportDialog.xaml b/Src/LexText/ParserUI/ParserReportDialog.xaml index 8197811047..23fa40cb3f 100644 --- a/Src/LexText/ParserUI/ParserReportDialog.xaml +++ b/Src/LexText/ParserUI/ParserReportDialog.xaml @@ -14,169 +14,183 @@ - - - - - -