/// <summary> /// Handle launching of the standard chooser. /// </summary> /// <remarks> /// Subclasses should override this method, if the SimpleListChooser is not suitable. /// </remarks> protected override void HandleChooser() { string displayWs = "analysis vernacular"; //string displayWs = "best analysis"; string postDialogMessageTrigger = null; if (m_configurationNode != null) { XmlNode node = m_configurationNode.SelectSingleNode("deParams"); if (node != null) { displayWs = XmlUtils.GetAttributeValue(node, "ws", "analysis vernacular").ToLower(); postDialogMessageTrigger = XmlUtils.GetAttributeValue(node, "postChangeMessageTrigger", null); } } var labels = ObjectLabel.CreateObjectLabels(m_cache, m_obj.ReferenceTargetCandidates(m_flid), m_displayNameProperty, displayWs); // I (JH) started down this road to sorting the object labels... it proved bumpy // and I bailed out and just turned on the "sorted" property of the chooser, // which gives us a dumb English sort. // but when it is time to get back to this... what I was doing what is misguided // because this sorter wants FdoObjects, but object labels don't have those on the // surface. instead, they can readily give a string, through ToString().which is // what made me realize that until we have a way to sort something based on ICU, I // might as well let .net do the sorting. // I'm thinking there's a good chance we will eventually use FieldWorks controls for // the chooser in fact we will probably just using normal browse view. Then, that // chooser can just do the normal sorting that browse view stew, including letting // the user sort based on different properties. // however, we need a TreeView in many cases... I think there's also a FieldWorks // one of those that probably doesn't have sorting built-in yet...in which case we // might want to do the sorting here. //SIL.FieldWorks.Filters.RecordSorter sorter = // new SIL.FieldWorks.Filters.PropertyRecordSorter("ShortName"); //sorter.Sort ((ArrayList) labels); using (SimpleListChooser chooser = GetChooser(labels)) { chooser.Cache = m_cache; chooser.SetObjectAndFlid(m_obj.Hvo, m_flid); // may set TextParamHvo if (m_configurationNode != null) { // Handle the default case ("owner") for text parameters. // This (old approach) works only if // all of the list items are owned by the same object as the first one in the // list. (Later elements can be owned by elements owned by that first owner, // if you know what I mean.) //if (candidates.Count != 0) // chooser.TextParamHvo = m_cache.GetOwnerOfObject((int)candidates[0]); // JohnT: this approach depends on a new FDO method. ICmObject referenceTargetOwner = m_obj.ReferenceTargetOwner(m_flid); if (referenceTargetOwner != null) { chooser.TextParamHvo = referenceTargetOwner.Hvo; } chooser.SetHelpTopic(Slice.GetChooserHelpTopicID()); chooser.InitializeExtras(m_configurationNode, Mediator, m_propertyTable); } var res = chooser.ShowDialog(MainControl.FindForm()); if (DialogResult.Cancel == res) { return; } if (m_configurationNode != null) { chooser.HandleAnyJump(); } if (chooser.ChosenOne != null) { AddItem(chooser.ChosenOne.Object); } else if (chooser.ChosenObjects != null) { SetItems(chooser.ChosenObjects); } } //if the configuration file says that we should put up a message dialog after a change has been made, //do that now. if (postDialogMessageTrigger != null) { XCore.XMessageBoxExManager.Trigger(postDialogMessageTrigger); } // If the configuration file says to refresh the slice list, do that now. if (ChoicesMade != null) { ChoicesMade(this, new EventArgs()); } }