protected virtual void m_launcher_Click(object sender, EventArgs e) { if (m_hvoList == (int)SpecialHVOValues.kHvoUninitializedObject) return; // Can't show a chooser for a non-existent list! // Show a wait cursor (LT-4673) using (new WaitCursor(this.Control)) { var list = m_cache.ServiceLocator.GetInstance<ICmPossibilityListRepository>().GetObject(m_hvoList); var persistProvider = new PersistenceProvider(m_mediator.PropertyTable); var labels = ObjectLabel.CreateObjectLabels(m_cache, list.PossibilitiesOS, m_displayNameProperty, m_displayWs); using (var chooser = new ReallySimpleListChooser(persistProvider, labels, m_fieldName, m_cache, m_chosenObjs, m_mediator.HelpTopicProvider)) { chooser.Atomic = Atomic; chooser.Cache = m_cache; chooser.SetObjectAndFlid(0, m_flid); chooser.ShowFuncButtons(); if (Convert.ToInt16(Right(m_flid.ToString(), 3)) >= 500 && Convert.ToInt16(Right(m_flid.ToString(),3)) < 600) chooser.SetHelpTopic("khtpBulkEditCustomField"); else chooser.SetHelpTopic("khtpBulkEdit" + m_fieldName.Replace(" ", "")); var res = chooser.ShowDialog((sender as Control).TopLevelControl); if (DialogResult.Cancel == res) return; m_chosenObjs = chooser.ChosenObjects.ToList(); m_fReplace = chooser.ReplaceMode; m_fRemove = chooser.RemoveMode; // Tell the parent control that we may have changed the selected item so it can // enable or disable the Apply and Preview buttons based on the selection. // We are just checking here if any item was selected by the user in the dialog if (ValueChanged != null) { int hvo = 0; if (m_chosenObjs.Count > 0) hvo = m_chosenObjs[0].Hvo; ValueChanged(sender, new FwObjectSelectionEventArgs(hvo)); } } } }
protected override void HandleChooser() { if (m_flid == LexEntryRefTags.kflidComponentLexemes) { using (LinkEntryOrSenseDlg dlg = new LinkEntryOrSenseDlg()) { ILexEntry le = null; if (m_obj.ClassID == LexEntryTags.kClassId) { // filter this entry from the list. le = m_obj as ILexEntry; } else { // assume the owner is the entry (e.g. owner of LexEntryRef) le = m_obj.OwnerOfClass<ILexEntry>(); } 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.SelectedObject); } } else if (m_flid == 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); var labels = ObjectLabel.CreateObjectLabels(m_cache, ler.ComponentLexemesRS.Cast<ICmObject>(), m_displayNameProperty, displayWs); using (ReallySimpleListChooser chooser = new ReallySimpleListChooser(null, labels, "PrimaryLexemes", m_cache, ler.PrimaryLexemesRS.Cast<ICmObject>(), false, m_mediator.HelpTopicProvider)) { chooser.HideDisplayUsageCheckBox(); chooser.SetObjectAndFlid(m_obj.Hvo, m_flid); // may set TextParamHvo chooser.Text = LexEdStrings.ksChooseWhereToShowSubentry; chooser.SetHelpTopic(Slice.GetChooserHelpTopicID()); chooser.InitializeExtras(null, Mediator); chooser.AddLink(LexEdStrings.ksAddAComponent, ReallySimpleListChooser.LinkType.kDialogLink, new AddPrimaryLexemeChooserCommand(m_cache, false, null, m_mediator, m_obj, FindForm())); DialogResult res = chooser.ShowDialog(); if (DialogResult.Cancel == res) return; if (chooser.ChosenObjects != null) SetItems(chooser.ChosenObjects); } } else { string fieldName = m_obj.Cache.MetaDataCacheAccessor.GetFieldName(m_flid); Debug.Assert(m_obj is ILexEntry || m_obj is ILexSense); switch(fieldName) { case "ComplexFormEntries": using (var dlg = new EntryGoDlg()) { dlg.StartingEntry = m_obj as ILexEntry ?? (m_obj as ILexSense).Entry; dlg.SetDlgInfo(m_cache, null, m_mediator); String str = ShowHelp.RemoveSpaces(Slice.Label); dlg.SetHelpTopic("khtpChooseComplexFormEntryOrSense-" + str); dlg.SetOkButtonText(LexEdStrings.ksMakeComponentOf); if (dlg.ShowDialog(FindForm()) == DialogResult.OK) { try { UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoAddComplexForm, LexEdStrings.ksRedoAddComplexForm, m_obj.Cache.ActionHandlerAccessor, () => ((ILexEntry)dlg.SelectedObject).AddComponent(m_obj)); } catch (ArgumentException) { MessageBoxes.ReportLexEntryCircularReference((ILexEntry) dlg.SelectedObject, m_obj, false); } } } break; case "VisibleComplexFormEntries": // obsolete? case "Subentries": HandleChooserForBackRefs(fieldName, false); break; case "VisibleComplexFormBackRefs": HandleChooserForBackRefs(fieldName, true); break; default: Debug.Fail("EntrySequenceReferenceLauncher should only be used for variants, components, or complex forms"); break; } } }
/// <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); } } }
private void HandleChooserForBackRefs(string fieldName, bool fPropContainsEntryRefs) { string displayWs = "analysis vernacular"; IEnumerable<ICmObject> options; if (m_obj is ILexEntry) options = ((ILexEntry) m_obj).ComplexFormEntries.Cast<ICmObject>(); else options = ((ILexSense)m_obj).ComplexFormEntries.Cast<ICmObject>(); var oldValue = from hvo in ((ISilDataAccessManaged) m_cache.DomainDataByFlid).VecProp(m_obj.Hvo, m_flid) select m_cache.ServiceLocator.GetObject(hvo); // We want a collection of LexEntries as the current values. If we're displaying lex entry refs we want their owners. if (fPropContainsEntryRefs) oldValue = from obj in oldValue select obj.Owner; var labels = ObjectLabel.CreateObjectLabels(m_cache, options, m_displayNameProperty, displayWs); using (ReallySimpleListChooser chooser = new ReallySimpleListChooser(null, labels, fieldName, m_cache, oldValue, false, m_mediator.HelpTopicProvider)) { chooser.HideDisplayUsageCheckBox(); chooser.SetObjectAndFlid(m_obj.Hvo, m_flid); // may set TextParamHvo chooser.Text = fieldName == "Subentries" ? LexEdStrings.ksChooseSubentries : LexEdStrings.ksChooseVisibleComplexForms; chooser.SetHelpTopic(Slice.GetChooserHelpTopicID() + "-CFChooser"); chooser.InitializeExtras(null, Mediator); // Step 3 of LT-11155: chooser.AddLink(LexEdStrings.ksAddAComplexForm, ReallySimpleListChooser.LinkType.kDialogLink, new AddComplexFormChooserCommand(m_cache, false, null, m_mediator, m_obj, FindForm())); DialogResult res = chooser.ShowDialog(); if (DialogResult.Cancel == res) return; var chosenObjects = chooser.ChosenObjects; if (chosenObjects != null) { if (fPropContainsEntryRefs) { chosenObjects = from ILexEntry le in chosenObjects from ler in le.EntryRefsOS where ler.RefType == LexEntryRefTags.krtComplexForm select (ICmObject) ler; } SetItems(chosenObjects); } } }
void m_launcher_Click(object sender, EventArgs e) { // Show a wait cursor (LT-4673) using (new SIL.FieldWorks.Common.Utils.WaitCursor(this.Control)) { ICmPossibilityList list = CmPossibilityList.CreateFromDBObject(m_cache, m_hvoList); List<int> candidates = new List<int>(list.PossibilitiesOS.HvoArray); XCore.PersistenceProvider persistProvider = new PersistenceProvider(m_mediator.PropertyTable); ObjectLabelCollection labels = new ObjectLabelCollection(m_cache, candidates, m_displayNameProperty, m_displayWs); //m_cache.MetaDataCacheAccessor.GetFieldName((uint)m_flid, out fieldName); using (ReallySimpleListChooser chooser = new ReallySimpleListChooser(persistProvider, labels, m_fieldName, m_cache, m_chosenHvos)) { chooser.Cache = m_cache; chooser.SetObjectAndFlid(0, m_flid); chooser.ShowFuncButtons(); chooser.SetHelpTopic("khtpBulkEdit" + m_fieldName.Replace(" ", "")); System.Windows.Forms.DialogResult res = chooser.ShowDialog((sender as Control).TopLevelControl); if (System.Windows.Forms.DialogResult.Cancel == res) return; m_chosenHvos = chooser.ChosenHvos.ToArray(); m_fReplace = chooser.ReplaceMode; m_fRemove = chooser.RemoveMode; // Tell the parent control that we may have changed the selected item so it can // enable or disable the Apply and Preview buttons based on the selection. // We are just checking here if any item was selected by the user in the dialog if (ValueChanged != null) { int itemCount = m_chosenHvos.Length; int hvo = 0; if (itemCount > 0) hvo = m_chosenHvos[0]; ValueChanged(sender, new FwObjectSelectionEventArgs(hvo)); } } } }
/// <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; }
internal IRnGenericRec ChooseNewOwner(IRnGenericRec[] records, string sTitle) { var helpTopic = "khtpDataNotebook-ChooseOwnerOfDemotedRecord"; XCore.PersistenceProvider persistProvider = new PersistenceProvider(m_mediator.PropertyTable); var labels = ObjectLabel.CreateObjectLabels(m_cache, records.Cast<ICmObject>(), "ShortName", m_cache.WritingSystemFactory.GetStrFromWs(m_cache.DefaultAnalWs)); using (var dlg = new ReallySimpleListChooser(persistProvider, labels, String.Empty, m_mediator.HelpTopicProvider)) { dlg.Text = sTitle; dlg.SetHelpTopic(helpTopic); if (dlg.ShowDialog() == DialogResult.OK) return dlg.SelectedObject as IRnGenericRec; } return null; }
/// <summary> /// Bring up a chooser for selecting a natural class, and insert it into the string /// representation stored in the rootbox. This static method is used by /// SIL.FieldWorks.Common.Framework.DetailControls.PhoneEnvReferenceSlice and /// SIL.FieldWorks.XWorks.MorphologyEditor.PhEnvStrRepresentationSlice. /// </summary> /// <param name="rootb"></param> /// <param name="cache"></param> /// <param name="persistenceProvider"></param> /// <param name="mediator"></param> /// <returns></returns> public static bool ChooseNaturalClass(IVwRootBox rootb, FdoCache cache, IPersistenceProvider persistenceProvider, XCore.Mediator mediator) { List<int> candidates = null; int hvoPhonData = cache.LangProject.PhonologicalDataOA.Hvo; int flidNatClasses = (int)PhPhonData.PhPhonDataTags.kflidNaturalClasses; int[] targetHvos = cache.GetVectorProperty(hvoPhonData, flidNatClasses, false); if (targetHvos.Length > 0) candidates = new List<int>(targetHvos); else candidates = new List<int>(0); ObjectLabelCollection labels = new ObjectLabelCollection(cache, candidates, "", cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(cache.DefaultAnalWs)); using (ReallySimpleListChooser chooser = new ReallySimpleListChooser(persistenceProvider, labels, "NaturalClass")) { string sTitle = null; string sDescription = null; string sJumpLabel = null; if (mediator != null && mediator.HasStringTable) { sTitle = mediator.StringTbl.GetString("kstidChooseNaturalClass", "Linguistics/Morphology/NaturalClassChooser"); sDescription = mediator.StringTbl.GetString("kstidNaturalClassListing", "Linguistics/Morphology/NaturalClassChooser"); sJumpLabel = mediator.StringTbl.GetString("kstidGotoNaturalClassList", "Linguistics/Morphology/NaturalClassChooser"); } if (sTitle == null || sTitle.Length == 0 || sTitle == "kstidChooseNaturalClass") sTitle = XMLViewsStrings.ksChooseNaturalClass; if (sDescription == null || sDescription.Length == 0 || sDescription == "kstidNaturalClassListing") sDescription = XMLViewsStrings.ksNaturalClassDesc; if (sJumpLabel == null || sJumpLabel.Length == 0 || sJumpLabel == "kstidGotoNaturalClassList") sJumpLabel = XMLViewsStrings.ksEditNaturalClasses; chooser.Cache = cache; chooser.SetObjectAndFlid(0, 0); chooser.InitializeRaw(mediator, sTitle, sDescription, sJumpLabel, "naturalClassedit", "analysis vernacular"); System.Windows.Forms.DialogResult res = chooser.ShowDialog(); if (System.Windows.Forms.DialogResult.Cancel == res) return true; if (chooser.HandleAnyJump()) return true; if (chooser.ChosenOne != null) { int hvo = chooser.ChosenOne.Hvo; IPhNaturalClass pnc = PhNaturalClass.CreateFromDBObject(cache, hvo); ITsString tss = pnc.Abbreviation.BestAnalysisVernacularAlternative; string sName = tss.Text; string sIns = String.Format("[{0}]", sName); int wsPending = cache.DefaultVernWs; IVwRootSite site = rootb.Site; IVwGraphics vg = null; if (site != null) vg = site.get_ScreenGraphics(rootb); rootb.OnTyping(vg, sIns, 0, 0, '[', ref wsPending); } } return true; }