/// <summary> /// Show a dialog to allow the user to select/unselect multiple writing systems /// at a time, whether or not to display them (if they don't have data) /// If they do have data, we show the fields anyhow. /// </summary> /// <param name="args"></param> /// <returns></returns> public bool OnDataTreeWritingSystemsConfigureDlg(object args) { CheckDisposed(); Set <int> wsSet = new Set <int>(HvosFromWss(WritingSystemOptionsForDisplay)); ObjectLabelCollection labels = new ObjectLabelCollection(m_cache, wsSet); ReloadWssToDisplayForPart(); List <int> wssToDisplay = HvosFromWss(WritingSystemsSelectedForDisplay); using (ReallySimpleListChooser chooser = new ReallySimpleListChooser(null, labels, "DataTreeWritingSystems", m_cache, wssToDisplay.ToArray(), false)) { chooser.ForbidNoItemChecked = true; IVwStylesheet stylesheet = (Control as LabeledMultiStringView).StyleSheet; chooser.SetFontForDialog(new int[] { Cache.DefaultVernWs, Cache.DefaultAnalWs }, stylesheet, Cache.LanguageWritingSystemFactoryAccessor); chooser.InitializeExtras(ConfigurationNode, Mediator); chooser.Text = String.Format(DetailControlsStrings.ksSliceConfigureWssDlgTitle, this.Label); chooser.InstructionalText = DetailControlsStrings.ksSliceConfigureWssDlgInstructionalText; if (chooser.ShowDialog() == DialogResult.OK) { PersistAndRedisplayWssToDisplayForPart(chooser.ChosenHvos); } } return(true); }
private void DoUpdateDisplayFromDatabase(string displayNameProperty) { m_processSelectionEvent = false; m_currentSelectedIndex = 0; m_combo.Items.Clear(); Set <int> candidates = Object.ReferenceTargetCandidates(m_flid); ObjectLabelCollection labels = new ObjectLabelCollection(m_cache, candidates, displayNameProperty); int currentValue = m_cache.GetObjProperty(Object.Hvo, m_flid); int idx = 0; foreach (ObjectLabel ol in labels) { m_combo.Items.Add(ol); if (ol.Hvo == currentValue) { m_combo.SelectedItem = ol; m_currentSelectedIndex = idx; } idx++; } idx = m_combo.Items.Add(NullItemLabel); if (currentValue == 0) { m_combo.SelectedIndex = idx; m_currentSelectedIndex = idx; } m_processSelectionEvent = true; }
public bool OnMoveReversalPOS(object cmd) { FdoCache cache = Cache; ObjectLabelCollection labels = new ObjectLabelCollection(); foreach (IPartOfSpeech pos in MergeOrMoveCandidates) { labels.Add(ObjectLabel.CreateObjectLabelOnly(cache, pos.Hvo, "ShortNameTSS", "best analysis")); } using (SimpleListChooser dlg = new SimpleListChooser(cache, null, labels, 0, LexEdStrings.ksCategoryToMoveTo, null)) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { IPartOfSpeech currentPOS = POS; IPartOfSpeech newOwner = PartOfSpeech.CreateFromDBObject(cache, dlg.ChosenOne.Hvo); cache.BeginUndoTask(LexEdStrings.ksUndoMoveRevCategory, LexEdStrings.ksRedoMoveRevCategory); ICmObject newOwningObj = newOwner.MoveIfNeeded(currentPOS); newOwner.SubPossibilitiesOS.Append(currentPOS); cache.EndUndoTask(); // Note: PropChanged should happen on the old owner and the new in the 'Add" method call. // Have to jump to a main PartOfSpeech, as RecordClerk doesn't know anything about subcategories. m_mediator.BroadcastMessageUntilHandled("JumpToRecord", newOwner.MainPossibility.Hvo); } } return(true); }
/// <summary> /// Get the SimpleListChooser/ /// </summary> /// <param name="labels">List of objects to show in the chooser.</param> /// <returns>The SimpleListChooser.</returns> protected virtual SimpleListChooser GetChooser(ObjectLabelCollection labels) { SimpleListChooser x = new SimpleListChooser(m_persistProvider, labels, m_fieldName); x.NullLabel.DisplayName = XmlUtils.GetOptionalAttributeValue(m_configurationNode, "nullLabel", "<EMPTY>"); return(x); }
static public SimpleListChooser MakeSenseChooser(FdoCache cache) { List <int> lexSenses = new List <int>(DbOps.ReadIntArrayFromCommand(cache, "SELECT Dst FROM LexEntry_Senses", null)); ObjectLabelCollection labels = new ObjectLabelCollection(cache, lexSenses, "LongNameTSS"); SimpleListChooser chooser = new SimpleListChooser(null, labels, LexEdStrings.ksSenses); chooser.Cache = cache; return(chooser); }
/// <summary> /// Get the SimpleListChooser/ /// </summary> /// <param name="labels">List of objects to show in the chooser.</param> /// <returns>The SimpleListChooser.</returns> protected new MorphTypeChooser GetChooser(ObjectLabelCollection labels) { string sShowAllTypes = m_mediator.StringTbl.GetStringWithXPath("ChangeLexemeMorphTypeShowAllTypes", m_ksPath); MorphTypeChooser x = new MorphTypeChooser(m_persistProvider, labels, m_fieldName, m_obj, m_displayNameProperty, m_flid, sShowAllTypes); x.Cache = m_cache; x.NullLabel.DisplayName = XmlUtils.GetOptionalAttributeValue(m_configurationNode, "nullLabel", "<EMPTY>"); return(x); }
/// <summary> /// constructor for use with adding a new value /// </summary> /// <param name="labels"></param> /// <param name="fieldName">the user-readable name of the field that is being edited /// </param> public MorphTypeChooser(IPersistenceProvider persistProvider, ObjectLabelCollection labels, string fieldName, ICmObject obj, string displayNameProperty, int flid, string sShowAllTypes) : base(persistProvider, labels, fieldName) { m_obj = obj; m_displayNameProperty = displayNameProperty; m_flid = flid; InitMorphTypeForm(sShowAllTypes); }
protected override SimpleListChooser GetChooser(ObjectLabelCollection labels) { string nullLabel = DetailControlsStrings.ksNullLabel; if (m_configurationNode != null) { System.Xml.XmlNode node = m_configurationNode.SelectSingleNode("deParams"); nullLabel = XmlUtils.GetOptionalAttributeValue(node, "nullLabel", nullLabel); } SimpleListChooser c = new SimpleListChooser(m_cache, m_persistProvider, labels, TargetHvo, m_fieldName, nullLabel, m_atomicRefView.StyleSheet); return(c); }
internal int DisplayChooser(string fieldName, string linkText, string toolName, string guiControl, Set <int> candidates) { int hvo = 0; ObjectLabelCollection labels = new ObjectLabelCollection(m_cache, candidates); using (SimpleListChooser chooser = new SimpleListChooser(m_persistenceProvider, labels, fieldName)) { chooser.Cache = m_cache; chooser.TextParamHvo = m_cache.LangProject.PhonologicalDataOAHvo; chooser.AddLink(linkText, SimpleListChooser.LinkType.kGotoLink, FwLink.Create(toolName, m_cache.GetGuidFromId(chooser.TextParamHvo), m_cache.ServerName, m_cache.DatabaseName)); chooser.ReplaceTreeView(m_mediator, guiControl); if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.RegRuleFormulaControl) { chooser.SetHelpTopic("khtpChoose-Grammar-PhonFeats-RegRuleFormulaControl"); } else if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.MetaRuleFormulaControl) { chooser.SetHelpTopic("khtpChoose-Grammar-PhonFeats-MetaRuleFormulaControl"); } else if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.MetaRuleFormulaControl) { chooser.SetHelpTopic("khtpChoose-LexiconEdit-PhonFeats-AffixRuleFormulaControl"); } DialogResult res = chooser.ShowDialog(); if (res != DialogResult.Cancel) { chooser.HandleAnyJump(); if (chooser.ChosenOne != null) { hvo = chooser.ChosenOne.Hvo; } } } return(hvo); }
private void cbShowAllTypes_CheckedChanged(object sender, System.EventArgs e) { // If a node is selected, try selecting again when we get through. int hvoSelected = SelectedHvo; Set <int> candidates = null; string displayWs = "best analorvern"; if (cbShowAllTypes.Checked) { MoForm form = m_obj as MoForm; candidates = form.GetAllMorphTypeReferenceTargetCandidates(); } else { candidates = m_obj.ReferenceTargetCandidates(m_flid); } ObjectLabelCollection labels = new ObjectLabelCollection(m_cache, candidates, m_displayNameProperty, displayWs); LoadTree(labels, 0, false); MakeSelection(hvoSelected); }
/// <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); } } Set <int> candidates = m_obj.ReferenceTargetCandidates(m_flid); ObjectLabelCollection labels = new ObjectLabelCollection(m_cache, candidates, 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.InitializeExtras(m_configurationNode, Mediator); } System.Windows.Forms.DialogResult res = chooser.ShowDialog(); if (System.Windows.Forms.DialogResult.Cancel == res) { return; } if (m_configurationNode != null) { chooser.HandleAnyJump(); } if (chooser.ChosenOne != null) { AddItem(chooser.ChosenOne.Hvo); } else if (chooser.ChosenHvos != null) { SetItems(chooser.ChosenHvos); } } //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()); } }
/// <summary> /// Override method to handle launching of a chooser for selecting lexical entries. /// </summary> protected override void HandleChooser() { string displayWs = "analysis vernacular"; 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); } } Set <int> candidates = m_obj.ReferenceTargetCandidates(m_flid); ObjectLabelCollection labels = new ObjectLabelCollection(m_cache, candidates, m_displayNameProperty, displayWs); using (MorphTypeChooser chooser = GetChooser(labels)) { bool fMadeMorphTypeChange = false; ILexEntry entry = LexEntry.CreateFromDBObject(m_cache, m_obj.OwnerHVO); chooser.InitializeExtras(m_configurationNode, Mediator); chooser.SetObjectAndFlid(m_obj.Hvo, m_flid); int hvoType = m_cache.GetObjProperty(m_obj.Hvo, m_flid); chooser.MakeSelection(hvoType); // LT-4433 changed the Alternate Forms to choose between Stem and Affix automatically // when inserting. Thus, we need the check box in that environment as well. //if (m_obj.OwningFlid != (int)LexEntry.LexEntryTags.kflidLexemeForm) // chooser.ShowAllTypesCheckBoxVisible = false; if (chooser.ShowDialog() == DialogResult.OK) { ObjectLabel selected = chooser.ChosenOne; int hvoOriginal = TargetHvo; string sUndo = m_mediator.StringTbl.GetStringWithXPath("ChangeLexemeMorphTypeUndo", m_ksPath); string sRedo = m_mediator.StringTbl.GetStringWithXPath("ChangeLexemeMorphTypeRedo", m_ksPath); bool fRemoveComponents = false; if (selected.Hvo == entry.Cache.GetIdFromGuid(new Guid(MoMorphType.kguidMorphRoot)) || selected.Hvo == entry.Cache.GetIdFromGuid(new Guid(MoMorphType.kguidMorphBoundRoot))) { // changing to root...not allowed to have complex forms. foreach (LexEntryRef ler in entry.EntryRefsOS) { if (ler.RefType == LexEntryRef.krtComplexForm) { fRemoveComponents = true; // If there are no components we will delete without asking...but must then check for more // complex forms that DO have components. if (ler.ComponentLexemesRS.Count > 0) { if (MessageBox.Show(FindForm(), DetailControlsStrings.ksRootNoComponentsMessage, DetailControlsStrings.ksRootNoComponentsCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 0, FwApp.App.HelpFile, HelpNavigator.Topic, "khtRootCannotHaveComponents") != DialogResult.Yes) { return; } break; } } } } using (new UndoRedoTaskHelper(entry.Cache, sUndo, sRedo)) { if (fRemoveComponents) { Set <int> delObjs = new Set <int>(); foreach (LexEntryRef ler in entry.EntryRefsOS) { if (ler.RefType == LexEntryRef.krtComplexForm) { delObjs.Add(ler.Hvo); } } CmObject.DeleteObjects(delObjs, m_cache); } if (IsStemType(hvoOriginal) || m_obj is MoStemAllomorph) { if (IsStemType(selected.Hvo)) { TargetHvo = selected.Hvo; } else { //have to switch from stem to affix fMadeMorphTypeChange = ChangeStemToAffix(entry, selected.Hvo, sUndo, sRedo); } } else { // original is affix variety if (IsStemType(selected.Hvo)) { //have to switch from affix to stem fMadeMorphTypeChange = ChangeAffixToStem(entry, selected.Hvo, sUndo, sRedo); } else { TargetHvo = selected.Hvo; } } if (selected.Hvo == entry.Cache.GetIdFromGuid(new Guid(MoMorphType.kguidMorphPhrase))) { ILexEntryRef ler = new LexEntryRef(); entry.EntryRefsOS.Append(ler); ler.RefType = LexEntryRef.krtComplexForm; ler.HideMinorEntry = 1; // No automatic propchanged for new objects, need to let the view see it. // At that point our slice will be disposed, so don't do anything after this. entry.Cache.PropChanged(entry.Hvo, (int)LexEntry.LexEntryTags.kflidEntryRefs, 0, 1, 0); } } } } }
//private System.ComponentModel.IContainer components = null; /// <summary> /// constructor for use with adding a new value /// </summary> /// <param name="labels"></param> /// <param name="fieldName">the user-readable name of the field that is being edited /// </param> public MorphTypeChooser(IPersistenceProvider persistProvider, ObjectLabelCollection labels, string fieldName) : base(persistProvider, labels, fieldName) { InitMorphTypeForm(null); }
/// <summary> /// (Deprecated) constructor for use with changing or setting a value /// </summary> /// <param name="persistProvider">optional, if you want to preserve the size and /// location</param> /// <param name="labels"></param> /// <param name="currentHvo">use zero if empty</param> /// <param name="fieldName">the user-readable name of the field that is being edited /// </param> public SimpleListChooser(IPersistenceProvider persistProvider, ObjectLabelCollection labels, int currentHvo, string fieldName) : base(persistProvider, labels, currentHvo, fieldName) { }
/// <summary> /// constructor for use with adding a new value /// </summary> /// <param name="labels"></param> /// <param name="fieldName">the user-readable name of the field that is being edited /// </param> public SimpleListChooser(IPersistenceProvider persistProvider, ObjectLabelCollection labels, string fieldName, IVwStylesheet stylesheet) : base(persistProvider, labels, fieldName, stylesheet) { }
/// <summary> /// Override method to handle launching of a chooser for selecting lexical entries or senses. /// </summary> protected override void HandleChooser() { Debug.Assert(m_flid == (int)LexEntryRef.LexEntryRefTags.kflidComponentLexemes || m_flid == (int)LexEntryRef.LexEntryRefTags.kflidPrimaryLexemes); if (m_flid == (int)LexEntryRef.LexEntryRefTags.kflidComponentLexemes) { using (LinkEntryOrSenseDlg dlg = new LinkEntryOrSenseDlg()) { ILexEntry le = null; if (m_obj.ClassID == LexEntry.kclsidLexEntry) { // filter this entry from the list. le = m_obj as ILexEntry; } else { // assume the owner is the entry (e.g. owner of LexEntryRef) int hvoEntry = m_cache.GetOwnerOfObjectOfClass(m_obj.Hvo, LexEntry.kclsidLexEntry); if (hvoEntry != 0) { le = LexEntry.CreateFromDBObject(m_cache, hvoEntry); } } dlg.SetDlgInfo(m_cache, m_mediator, le); String str = ShowHelp.RemoveSpaces(this.Slice.Label); dlg.SetHelpTopic("khtpChooseLexicalEntryOrSense-" + str); if (dlg.ShowDialog(FindForm()) == DialogResult.OK) { AddItem(dlg.SelectedID); } } } else if (m_flid == (int)LexEntryRef.LexEntryRefTags.kflidPrimaryLexemes) { string displayWs = "analysis vernacular"; if (m_configurationNode != null) { XmlNode node = m_configurationNode.SelectSingleNode("deParams"); if (node != null) { displayWs = XmlUtils.GetAttributeValue(node, "ws", "analysis vernacular").ToLower(); } } ILexEntryRef ler = m_obj as ILexEntryRef; Debug.Assert(ler != null); List <int> candidates = new List <int>(); candidates.AddRange(ler.ComponentLexemesRS.HvoArray); ObjectLabelCollection labels = new ObjectLabelCollection(m_cache, candidates, m_displayNameProperty, displayWs); using (ReallySimpleListChooser chooser = new ReallySimpleListChooser(null, labels, "PrimaryLexemes", m_cache, ler.PrimaryLexemesRS.HvoArray, false)) { chooser.SetObjectAndFlid(m_obj.Hvo, m_flid); // may set TextParamHvo chooser.Text = "Choose where to show subentry"; //chooser.ReplaceTreeView(Mediator, "WordformsBrowseView"); chooser.InitializeExtras(null, Mediator); chooser.AddLink("Add a Component...", ReallySimpleListChooser.LinkType.kDialogLink, new AddComponentChooserCommand(m_cache, false, null, m_mediator, m_obj, FindForm())); DialogResult res = chooser.ShowDialog(); if (DialogResult.Cancel == res) { return; } if (chooser.ChosenHvos != null) { SetItems(chooser.ChosenHvos); } } } }
/// <summary> /// constructor for use with changing or setting a value /// </summary> /// <param name="cache"></param> /// <param name="persistProvider">optional, if you want to preserve the size and /// location</param> /// <param name="labels"></param> /// <param name="currentHvo">use zero if empty</param> /// <param name="fieldName">the user-readable name of the field that is being edited /// </param> public SimpleListChooser(FdoCache cache, IPersistenceProvider persistProvider, ObjectLabelCollection labels, int currentHvo, string fieldName, string nullLabel, IVwStylesheet stylesheet) : base(cache, persistProvider, labels, currentHvo, fieldName, nullLabel, stylesheet) { }
/// <summary> /// Overridden to provide a chooser with multiple selections (checkboxes and all). /// </summary> protected override SimpleListChooser GetChooser(ObjectLabelCollection labels) { return(new SimpleListChooser(m_persistProvider, labels, m_fieldName, m_cache, m_cache.GetVectorProperty(m_obj.Hvo, m_flid, false))); }
/// <summary> /// constructor for use with changing or setting multiple values. /// </summary> /// <param name="persistProvider">optional, if you want to preserve the size and /// location</param> /// <param name="labels"></param> /// <param name="fieldName">the user-readable name of the field that is being edited /// </param> /// <param name="cache"></param> /// <param name="rghvoChosen">use null or int[0] if empty</param> public SimpleListChooser(IPersistenceProvider persistProvider, ObjectLabelCollection labels, string fieldName, FdoCache cache, int[] rghvoChosen) : base(persistProvider, labels, fieldName, cache, rghvoChosen) { }