public int CompatibleSorterIndex(RecordSorter other) { for (int i = 0; i < m_sorters.Count; i++) if (((RecordSorter)m_sorters[i]).CompatibleSorter(other)) return i; return -1; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Return true if the other sorter is 'compatible' with this, in the sense that /// either they produce the same sort sequence, or one derived from it (e.g., by reversing). /// </summary> /// <param name="other"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public override bool CompatibleSorter(RecordSorter other) { GenRecordSorter grsOther = other as GenRecordSorter; if (grsOther == null) return false; if (CompatibleComparers(m_comp, grsOther.m_comp)) return true; // Currently the only other kind of compatibility we know how to detect // is StringFinderCompares that do more-or-less the same thing. StringFinderCompare sfcThis = m_comp as StringFinderCompare; StringFinderCompare sfcOther = grsOther.Comparer as StringFinderCompare; if (sfcThis == null || sfcOther == null) return false; if (!sfcThis.Finder.SameFinder(sfcOther.Finder)) return false; // We deliberately don't care if one has a ReverseCompare and the other // doesn't. That's handled by a different icon. IComparer subCompOther = UnpackReverseCompare(sfcOther); IComparer subCompThis = UnpackReverseCompare(sfcThis); return CompatibleComparers(subCompThis, subCompOther); }
/// ------------------------------------------------------------------------------------------ /// <summary> /// Replaces a sorter /// </summary> /// <param name="index">The index where we want to replace the sorter</param> /// <param name="oldSorter">A reference to the old sorter</param> /// <param name="newSorter">A reference to the new sorter</param> /// ------------------------------------------------------------------------------------------ public void ReplaceAt(int index, RecordSorter oldSorter, RecordSorter newSorter) { if (index < 0 || index >= m_sorters.Count) throw new IndexOutOfRangeException(); m_sorters[index] = newSorter; }
public override bool CompatibleSorter(RecordSorter other) { foreach (RecordSorter rs in m_sorters) if(rs.CompatibleSorter(other)) return true; return false; }
/// <summary> /// Return true if the other sorter is 'compatible' with this, in the sense that /// either they produce the same sort sequence, or one derived from it (e.g., by reversing). /// </summary> /// <param name="other"></param> /// <returns></returns> public virtual bool CompatibleSorter(RecordSorter other) { return false; }
/// ------------------------------------------------------------------------------------------ /// <summary> /// Adds a sorter /// </summary> /// <param name="sorter">A reference to a sorter</param> /// ------------------------------------------------------------------------------------------ public void Add(RecordSorter sorter) { m_sorters.Add(sorter); }
public FindResultSorter(ITsString searchString, RecordSorter sorter) { m_comp = searchString.Text != null ? new ExactMatchFirstComparer(searchString.Text, sorter.getComparer()) : sorter.getComparer(); }
public override void ChangeSorter(RecordSorter sorter) { RequestRefresh(); base.ChangeSorter(sorter); }
/// <summary> /// Test to see if the two given sorters are compatible, override if you need to check for something /// beyond what the RecordSorter.CompatibleSorter() will test. /// </summary> /// <param name="first"></param> /// <param name="second"></param> /// <returns></returns> public virtual bool AreSortersCompatible(RecordSorter first, RecordSorter second) { return first.CompatibleSorter(second); }
/// <summary> /// Allow the sorter to be set according to the search criteria. /// </summary> public void SetSorter(RecordSorter sorter) { m_list.Sorter = sorter; }
/// <summary> /// Called when the sorter changes. A name indicating what is being sorted is /// passed along with the record sorter. /// </summary> /// <param name="sorter">The sorter.</param> /// <param name="sortName">The sort name.</param> /// <param name="isDefaultSort"><c>true</c> if default sorting is being used, otherwise <c>false</c>.</param> public void OnSorterChanged(RecordSorter sorter, string sortName, bool isDefaultSort) { CheckDisposed(); m_isDefaultSort = isDefaultSort; m_sortName = sortName; m_mediator.PropertyTable.SetProperty(SortNamePropertyTableId, m_sortName, PropertyTable.SettingsGroup.LocalSettings); m_list.ChangeSorter(sorter); // Remember how we're sorted. string persistSorter = DynamicLoader.PersistObject(Sorter, "sorter"); m_mediator.PropertyTable.SetProperty(SorterPropertyTableId, persistSorter, PropertyTable.SettingsGroup.LocalSettings); UpdateSortStatusBarPanel(); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected virtual void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) return; if (disposing) { // Dispose managed resources here. // We didn't make these either, but we need to deal with them. // No. These belong to the RecordList. //if (m_finder != null && (m_finder is IDisposable)) // (m_finder as IDisposable).Dispose(); //if (m_sorter != null && (m_sorter is IDisposable)) // (m_sorter as IDisposable).Dispose(); //if (m_filter != null) // (m_filter as IDisposable).Dispose(); //if (m_matcher != null && m_matcher is IDisposable) // (m_matcher as IDisposable).Dispose(); } // Dispose unmanaged resources here, whether disposing is true or false. m_viewSpec = null; m_combo = null; // We didn't create it, so let whoever did dispose it. m_finder = null; m_sorter = null; m_filter = null; m_matcher = null; m_isDisposed = true; }
/// <summary> /// The reversal should not be checking the writing system when testing for sorter compatibility since /// that writing system is changed in the Clerk through events and the bulkedit and browse view share the same clerk. /// </summary> /// <param name="first"></param> /// <param name="second"></param> /// <remarks>This method is only valid because there are no multi-lingual columns in the reversal views</remarks> /// <returns></returns> public override bool AreSortersCompatible(RecordSorter first, RecordSorter second) { if (first == null || second == null) return false; var secondSorter = second as GenRecordSorter; var firstSorter = first as GenRecordSorter; if (secondSorter == null || firstSorter == null) return first.CompatibleSorter(second); var sfcThis = firstSorter.Comparer as StringFinderCompare; var sfcOther = secondSorter.Comparer as StringFinderCompare; if (sfcThis == null || sfcOther == null) return false; if (!sfcThis.Finder.SameFinder(sfcOther.Finder)) return false; return true; }
/// <summary> /// Change the sorter...and resort if the list already exists. /// </summary> /// <param name="sorter"></param> public void ChangeSorter(RecordSorter sorter) { CheckDisposed(); Sorter = sorter; // JohnT: a different sorter may create a quite different set of ManyOnePathSortItems. // Optimize: it may be possible to find some cases in which we don't need to reload fully, // for example, when reversing the order on the same column. if (m_sortedObjects != null) ReloadList(); // if (m_sortedObjects != null && m_sorter != null) // m_sorter.Sort(/*ref*/ m_sortedObjects); // // Update everything that depends on the list. // SendPropChangedOnListChange(); }
protected override void DisposeUnmanagedResources() { m_sda = null; m_cache = null; m_mediator = null; m_sorter = null; m_filter = null; m_owningObject = null; m_propertyName = null; m_fontName = null; m_insertableClasses = null; m_sortedObjects = null; m_owningObject = null; }