Exemple #1
0
        public virtual void SetRoot(int hvo)
        {
            CheckDisposed();


            if (hvo != m_hvoRoot || m_vc == null)
            {
                SetStyleSheet(hvo);
                m_hvoRoot = hvo;
                SetupVc();
                ChangeOrMakeRoot(m_hvoRoot, m_vc, (int)StTextFrags.kfrText, m_styleSheet);
            }
            this.BringToFront();
            if (m_hvoRoot == 0)
            {
                return;
            }
            // if editable, parse the text to make sure annotations are in a valid initial state
            // with respect to the text so AnnotatedTextEditingHelper can make the right changes
            // to annotations effected by MonitorTextsEdits being true;
            if (m_vc != null && m_vc.Editable)
            {
                if (InterlinMaster.HasParagraphNeedingParse(RootObject))
                {
                    NonUndoableUnitOfWorkHelper.Do(Cache.ActionHandlerAccessor,
                                                   () =>
                                                   { InterlinMaster.LoadParagraphAnnotationsAndGenerateEntryGuessesIfNeeded(RootObject, false); });
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// non-undoable task
        /// </summary>
        private void DoSetupFixture()
        {
            var textFactory   = Cache.ServiceLocator.GetInstance <ITextFactory>();
            var stTextFactory = Cache.ServiceLocator.GetInstance <IStTextFactory>();

            m_text1 = textFactory.Create();
            //Cache.LangProject.TextsOC.Add(m_text1);
            var stText1 = stTextFactory.Create();

            m_text1.ContentsOA = stText1;
            var para1 = stText1.AddNewTextPara(null);

            (m_text1.ContentsOA[0]).Contents =
                TsStringUtils.MakeString("xxxa xxxb xxxc xxxd xxxe, xxxa xxxb.", Cache.DefaultVernWs);
            InterlinMaster.LoadParagraphAnnotationsAndGenerateEntryGuessesIfNeeded(stText1, false);

            // setup language project parts of speech
            var partOfSpeechFactory = Cache.ServiceLocator.GetInstance <IPartOfSpeechFactory>();
            var adjunct             = partOfSpeechFactory.Create();
            var noun           = partOfSpeechFactory.Create();
            var verb           = partOfSpeechFactory.Create();
            var transitiveVerb = partOfSpeechFactory.Create();

            Cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Add(adjunct);
            Cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Add(noun);
            Cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Add(verb);
            verb.SubPossibilitiesOS.Add(transitiveVerb);
            adjunct.Name.set_String(Cache.DefaultAnalWs, "adjunct");
            noun.Name.set_String(Cache.DefaultAnalWs, "noun");
            verb.Name.set_String(Cache.DefaultAnalWs, "verb");
            transitiveVerb.Name.set_String(Cache.DefaultAnalWs, "transitive verb");
        }
Exemple #3
0
        /// <summary>
        /// non-undoable task
        /// </summary>
        private void DoSetupFixture()
        {
            // setup default vernacular ws.
            CoreWritingSystemDefinition wsXkal = Cache.ServiceLocator.WritingSystemManager.Set("qaa-x-kal");

            wsXkal.DefaultFont = new FontDefinition("Times New Roman");
            Cache.ServiceLocator.WritingSystems.VernacularWritingSystems.Add(wsXkal);
            Cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Insert(0, wsXkal);
            var textFactory   = Cache.ServiceLocator.GetInstance <ITextFactory>();
            var stTextFactory = Cache.ServiceLocator.GetInstance <IStTextFactory>();

            m_text0 = textFactory.Create();
            //Cache.LangProject.TextsOC.Add(m_text0);
            m_stText0          = stTextFactory.Create();
            m_text0.ContentsOA = m_stText0;
            m_para0_0          = m_stText0.AddNewTextPara(null);
            m_para0_0.Contents = TsStringUtils.MakeString("Xxxhope xxxthis xxxwill xxxdo. xxxI xxxhope.", wsXkal.Handle);

            InterlinMaster.LoadParagraphAnnotationsAndGenerateEntryGuessesIfNeeded(m_stText0, false);
            // paragraph 0_0 simply has wordforms as analyses
            foreach (var occurence in SegmentServices.GetAnalysisOccurrences(m_para0_0))
            {
                if (occurence.HasWordform)
                {
                    m_analysis_para0_0.Add(new AnalysisTree(occurence.Analysis));
                }
            }
        }
        public void SandBoxWithGlossConfig_LoadsGuessForGlossFromAnalysis()
        {
            var mockRb = MockRepository.GenerateMock <IVwRootBox>();

            mockRb.Expect(rb => rb.DataAccess).Return(Cache.MainCacheAccessor);
            var textFactory   = Cache.ServiceLocator.GetInstance <ITextFactory>();
            var stTextFactory = Cache.ServiceLocator.GetInstance <IStTextFactory>();

            text = textFactory.Create();
            var stText1 = stTextFactory.Create();

            text.ContentsOA = stText1;
            var para1 = stText1.AddNewTextPara(null);

            (text.ContentsOA[0]).Contents = TsStringUtils.MakeTss("xxxa xxxa xxxa.", Cache.DefaultVernWs);
            InterlinMaster.LoadParagraphAnnotationsAndGenerateEntryGuessesIfNeeded(stText1, true);
            using (var mockInterlinDocForAnalyis = new MockInterlinDocForAnalyis(stText1)
            {
                MockedRootBox = mockRb
            })
            {
                m_sandbox.SetInterlinDocForTest(mockInterlinDocForAnalyis);

                var cba0_0 = AddWordsToLexiconTests.GetNewAnalysisOccurence(text, 0, 0, 0);
                var wf     = Cache.ServiceLocator.GetInstance <IWfiWordformFactory>().Create(TsStringUtils.MakeTss("xxxa", Cache.DefaultVernWs));
                cba0_0.Analysis = Cache.ServiceLocator.GetInstance <IWfiAnalysisFactory>().Create(wf, Cache.ServiceLocator.GetInstance <IWfiGlossFactory>());
                var gloss    = cba0_0.Analysis.Analysis.MeaningsOC.First();
                var glossTss = TsStringUtils.MakeTss("I did it", Cache.DefaultAnalWs);
                gloss.Form.set_String(Cache.DefaultAnalWs, glossTss);
                m_sandbox.SwitchWord(cba0_0);
                // Verify that the wordgloss was loaded into the m_sandbox
                Assert.AreNotEqual(0, m_sandbox.WordGlossHvo, "The gloss was not set to Default gloss from the analysis.");
                Assert.AreEqual(m_sandbox.WordGlossHvo, gloss.Hvo, "The gloss was not set to Default gloss from the analysis.");
            }
        }
Exemple #5
0
 protected virtual void SetRootInternal(int hvo)
 {
     // since we are rebuilding the display, reset our sandbox mask.
     m_hvoRoot = hvo;
     if (hvo != 0)
     {
         RootStText = Cache.ServiceLocator.GetInstance <IStTextRepository>().GetObject(hvo);
         // Here we force the text to be reparsed even if we think it is already parsed.
         // This is partly for safety, but mainly so we can guess phrases.
         // AnalysisAdjuster does not try to guess phrases, so an analysis it has adjusted
         // may miss a phrase that has come into existence because of an edit.
         // Even if we could fix that, a paragraph that was once correctly parsed and has
         // not changed since could be missing some possible phrase guesses, if those phrases
         // have been created since the previous parse.
         // Enhance JohnT: The problem is that this can be slow! Especially when using this
         // as a display view in a concordance. Should we detect that somehow, and in that
         // case only parse paragraphs that need it?
         NonUndoableUnitOfWorkHelper.Do(Cache.ActionHandlerAccessor, () =>
                                        InterlinMaster.LoadParagraphAnnotationsAndGenerateEntryGuessesIfNeeded(RootStText, true));
         // Sync Guesses data before we redraw anything.
         UpdateGuessData();
     }
     // FWR-191: we don't need to reconstruct the display if we didn't need to reload annotations
     // but until we detect that condition, we need to redisplay just in case, to keep things in sync.
     // especially if someone edited the baseline.
     ChangeOrMakeRoot(m_hvoRoot, m_vc, InterlinVc.kfragStText, m_styleSheet);
     m_vc.RootSite = this;
 }
            /// <summary>
            /// updates NewStText
            /// </summary>
            protected void CreateNewTextWithEmptyParagraph(int wsText)
            {
                var newText =
                    Cache.ServiceLocator.GetInstance <ITextFactory>().Create();

                NewStText =
                    Cache.ServiceLocator.GetInstance <IStTextFactory>().Create();
                newText.ContentsOA = NewStText;
                Clerk.CreateFirstParagraph(NewStText, wsText);
                InterlinMaster.LoadParagraphAnnotationsAndGenerateEntryGuessesIfNeeded(NewStText, false);
            }
Exemple #7
0
            /// <summary>
            /// updates NewStText
            /// </summary>
            protected void CreateNewTextWithEmptyParagraph(int wsText)
            {
                var newText =
                    Cache.ServiceLocator.GetInstance <ITextFactory>().Create();

                NewStText =
                    Cache.ServiceLocator.GetInstance <IStTextFactory>().Create();
                newText.ContentsOA = NewStText;
                Clerk.CreateFirstParagraph(NewStText, wsText);
                InterlinMaster.LoadParagraphAnnotationsAndGenerateEntryGuessesIfNeeded(NewStText, false);
                if (Cache.LangProject.DiscourseDataOA == null)
                {
                    Cache.LangProject.DiscourseDataOA = Cache.ServiceLocator.GetInstance <IDsDiscourseDataFactory>().Create();
                }
                Cache.ServiceLocator.GetInstance <IDsConstChartFactory>().Create(Cache.LangProject.DiscourseDataOA, newText.ContentsOA,
                                                                                 Cache.LangProject.GetDefaultChartTemplate());
            }