/// <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);
}