Exemplo n.º 1
0
        /// <summary>
        /// Handles the xWorks message to insert a new FsFeatDefn.
        /// Invoked by the RecordClerk via a main menu.
        /// </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 override 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 != "FsClosedFeature"))
            {
                return(false);
            }
            if (className == "FsClosedFeature" && (argument as XCore.Command).Id != "CmdInsertPhonologicalClosedFeature")
            {
                return(false);
            }

            using (MasterPhonologicalFeatureListDlg dlg = new MasterPhonologicalFeatureListDlg(className))
            {
                LcmCache cache = m_propertyTable.GetValue <LcmCache>("cache");
                Debug.Assert(cache != null);
                string sXmlFile = Path.Combine(FwDirectoryFinder.CodeDirectory, String.Format("Language Explorer{0}MGA{0}GlossLists{0}PhonFeatsEticGlossList.xml", Path.DirectorySeparatorChar));
                if (cache.LanguageProject.PhFeatureSystemOA == null)
                {
                    // Mainly for Memory-only backend, makes system more self-repairing.
                    NonUndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(cache.ActionHandlerAccessor,
                                                                       () =>
                    {
                        cache.LanguageProject.PhFeatureSystemOA =
                            cache.ServiceLocator.GetInstance <IFsFeatureSystemFactory>().Create();
                    });
                }
                dlg.SetDlginfo(cache.LangProject.PhFeatureSystemOA, m_mediator, m_propertyTable, true, "masterPhonFeatListDlg", sXmlFile);
                switch (dlg.ShowDialog(m_propertyTable.GetValue <Form>("window")))
                {
                case DialogResult.OK:                         // Fall through.
                case DialogResult.Yes:
                    //m_mediator.SendMessage("JumpToRecord", dlg.SelectedFeatDefn.Hvo);
                    // This is the equivalent functionality, but is deferred processing.
                    // This is done so that the JumpToRecord can be processed last.
                    if (dlg.SelectedFeatDefn != null)
                    {
                        m_mediator.BroadcastMessageUntilHandled("JumpToRecord", dlg.SelectedFeatDefn.Hvo);
                    }
                    // LT-6412: this call will now cause the Mediator to be disposed while it is busy processing
                    // this call, so there is code in the Mediator to handle in the middle of a msg the case
                    // where the object is nolonger valid.  This has happend before and was being handled, this
                    // call "SendMessageToAllNow" has not had the code to handle the exception, so it was added.
                    m_mediator.SendMessageToAllNow("MasterRefresh", cache.LangProject.PhFeatureSystemOA);
                    break;
                }
            }
            return(true);            // We "handled" the message, regardless of what happened.
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the xWorks message to insert a new FsFeatDefn.
        /// Invoked by the RecordClerk via a main menu.
        /// </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 override 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 != "FsClosedFeature"))
            {
                return(false);
            }
            if (className == "FsClosedFeature" && (argument as XCore.Command).Id != "CmdInsertPhonologicalClosedFeature")
            {
                return(false);
            }

            using (MasterPhonologicalFeatureListDlg dlg = new MasterPhonologicalFeatureListDlg(className))
            {
                FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
                Debug.Assert(cache != null);
                string sXmlFile = Path.Combine(DirectoryFinder.FWCodeDirectory, @"Language Explorer\MGA\GlossLists\PhonFeatsEticGlossList.xml");
                dlg.SetDlginfo(cache.LangProject.PhFeatureSystemOA, m_mediator, true, "masterPhonFeatListDlg", sXmlFile);
                switch (dlg.ShowDialog((Form)m_mediator.PropertyTable.GetValue("window")))
                {
                case DialogResult.OK:                         // Fall through.
                case DialogResult.Yes:
                    //m_mediator.SendMessage("JumpToRecord", dlg.SelectedFeatDefn.Hvo);
                    // This is the equivalent functionality, but is deferred processing.
                    // This is done so that the JumpToRecord can be processed last.
                    m_mediator.BroadcastMessageUntilHandled("JumpToRecord", dlg.SelectedFeatDefn.Hvo);
                    // LT-6412: this call will now cause the Mediator to be disposed while it is busy processing
                    // this call, so there is code in the Mediator to handle in the middle of a msg the case
                    // where the object is nolonger valid.  This has happend before and was being handled, this
                    // call "SendMessageToAllNow" has not had the code to handle the exception, so it was added.
                    m_mediator.SendMessageToAllNow("MasterRefresh", cache.LangProject.PhFeatureSystemOA);
                    break;
                }
            }
            return(true);            // We "handled" the message, regardless of what happened.
        }