diff --git a/Src/LexText/ParserCore/ParserReport.cs b/Src/LexText/ParserCore/ParserReport.cs index ec6db14851..ea04de3231 100644 --- a/Src/LexText/ParserCore/ParserReport.cs +++ b/Src/LexText/ParserCore/ParserReport.cs @@ -40,6 +40,11 @@ public class ParserReport: IEquatable /// public long DiffTimestamp { get; set; } + /// + /// User-specified comment. + /// + public string Comment { get; set; } + /// /// Number of words parsed /// diff --git a/Src/LexText/ParserUI/ParserListener.cs b/Src/LexText/ParserUI/ParserListener.cs index 22e3c8eb71..4ec98804bf 100644 --- a/Src/LexText/ParserUI/ParserListener.cs +++ b/Src/LexText/ParserUI/ParserListener.cs @@ -69,6 +69,7 @@ public class ParserListener : IxCoreColleague, IDisposable, IVwNotifyChange private string m_sourceText = null; private ObservableCollection m_parserReports = null; private ParserReportsDialog m_parserReportsDialog = null; + private string m_defaultComment = null; public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configurationParameters) { @@ -617,7 +618,7 @@ private void UpdateWordforms(IEnumerable wordforms, ParserPriority { ReadParserReports(); // Write an empty parser report. - var parserReport = WriteParserReport(); + var parserReport = CreateParserReport(); AddParserReport(parserReport); ShowParserReport(parserReport, m_mediator, m_cache); } @@ -668,18 +669,17 @@ private void WordformUpdatedEventHandler(object sender, WordformUpdatedEventArgs // Read parser reports before writing and adding a parser report to avoid duplicates. ReadParserReports(); // Convert parse results into ParserReport. - var parserReport = WriteParserReport(); + var parserReport = CreateParserReport(); AddParserReport(parserReport); ShowParserReport(parserReport, m_mediator, m_cache); } } /// - /// Write the parse results as a parser report in the standard place. + /// Create a parser report from the parse results. /// - ParserReport WriteParserReport() + ParserReport CreateParserReport() { - // Create a parser report from the parse results. var parserReport = new ParserReport(m_cache) { SourceText = m_sourceText @@ -696,13 +696,62 @@ ParserReport WriteParserReport() parserReport.AddParseReport(form.Text, parseReport); } } - // Write the parser report to the default place. - parserReport.WriteJsonFile(m_cache); // Clear the data we wrote. m_checkParserResults = null; return parserReport; } + public static void SaveParserReport(ParserReport report, LcmCache cache, string defaultComment) + { + Form inputBox = CreateInputBox(ParserUIStrings.ksEnterComment, ref defaultComment); + DialogResult result = inputBox.ShowDialog(); + if (result == DialogResult.OK) + { + Control textBox = inputBox.Controls["input"]; + report.Comment = textBox.Text; + report.WriteJsonFile(cache); + } + } + + private static Form CreateInputBox(string title, ref string input) + { + System.Drawing.Size size = new System.Drawing.Size(400, 70); + Form inputBox = new Form(); + + inputBox.FormBorderStyle = FormBorderStyle.FixedDialog; + inputBox.ClientSize = size; + inputBox.Text = title; + inputBox.StartPosition = FormStartPosition.CenterScreen; + + TextBox textBox = new TextBox(); + textBox.Size = new System.Drawing.Size(size.Width - 10, 23); + textBox.Location = new System.Drawing.Point(5, 5); + textBox.Text = input; + textBox.Name = "input"; + inputBox.Controls.Add(textBox); + + Button okButton = new Button(); + okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + okButton.Name = "okButton"; + okButton.Size = new System.Drawing.Size(75, 23); + okButton.Text = "&OK"; + okButton.Location = new System.Drawing.Point(size.Width - 80 - 80, 39); + inputBox.Controls.Add(okButton); + + Button cancelButton = new Button(); + cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + cancelButton.Name = "cancelButton"; + cancelButton.Size = new System.Drawing.Size(75, 23); + cancelButton.Text = "&Cancel"; + cancelButton.Location = new System.Drawing.Point(size.Width - 80, 39); + inputBox.Controls.Add(cancelButton); + + inputBox.AcceptButton = okButton; + inputBox.CancelButton = cancelButton; + + return inputBox; + } + /// /// Suppress this parse result if it is an uppercase wordform whose analyses all came from its lowercase version. /// This only happens in projects that were parsed before we decided that the case of wordforms in analyses @@ -765,7 +814,7 @@ public void ShowParserReports() { ReadParserReports(); // Create parser reports window. - m_parserReportsDialog = new ParserReportsDialog(m_parserReports, m_mediator, m_cache); + m_parserReportsDialog = new ParserReportsDialog(m_parserReports, m_mediator, m_cache, m_defaultComment); m_parserReportsDialog.Closed += ParserReportsDialog_Closed; } m_parserReportsDialog.Show(); // Show the dialog but do not block other app access @@ -774,6 +823,10 @@ public void ShowParserReports() private void ParserReportsDialog_Closed(object sender, EventArgs e) { + ParserReportsDialog dialog = (ParserReportsDialog)sender; + // Preserve the default comment for the next call to ShowParserReports. + if (dialog != null) + m_defaultComment = dialog.DefaultComment; m_parserReportsDialog = null; } diff --git a/Src/LexText/ParserUI/ParserReportsDialog.xaml b/Src/LexText/ParserUI/ParserReportsDialog.xaml index 9941d38385..630b7c6d6d 100644 --- a/Src/LexText/ParserUI/ParserReportsDialog.xaml +++ b/Src/LexText/ParserUI/ParserReportsDialog.xaml @@ -25,7 +25,7 @@ - + + + + + + +