From c01a672ec98810ddb5f8b8effac0d64311aedd2c Mon Sep 17 00:00:00 2001 From: Jake Oliver Date: Fri, 10 May 2024 10:29:01 -0400 Subject: [PATCH 1/2] Do some minor refactoring in InterlinMaster.cs --- Src/LexText/Interlinear/InterlinMaster.cs | 83 +++++++---------------- 1 file changed, 24 insertions(+), 59 deletions(-) diff --git a/Src/LexText/Interlinear/InterlinMaster.cs b/Src/LexText/Interlinear/InterlinMaster.cs index f4678166a2..b73c83705d 100644 --- a/Src/LexText/Interlinear/InterlinMaster.cs +++ b/Src/LexText/Interlinear/InterlinMaster.cs @@ -166,9 +166,8 @@ private void SetupInterlinearTabControlForStText(IInterlinearTabControl site) { InitializeInterlinearTabControl(site); //if (site is ISetupLineChoices && m_tabCtrl.SelectedIndex != ktpsCChart) - if (site is ISetupLineChoices) + if (site is ISetupLineChoices interlinearView) { - var interlinearView = site as ISetupLineChoices; interlinearView.SetupLineChoices($"InterlinConfig_v3_{(interlinearView.ForEditing ? "Edit" : "Doc")}_{InterlinearTab}", $"InterlinConfig_v2_{(interlinearView.ForEditing ? "Edit" : "Doc")}_{InterlinearTab}", GetLineMode()); @@ -290,9 +289,7 @@ internal void SaveBookMark() return; // nothing to save...for now, don't overwrite existing one. if (RootStText == null) - { return; - } AnalysisOccurrence curAnalysis = null; var fSaved = false; @@ -509,17 +506,12 @@ public bool OnDisplayLexiconLookup(object commandObject, CheckDisposed(); display.Visible = true; - if (m_tabCtrl.SelectedIndex != ktpsRawText) - display.Enabled = false; - else - { - //LT-6904 : exposed this case where the m_rtPane was null - // (another case of toolbar processing being done at an unepxected time) - if (m_rtPane == null) - display.Enabled = false; - else - display.Enabled = m_rtPane.LexiconLookupEnabled(); - } + + //LT-6904 : exposed the case where the m_rtPane was null + // (another case of toolbar processing being done at an unexpected time) + display.Enabled = m_tabCtrl.SelectedIndex == ktpsRawText ? + m_rtPane?.LexiconLookupEnabled() ?? false : false; + return true; } @@ -600,16 +592,10 @@ protected void ShowTabView() m_infoPane.Dock = DockStyle.Fill; m_infoPane.Enabled = m_infoPane.CurrentRootHvo != 0; - if (m_infoPane.Enabled) - { - m_infoPane.BackColor = System.Drawing.SystemColors.Control; - if (ParentForm == Form.ActiveForm) - m_infoPane.Focus(); - } - else - { - m_infoPane.BackColor = System.Drawing.Color.White; - } + m_infoPane.BackColor = m_infoPane.Enabled ? SystemColors.Control : Color.White; + + if (m_infoPane.Enabled && ParentForm == Form.ActiveForm) + m_infoPane.Focus(); break; default: break; @@ -637,7 +623,7 @@ private void CreateCChart() private void SetupChartPane() { (m_constChartPane as IxCoreColleague).Init(m_mediator, m_propertyTable, m_configurationParameters); - m_constChartPane.BackColor = System.Drawing.SystemColors.Window; + m_constChartPane.BackColor = SystemColors.Window; m_constChartPane.Name = "m_constChartPane"; m_constChartPane.Dock = DockStyle.Fill; } @@ -725,12 +711,12 @@ public override void Init(Mediator mediator, PropertyTable propertyTable, XmlNod // Do this BEFORE calling InitBase, which calls ShowRecord, whose correct behavior // depends on the suppressAutoCreate flag. bool fHideTitlePane = XmlUtils.GetBooleanAttributeValue(configurationParameters, "hideTitleContents"); + + // When used as the third pane of a concordance, we don't want the + // title/contents stuff. if (fHideTitlePane) - { - // When used as the third pane of a concordance, we don't want the - // title/contents stuff. m_tcPane.Visible = false; - } + m_fSuppressAutoCreate = XmlUtils.GetBooleanAttributeValue(configurationParameters, "suppressAutoCreate"); @@ -773,15 +759,10 @@ private void SetInitialTabPage() { // If the Record Clerk has remembered we're IsPersistedForAnInterlinearTabPage, // and we haven't already switched to that tab page, do so now. - if (this.Visible && m_tabCtrl.SelectedIndex != (int)InterlinearTab) - { + m_tabCtrl.SelectedIndex = Visible && m_tabCtrl.SelectedIndex != (int)InterlinearTab ? // Switch to the persisted tab page index. - m_tabCtrl.SelectedIndex = (int)InterlinearTab; - } - else - { - m_tabCtrl.SelectedIndex = ktpsRawText; - } + (int)InterlinearTab : + ktpsRawText; } /// @@ -798,7 +779,7 @@ public override bool PrepareToGoAway() private bool SaveWorkInProgress() { - if (m_idcAnalyze != null && m_idcAnalyze.Visible && !m_idcAnalyze.PrepareToGoAway()) + if (m_idcAnalyze != null && m_idcAnalyze.Visible && !m_idcAnalyze.PrepareToGoAway()) return false; if (m_idcGloss != null && m_idcGloss.Visible && !m_idcGloss.PrepareToGoAway()) return false; @@ -912,9 +893,7 @@ protected override void ShowRecord() return; //This is our very first time trying to show a text, if possible we would like to show the stored text. if (m_bookmarks == null) - { m_bookmarks = new Dictionary, InterAreaBookmark>(); - } // It's important not to do this if there is a filter, as there's a good chance the new // record doesn't pass the filter and we get into an infinite loop. Also, if the user @@ -962,27 +941,21 @@ protected override void ShowRecord() { var stText = Cache.ServiceLocator.GetInstance().GetObject(hvoRoot); if (stText.ParagraphsOS.Count == 0) - { NonUndoableUnitOfWorkHelper.Do(Cache.ActionHandlerAccessor, () => ((InterlinearTextsRecordClerk)Clerk).CreateFirstParagraph(stText, Cache.DefaultVernWs)); - } if (stText.ParagraphsOS.Count == 1 && ((IStTxtPara)stText.ParagraphsOS[0]).Contents.Length == 0) { // If we have restarted FLEx since this text was created, the WS has been lost and replaced with the userWs. // If this is the case, default to the Default Vernacular WS (LT-15688 & LT-20837) var userWs = Cache.ServiceLocator.WritingSystemManager.UserWs; if(stText.MainWritingSystem == userWs) - { NonUndoableUnitOfWorkHelper.Do(Cache.ActionHandlerAccessor, () => ((IStTxtPara)stText.ParagraphsOS[0]).Contents = TsStringUtils.MakeString(string.Empty, Cache.DefaultVernWs)); - } // since we have no text, we should not sit on any of the analyses tabs, // the info tab is still useful though. if (InterlinearTab != TabPageSelection.Info && InterlinearTab != TabPageSelection.RawText) - { InterlinearTab = TabPageSelection.RawText; - } // Don't steal the focus from another window. See FWR-1795. if (ParentForm == Form.ActiveForm) m_rtPane.Focus(); @@ -1054,13 +1027,9 @@ private void CreateOrRestoreBookmark(IStText stText) { InterAreaBookmark mark; if (m_bookmarks.TryGetValue(new Tuple(CurrentTool, stText.Guid), out mark)) - { mark.Restore(IndexOfTextRecord); - } else - { m_bookmarks.Add(new Tuple(CurrentTool, stText.Guid), new InterAreaBookmark(this, Cache, m_propertyTable)); - } } } @@ -1312,7 +1281,6 @@ protected override void UpdateContextHistory() Guid guid = Guid.Empty; if (Clerk.CurrentObject != null) guid = Clerk.CurrentObject.Guid; - LcmCache cache = Cache; // Not sure what will happen with guid == Guid.Empty on the link... FwLinkArgs link = new FwLinkArgs(toolName, guid, InterlinearTab.ToString()); link.PropertyTableEntries.Add(new Property("InterlinearTab", @@ -1358,9 +1326,8 @@ public bool OnDisplayITexts_AddWordsToLexicon(object commandObject, ref UIItemDisplayProperties display) { CheckDisposed(); - var fCanDisplayAddWordsToLexiconPanelBarButton = InterlinearTab == TabPageSelection.Gloss; - display.Visible = fCanDisplayAddWordsToLexiconPanelBarButton; - display.Enabled = fCanDisplayAddWordsToLexiconPanelBarButton; + // Can display add words to lexicon panel bar button + display.Visible = display.Enabled = InterlinearTab == TabPageSelection.Gloss; return true; } @@ -1381,9 +1348,8 @@ public bool OnDisplayShowHiddenFields_interlinearEdit(object commandObject, ref UIItemDisplayProperties display) { CheckDisposed(); - var fCanDisplayAddWordsToLexiconPanelBarButton = InterlinearTab == TabPageSelection.Info; - display.Visible = fCanDisplayAddWordsToLexiconPanelBarButton; - display.Enabled = fCanDisplayAddWordsToLexiconPanelBarButton; + // Can display add words to lexicon panel bar button + display.Visible = display.Enabled = InterlinearTab == TabPageSelection.Info; return true; } @@ -1435,7 +1401,6 @@ private void m_tabCtrl_Deselecting(object sender, TabControlCancelEventArgs e) // params. if (m_configurationParameters != null /* && !Cache.DatabaseAccessor.IsTransactionOpen() */) Clerk.SaveOnChangeRecord(); - bool fParsedTextDuringSave = false; // Pane-individual updates; None did anything, I removed them; GJM // Is this where we need to hook in reparsing of segments/paras, etc. if RawTextPane is deselected? // No. See DomainImpl.AnalysisAdjuster. From 4c8ce06b663da1f21b51972b57ce35290d774eb8 Mon Sep 17 00:00:00 2001 From: Jake Oliver Date: Mon, 13 May 2024 11:13:03 -0400 Subject: [PATCH 2/2] Remove trailing whitespace in InterlinMaster.cs --- Src/LexText/Interlinear/InterlinMaster.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Src/LexText/Interlinear/InterlinMaster.cs b/Src/LexText/Interlinear/InterlinMaster.cs index b73c83705d..87fd9523bb 100644 --- a/Src/LexText/Interlinear/InterlinMaster.cs +++ b/Src/LexText/Interlinear/InterlinMaster.cs @@ -511,7 +511,6 @@ public bool OnDisplayLexiconLookup(object commandObject, // (another case of toolbar processing being done at an unexpected time) display.Enabled = m_tabCtrl.SelectedIndex == ktpsRawText ? m_rtPane?.LexiconLookupEnabled() ?? false : false; - return true; } @@ -593,7 +592,6 @@ protected void ShowTabView() m_infoPane.Enabled = m_infoPane.CurrentRootHvo != 0; m_infoPane.BackColor = m_infoPane.Enabled ? SystemColors.Control : Color.White; - if (m_infoPane.Enabled && ParentForm == Form.ActiveForm) m_infoPane.Focus(); break; @@ -716,7 +714,6 @@ public override void Init(Mediator mediator, PropertyTable propertyTable, XmlNod // title/contents stuff. if (fHideTitlePane) m_tcPane.Visible = false; - m_fSuppressAutoCreate = XmlUtils.GetBooleanAttributeValue(configurationParameters, "suppressAutoCreate");