protected override void SetupDataContext() { TriggerMessageBoxIfAppropriate(); System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; //m_flid = RecordClerk.GetFlidOfVectorFromName(m_vectorName, Cache, out m_owningObject); RecordClerk clerk = Clerk; clerk.ActivateUI(false); m_fakeFlid = clerk.VirtualFlid; // retrieve persisted clerk index and set it. int idx = m_mediator.PropertyTable.GetIntProperty(clerk.PersistedIndexProperty, -1, PropertyTable.SettingsGroup.LocalSettings); if (idx >= 0 && !clerk.HasEmptyList) { int idxOld = clerk.CurrentIndex; try { clerk.JumpToIndex(idx); } catch { clerk.JumpToIndex(idxOld >= 0 ? idxOld : 0); } } clerk.SelectedRecordChanged(); m_hvoOwner = clerk.OwningObject.Hvo; clerk.IsDefaultSort = false; // Create the main view // Review JohnT: should it be m_configurationParameters or .FirstChild? m_mainView = new XmlSeqView(m_hvoOwner, m_fakeFlid, m_configurationParameters); m_mainView.Init(m_mediator, m_configurationParameters); // Required call to xCore.Colleague. m_mainView.Dock = System.Windows.Forms.DockStyle.Fill; m_mainView.Cache = Cache; m_mainView.SelectionChangedEvent += new FwSelectionChangedEventHandler(OnSelectionChanged); m_mainView.ShowRangeSelAfterLostFocus = true; // This makes selections visible. // If the rootsite doesn't have a rootbox, we can't display the record! // Calling ShowRecord() from InitBase() sets the state to appear that we have // displayed (and scrolled), even though we haven't. See LT-7588 for the effect. m_mainView.MakeRoot(); SetupStylesheet(); Controls.Add(m_mainView); if (Controls.Count == 2) { Controls.SetChildIndex(m_mainView, 1); m_mainView.BringToFront(); } m_fullyInitialized = true; // Review JohnT: was this really the crucial last step? }
protected override void ShowRecord() { // ShowRecord is called by InitBase, // but it isn't set up enough to do anything at that call. // Out own Init method needs to call it again. // Either that, or we can try initializing the browse viewer, before calling InitBase, // but that may be worse. if (!m_fullyInitialized || m_suppressShowRecord) { return; } Debug.Assert(m_browseViewer != null, "RecordBrowseView.SetupDataContext() has to be called before RecordBrowseView.ShowRecord()."); RecordClerk clerk = Clerk; // This is a bizarre situation that occurs when the root object is changing and // notifications get sent in non-optimal order. There will be another // ShowRecord call after the two get synchronized. if (clerk.OwningObject != null && clerk.OwningObject.Hvo != m_browseViewer.RootObjectHvo) { return; } int currentIndex = clerk.CurrentIndex; int storedIndex = m_propertyTable.GetIntProperty(Clerk.PersistedIndexProperty, currentIndex, PropertyTable.SettingsGroup.LocalSettings); if (storedIndex != currentIndex && storedIndex >= 0 && !clerk.HasEmptyList) { try { clerk.JumpToIndex(storedIndex); currentIndex = clerk.CurrentIndex; Debug.Assert(currentIndex == storedIndex); } catch { if (currentIndex >= 0) { clerk.JumpToIndex(currentIndex); } } } // all that the base method currently does is put the class name of the selected object // into our information bar. If we're supposed to be showing the short name of the root // object, that needs to be suppressed. // if (!XmlUtils.GetBooleanAttributeValue(m_configurationParameters, "ShowOwnerShortname")) // base.ShowRecord(); // else //SetInfoBarText(); base.ShowRecord(); try { // NOTE: If the clerk's current index is less than zero, // or greater than the number of objects in the vector, // SelectedIndex will assert in a debug build, // and throw an exception in a release build. // The call to m_browseViewer.SelectedIndex will trigger an event, // which will run the OnRecordNavigation method, // which will again try and set m_browseViewer.SelectedIndex, // so we set this to true, so OnRecordNavigation bails out. m_suppressRecordNavigation = true; m_browseViewer.SelectedIndex = currentIndex; } finally { m_suppressRecordNavigation = false; } }