/// <summary> /// Override this to handle any special items like 'More...'. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void m_treeCombo_AfterSelect(object sender, TreeViewEventArgs e) { HvoTreeNode selectedNode = e.Node as HvoTreeNode; if (selectedNode == null) { return; // User moved highlight off any item and hit enter; ignore. } PopupTree pt = GetPopupTree(); if (e.Action == TreeViewAction.ByMouse) { // bookmark this confirmed selection - required before PopupTree.Hide() // (cf. comments in LT-2522) if (pt != null) { m_lastConfirmedNode = (HvoTreeNode)pt.SelectedNode; } } // Pass on the event to owners/clients and close the PopupTree, only if it has been confirmed // "ByMouse" (or simulated mouse event). This will ensure that the user can use the keyboard // to move to items in the list, without actually affecting their previous selection until they // CONFIRM it "ByMouse" which can happen by clicking or by pressing ENTER. This allows the user // to ESCape there movement and revert to previously confirmed selection. (cf. comments in LT-2522) if (e.Action == TreeViewAction.ByMouse) { // If we are managing a treeCombo, then go ahead and set its Text in case the owner // does not want to do so in the AfterSelect below. if (m_treeCombo != null) { if (m_treeCombo.Text != m_lastConfirmedNode.Text) { m_treeCombo.Tss = m_lastConfirmedNode.Tss; } } if (AfterSelect != null) { AfterSelect(this, new TreeViewEventArgs(m_lastConfirmedNode, e.Action)); } // Close the PopupTree for confirmed selections. if (GetPopupTree() != null) { GetPopupTree().Hide(); // This should trigger popupTree_PopupTreeClosed() below. } } }
protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget) { TreeNode match = null; // We need a way to store feature structures the user has chosen during this session. // We use an annotation to do this. foreach (ICmBaseAnnotation cba in m_annotations) { IFsFeatStruc fs = cba.FeaturesOA; if (fs == null || fs.IsEmpty) { continue; } if (cba.BeginObjectRA != null) { continue; // is not one of the feature structures created via the phon feat chooser } HvoTreeNode node = new HvoTreeNode(fs.LongNameTSS, fs.Hvo); popupTree.Nodes.Add(node); if (fs.Hvo == hvoTarget) { match = node; } } if (ClosedFeature != null) { var sortedVaues = from v in ClosedFeature.ValuesOC orderby v.Abbreviation.BestAnalysisAlternative.Text select v; foreach (var closedValue in sortedVaues) { HvoTreeNode node = new HvoTreeNode(closedValue.Abbreviation.BestAnalysisAlternative, closedValue.Hvo); popupTree.Nodes.Add(node); if (closedValue.Hvo == hvoTarget) { match = node; } } } popupTree.Nodes.Add(new HvoTreeNode( TsStringUtils.MakeString(LexTextControls.ksRemoveThisFeature, Cache.WritingSystemFactory.UserWs), kRemoveThisFeature)); return(match); }
/// <summary> /// Select the specified menu item in the tree. /// </summary> /// <param name="item"></param> /// <param name="popupTree"></param> protected void SelectChosenItem(TreeNode item, PopupTree popupTree) { CheckDisposed(); if (item != null) { // We do NOT want to simulate a mouse click because that will cause the // text box in the combo to be focused. We may be updating this from a PropChanged // that should not set focus. popupTree.SelectByAction = TreeViewAction.Unknown; popupTree.SelectedNode = item; if (m_treeCombo != null) { m_treeCombo.SetComboText(item); } } }
private HvoTreeNode AddTreeNodeForMsa(PopupTree popupTree, ITsStrFactory tsf, IMoMorphSynAnalysis msa) { // JohnT: as described in LT-4633, a stem can be given an allomorph that // is an affix. So we need some sort of way to handle this. //Debug.Assert(msa is MoStemMsa); ITsString tssLabel = msa.InterlinearNameTSS; if (msa is IMoStemMsa && (msa as IMoStemMsa).PartOfSpeechRA == null) { tssLabel = tsf.MakeString( m_sUnknown, Cache.ServiceLocator.WritingSystemManager.UserWs); } var node = new HvoTreeNode(tssLabel, msa.Hvo); popupTree.Nodes.Add(node); return(node); }
private void 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. if (m_sense.MorphoSyntaxAnalysisRA != null) { pt.SelectObjWithoutTriggeringBeforeAfterSelects(m_sense.MorphoSyntaxAnalysisRA.Hvo); } // FWR-3542 -- Need this in .Net too, or it eats the first mouse click intended // for the dialog we're about to show below. pt.HideForm(); new MasterCategoryListChooserLauncher(ParentForm, m_mediator, m_propertyTable, List, FieldName, m_sense); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected virtual void Dispose(bool disposing) { Debug.WriteLineIf(!disposing, "****************** Missing Dispose() call for " + GetType().Name + ". ******************"); // Must not be run more than once. if (m_isDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_treeCombo != null && !m_treeCombo.IsDisposed) { m_treeCombo.BeforeSelect -= m_treeCombo_BeforeSelect; m_treeCombo.AfterSelect -= m_treeCombo_AfterSelect; if (m_treeCombo.Tree != null) { m_treeCombo.Tree.PopupTreeClosed -= new TreeViewEventHandler(popupTree_PopupTreeClosed); } // We only manage m_treeCombo, so it gets disposed elsewhere. } if (m_popupTree != null) { m_popupTree.BeforeSelect -= m_treeCombo_BeforeSelect; m_popupTree.AfterSelect -= m_treeCombo_AfterSelect; m_popupTree.PopupTreeClosed -= popupTree_PopupTreeClosed; // We only manage m_popupTree, so it gets disposed elsewhere. } } // Dispose unmanaged resources here, whether disposing is true or false. m_mediator = null; m_lastConfirmedNode = null; m_kEmptyNode = null; m_treeCombo = null; m_popupTree = null; m_parent = null; m_cache = null; m_list = null; m_isDisposed = true; }
/// <summary> /// Populate the tree with just ONE menu item, the one that we want to select. /// </summary> public TreeNode MakeTargetMenuItem() { CheckDisposed(); PopupTree popupTree = GetPopupTree(); popupTree.Nodes.Clear(); var msa = m_sense.MorphoSyntaxAnalysisRA; TreeNode match = null; if (msa == null) { match = AddNotSureItem(popupTree); } else { match = AddTreeNodeForMsa(popupTree, msa); } return(match); }
/// <summary> /// /// </summary> /// <param name="popupTree"></param> /// <param name="hvoTarget"></param> /// <returns>the node matching hvoTarget, if found</returns> protected TreeNode AddPossibilityListItems(PopupTree popupTree, int hvoTarget) { int tagName = UseAbbr ? CmPossibilityTags.kflidAbbreviation : CmPossibilityTags.kflidName; TreeNode match; try { // detect whether this possibility list is (to be) sorted. popupTree.Sorted = List.IsSorted; match = AddNodes(popupTree.Nodes, List.Hvo, CmPossibilityListTags.kflidPossibilities, hvoTarget, tagName); } finally { // now allow subsequent items to get added, but not necessarily sorted. popupTree.Sorted = false; } return(match); }
protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget) { int tagNamePOS = UseAbbr ? CmPossibilityTags.kflidAbbreviation : CmPossibilityTags.kflidName; List <HvoTreeNode> relevantPartsOfSpeech = new List <HvoTreeNode>(); InflectionClassPopupTreeManager.GatherPartsOfSpeech(Cache, List.Hvo, CmPossibilityListTags.kflidPossibilities, CmPossibilityTags.kflidSubPossibilities, PartOfSpeechTags.kflidInflectableFeats, tagNamePOS, WritingSystem, relevantPartsOfSpeech); relevantPartsOfSpeech.Sort(); TreeNode match = null; foreach (HvoTreeNode item in relevantPartsOfSpeech) { popupTree.Nodes.Add(item); var pos = Cache.ServiceLocator.GetInstance <IPartOfSpeechRepository>().GetObject(item.Hvo); foreach (IFsFeatStruc fs in pos.ReferenceFormsOC) { // Note: beware of using fs.ShortName. That can be // absolutely EMPTY (if the user has turned off the 'Show Abbreviation as its label' // field for both the feature category and value). // ChooserName shows the short name if it is non-empty, otherwise the long name. HvoTreeNode node = new HvoTreeNode(fs.ChooserNameTS, fs.Hvo); item.Nodes.Add(node); if (fs.Hvo == hvoTarget) { match = node; } } item.Nodes.Add(new HvoTreeNode( TsStringUtils.MakeString(LexTextControls.ksChooseInflFeats, Cache.WritingSystemFactory.UserWs), kMore)); } return(match); }
protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget) { int tagName = UseAbbr ? CmPossibilityTags.kflidAbbreviation : CmPossibilityTags.kflidName; popupTree.Sorted = Sorted; TreeNode match = null; if (List != null) { match = AddNodes(popupTree.Nodes, List.Hvo, CmPossibilityListTags.kflidPossibilities, hvoTarget, tagName); } var empty = AddAnyItem(popupTree); if (hvoTarget == 0) { match = empty; } return(match); }
/// <summary> /// Populate the tree with just ONE menu item, the one that we want to select, and select it. /// </summary> /// <param name="popupTree"></param> public TreeNode MakeTargetMenuItem() { CheckDisposed(); PopupTree popupTree = GetPopupTree(); popupTree.Nodes.Clear(); IMoMorphSynAnalysis msa = m_sense.MorphoSyntaxAnalysisRA; if (msa == null) { // CreateEmptyMSA during an Undo can crash out, // or cause the Undo (e.g. merge senses) not to complete. (cf. LT-7776) //CreateEmptyMsa(); //msa = m_sense.MorphoSyntaxAnalysisRA; //if (msa == null) return null; } int hvoTarget = msa.Hvo; ITsStrFactory tsf = TsStrFactoryClass.Create(); TreeNode match = AddTreeNodeForMsa(popupTree, tsf, msa); SelectChosenItem(match, popupTree); return match; }
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. if (m_sense.MorphoSyntaxAnalysisRA != null) { pt.SelectObj(m_sense.MorphoSyntaxAnalysisRA.Hvo); } if (Platform.IsMono) { // If Popup tree is shown whilest the dialog is shown, the first click on the dialog is consumed by the // Popup tree, (and closes it down). On .NET the PopupTree appears to be automatically closed. pt.HideForm(); } SandboxGenericMSA dummyMsa = SandboxGenericMSA.Create(m_sense.MorphoSyntaxAnalysisRA); using (MsaCreatorDlg dlg = new MsaCreatorDlg()) { dlg.SetDlgInfo(Cache, m_persistProvider, m_mediator, m_propertyTable, m_sense.Entry, dummyMsa, m_sense.MorphoSyntaxAnalysisRA.Hvo, true, m_sEditGramFunc); if (dlg.ShowDialog(ParentForm) == DialogResult.OK) { Cache.DomainDataByFlid.BeginUndoTask(String.Format(LexTextControls.ksUndoSetX, FieldName), String.Format(LexTextControls.ksRedoSetX, FieldName)); m_sense.SandboxMSA = dlg.SandboxMSA; Cache.DomainDataByFlid.EndUndoTask(); LoadPopupTree(m_sense.MorphoSyntaxAnalysisRA.Hvo); return(true); } } return(false); }
protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget) { int tagName = UseAbbr ? (int)CmPossibility.CmPossibilityTags.kflidAbbreviation : (int)CmPossibility.CmPossibilityTags.kflidName; popupTree.Sorted = true; TreeNode match = AddNodes(popupTree.Nodes, List.Hvo, (int)CmPossibilityList.CmPossibilityListTags.kflidPossibilities, hvoTarget, tagName); popupTree.Sorted = false; // Add two special nodes used to: // 1. Set the value to 'empty', or // 2. Launch the new Grammatical Category Catalog dlg. AddTimberLine(popupTree); TreeNode empty = m_fNotSureIsAny ? AddAnyItem(popupTree, hvoTarget) : AddNotSureItem(popupTree, hvoTarget); if (hvoTarget == 0) { match = empty; } AddMoreItem(popupTree); return(match); }
/// <summary> /// override to add additional nodes to popupTree (e.g. AddNotSureItem, AddTimberline) /// </summary> protected virtual TreeNode AppendAdditionalItems(PopupTree popupTree, int hvoTarget) { return(null); // subclasses override. }
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); }
/// <summary> /// NOTE that this implementation IGNORES hvoTarget and selects the MSA indicated by the sense. /// </summary> /// <param name="popupTree"></param> /// <param name="hvoTarget"></param> /// <returns></returns> protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget) { Debug.Assert(m_sense != null); hvoTarget = m_sense.MorphoSyntaxAnalysisRA == null ? 0 : m_sense.MorphoSyntaxAnalysisRA.Hvo; TreeNode match = null; bool fStem = m_sense.GetDesiredMsaType() == MsaType.kStem; if (fStem /*m_sense.Entry.MorphoSyntaxAnalysesOC.Count != 0*/) { // We want the order to be: // 1. current msa items // 2. possible Parts of Speech // 3. "not sure" items // We also want the Parts of Speech to be sorted, but not the whole tree. // First add the part of speech items (which may be a tree...). int tagName = CmPossibilityTags.kflidName; // make sure they are sorted popupTree.Sorted = true; AddNodes(popupTree.Nodes, List.Hvo, CmPossibilityListTags.kflidPossibilities, 0, tagName); // reset the sorted flag - we only want the parts of speech to be sorted. popupTree.Sorted = false; // Remember the (sorted) nodes in an array (so we can use the AddRange() method). TreeNode[] posArray = new TreeNode[popupTree.Nodes.Count]; popupTree.Nodes.CopyTo(posArray, 0); // now clear out the nodes so we can get the order we want popupTree.Nodes.Clear(); // Add the existing MSA items for the sense's owning entry. foreach (var msa in m_sense.Entry.MorphoSyntaxAnalysesOC) { HvoTreeNode node = AddTreeNodeForMsa(popupTree, msa); if (msa.Hvo == hvoTarget) { match = node; } } AddTimberLine(popupTree); // now add the sorted parts of speech popupTree.Nodes.AddRange(posArray); AddTimberLine(popupTree); // 1. "<Not Sure>" to produce a negligible Msa reference. // 2. "More..." command to launch category chooser dialog. TreeNode empty = AddNotSureItem(popupTree); if (match == null) { match = empty; } AddMoreItem(popupTree); } else { int cMsa = m_sense.Entry.MorphoSyntaxAnalysesOC.Count; if (cMsa == 0) { // 1. "<Not Sure>" to produce a negligible Msa reference. // 2. "Specify..." command. //Debug.Assert(hvoTarget == 0); match = AddNotSureItem(popupTree); popupTree.Nodes.Add(new HvoTreeNode(TsStringUtils.MakeString(m_sSpecifyGramFunc, Cache.WritingSystemFactory.UserWs), kCreate)); } else { // 1. Show the current Msa at the top. // 2. "Modify ..." command. // 3. Show other existing Msas next (if any). // 4. <Not Sure> to produce a negligible Msa reference. // 5. "Specify different..." command. hvoTarget = 0; // We should always have an MSA assigned to every sense, but sometimes this // hasn't happened. Don't crash if the data isn't quite correct. See FWR-3090. if (m_sense.MorphoSyntaxAnalysisRA != null) { hvoTarget = m_sense.MorphoSyntaxAnalysisRA.Hvo; } if (hvoTarget != 0) { ITsString tssLabel = m_sense.MorphoSyntaxAnalysisRA.InterlinearNameTSS; HvoTreeNode node = new HvoTreeNode(tssLabel, hvoTarget); popupTree.Nodes.Add(node); match = node; popupTree.Nodes.Add(new HvoTreeNode(TsStringUtils.MakeString(m_sModifyGramFunc, Cache.WritingSystemFactory.UserWs), kModify)); AddTimberLine(popupTree); } int cMsaExtra = 0; foreach (var msa in m_sense.Entry.MorphoSyntaxAnalysesOC) { if (msa.Hvo == hvoTarget) { continue; } ITsString tssLabel = msa.InterlinearNameTSS; HvoTreeNode node = new HvoTreeNode(tssLabel, msa.Hvo); popupTree.Nodes.Add(node); ++cMsaExtra; } if (cMsaExtra > 0) { AddTimberLine(popupTree); } // Per final decision on LT-5084, don't want <not sure> for affixes. //TreeNode empty = AddNotSureItem(popupTree, hvoTarget); //if (match == null) // match = empty; popupTree.Nodes.Add(new HvoTreeNode(TsStringUtils.MakeString(m_sSpecifyDifferent, Cache.WritingSystemFactory.UserWs), kCreate)); } } return(match); }
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); }
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); }
/// <summary> /// Add the --- line to the popup (use if adding any 'extra' items). /// </summary> /// <param name="popupTree"></param> protected void AddTimberLine(PopupTree popupTree) { popupTree.Nodes.Add(new HvoTreeNode(Cache.TsStrFactory.MakeString(TimberLine, Cache.WritingSystemFactory.UserWs), kLine)); }
/// <summary> /// Add a 'More...' item to the tree. Subclass is responsible to implement. /// </summary> /// <param name="popupTree"></param> protected void AddMoreItem(PopupTree popupTree) { popupTree.Nodes.Add(new HvoTreeNode(Cache.TsStrFactory.MakeString(LexTextControls.ksMore_, Cache.WritingSystemFactory.UserWs), kMore)); }
/// <summary> /// Make all the menu items. May well call things like AddTimberline, AddNotSureItem, AddMoreItem. /// </summary> /// <param name="popupTree"></param> /// <param name="hvoTarget"></param> /// <returns></returns> protected abstract TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget);
/// <summary> /// Add the --- line to the popup (use if adding any 'extra' items). /// </summary> /// <param name="popupTree"></param> protected void AddTimberLine(PopupTree popupTree) { popupTree.Nodes.Add(new HvoTreeNode(Cache.MakeUserTss(TimberLine), kLine)); }
/// <summary> /// Constructor. /// </summary> public MSAPopupTreeManager(PopupTree popupTree, LcmCache cache, ICmPossibilityList list, int ws, bool useAbbr, Mediator mediator, XCore.PropertyTable propertyTable, Form parent) : base(popupTree, cache, mediator, propertyTable, list, ws, useAbbr, parent) { LoadStrings(); }
/// <summary> /// Constructor. /// </summary> public POSPopupTreeManager(PopupTree popupTree, FdoCache cache, ICmPossibilityList list, int ws, bool useAbbr, Mediator mediator, Form parent) : base(popupTree, cache, mediator, list, ws, useAbbr, parent) { }
/// <summary> /// Add a 'More...' item to the tree. Subclass is responsible to implement. /// </summary> /// <param name="popupTree"></param> protected void AddMoreItem(PopupTree popupTree) { popupTree.Nodes.Add(new HvoTreeNode(Cache.MakeUserTss(LexTextControls.ksMore_), kMore)); }