/// <summary> /// Notify clients that the clerk has changed the filter. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Clerk_FilterChangedByClerk(object sender, FilterChangeEventArgs e) { m_fHandlingFilterChangedByClerk = true; // Let the client(s) know about the change. m_browseViewer.UpdateFilterBar(Clerk.Filter); m_fHandlingFilterChangedByClerk = false; }
protected override void SetupDataContext() { base.SetupDataContext(); // Make sure our persisted sorter/filters are up to date so browse viewer // has the latest set for configuring/activating the filterBar bool fNeedReload = Clerk.UpdateFiltersAndSortersIfNeeded(); // This is mainly to handle the possibility that one of our objects in a virtual // property has been deleted, either by some other tool, or by another client altogether. // Enhance: it would be very nice not to do this any time we can be sure it isn't needed. // The second 'true' here is to make it skip the sort. The sort has to be skipped at this // point because our VC has been disposed, and we haven't made a new one yet. The sort // will happen later in the sequence of Init when InitSorter is called int hvo = 0; if (Clerk.OwningObject != null) { hvo = Clerk.OwningObject.Hvo; } // We must update the list if needed BEFORE we create the actual view, otherwise, if it is trying // to display an out-of-date list containing deleted objects, all kinds of things may go wrong. if (XmlUtils.GetOptionalBooleanAttributeValue(m_configurationParameters, "forceReloadListOnInitOrChangeRoot", false)) { m_propertyTable.SetProperty(Clerk.Id + "_AlwaysRecomputeVirtualOnReloadList", true, true); // (EricP) when called by RecordView.InitBase() in the context of ListUpdateHelper.ClearBrowseListUntilReload // the list does not get reloaded until ListUpdateHelper is disposed, but the views property // will get cleared to prevent these views from accessing invalid objects. Clerk.UpdateList(false, true); } m_browseViewer = CreateBrowseViewer(m_configurationParameters, hvo, m_fakeFlid, Cache, m_mediator, m_propertyTable, Clerk.SortItemProvider, Clerk.VirtualListPublisher); m_browseViewer.SortersCompatible += Clerk.AreSortersCompatible; // If possible make it use the style sheet appropriate for its main window. m_browseViewer.SuspendLayout(); SetStyleSheet(); m_browseViewer.Dock = DockStyle.Fill; RecordFilter linkFilter = m_browseViewer.FilterFromLink(); SetupLinkScripture(); if (linkFilter != null) { Clerk.OnChangeFilter(new FilterChangeEventArgs(linkFilter, Clerk.Filter)); } if (Clerk.Filter != null && !Clerk.Filter.IsValid) { Clerk.ResetFilterToDefault(); } m_browseViewer.UpdateFilterBar(Clerk.Filter); bool fSortChanged = m_browseViewer.InitSorter(Clerk.Sorter); // true if we had to change sorter // Do this AFTER we init the sorter and filter, so if any changes are made to the // sorter or filter as we install, we still get the right load. if (fSortChanged) { HandleSortChange(); // Keep the current index -- see LT-8755. } else { List <int> sortedCols = m_browseViewer.SortedColumns; Clerk.IsDefaultSort = sortedCols.Count > 0 && sortedCols[0] == m_browseViewer.DefaultSortColumn; // This won't actually load if in the context of UpdateListHelper() Clerk.UpdateList(true, fNeedReload); } // Do this very late, it can't display properly until its record list has been built and sorted. Controls.Add(m_browseViewer); m_browseViewer.BringToFront(); m_browseViewer.ResumeLayout(); }
protected override void SetupDataContext() { base.SetupDataContext(); // Make sure our persisted sorter/filters are up to date so browse viewer // has the latest set for configuring/activating the filterBar bool fNeedReload = Clerk.UpdateFiltersAndSortersIfNeeded(); // This is mainly to handle the possibility that one of our objects in a virtual // property has been deleted, either by some other tool, or by another client altogether. // Enhance: it would be very nice not to do this any time we can be sure it isn't needed. // The second 'true' here is to make it skip the sort. The sort has to be skipped at this // point because our VC has been disposed, and we haven't made a new one yet. The sort // will happen later in the sequence of Init when InitSorter is called int hvo = 0; if (Clerk.OwningObject != null) hvo = Clerk.OwningObject.Hvo; // We must update the list if needed BEFORE we create the actual view, otherwise, if it is trying // to display an out-of-date list containing deleted objects, all kinds of things may go wrong. if (XmlUtils.GetOptionalBooleanAttributeValue(m_configurationParameters, "forceReloadListOnInitOrChangeRoot", false)) { m_mediator.PropertyTable.SetProperty(Clerk.Id + "_AlwaysRecomputeVirtualOnReloadList", true); // (EricP) when called by RecordView.InitBase() in the context of ListUpdateHelper.ClearBrowseListUntilReload // the list does not get reloaded until ListUpdateHelper is disposed, but the views property // will get cleared to prevent these views from accessing invalid objects. Clerk.UpdateList(false, true); } m_browseViewer = CreateBrowseViewer(m_configurationParameters, hvo, m_fakeFlid, Cache, m_mediator, Clerk.SortItemProvider); // If possible make it use the style sheet appropriate for its main window. m_browseViewer.SuspendLayout(); SetStyleSheet(); m_browseViewer.Dock = DockStyle.Fill; RecordFilter linkFilter = m_browseViewer.FilterFromLink(); if (linkFilter != null) Clerk.OnChangeFilter(new FilterChangeEventArgs(linkFilter, Clerk.Filter)); if (Clerk.Filter != null && !Clerk.Filter.IsValid) Clerk.ResetFilterToDefault(); m_browseViewer.UpdateFilterBar(Clerk.Filter); bool fSortChanged = m_browseViewer.InitSorter(Clerk.Sorter); // true if we had to change sorter // Do this AFTER we init the sorter and filter, so if any changes are made to the // sorter or filter as we install, we still get the right load. if (fSortChanged) { HandleSortChange(); // Keep the current index -- see LT-8755. } else { List<int> sortedCols = m_browseViewer.SortedColumns; Clerk.IsDefaultSort = sortedCols.Count > 0 && sortedCols[0] == m_browseViewer.DefaultSortColumn; // This won't actually load if in the context of UpdateListHelper() Clerk.UpdateList(true, fSortChanged || fNeedReload); } // Do this very late, it can't display properly until its record list has been built and sorted. Controls.Add(m_browseViewer); m_browseViewer.BringToFront(); m_browseViewer.ResumeLayout(); }