//methods public override ObjectLabel Execute() { // Make create lex entry dialog and invoke it. ObjectLabel result = null; using (InsertEntryDlg dlg = new InsertEntryDlg()) { var morphType = GetMorphType(); dlg.SetDlgInfo(m_cache, morphType, MsaType.kInfl, m_slot, m_mediator, m_fPrefix ? InsertEntryDlg.MorphTypeFilterType.Prefix : InsertEntryDlg.MorphTypeFilterType.Suffix); dlg.DisableAffixTypeMainPosAndSlot(); if (dlg.ShowDialog() == DialogResult.OK) { bool fCreated; ILexEntry entry; dlg.GetDialogInfo(out entry, out fCreated); if (entry == null) throw new ArgumentNullException("Expected entry cannot be null", "entry"); // TODO: what do to make sure it has an infl affix msa? // this just assumes it will bool fInflAffix = false; foreach (var msa in entry.MorphoSyntaxAnalysesOC) { if (msa is IMoInflAffMsa) { fInflAffix = true; break; } } if (!fInflAffix) { UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(DetailControlsStrings.ksUndoCreatingInflectionalAffixCategoryItem, DetailControlsStrings.ksRedoCreatingInflectionalAffixCategoryItem, m_cache.ActionHandlerAccessor, () => { var newby = m_cache.ServiceLocator.GetInstance<IMoInflAffMsaFactory>().Create(); entry.MorphoSyntaxAnalysesOC.Add(newby); }); } if (entry.MorphoSyntaxAnalysesOC.Count > 0) result = ObjectLabel.CreateObjectLabel(m_cache, entry.MorphoSyntaxAnalysesOC.First(), ""); } } return result; }
//methods public override ObjectLabel Execute() { // Make create lex entry dialog and invoke it. ObjectLabel result = null; using (InsertEntryDlg dlg = new InsertEntryDlg()) { IMoMorphType morphType = GetMorphType(); dlg.SetDlgInfo(m_cache, morphType, MsaType.kInfl, m_slot, m_mediator, m_fPrefix ? InsertEntryDlg.MorphTypeFilterType.prefix : InsertEntryDlg.MorphTypeFilterType.suffix); dlg.DisableAffixTypeMainPosAndSlot(); if (dlg.ShowDialog() == DialogResult.OK) { bool fCreated; int entryID; dlg.GetDialogInfo(out entryID, out fCreated); if (entryID <= 0) throw new ArgumentException("Expected entry ID to be greater than 0", "entryID"); ILexEntry lex = LexEntry.CreateFromDBObject(m_cache, entryID); // TODO: what do to make sure it has an infl affix msa? // this just assumes it will bool fInflAffix = false; foreach (IMoMorphSynAnalysis msa in lex.MorphoSyntaxAnalysesOC) { if (msa is IMoInflAffMsa) { fInflAffix = true; break; } } if (!fInflAffix) { int hvoNew = m_cache.CreateObject((int)MoInflAffMsa.kClassId, lex.Hvo, (int)LexEntry.LexEntryTags.kflidMorphoSyntaxAnalyses, 0); } int[] hvos = lex.MorphoSyntaxAnalysesOC.HvoArray; if (hvos.Length > 0) result = ObjectLabel.CreateObjectLabel(m_cache, hvos[0], ""); } } return result; }