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; } } }
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)); } } } }
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); } } }
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; }