Summary description for MasterCategoryListDlg.
Inheritance: System.Windows.Forms.Form, IFWDisposable
		/// <summary>
		/// Handles the xWorks message to insert a new PartOfSpeech.
		/// Invoked by the RecordClerk via a main menu.
		/// </summary>
		/// <param name="argument">The xCore Command object.</param>
		/// <returns>true, if we handled the message, otherwise false, if there was an unsupported 'classname' parameter</returns>
		public override bool OnDialogInsertItemInVector(object argument)
		{
			CheckDisposed();

			Debug.Assert(argument != null && argument is XCore.Command);
			string className = XmlUtils.GetOptionalAttributeValue(
				(argument as XCore.Command).Parameters[0], "className");
			if (className == null || className != "PartOfSpeech")
				return false;

			using (var dlg = new MasterCategoryListDlg())
			{
				FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
				Debug.Assert(cache != null);
				var owningObj = m_mediator.PropertyTable.GetValue("ActiveClerkOwningObject") as ICmObject;
				dlg.SetDlginfo((owningObj is ICmPossibilityList) ? owningObj as ICmPossibilityList : cache.LangProject.PartsOfSpeechOA, m_mediator, true, null);
				switch (dlg.ShowDialog((Form)m_mediator.PropertyTable.GetValue("window")))
				{
					case DialogResult.OK: // Fall through.
					case DialogResult.Yes:
						// This is the equivalent functionality, but is deferred processing.
						// This is done so that the JumpToRecord can be processed last.
						m_mediator.BroadcastMessageUntilHandled("JumpToRecord", dlg.SelectedPOS.Hvo);
						break;
				}
			}
			return true; // We "handled" the message, regardless of what happened.
		}
Example #2
0
        void LaunchChooseFromMasterCategoryListOnIdle(object sender, EventArgs e)
        {
            Application.Idle -= LaunchChooseFromMasterCategoryListOnIdle;             // now being handled

            // now launch the dialog
            using (MasterCategoryListDlg dlg = new MasterCategoryListDlg())
            {
                dlg.SetDlginfo(CategoryList, m_mediator, m_propertyTable, false, null);
                switch (dlg.ShowDialog(m_parentOfPopupMgr))
                {
                case DialogResult.OK:
                    var sandboxMsa = new SandboxGenericMSA();
                    sandboxMsa.MainPOS = dlg.SelectedPOS;
                    sandboxMsa.MsaType = m_sense.GetDesiredMsaType();
                    UndoableUnitOfWorkHelper.Do(String.Format(LexTextControls.ksUndoSetX, FieldName),
                                                String.Format(LexTextControls.ksRedoSetX, FieldName), m_sense, () =>
                    {
                        m_sense.SandboxMSA = sandboxMsa;
                    });
                    // Under certain circumstances (LT-11548) 'this' was disposed during the EndUndotask above!
                    // That's why we're now launching this on idle.
                    // Here's hoping we can get away without doing this! (It doesn't seem to make a difference.)
                    //LoadPopupTree(m_sense.MorphoSyntaxAnalysisRA.Hvo);
                    // everything should be setup with new node selected, so return.
                    break;

                case DialogResult.Yes:
                    // represents a click on the link to create a new Grammar Category.
                    // 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", new FwLinkArgs("posEdit", dlg.SelectedPOS.Guid));
                    if (m_parentOfPopupMgr != null && m_parentOfPopupMgr.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.
                        m_parentOfPopupMgr.DialogResult = DialogResult.Cancel;
                        m_parentOfPopupMgr.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;
                }
            }
        }
Example #3
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;
				}
			}
		}
