/// <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 = parentSlice.Object.ClassID;
					switch (parentSliceClass)
					{
						case MoAffixAllomorph.kclsidMoAffixAllomorph:
							IMoAffixAllomorph allo = parentSlice.Object as IMoAffixAllomorph;
							owningFlid = (parentSlice as MsaInflectionFeatureListDlgLauncherSlice).Flid;
							dlg.SetDlgInfo(m_cache, m_mediator, allo, 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);
				}

				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)
				{
					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.Controls.Count; ++i)
						{
							Slice sliceT = dt.FieldOrDummyAt(i);
							vrl = sliceT.Control as VectorReferenceLauncher;
							if (vrl != null)
							{
								if (vrl.Flid == (int)PartOfSpeech.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?
						FdoUi.FwLink linkJump = new SIL.FieldWorks.FdoUi.FwLink("Language Explorer", "posEdit",
							dlg.HighestPOS.Guid, m_cache.ServerName, m_cache.DatabaseName);
						m_mediator.PostMessage("FollowLink", linkJump);
					}
					else
					{
						vrl.HandleExternalChooser();
					}
				}
			}
		}
Пример #2
0
        /// <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 = parentSlice.Object.ClassID;
                    switch (parentSliceClass)
                    {
                    case MoAffixAllomorph.kclsidMoAffixAllomorph:
                        IMoAffixAllomorph allo = parentSlice.Object as IMoAffixAllomorph;
                        owningFlid = (parentSlice as MsaInflectionFeatureListDlgLauncherSlice).Flid;
                        dlg.SetDlgInfo(m_cache, m_mediator, allo, 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);
                }

                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)
                {
                    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.Controls.Count; ++i)
                        {
                            Slice sliceT = dt.FieldOrDummyAt(i);
                            vrl = sliceT.Control as VectorReferenceLauncher;
                            if (vrl != null)
                            {
                                if (vrl.Flid == (int)PartOfSpeech.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?
                        FdoUi.FwLink linkJump = new SIL.FieldWorks.FdoUi.FwLink("Language Explorer", "posEdit",
                                                                                dlg.HighestPOS.Guid, m_cache.ServerName, m_cache.DatabaseName);
                        m_mediator.PostMessage("FollowLink", linkJump);
                    }
                    else
                    {
                        vrl.HandleExternalChooser();
                    }
                }
            }
        }
        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;
						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);
		}