예제 #1
0
 protected override void m_btnInsert_Click(object sender, EventArgs e)
 {
     using (var dlg = new InsertEntryDlg())
     {
         string    form           = m_tbForm.Text.Trim();
         ITsString tssFormTrimmed = TsStringUtils.MakeTss(form, TsStringUtils.GetWsAtOffset(m_tbForm.Tss, 0));
         dlg.SetDlgInfo(m_cache, tssFormTrimmed, m_mediator);
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             ILexEntry entry;
             dlg.GetDialogInfo(out entry, out m_fNewlyCreated);
             m_selObject = entry;
             if (m_fNewlyCreated)
             {
                 m_newSense = entry.SensesOS[0];
             }
             // If we ever decide not to simulate the btnOK click at this point, then
             // the new sense id will need to be handled by a subclass differently (ie,
             // being added to the list of senses maintained by LinkEntryOrSenseDlg,
             // the selected index into that list also being changed).
             HandleMatchingSelectionChanged();
             if (m_btnOK.Enabled)
             {
                 m_btnOK.PerformClick();
             }
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Handles the xWorks message to insert a new lexical entry.
        /// Invoked by the RecordClerk
        /// </summary>
        /// <param name="argument">The xCore Command object.</param>
        /// <returns>true, if we handled the message, otherwise false, if there was an unsupported 'classname' parameter</returns>
        public bool OnDialogInsertItemInVector(object argument)
        {
            CheckDisposed();

            Debug.Assert(argument != null && argument is XCore.Command);
            string className = XmlUtils.GetOptionalAttributeValue(
                (argument as XCore.Command).Parameters[0],
                "className");

            if (className == null || className != "LexEntry")
            {
                return(false);
            }

            using (InsertEntryDlg dlg = new InsertEntryDlg())
            {
                FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
                Debug.Assert(cache != null);
                dlg.SetDlgInfo(cache, m_mediator, m_persistProvider);
                if (dlg.ShowDialog(Form.ActiveForm) == DialogResult.OK)
                {
                    ILexEntry entry;
                    bool      newby;
                    dlg.GetDialogInfo(out entry, out newby);
                    // No need for a PropChanged here because InsertEntryDlg takes care of that. (LT-3608)
                    m_mediator.SendMessage("JumpToRecord", entry.Hvo);
                }
            }
            return(true);            // We "handled" the message, regardless of what happened.
        }
예제 #3
0
        //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);
        }
예제 #4
0
        //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);
        }
예제 #5
0
        public bool OnAddToLexicon(object argument)
        {
            CheckDisposed();

            int       ichMin;
            int       ichLim;
            int       hvo;
            int       tag;
            int       ws;
            ITsString tss;

            GetWordLimitsOfSelection(out ichMin, out ichLim, out hvo, out tag, out ws, out tss);
            if (ws == 0)
            {
                ws = GetWsFromString(tss, ichMin, ichLim);
            }
            if (ichLim > ichMin && ws == m_cache.DefaultVernWs)
            {
                ITsStrBldr tsb = tss.GetBldr();
                if (ichLim < tsb.Length)
                {
                    tsb.Replace(ichLim, tsb.Length, null, null);
                }
                if (ichMin > 0)
                {
                    tsb.Replace(0, ichMin, null, null);
                }
                ITsString tssForm = tsb.GetString();
                using (var dlg = new InsertEntryDlg())
                {
                    dlg.SetDlgInfo(m_cache, tssForm, m_mediator);
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        // is there anything special we want to do?
                    }
                }
                return(true);
            }
            return(false);
        }