/// ------------------------------------------------------------------------------------ /// <summary> /// a factory method for RecordFilterListProvider /// </summary> /// <param name="mediator">The mediator.</param> /// <param name="configuration">The configuration.</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ static public RecordFilterListProvider Create(Mediator mediator, XmlNode configuration) { RecordFilterListProvider p = (RecordFilterListProvider)DynamicLoader.CreateObject(configuration); if (p != null) { p.Init(mediator, configuration); } return(p); }
/// <summary> /// Initialize the IxCoreColleague /// </summary> /// <param name="mediator"></param> /// <param name="viewConfiguration"></param> public virtual void Init(Mediator mediator, XmlNode viewConfiguration) { CheckDisposed(); XmlNode clerkConfiguration = ToolConfiguration.GetClerkNodeFromToolParamsNode(viewConfiguration); m_mediator = mediator; m_clerkConfiguration = clerkConfiguration; m_id = XmlUtils.GetOptionalAttributeValue(clerkConfiguration, "id", "missingId"); m_clerkProvidingRootObject = XmlUtils.GetOptionalAttributeValue(clerkConfiguration,"clerkProvidingOwner"); m_shouldHandleDeletion = XmlUtils.GetOptionalBooleanAttributeValue(clerkConfiguration, "shouldHandleDeletion", true); m_fAllowDeletions = XmlUtils.GetOptionalBooleanAttributeValue(clerkConfiguration, "allowDeletions", true); var cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache"); m_list = RecordList.Create(cache, mediator, clerkConfiguration.SelectSingleNode("recordList")); m_list.Clerk = this; m_relatedClerk = XmlUtils.GetOptionalAttributeValue(clerkConfiguration, "relatedClerk"); m_relationToRelatedClerk = XmlUtils.GetOptionalAttributeValue(clerkConfiguration, "relationToRelatedClerk"); TryRestoreSorter(mediator, clerkConfiguration, cache); TryRestoreFilter(mediator, clerkConfiguration, cache); m_list.ListChanged += OnListChanged; m_list.AboutToReload += m_list_AboutToReload; m_list.DoneReload += m_list_DoneReload; XmlNode recordFilterListProviderNode = ToolConfiguration.GetDefaultRecordFilterListProvider(clerkConfiguration); bool fSetFilterMenu = false; if (recordFilterListProviderNode != null) { m_filterProvider = RecordFilterListProvider.Create(m_mediator, recordFilterListProviderNode); if (m_filterProvider != null && m_list.Filter != null) { // find any matching persisted menubar filter // NOTE: for now assume we can only set/persist one such menubar filter at a time. foreach (RecordFilter menuBarFilterOption in m_filterProvider.Filters) { if (m_list.Filter.Contains(menuBarFilterOption)) { m_activeMenuBarFilter = menuBarFilterOption; m_filterProvider.OnAdjustFilterSelection(m_activeMenuBarFilter); m_mediator.PropertyTable.SetDefault(CurrentFilterPropertyTableId, m_activeMenuBarFilter.id, false, PropertyTable.SettingsGroup.LocalSettings); fSetFilterMenu = true; break; } } } } if (!fSetFilterMenu) { OnAdjustFilterSelection(null); } // we never want to persist this value, since it is dependent upon the filter property. m_mediator.PropertyTable.SetPropertyPersistence(CurrentFilterPropertyTableId, false, PropertyTable.SettingsGroup.LocalSettings); //we handled the tree bar only if we are the root clerk if (m_clerkProvidingRootObject == null) { m_recordBarHandler = RecordBarHandler.Create(m_mediator, clerkConfiguration);//,m_flid); } else { RecordClerk clerkProvidingRootObject; Debug.Assert(TryClerkProvidingRootObject(out clerkProvidingRootObject), "We expected to find clerkProvidingOwner '" + m_clerkProvidingRootObject + "'. Possibly misspelled."); } //mediator. TraceLevel = TraceLevel.Info; //we do not want to be a top-level colleague, because //if we were, we would always receive events, for example navigation events //which might be intended for another RecordClerk, specifically the RecordClerk //being used by the currently active vector editor, browse view, etc. //so, instead, we let the currently active view include us as a "child" colleague. //NO! mediator.AddColleague(this); // Install this object in the PropertyTable so that others can find it. // NB: This *must* be done before the call to SetupDataContext, // or we are asking for an infinite loop, has SetupDataContext() // causes user interface widgets to wake up and look for this object. // If we have not registered the existence of this object yet in the property table, // those widgets will be inclined to try to create us. Hence, the infinite loop. //Note that, on the downside, this means that we need to be careful //not to broadcast any record changes until we are actually initialize enough //to deal with the resulting request that will come from those widgets. StoreClerkInPropertyTable(clerkConfiguration); SetupDataContext(false); }
/// <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) { System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** "); // Must not be run more than once. if (m_isDisposed) return; if (disposing) { // Dispose managed resources here. //ResetStatusBarPanel("StatusPanelRecordNumber", ""); //ResetStatusBarPanel("StatusPanelMessage", ""); m_list.ListChanged -= OnListChanged; m_list.AboutToReload -= m_list_AboutToReload; m_list.DoneReload -= m_list_DoneReload; RemoveNotification(); // before disposing list, we need it to get to the Cache. m_list.Dispose(); if (m_mediator != null) { m_mediator.RemoveColleague(this); } if (m_rch != null) m_rch.Dispose(); if (m_recordBarHandler != null) m_recordBarHandler.Dispose(); } // Dispose unmanaged resources here, whether disposing is true or false. m_mediator = null; // This has to be done after the calls to ResetStatusBarPanel in the 'true' section. m_list = null; m_id = null; m_clerkProvidingRootObject = null; m_recordBarHandler = null; m_filterProvider = null; m_activeMenuBarFilter = null; m_rch = null; m_fIsActiveInGui = false; m_isDisposed = true; }
/// <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. //ResetStatusBarPanel("StatusPanelRecordNumber", ""); //ResetStatusBarPanel("StatusPanelMessage", ""); m_list.ListChanged -= new ListChangedEventHandler(OnListChanged); m_list.AboutToReload -= new EventHandler(m_list_AboutToReload); m_list.DoneReload -= new EventHandler(m_list_DoneReload); m_list.Dispose(); if (m_mediator != null) { m_mediator.RemoveColleague(this); } if (m_filterProvider != null) m_filterProvider.Dispose(); if (m_rch != null && m_rch is IDisposable) (m_rch as IDisposable).Dispose(); if (m_recordBarHandler != null) m_recordBarHandler.Dispose(); } // Dispose unmanaged resources here, whether disposing is true or false. m_mediator = null; // This has to be done after the calls to ResetStatusBarPanel in the 'true' section. m_list = null; m_id = null; m_clerkProvidingRootObject = null; m_recordBarHandler = null; m_filterProvider = null; m_activeMenuBarFilter = null; m_rch = null; m_fIsActiveInGui = false; m_isDisposed = true; }