Example #4
0
		/// <summary>
		/// Handle the context menu for inserting a POS.
		/// </summary>
		/// <param name="mediator"></param>
		/// <param name="classId"></param>
		/// <param name="hvoOwner"></param>
		/// <param name="flid"></param>
		/// <param name="insertionPosition"></param>
		/// <returns></returns>
		public new static PartOfSpeechUi CreateNewUiObject(Mediator mediator, int classId, int hvoOwner, int flid, int insertionPosition)
		{
			PartOfSpeechUi posUi = null;
			using (MasterCategoryListDlg dlg = new MasterCategoryListDlg())
			{
				FdoCache cache = (FdoCache)mediator.PropertyTable.GetValue("cache");
				Debug.Assert(cache != null);
				var newOwner = cache.ServiceLocator.GetInstance<IPartOfSpeechRepository>().GetObject(hvoOwner);
				dlg.SetDlginfo(newOwner.OwningList, mediator, true, newOwner);
				switch (dlg.ShowDialog((Form)mediator.PropertyTable.GetValue("window")))
				{
					case DialogResult.OK: // Fall through.
					case DialogResult.Yes:
						posUi = new PartOfSpeechUi(dlg.SelectedPOS);
						mediator.SendMessage("JumpToRecord", dlg.SelectedPOS.Hvo);
						break;
				}
			}
			return posUi;
		}
		void LaunchChooseFromMasterCategoryListOnIdle(object sender, EventArgs e)
		{
			Application.Idle -= LaunchChooseFromMasterCategoryListOnIdle; // now being handled

			// now launch the dialog
			using (MasterCategoryListDlg dlg = new MasterCategoryListDlg())
			{
				dlg.SetDlginfo(CategoryList, m_mediator, false, null);
				switch (dlg.ShowDialog(m_parentOfPopupMgr))
				{
					case DialogResult.OK:
						var sandboxMsa = new SandboxGenericMSA();
						sandboxMsa.MainPOS = dlg.SelectedPOS;
						sandboxMsa.MsaType = m_sense.GetDesiredMsaType();
						UndoableUnitOfWorkHelper.Do(String.Format(LexTextControls.ksUndoSetX, FieldName),
							String.Format(LexTextControls.ksRedoSetX, FieldName), m_sense, () =>
							{
								m_sense.SandboxMSA = sandboxMsa;
							});
						// Under certain circumstances (LT-11548) 'this' was disposed during the EndUndotask above!
						// That's why we're now launching this on idle.
						// Here's hoping we can get away without doing this! (It doesn't seem to make a difference.)
						//LoadPopupTree(m_sense.MorphoSyntaxAnalysisRA.Hvo);
						// everything should be setup with new node selected, so return.
						break;
					case DialogResult.Yes:
						// represents a click on the link to create a new Grammar Category.
						// 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", new FwLinkArgs("posEdit", dlg.SelectedPOS.Guid));
						if (m_parentOfPopupMgr != null && m_parentOfPopupMgr.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.
							m_parentOfPopupMgr.DialogResult = DialogResult.Cancel;
							m_parentOfPopupMgr.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;
				}
			}
		}
Example #6
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();
                if (TreeCombo != null)
                {
                    TreeCombo.SelectedNode = m_selPrior;
                }
                else
                {
                    GetPopupTree().SelectedNode = m_selPrior;
                }

                // If we wait to hide it until after we show the dialog, hiding it activates the disabled main
                // window which owns it, with weird results. Since we're going to launch another window,
                // we don't want to activate the parent at all.
                GetPopupTree().HideForm(false);

                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",
                                               new FwLinkArgs(JumpToToolNamed, dlg.SelectedPOS.Guid));
                        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:
                    {
                        return;
                    }
                    }
                }
            }

            base.m_treeCombo_AfterSelect(sender, e);
        }
		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();
				if (TreeCombo != null)
					TreeCombo.SelectedNode = m_selPrior;
				else
					GetPopupTree().SelectedNode = m_selPrior;

				// If we wait to hide it until after we show the dialog, hiding it activates the disabled main
				// window which owns it, with weird results. Since we're going to launch another window,
				// we don't want to activate the parent at all.
				GetPopupTree().HideForm(false);

				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, but now we need to trigger
							// any side effects, as if we had selected that item by mouse. So go ahead and
							// call the base method to do this. (LT-14062)
							break;
						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",
								new FwLinkArgs(JumpToToolNamed, dlg.SelectedPOS.Guid));
							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:
						{
							return;
						}
					}
				}
			}

			base.m_treeCombo_AfterSelect(sender, e);
		}
Example #8
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);
        }
Example #9
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);
		}