private void MakeFeatureStructure(FeatureStructureTreeView tv, IFsFeatStruc featStruct)
 {
     using (MsaInflectionFeatureListDlg dlg = new MsaInflectionFeatureListDlg())
     {
         foreach (IFsFeatureSpecification spec in featStruct.FeatureSpecsOC)
         {
             featStruct.FeatureSpecsOC.Remove(spec);
         }
         dlg.SetDlgInfo(Cache, null, featStruct, MoStemMsaTags.kflidMsFeatures);
         dlg.UpdateFeatureStructure(tv.Nodes);
     }
 }
Exemple #2
0
        protected override void m_treeCombo_AfterSelect(object sender, TreeViewEventArgs e)
        {
            HvoTreeNode selectedNode = e.Node as HvoTreeNode;
            PopupTree   pt           = GetPopupTree();

            switch (selectedNode.Hvo)
            {
            case kMore:
                // Only launch the dialog by a mouse click (or simulated mouse click).
                if (e.Action != TreeViewAction.ByMouse)
                {
                    break;
                }
                // Force the PopupTree to Hide() to trigger popupTree_PopupTreeClosed().
                // This will effectively revert the list selection to a previous confirmed state.
                // Whatever happens below, we don't want to actually leave the "More..." node selected!
                // This is at least required if the user selects "Cancel" from the dialog below.
                pt.Hide();
                using (MsaInflectionFeatureListDlg dlg = new MsaInflectionFeatureListDlg())
                {
                    HvoTreeNode parentNode = selectedNode.Parent as HvoTreeNode;
                    int         hvoPos     = parentNode.Hvo;
                    var         pos        = Cache.ServiceLocator.GetInstance <IPartOfSpeechRepository>().GetObject(hvoPos);
                    dlg.SetDlgInfo(Cache, m_mediator, m_propertyTable, pos);
                    switch (dlg.ShowDialog(ParentForm))
                    {
                    case DialogResult.OK:
                    {
                        int hvoFs = 0;
                        if (dlg.FS != null)
                        {
                            hvoFs = dlg.FS.Hvo;
                        }
                        LoadPopupTree(hvoFs);
                        // In the course of loading the popup tree, we will have selected the hvoFs item, and triggered an AfterSelect.
                        // But, it will have had an Unknown action, and thus will not trigger some effects we want.
                        // That one will work like arrowing over items: they are 'selected', but the system will not
                        // behave as if the user actually chose this item.
                        // But, we want clicking OK in the dialog to produce the same result as clicking an item in the list.
                        // So, we need to trigger an AfterSelect with our own event args, which (since we're acting on it)
                        // must have a ByMouse TreeViewAction.
                        base.m_treeCombo_AfterSelect(sender, e);
                        // everything should be setup with new node selected, so return.
                        return;
                    }

                    case DialogResult.Yes:
                    {
                        // go to m_highestPOS in editor
                        m_mediator.PostMessage("FollowLink", new FwLinkArgs("posEdit", dlg.HighestPOS.Guid));
                        if (ParentForm != null && ParentForm.Modal)
                        {
                            // Close the dlg that opened the popup tree,
                            // since its hotlink was used to close it,
                            // and a new item has been created.
                            ParentForm.DialogResult = DialogResult.Cancel;
                            ParentForm.Close();
                        }
                        break;
                    }

                    default:
                        // NOTE: If the user has selected "Cancel", then don't change
                        // our m_lastConfirmedNode to the "More..." node. Keep it
                        // the value set by popupTree_PopupTreeClosed() when we
                        // called pt.Hide() above. (cf. comments in LT-2522)
                        break;
                    }
                }
                break;

            default:
                break;
            }
            // FWR-3432 - If we get here and we still haven't got a valid Hvo, don't continue
            // on to the base method. It'll crash.
            if (selectedNode.Hvo == kMore)
            {
                return;
            }
            base.m_treeCombo_AfterSelect(sender, e);
        }
		/// <summary>
		/// Handle launching of the MSA editor.
		/// </summary>
		protected override void HandleChooser()
		{
			VectorReferenceLauncher vrl = null;
			using (MsaInflectionFeatureListDlg dlg = new MsaInflectionFeatureListDlg())
			{
				IFsFeatStruc originalFs = m_obj as IFsFeatStruc;

				Slice parentSlice = Slice;
				if (originalFs == null)
				{
					int owningFlid;
					int parentSliceClass = (int)parentSlice.Object.ClassID;
					switch (parentSliceClass)
					{
						case MoAffixAllomorphTags.kClassId:
							IMoAffixAllomorph allo = parentSlice.Object as IMoAffixAllomorph;
							owningFlid = (parentSlice as MsaInflectionFeatureListDlgLauncherSlice).Flid;
							dlg.SetDlgInfo(m_cache, m_mediator, allo, owningFlid);
							break;
						/*case LexEntryInflTypeTags.kClassId:
							ILexEntryInflType leit = parentSlice.Object as ILexEntryInflType;
							owningFlid = (parentSlice as MsaInflectionFeatureListDlgLauncherSlice).Flid;
							dlg.SetDlgInfo(m_cache, m_mediator, leit, owningFlid);
							break;*/
						default:
							IMoMorphSynAnalysis msa = parentSlice.Object as IMoMorphSynAnalysis;
							owningFlid = (parentSlice as MsaInflectionFeatureListDlgLauncherSlice).Flid;
							dlg.SetDlgInfo(m_cache, m_mediator, msa, owningFlid);
							break;
					}
				}
				else
				{
					dlg.SetDlgInfo(m_cache, m_mediator, originalFs,
						(parentSlice as MsaInflectionFeatureListDlgLauncherSlice).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("InflectionFeaturePrompt", ksPath);
				dlg.LinkText = m_mediator.StringTbl.GetStringWithXPath("InflectionFeatureLink", ksPath);
				DialogResult result = dlg.ShowDialog(parentSlice.FindForm());
				if (result == DialogResult.OK)
				{
					// Note that this may set m_obj to null. dlg.FS will be null if all inflection features have been
					// removed. That is a valid state for this slice; m_obj deleted is not.
					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("posEdit", dlg.HighestPOS.Guid);
						m_mediator.PostMessage("FollowLink", linkJump);
					}
					else
					{
						vrl.HandleExternalChooser();
					}
				}
			}
		}
		private void MakeFeatureStructure(FeatureStructureTreeView tv, IFsFeatStruc featStruct)
		{
			using (MsaInflectionFeatureListDlg dlg = new MsaInflectionFeatureListDlg())
			{
				foreach (IFsFeatureSpecification spec in featStruct.FeatureSpecsOC)
					featStruct.FeatureSpecsOC.Remove(spec);
				dlg.SetDlgInfo(Cache, null, featStruct);
				dlg.UpdateFeatureStructure(tv.Nodes);
			}
		}
        protected override void m_treeCombo_AfterSelect(object sender, TreeViewEventArgs e)
        {
            HvoTreeNode selectedNode = e.Node as HvoTreeNode;
            PopupTree   pt           = GetPopupTree();

            switch (selectedNode.Hvo)
            {
            case kMore:
                // Only launch the dialog by a mouse click (or simulated mouse click).
                if (e.Action != TreeViewAction.ByMouse)
                {
                    break;
                }
                // Force the PopupTree to Hide() to trigger popupTree_PopupTreeClosed().
                // This will effectively revert the list selection to a previous confirmed state.
                // Whatever happens below, we don't want to actually leave the "More..." node selected!
                // This is at least required if the user selects "Cancel" from the dialog below.
                pt.Hide();
                using (MsaInflectionFeatureListDlg dlg = new MsaInflectionFeatureListDlg())
                {
                    HvoTreeNode   parentNode = selectedNode.Parent as HvoTreeNode;
                    int           hvoPos     = parentNode.Hvo;
                    IPartOfSpeech pos        = (IPartOfSpeech)PartOfSpeech.CreateFromDBObject(Cache, hvoPos, false);
                    dlg.SetDlgInfo(Cache, m_mediator, pos);
                    switch (dlg.ShowDialog(ParentForm))
                    {
                    case DialogResult.OK:
                    {
                        int hvoFs = 0;
                        if (dlg.FS != null)
                        {
                            hvoFs = dlg.FS.Hvo;
                        }
                        LoadPopupTree(hvoFs);
                        // everything should be setup with new node selected, so return.
                        return;
                    }

                    case DialogResult.Yes:
                    {
                        // go to m_highestPOS in editor
                        // Also, is there some way to know the application name and tool name without hard coding them?
                        FdoUi.FwLink linkJump = new SIL.FieldWorks.FdoUi.FwLink("Language Explorer", "posEdit",
                                                                                dlg.HighestPOS.Guid, Cache.ServerName, Cache.DatabaseName);
                        m_mediator.PostMessage("FollowLink", linkJump);
                        if (ParentForm != null && ParentForm.Modal)
                        {
                            // Close the dlg that opened the popup tree,
                            // since its hotlink was used to close it,
                            // and a new item has been created.
                            ParentForm.DialogResult = DialogResult.Cancel;
                            ParentForm.Close();
                        }
                        break;
                    }

                    default:
                        // NOTE: If the user has selected "Cancel", then don't change
                        // our m_lastConfirmedNode to the "More..." node. Keep it
                        // the value set by popupTree_PopupTreeClosed() when we
                        // called pt.Hide() above. (cf. comments in LT-2522)
                        break;
                    }
                }
                break;

            default:
                break;
            }

            base.m_treeCombo_AfterSelect(sender, e);
        }
		protected override void m_treeCombo_AfterSelect(object sender, TreeViewEventArgs e)
		{
			HvoTreeNode selectedNode = e.Node as HvoTreeNode;
			PopupTree pt = GetPopupTree();

			switch (selectedNode.Hvo)
			{
				case kMore:
					// Only launch the dialog by a mouse click (or simulated mouse click).
					if (e.Action != TreeViewAction.ByMouse)
						break;
					// Force the PopupTree to Hide() to trigger popupTree_PopupTreeClosed().
					// This will effectively revert the list selection to a previous confirmed state.
					// Whatever happens below, we don't want to actually leave the "More..." node selected!
					// This is at least required if the user selects "Cancel" from the dialog below.
					pt.Hide();
					using (MsaInflectionFeatureListDlg dlg = new MsaInflectionFeatureListDlg())
					{
						HvoTreeNode parentNode = selectedNode.Parent as HvoTreeNode;
						int hvoPos = parentNode.Hvo;
						var pos = Cache.ServiceLocator.GetInstance<IPartOfSpeechRepository>().GetObject(hvoPos);
						dlg.SetDlgInfo(Cache, m_mediator, pos);
						switch (dlg.ShowDialog(ParentForm))
						{
							case DialogResult.OK:
							{
								int hvoFs = 0;
								if (dlg.FS != null)
									hvoFs = dlg.FS.Hvo;
								LoadPopupTree(hvoFs);
								// In the course of loading the popup tree, we will have selected the hvoFs item, and triggered an AfterSelect.
								// But, it will have had an Unknown action, and thus will not trigger some effects we want.
								// That one will work like arrowing over items: they are 'selected', but the system will not
								// behave as if the user actually chose this item.
								// But, we want clicking OK in the dialog to produce the same result as clicking an item in the list.
								// So, we need to trigger an AfterSelect with our own event args, which (since we're acting on it)
								// must have a ByMouse TreeViewAction.
								base.m_treeCombo_AfterSelect(sender, e);
								// everything should be setup with new node selected, so return.
								return;
							}
							case DialogResult.Yes:
							{
								// go to m_highestPOS in editor
								m_mediator.PostMessage("FollowLink", new FwLinkArgs("posEdit", dlg.HighestPOS.Guid));
								if (ParentForm != null && ParentForm.Modal)
								{
									// Close the dlg that opened the popup tree,
									// since its hotlink was used to close it,
									// and a new item has been created.
									ParentForm.DialogResult = DialogResult.Cancel;
									ParentForm.Close();
								}
								break;
							}
							default:
								// NOTE: If the user has selected "Cancel", then don't change
								// our m_lastConfirmedNode to the "More..." node. Keep it
								// the value set by popupTree_PopupTreeClosed() when we
								// called pt.Hide() above. (cf. comments in LT-2522)
								break;
						}
					}
					break;
				default:
					break;
			}
			// FWR-3432 - If we get here and we still haven't got a valid Hvo, don't continue
			// on to the base method. It'll crash.
			if (selectedNode.Hvo == kMore)
				return;
			base.m_treeCombo_AfterSelect(sender, e);
		}
		protected override void m_treeCombo_AfterSelect(object sender, TreeViewEventArgs e)
		{
			HvoTreeNode selectedNode = e.Node as HvoTreeNode;
			PopupTree pt = GetPopupTree();

			switch (selectedNode.Hvo)
			{
				case kMore:
					// Only launch the dialog by a mouse click (or simulated mouse click).
					if (e.Action != TreeViewAction.ByMouse)
						break;
					// Force the PopupTree to Hide() to trigger popupTree_PopupTreeClosed().
					// This will effectively revert the list selection to a previous confirmed state.
					// Whatever happens below, we don't want to actually leave the "More..." node selected!
					// This is at least required if the user selects "Cancel" from the dialog below.
					pt.Hide();
					using (MsaInflectionFeatureListDlg dlg = new MsaInflectionFeatureListDlg())
					{
						HvoTreeNode parentNode = selectedNode.Parent as HvoTreeNode;
						int hvoPos = parentNode.Hvo;
						IPartOfSpeech pos = (IPartOfSpeech)PartOfSpeech.CreateFromDBObject(Cache, hvoPos, false);
						dlg.SetDlgInfo(Cache, m_mediator, pos);
						switch (dlg.ShowDialog(ParentForm))
						{
							case DialogResult.OK:
							{
								int hvoFs = 0;
								if (dlg.FS != null)
									hvoFs = dlg.FS.Hvo;
								LoadPopupTree(hvoFs);
								// everything should be setup with new node selected, so return.
								return;
							}
							case DialogResult.Yes:
							{
								// go to m_highestPOS in editor
								// Also, is there some way to know the application name and tool name without hard coding them?
								FdoUi.FwLink linkJump = new SIL.FieldWorks.FdoUi.FwLink("Language Explorer", "posEdit",
									dlg.HighestPOS.Guid, Cache.ServerName, Cache.DatabaseName);
								m_mediator.PostMessage("FollowLink", linkJump);
								if (ParentForm != null && ParentForm.Modal)
								{
									// Close the dlg that opened the popup tree,
									// since its hotlink was used to close it,
									// and a new item has been created.
									ParentForm.DialogResult = DialogResult.Cancel;
									ParentForm.Close();
								}
								break;
							}
							default:
								// NOTE: If the user has selected "Cancel", then don't change
								// our m_lastConfirmedNode to the "More..." node. Keep it
								// the value set by popupTree_PopupTreeClosed() when we
								// called pt.Hide() above. (cf. comments in LT-2522)
								break;
						}
					}
					break;
				default:
					break;
			}

			base.m_treeCombo_AfterSelect(sender, e);
		}