From a7825b650d2688d9455ef7570a33c64b2d89edd8 Mon Sep 17 00:00:00 2001 From: mark-sil <83427558+mark-sil@users.noreply.github.com> Date: Thu, 15 Oct 2026 08:28:31 -0400 Subject: [PATCH] Remove the unreachable reversal-index delete command LT-16385 (2161fc27a, 2015) removed CmdInsertReversalIndex and CmdDeleteReversalIndex from the Lexicon areaConfiguration.xml, since reversal indexes became one per analysis writing system, created on demand by IReversalIndexRepository.FindOrCreateIndexForWs. Nothing has sent the InsertReversalIndex or DeleteReversalIndex messages since, but ReversalClerk kept their handlers. Nothing reachable changes. Co-Authored-By: Claude Opus 5.5 --- Src/LexText/Lexicon/LexEdStrings.Designer.cs | 18 --- Src/LexText/Lexicon/LexEdStrings.resx | 6 - Src/LexText/Lexicon/ReversalListener.cs | 145 ------------------- 3 files changed, 169 deletions(-) diff --git a/Src/LexText/Lexicon/LexEdStrings.Designer.cs b/Src/LexText/Lexicon/LexEdStrings.Designer.cs index 12c42f1f90..03a16fdbd1 100644 --- a/Src/LexText/Lexicon/LexEdStrings.Designer.cs +++ b/Src/LexText/Lexicon/LexEdStrings.Designer.cs @@ -564,15 +564,6 @@ internal static string ksDeleteSequenceCollectionB { } } - /// - /// Looks up a localized string similar to You are deleting the following Reversal Index:. - /// - internal static string ksDeletingThisRevIndex { - get { - return ResourceManager.GetString("ksDeletingThisRevIndex", resourceCulture); - } - } - /// /// Looks up a localized string similar to Edit {0}. /// @@ -762,15 +753,6 @@ internal static string ksNormallyHidden { } } - /// - /// Looks up a localized string similar to Do you really want to delete this Reversal Index?. - /// - internal static string ksReallyWantToDeleteRevIndex { - get { - return ResourceManager.GetString("ksReallyWantToDeleteRevIndex", resourceCulture); - } - } - /// /// Looks up a localized string similar to Reassign Homographs. /// diff --git a/Src/LexText/Lexicon/LexEdStrings.resx b/Src/LexText/Lexicon/LexEdStrings.resx index 4ae891d96f..8f4c2d99fc 100644 --- a/Src/LexText/Lexicon/LexEdStrings.resx +++ b/Src/LexText/Lexicon/LexEdStrings.resx @@ -162,9 +162,6 @@ relation. - - You are deleting the following Reversal Index: - Edit {0} @@ -218,9 +215,6 @@ Normally hidden menu item - - Do you really want to delete this Reversal Index? - Reassign Homographs diff --git a/Src/LexText/Lexicon/ReversalListener.cs b/Src/LexText/Lexicon/ReversalListener.cs index f4733f29bd..59f15cca68 100644 --- a/Src/LexText/Lexicon/ReversalListener.cs +++ b/Src/LexText/Lexicon/ReversalListener.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Xml; @@ -15,8 +14,6 @@ using static SIL.FieldWorks.Common.FwUtils.FwUtils; using SIL.FieldWorks.Common.RootSites; using SIL.LCModel; -using SIL.LCModel.Infrastructure; -using SIL.FieldWorks.FdoUi.Dialogs; using SIL.FieldWorks.Filters; using XCore; using SIL.FieldWorks.FdoUi; @@ -618,148 +615,6 @@ private int GetRootIndex(int lastValidIndex) return parentIndex == -1 ? lastValidIndex : GetRootIndex(parentIndex); } - /// - /// This is enabled whenever the ReversalClerk is active. - /// - /// - /// - /// - public virtual bool OnDisplayInsertReversalIndex(object commandObject, ref UIItemDisplayProperties display) - { - CheckDisposed(); - - if (Cache == null) - { - display.Enabled = false; - } - else - { - int cRevIdx = Cache.LanguageProject.LexDbOA.ReversalIndexesOC.Count; - int cWs = Cache.ServiceLocator.WritingSystems.AllWritingSystems.Count(); - display.Enabled = cRevIdx < cWs; - } - display.Visible = true; - return true; - } - - /// - /// This is enabled whenever the ReversalClerk is active. - /// - /// - /// - /// - public virtual bool OnDisplayDeleteReversalIndex(object commandObject, ref UIItemDisplayProperties display) - { - CheckDisposed(); - - if (Cache == null) - { - display.Enabled = false; - } - else - { - int cRevIdx = Cache.LanguageProject.LexDbOA.ReversalIndexesOC.Count; - display.Enabled = cRevIdx > 0; - } - display.Visible = true; - return true; - } - - /// - /// - /// - /// - public virtual void OnDeleteReversalIndex(object argument) - { - CheckDisposed(); - - var oldGuid = ReversalIndexEntryUi.GetObjectGuidIfValid(m_propertyTable, "ReversalIndexGuid"); - if (oldGuid.Equals(Guid.Empty)) - return; - - if (Cache == null) - return; - IReversalIndex ri = (IReversalIndex)Cache.ServiceLocator.GetObject(oldGuid); - DeleteReversalIndex(ri); - } - - public void DeleteReversalIndex(IReversalIndex ri) - { - CheckDisposed(); - - var mainWindow = m_propertyTable.GetValue
("window"); - using (new WaitCursor(mainWindow)) - { - using (var dlg = new ConfirmDeleteObjectDlg(m_propertyTable.GetValue("HelpTopicProvider"))) - { - var ui = new CmObjectUi(ri); - dlg.SetDlgInfo(ui, Cache, m_mediator, m_propertyTable); - dlg.TopMessage = LexEdStrings.ksDeletingThisRevIndex; - dlg.BottomQuestion = LexEdStrings.ksReallyWantToDeleteRevIndex; - if (DialogResult.Yes == dlg.ShowDialog(mainWindow)) - ReallyDeleteReversalIndex(ri); - } - } - } - - protected virtual void ReallyDeleteReversalIndex(IReversalIndex ri) - { - try - { - Debug.Assert(ri.Hvo == m_list.OwningObject.Hvo); - m_list.ListModificationInProgress = true; // can't reload deleted list! (LT-5353) - // We're about to do a MasterRefresh which clobbers the Undo stack, - // so we might as well make this UOW not undoable - NonUndoableUnitOfWorkHelper.Do(Cache.ActionHandlerAccessor, - () => - { - Cache.DomainDataByFlid.DeleteObj(ri.Hvo); - int cobjNew; - var idxNew = ReversalIndexAfterDeletion(Cache, out cobjNew); - SetReversalIndexGuid(idxNew.Guid); - }); - ChangeOwningObjectIfPossible(true); - } - finally - { - m_list.ListModificationInProgress = false; - } - // Without this, stale data can still display in the BulkEditSenses tool if you - // recreate the deleted reversal index. - Publisher.Publish(new PublisherParameterObject(EventConstants.MasterRefresh, null, m_propertyTable.GetWindow())); - } - - internal static IReversalIndex ReversalIndexAfterDeletion(LcmCache cache, out int cobjNew) - { - IReversalIndex newIdx; - cobjNew = cache.LanguageProject.LexDbOA.ReversalIndexesOC.Count; - if (cobjNew == 0) - { - // Big trouble ensues if we don't have any reversal indexes at all, so ... - // Create a reversal index for the current default analysis writing system. - var riRepo = cache.ServiceLocator.GetInstance(); - newIdx = riRepo.FindOrCreateIndexForWs(cache.DefaultAnalWs); - - cobjNew = 1; - } - else - { - // Regardless, we need to change the reversal index hvo since the old one just - // disappeared. - newIdx = cache.LanguageProject.LexDbOA.ReversalIndexesOC.ToArray()[0]; - } - return newIdx; - } - - private void SetReversalIndexGuid(Guid ReversalIndexGuid) - { - if (Cache.ServiceLocator.GetObject(ReversalIndexGuid) is IReversalIndex) - { - m_propertyTable.SetProperty("ReversalIndexGuid", ReversalIndexGuid.ToString(), true); - m_propertyTable.SetPropertyPersistence("ReversalIndexGuid", true); - } - } - abstract protected ICmObject NewOwningObject(IReversalIndex ri); }