Exemplo n.º 1
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");
        }
Exemplo n.º 2
0
 internal void Init(InterlinMaster interlinMaster, LcmCache cache, PropertyTable propertyTable)
 {
     Debug.Assert(interlinMaster != null);
     Debug.Assert(cache != null);
     Debug.Assert(propertyTable != null);
     m_propertyTable = propertyTable;
 }
Exemplo n.º 3
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); });
                }
            }
        }
Exemplo n.º 4
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));
                }
            }
        }
Exemplo n.º 5
0
 internal InterAreaBookmark(InterlinMaster interlinMaster, Mediator mediator, FdoCache cache)            // For restoring
 {
     // Note: resist any temptation to save mediator in a memer variable. Bookmarks are kept in a static dictionary
     // and may well have a longer life than the mediator. There is danger of using if after it is disposed. See LT-12435.
     Init(interlinMaster, cache);
     Restore(interlinMaster.IndexOfTextRecord, mediator);
 }
Exemplo n.º 6
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;
 }
        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.");
            }
        }
Exemplo n.º 8
0
		internal InterAreaBookmark(InterlinMaster interlinMaster, Mediator mediator, FdoCache cache)	// For restoring
		{
			// Note: resist any temptation to save mediator in a memer variable. Bookmarks are kept in a static dictionary
			// and may well have a longer life than the mediator. There is danger of using if after it is disposed. See LT-12435.
			Init(interlinMaster, cache);
			Restore(interlinMaster.IndexOfTextRecord, mediator);
		}
Exemplo n.º 9
0
        public virtual void SetRoot(int hvo)
        {
            CheckDisposed();


            if (hvo != m_hvoRoot)
            {
                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)
            {
                bool fDidParse;
                InterlinMaster.ParseText(Cache, m_hvoRoot, Mediator, out fDidParse);
            }
        }
            /// <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);
            }
Exemplo n.º 11
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());
            }
Exemplo n.º 12
0
 internal void Init(InterlinMaster interlinMaster, FdoCache cache)
 {
     Debug.Assert(interlinMaster != null);
     Debug.Assert(cache != null);
     m_cache = cache;
 }
Exemplo n.º 13
0
		internal void Init(InterlinMaster interlinMaster, FdoCache cache)
		{
			Debug.Assert(interlinMaster != null);
			Debug.Assert(cache != null);
			m_cache = cache;
		}
Exemplo n.º 14
0
		internal void Init(InterlinMaster interlinMaster, Mediator mediator, FdoCache cache)
		{
			Debug.Assert(interlinMaster != null);
			Debug.Assert(mediator != null);
			Debug.Assert(cache != null);
			m_interlinMaster = interlinMaster;
			m_mediator = mediator;
			m_cache = cache;
			m_fInTextsArea = m_interlinMaster.InTextsArea;
			if (!m_fInTextsArea)
			{
				// We may be switching areas to the Texts from somewhere else, which isn't yet
				// reflected in the value of "areaChoice", but is reflected in the value of
				// "currentContentControlParameters" if we dig a little bit.
				System.Xml.XmlElement x =
					m_mediator.PropertyTable.GetValue("currentContentControlParameters", null)
					as System.Xml.XmlElement;
				if (x != null)
				{
					System.Xml.XmlNodeList xnl = x.GetElementsByTagName("parameters");
					foreach (System.Xml.XmlNode xn in xnl)
					{
						System.Xml.XmlElement xe = xn as System.Xml.XmlElement;
						if (xe != null)
						{
							string sVal = xe.GetAttribute("area");
							if (sVal != null && sVal == "textsWords")
							{
								m_fInTextsArea = true;
								break;
							}
						}
					}
				}
			}
		}
Exemplo n.º 15
0
		internal InterAreaBookmark(InterlinMaster interlinMaster, Mediator mediator, FdoCache cache)	// For restoring
		{
			Init(interlinMaster, mediator, cache);
			this.Restore();
		}
Exemplo n.º 16
0
			internal void SwitchTab(InterlinMaster.TabPageSelection tabSelection)
			{
				InterlinMaster interlinMaster = CurrentInterlinMasterControl;
				TabControl interlinTabs = interlinMaster.Controls.Find("m_tabCtrl", false)[0] as TabControl;
				interlinTabs.SelectedIndex = (int)tabSelection;
			}