/// <summary> /// factory method which creates the correct subclass based on the XML parameters /// </summary> /// <param name="dataEntryForm"></param> /// <param name="configuration"></param> /// <returns></returns> public static DTMenuHandler Create(DataTree dataEntryForm, XmlNode configuration) { DTMenuHandler h= null; if(configuration !=null) { XmlNode node = configuration.SelectSingleNode("menuHandler/dynamicloaderinfo"); if (node != null) { h = (DTMenuHandler) SIL.Utils.DynamicLoader.CreateObject(node); } } if(h==null) //no class specified, so just returned a generic DTMenuHandler h = new DTMenuHandler(); h.DtTree = dataEntryForm; return h; }
protected override void SetupDataContext() { Debug.Assert(m_configurationParameters != null); base.SetupDataContext(); //this will normally be the same name as the view, e.g. "basicEdit". This plus the name of the vector //should give us a unique context for the dataTree control parameters. string persistContext = XmlUtils.GetOptionalAttributeValue(m_configurationParameters, "persistContext"); if (persistContext !="") persistContext=m_vectorName+"."+persistContext+".DataTree"; else persistContext=m_vectorName+".DataTree"; m_dataEntryForm.PersistenceProvder = new PersistenceProvider(persistContext, m_mediator.PropertyTable); Clerk.UpdateRecordTreeBarIfNeeded(); SetupSliceFilter(); m_dataEntryForm.Dock = DockStyle.Fill; m_dataEntryForm.StringTbl = StringTbl; m_dataEntryForm.SmallImages =(ImageCollection) m_mediator.PropertyTable.GetValue("smallImages"); string sDatabase = Cache.ProjectId.Name; m_dataEntryForm.Initialize(Cache, true, Inventory.GetInventory("layouts", sDatabase), Inventory.GetInventory("parts", sDatabase)); m_dataEntryForm.Init(m_mediator, m_configurationParameters); if (m_dataEntryForm.AccessibilityObject != null) m_dataEntryForm.AccessibilityObject.Name = "RecordEditView.DataTree"; //set up the context menu, overriding the automatic menu creator/handler m_menuHandler = DTMenuHandler.Create(m_dataEntryForm, m_configurationParameters); m_menuHandler.Init(m_mediator, m_configurationParameters); // m_dataEntryForm.SetContextMenuHandler(new SliceMenuRequestHandler((m_menuHandler.GetSliceContextMenu)); m_dataEntryForm.SetContextMenuHandler(m_menuHandler.ShowSliceContextMenu); Controls.Add(m_dataEntryForm); m_dataEntryForm.BringToFront(); }