Ejemplo n.º 1
0
		private bool EditExistingMsa()
		{
			PopupTree pt = GetPopupTree();
			// 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 "Modify ..." node selected!
			// This is at least required if the user selects "Cancel" from the dialog below.
			pt.Hide();
			DummyGenericMSA dummyMsa = DummyGenericMSA.Create(m_sense.MorphoSyntaxAnalysisRA);
			using (MsaCreatorDlg dlg = new MsaCreatorDlg())
			{
				dlg.SetDlgInfo(Cache, m_persistProvider, m_mediator, m_sense.Entry, dummyMsa,
					m_sense.MorphoSyntaxAnalysisRAHvo, true, m_sEditGramFunc);
				if (dlg.ShowDialog(ParentForm) == DialogResult.OK)
				{
					Cache.BeginUndoTask(String.Format(LexTextControls.ksUndoSetX, FieldName),
						String.Format(LexTextControls.ksRedoSetX, FieldName));
					(m_sense as LexSense).DummyMSA = dlg.DummyMSA;
					Cache.EndUndoTask();
					LoadPopupTree(m_sense.MorphoSyntaxAnalysisRAHvo);
					return true;
				}
			}
			return false;
		}
Ejemplo n.º 2
0
		private bool ChooseFromMasterCategoryList()
		{
			PopupTree pt = GetPopupTree();
			// 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 (MasterCategoryListDlg dlg = new MasterCategoryListDlg())
			{
				dlg.SetDlginfo(List, m_mediator, false, null);
				switch (dlg.ShowDialog(ParentForm))
				{
				case DialogResult.OK:
					DummyGenericMSA dummyMSA = new DummyGenericMSA();
					dummyMSA.MainPOS = dlg.SelectedPOS.Hvo;
					dummyMSA.MsaType = m_sense.GetDesiredMsaType();
					Cache.BeginUndoTask(String.Format(LexTextControls.ksUndoSetX, FieldName),
						String.Format(LexTextControls.ksRedoSetX, FieldName));
					(m_sense as LexSense).DummyMSA = dummyMSA;
					Cache.EndUndoTask();
					LoadPopupTree(m_sense.MorphoSyntaxAnalysisRAHvo);
					// everything should be setup with new node selected, so return.
					return true;
				case DialogResult.Yes:
					// Post a message so that we jump to Grammar(area)/Categories tool.
					// Do this before we close any parent dialog in case
					// the parent wants to check to see if such a Jump is pending.
					// NOTE: We use PostMessage here, rather than SendMessage which
					// disposes of the PopupTree before we and/or our parents might
					// be finished using it (cf. LT-2563).
					m_mediator.PostMessage("FollowLink",
						SIL.FieldWorks.FdoUi.FwLink.Create("posEdit", Cache.GetGuidFromId(dlg.SelectedPOS.Hvo),
						Cache.ServerName,
						Cache.DatabaseName));
					if (ParentForm != null && ParentForm.Modal)
					{
						// Close the dlg that opened the master POS dlg,
						// since its hotlink was used to close it,
						// and a new POS has been created.
						ParentForm.DialogResult = DialogResult.Cancel;
						ParentForm.Close();
					}
					return false;
				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)
					return false;
				}
			}
		}
Ejemplo n.º 3
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);
        }
        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);
        }
Ejemplo n.º 5
0
        protected override void m_treeCombo_AfterSelect(object sender, TreeViewEventArgs e)
        {
            HvoTreeNode selectedNode = e.Node as HvoTreeNode;

            if (selectedNode != null && selectedNode.Hvo == kMore && e.Action == TreeViewAction.ByMouse)
            {
                // Only launch the dialog by a mouse click (or simulated mouse click).
                PopupTree pt = GetPopupTree();
                // 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 (MasterCategoryListDlg dlg = new MasterCategoryListDlg())
                {
                    dlg.SetDlginfo(List, m_mediator, false, null);
                    switch (dlg.ShowDialog(ParentForm))
                    {
                    case DialogResult.OK:
                    {
                        LoadPopupTree(dlg.SelectedPOS.Hvo);
                        // everything should be setup with new node selected, so return.
                        return;
                    }

                    case DialogResult.Yes:
                    {
                        // Post a message so that we jump to Grammar(area)/Categories tool.
                        // Do this before we close any parent dialog in case
                        // the parent wants to check to see if such a Jump is pending.
                        // NOTE: We use PostMessage here, rather than SendMessage which
                        // disposes of the PopupTree before we and/or our parents might
                        // be finished using it (cf. LT-2563).
                        m_mediator.PostMessage("FollowLink",
                                               SIL.FieldWorks.FdoUi.FwLink.Create(JumpToToolNamed,
                                                                                  Cache.GetGuidFromId(dlg.SelectedPOS.Hvo),
                                                                                  Cache.ServerName,
                                                                                  Cache.DatabaseName));
                        if (ParentForm != null && ParentForm.Modal)
                        {
                            // Close the dlg that opened the master POS dlg,
                            // since its hotlink was used to close it,
                            // and a new POS 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;
                    }
                }
            }

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

            switch (selectedNode.Hvo)
            {
            case kChoosePhonologicaFeatures:
                // 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 "Choose phonological features" node selected!
                // This is at least required if the user selects "Cancel" from the dialog below.
                // N.B. the above does not seem to be true; therefore we check for cancel and an empty result
                // and force the combo text to be what it should be.
                pt.Hide();
                using (PhonologicalFeatureChooserDlg dlg = new PhonologicalFeatureChooserDlg())
                {
                    Cache.DomainDataByFlid.BeginUndoTask(LexTextControls.ksUndoInsertPhonologicalFeature, LexTextControls.ksRedoInsertPhonologicalFeature);
                    var fs = CreateEmptyFeatureStructureInAnnotation(null);
                    dlg.SetDlgInfo(Cache, m_mediator, m_propertyTable, fs);
                    dlg.ShowIgnoreInsteadOfDontCare = true;
                    dlg.SetHelpTopic("khtptoolBulkEditPhonemesChooserDlg");

                    DialogResult result = dlg.ShowDialog(ParentForm);
                    if (result == DialogResult.OK)
                    {
                        if (dlg.FS != null)
                        {
                            var sFeatures = dlg.FS.LongName;
                            if (string.IsNullOrEmpty(sFeatures))
                            {
                                // user did not select anything in chooser; we want to show the last known node
                                // in the dropdown, not "choose phonological feature".
                                SetComboTextToLastConfirmedSelection();
                            }
                            else if (!pt.Nodes.ContainsKey(sFeatures))
                            {
                                var newSelectedNode = new HvoTreeNode(fs.LongNameTSS, fs.Hvo);
                                pt.Nodes.Add(newSelectedNode);
                                LoadPopupTree(fs.Hvo);
                                selectedNode = newSelectedNode;
                            }
                        }
                    }
                    else if (result != DialogResult.Cancel)
                    {
                        dlg.HandleJump();
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        // The user canceled out of the chooser; we want to show the last known node
                        // in the dropdown, not "choose phonological feature".
                        SetComboTextToLastConfirmedSelection();
                    }
                    Cache.DomainDataByFlid.EndUndoTask();
                }
                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 == kChoosePhonologicaFeatures)
            {
                return;
            }
            base.m_treeCombo_AfterSelect(sender, e);
        }