diff --git a/Src/xWorks/FwXWindow.cs b/Src/xWorks/FwXWindow.cs index b03d8d48ad..9cac0726fe 100644 --- a/Src/xWorks/FwXWindow.cs +++ b/Src/xWorks/FwXWindow.cs @@ -1242,7 +1242,7 @@ protected bool OnJumpToPopupLexEntry(object command) } m_popupLexEntryWindow.BringToFront(); m_popupLexEntryWindow.Activate(); - Mediator.BroadcastMessage("JumpToRecord", command); + Mediator.BroadcastMessage("JumpToPopupRecord", command); Mediator.BroadcastMessage("FocusFirstPossibleSlice", null); } return true; diff --git a/Src/xWorks/PopupToolWindow.cs b/Src/xWorks/PopupToolWindow.cs index 9383397523..c439f67eb6 100644 --- a/Src/xWorks/PopupToolWindow.cs +++ b/Src/xWorks/PopupToolWindow.cs @@ -1,5 +1,6 @@ using SIL.LCModel; using SIL.Utils; +using System; using System.Windows.Forms; using System.Xml; using XCore; @@ -15,6 +16,9 @@ public Control MainControl get { return m_mainContentControl; } } + private PropertyTable m_propertyTable; + private RecordClerk m_recordClerk; + public PopupToolWindow() { InitializeComponent(); @@ -36,9 +40,30 @@ private void InitializeComponent() this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; this.Text = "Popup Tool Window"; this.WindowState = System.Windows.Forms.FormWindowState.Normal; + this.Deactivate += new System.EventHandler(PopupToolWindow_Deactivate); + this.Activated += new System.EventHandler(PopupToolWindow_Activated); this.ResumeLayout(false); } + private void PopupToolWindow_Deactivate(object sender, EventArgs e) + { + var oldActiveClerk = m_propertyTable.GetValue("OldActiveClerk"); + var oldUseRecordTreeBar = m_propertyTable.GetValue("OldUseRecordTreeBar"); + var oldOldUpdateStatusBar = m_propertyTable.GetValue("OldUpdateStatusBar"); + if (oldActiveClerk != null) + { + oldActiveClerk.ActivateUI(oldUseRecordTreeBar, oldOldUpdateStatusBar); + } + } + + private void PopupToolWindow_Activated(object sender, EventArgs e) + { + if (m_recordClerk != null) + { + m_recordClerk.ActivateUI(false); + } + } + private IxCoreColleague MainContentControlAsIxCoreColleague { get { return m_mainContentControl as IxCoreColleague; } @@ -61,6 +86,7 @@ public virtual IxCoreColleague[] GetMessageTargets() public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode toolNode) { + m_propertyTable = propertyTable; XmlNode contentClassNode = toolNode.SelectSingleNode("control"); XmlNode dynLoaderNode = contentClassNode.SelectSingleNode("dynamicloaderinfo"); string contentAssemblyPath = XmlUtils.GetMandatoryAttributeValue(dynLoaderNode, "assemblyPath"); @@ -93,6 +119,7 @@ public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode toolNod this.Show(); this.BringToFront(); this.Activate(); + m_recordClerk = m_propertyTable.GetValue("ActiveClerk"); } } } diff --git a/Src/xWorks/RecordClerk.cs b/Src/xWorks/RecordClerk.cs index b7377b9fac..f1ed3af84f 100644 --- a/Src/xWorks/RecordClerk.cs +++ b/Src/xWorks/RecordClerk.cs @@ -654,6 +654,9 @@ internal protected bool IsActiveInGui get { return m_fIsActiveInGui; } } + private bool m_updateStatusBar; + private bool m_useRecordTreeBar; + /// /// determine if we're in the (given) tool /// @@ -1051,12 +1054,22 @@ protected virtual bool AddItemToList(int hvoItem) return false; } + public bool OnJumpToPopupRecord(object argument) + { + return JumpToRecord(argument, true); + } + + public bool OnJumpToRecord(object argument) + { + return JumpToRecord(argument); + } + /// /// display the given record /// /// the hvo of the record /// - public bool OnJumpToRecord(object argument) + bool JumpToRecord(object argument, bool popup = false) { CheckDisposed(); @@ -1101,7 +1114,10 @@ public bool OnJumpToRecord(object argument) // update issue reported in (LT-2448). However, that message only works in the context of a // BrowseViewer, not a document view (e.g. Dictionary) (see LT-7298). So, I've // tested OnChangeFilterClearAll, and it seems to solve both problems now. - OnChangeFilterClearAll(null); + if (!popup) + { + OnChangeFilterClearAll(null); + } m_activeMenuBarFilter = null; index = IndexOfObjOrChildOrParent(hvoTarget); } @@ -2027,8 +2043,22 @@ virtual public bool IsControllingTheRecordTreeBar var oldActiveClerk = m_propertyTable.GetValue("ActiveClerk"); if (oldActiveClerk != this) { + var oldUseRecordTreeBar = m_propertyTable.GetValue("UseRecordTreeBar"); + m_propertyTable.SetProperty("OldUseRecordTreeBar", oldUseRecordTreeBar, true); + m_propertyTable.SetPropertyPersistence("OldUseRecordTreeBar", false); + m_propertyTable.SetProperty("UseRecordTreeBar", m_useRecordTreeBar, true); + m_propertyTable.SetPropertyPersistence("UseRecordTreeBar", false); + + var oldUpdateStatusBar = m_propertyTable.GetValue("UpdateStatusBar"); + m_propertyTable.SetProperty("OldUpdateStatusBar", oldUpdateStatusBar, true); + m_propertyTable.SetPropertyPersistence("OldUpdateStatusBar", false); + m_propertyTable.SetProperty("UpdateStatusBar", m_updateStatusBar, true); + m_propertyTable.SetPropertyPersistence("UpdateStatusBar", false); + if (oldActiveClerk != null) oldActiveClerk.BecomeInactive(); + m_propertyTable.SetProperty("OldActiveClerk", oldActiveClerk, true); + m_propertyTable.SetPropertyPersistence("OldActiveClerk", false); m_propertyTable.SetProperty("ActiveClerk", this, true); m_propertyTable.SetPropertyPersistence("ActiveClerk", false); // We are adding this property so that EntryDlgListener can get access to the owning object @@ -2077,6 +2107,9 @@ virtual public void ActivateUI(bool useRecordTreeBar, bool updateStatusBar = tru m_fIsActiveInGui = true; CheckDisposed(); + m_useRecordTreeBar = useRecordTreeBar; + m_updateStatusBar = updateStatusBar; + if (m_recordBarHandler != null) { IsControllingTheRecordTreeBar = true;