public void PopulateTreeFromFeatureSystem()
        {
            // Set up sample data
            IFsFeatStruc featStruct;
            ILangProject lp = CreateFeatureSystem(out featStruct);


            // Set up the xml fs description
            XmlDocument doc      = new XmlDocument();
            string      sFileDir = Path.Combine(SIL.FieldWorks.Common.FwUtils.DirectoryFinder.FwSourceDirectory,
                                                Path.Combine(@"FDO", Path.Combine(@"FDOTests", @"TestData")));
            string sFile = Path.Combine(sFileDir, "FeatureSystem2.xml");

            doc.Load(sFile);
            XmlNode itemNeut = doc.SelectSingleNode("//item[@id='vNeut']");
            // Add some complex features
            IFsFeatureSystem msfs = lp.MsFeatureSystemOA;

            msfs.AddFeatureFromXml(itemNeut);
            // Now add a feature that differs only in value
            XmlNode itemFem = doc.SelectSingleNode("//item[@id='vFem']");

            msfs.AddFeatureFromXml(itemFem);
            // Now add another feature to the complex one
            XmlNode item1st = doc.SelectSingleNode("//item[@id='v1']");

            msfs.AddFeatureFromXml(item1st);
            // now get a simple, top-level closed feature
            sFile = Path.Combine(sFileDir, "FeatureSystem3.xml");
            doc.Load(sFile);
            XmlNode itemImpfv = doc.SelectSingleNode("//item[@id='vImpfv']");

            msfs.AddFeatureFromXml(itemImpfv);
            XmlNode itemCont = doc.SelectSingleNode("//item[@id='vCont']");

            msfs.AddFeatureFromXml(itemCont);

            using (var dlg = new FeatureSystemInflectionFeatureListDlg())
            {
                ILexEntryInflType cobj =
                    Cache.ServiceLocator.GetInstance <ILexEntryInflTypeFactory>().Create();
                lp.LexDbOA.VariantEntryTypesOA.PossibilitiesOS.Add(cobj);
                dlg.SetDlgInfo(Cache, (Mediator)null, cobj, 0);

                // load some feature system values into treeview
                FeatureStructureTreeView tv = dlg.TreeView;

                Assert.AreEqual(2, tv.Nodes.Count, "Count of top level nodes in tree view");
                TreeNodeCollection col = tv.Nodes[0].Nodes;
                Assert.AreEqual(3, col.Count, "Count of first level nodes in tree view");
            }
        }
		protected override void HandleChooser()
		{
			VectorReferenceLauncher vrl = null;
			using (FeatureSystemInflectionFeatureListDlg dlg = new FeatureSystemInflectionFeatureListDlg())
			{
				IFsFeatStruc originalFs = m_obj as IFsFeatStruc;

				Slice parentSlice = Slice;
				if (originalFs == null)
				{
					int owningFlid;
					ILexEntryInflType leit = parentSlice.Object as ILexEntryInflType;
					owningFlid = (parentSlice as FeatureSystemInflectionFeatureListDlgLauncherSlice).Flid;
					dlg.SetDlgInfo(m_cache, m_mediator, leit, owningFlid);
				}
				else
				{
					dlg.SetDlgInfo(m_cache, m_mediator, originalFs,
						(parentSlice as FeatureSystemInflectionFeatureListDlgLauncherSlice).Flid);
				}

				const string ksPath = "/group[@id='Linguistics']/group[@id='Morphology']/group[@id='FeatureChooser']/";
				dlg.Text = m_mediator.StringTbl.GetStringWithXPath("InflectionFeatureTitle", ksPath);
				dlg.Prompt = m_mediator.StringTbl.GetStringWithXPath("InflectionFeaturesPrompt", ksPath);
				dlg.LinkText = m_mediator.StringTbl.GetStringWithXPath("InflectionFeaturesLink", ksPath);
				DialogResult result = dlg.ShowDialog(parentSlice.FindForm());
				if (result == DialogResult.OK)
				{
					if (dlg.FS != null)
						m_obj = dlg.FS;
					m_msaInflectionFeatureListDlgLauncherView.Init(m_mediator, dlg.FS);
				}
				else if (result == DialogResult.Yes)
				{
					/*
										// Get the VectorReferenceLauncher for the Inflection Features slice.
										// Since we're not changing tools, we want to change the chooser dialog.
										// See LT-5913 for motivation.
										Control ctl = this.Parent;
										while (ctl != null && !(ctl is Slice))
											ctl = ctl.Parent;
										Slice slice = ctl as Slice;
										if (slice != null)
										{
											DataTree dt = slice.ContainingDataTree;
											for (int i = 0; i < dt.Slices.Count; ++i)
											{
												Slice sliceT = dt.FieldOrDummyAt(i);
												vrl = sliceT.Control as VectorReferenceLauncher;
												if (vrl != null)
												{
													if (vrl.Flid == PartOfSpeechTags.kflidInflectableFeats)
														break;
													vrl = null;
												}
											}
										}
										if (vrl == null)
										{
											// We do, too, need to change tools! Sometimes this slice shows up in a different context,
											// such as the main data entry view. See LT-7167.
											// go to m_highestPOS in editor
											// TODO: this should be reviewed by someone who knows how these links should be done
											// I'm just guessing.
											// Also, is there some way to know the application name and tool name without hard coding them?
					*/
					var linkJump = new FwLinkArgs("featuresAdvancedEdit", m_cache.LanguageProject.MsFeatureSystemOA.Guid);
					m_mediator.PostMessage("FollowLink", linkJump);
					/*}
					else
					{
						vrl.HandleExternalChooser();
					}*/
				}
			}
		}
		public void PopulateTreeFromFeatureSystem()
		{
			// Set up sample data
			IFsFeatStruc featStruct;
			ILangProject lp = CreateFeatureSystem(out featStruct);


			// Set up the xml fs description
			XmlDocument doc = new XmlDocument();
			string sFileDir = Path.Combine(SIL.FieldWorks.Common.FwUtils.FwDirectoryFinder.SourceDirectory,
										   Path.Combine(@"FDO", Path.Combine(@"FDOTests", @"TestData")));
			string sFile = Path.Combine(sFileDir, "FeatureSystem2.xml");
			doc.Load(sFile);
			XmlNode itemNeut = doc.SelectSingleNode("//item[@id='vNeut']");
			// Add some complex features
			IFsFeatureSystem msfs = lp.MsFeatureSystemOA;
			msfs.AddFeatureFromXml(itemNeut);
			// Now add a feature that differs only in value
			XmlNode itemFem = doc.SelectSingleNode("//item[@id='vFem']");
			msfs.AddFeatureFromXml(itemFem);
			// Now add another feature to the complex one
			XmlNode item1st = doc.SelectSingleNode("//item[@id='v1']");
			msfs.AddFeatureFromXml(item1st);
			// now get a simple, top-level closed feature
			sFile = Path.Combine(sFileDir, "FeatureSystem3.xml");
			doc.Load(sFile);
			XmlNode itemImpfv = doc.SelectSingleNode("//item[@id='vImpfv']");
			msfs.AddFeatureFromXml(itemImpfv);
			XmlNode itemCont = doc.SelectSingleNode("//item[@id='vCont']");
			msfs.AddFeatureFromXml(itemCont);

			using (var dlg = new FeatureSystemInflectionFeatureListDlg())
			{
				ILexEntryInflType cobj =
					Cache.ServiceLocator.GetInstance<ILexEntryInflTypeFactory>().Create();
				lp.LexDbOA.VariantEntryTypesOA.PossibilitiesOS.Add(cobj);
				dlg.SetDlgInfo(Cache, (Mediator)null, cobj, 0);

				// load some feature system values into treeview
				FeatureStructureTreeView tv = dlg.TreeView;

				Assert.AreEqual(2, tv.Nodes.Count, "Count of top level nodes in tree view");
				TreeNodeCollection col = tv.Nodes[0].Nodes;
				Assert.AreEqual(3, col.Count, "Count of first level nodes in tree view");
			}
		}