Esempio n. 1
0
        public void InsertORCAt_Simple()
        {
            CheckDisposed();

            ILangProject lp = Cache.LangProject;

            lp.Description.AnalysisDefaultWritingSystem.Text = "This is my language project";
            ITsString tss                 = lp.Description.AnalysisDefaultWritingSystem.UnderlyingTsString;
            int       ichInsert           = 4;
            int       cchOrigStringLength = tss.Length;

            ((CmPicture)m_pict).InsertORCAt(tss, ichInsert, lp.Hvo,
                                            (int)CmProject.CmProjectTags.kflidDescription,
                                            lp.DefaultAnalysisWritingSystem);

            Guid guidPicture = Cache.GetGuidFromId(m_pict.Hvo);

            tss = lp.Description.AnalysisDefaultWritingSystem.UnderlyingTsString;
            Assert.AreEqual(cchOrigStringLength + 1, tss.Length);
            Assert.AreEqual(3, tss.RunCount, "ORC should split original run into 3 runs");
            Assert.AreEqual(0, tss.get_RunAt(ichInsert - 1), "First run should end before where we inserted the ORC");
            Assert.AreEqual(1, tss.get_RunAt(ichInsert), "Second run should be where we inserted the ORC");
            Assert.AreEqual(2, tss.get_RunAt(ichInsert + 1), "Third run should start after where we inserted the ORC");
            string strGuid = tss.get_Properties(1).GetStrPropValue((int)FwTextPropType.ktptObjData);
            Guid   guid    = MiscUtils.GetGuidFromObjData(strGuid.Substring(1));

            Assert.AreEqual(guidPicture, guid, "Wrong guid was inserted");
        }
Esempio n. 2
0
		public void Teardown()
		{
			CheckDisposed();
			m_mock.Dispose();
			m_mock = null;
			m_lp = null;
		}
Esempio n. 3
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                // Dispose managed resources here.
                if (m_stylesComboBox != null)
                {
                    m_stylesComboBox.Dispose();
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_stylesComboBox  = null;
            m_styleListHelper = null;
            m_styleSheet      = null;
            m_lp = null;

            base.Dispose(disposing);
        }
        /// <summary>
        /// Add the agent types with their guids to the proper list.
        /// </summary>
        /// <param name="lp"></param>
        private static void SetupAgents(ILangProject lp)
        {
            var servLoc      = lp.Cache.ServiceLocator;
            var dataReader   = (IDataReader)servLoc.GetInstance <IDataSetup>();
            var agentFactory = servLoc.GetInstance <ICmAgentFactory>() as ICmAgentFactoryInternal;

            Debug.Assert(agentFactory != null, "ServiceLocator has no instance of ICmAgentFactory.");
            var agent = agentFactory.Create(
                CmAgentTags.kguidAgentDefUser,
                dataReader.GetNextRealHvo(),
                true,
                null);

            lp.AnalyzingAgentsOC.Add(agent);

            agent = agentFactory.Create(
                CmAgentTags.kguidAgentXAmpleParser,
                dataReader.GetNextRealHvo(),
                false,
                "Normal");
            lp.AnalyzingAgentsOC.Add(agent);

            agent = agentFactory.Create(
                CmAgentTags.kguidAgentComputer,
                dataReader.GetNextRealHvo(),
                false,
                null);
            lp.AnalyzingAgentsOC.Add(agent);
        }
		/// <summary>
		/// Export the grammar and lexicon.
		/// </summary>
		public static XDocument ExportGrammarAndLexicon(ILangProject languageProject)
		{
			if (languageProject == null) throw new ArgumentNullException("languageProject");

			var servLoc = languageProject.Cache.ServiceLocator;
			const Icu.UNormalizationMode mode = Icu.UNormalizationMode.UNORM_NFD;
			var morphologicalData = languageProject.MorphologicalDataOA;
			var doc = new XDocument(
				new XDeclaration("1.0", "utf-8", "yes"),
				new XElement("M3Dump",
					ExportPartsOfSpeech(languageProject, mode),
					ExportPhonologicalData(languageProject.PhonologicalDataOA, mode),
					ExportParserParameters(morphologicalData, mode),
					ExportCompoundRules(servLoc.GetInstance<IMoEndoCompoundRepository>(),
						servLoc.GetInstance<IMoExoCompoundRepository>(), mode),
					ExportAdhocCoProhibitions(morphologicalData, mode),
					ExportProdRestrict(morphologicalData, mode),
					ExportMorphTypes(servLoc.GetInstance<IMoMorphTypeRepository>(), mode),
					ExportLexEntryInflTypes(servLoc.GetInstance<ILexEntryInflTypeRepository>(), mode),
					ExportLexiconFull(servLoc, mode),
					ExportFeatureSystem(languageProject.MsFeatureSystemOA, "FeatureSystem", mode),
					ExportFeatureSystem(languageProject.PhFeatureSystemOA, "PhFeatureSystem", mode)
				)
			);
			return doc;
		}
Esempio n. 6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// TODO: for now, this just creates the key terms list if the list isn't in the DB...
        /// If the current key terms version in the DD doesn't match that of the current XML
        /// file, update the DB.
        /// </summary>
        /// <param name="lp">language project</param>
        /// <param name="app">The TE application.</param>
        /// <param name="existingProgressDlg">The existing progress dialog, if any.</param>
        /// ------------------------------------------------------------------------------------
        public static void EnsureCurrentKeyTerms(ILangProject lp, FwApp app,
                                                 IThreadedProgress existingProgressDlg)
        {
            TeKeyTermsInit keyTermsInit = new TeKeyTermsInit(lp.TranslatedScriptureOA, app);

            keyTermsInit.EnsureCurrentResource(existingProgressDlg);
        }
Esempio n. 7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create and Check an Annotation
        /// </summary>
        /// <param name="hvoParaStart">The hvo para start.</param>
        /// <param name="hvoParaEnd">The hvo para end.</param>
        /// <param name="startRef">The start ref.</param>
        /// <param name="endRef">The end ref.</param>
        /// <param name="startOffset">The start offset.</param>
        /// <param name="endOffset">The end offset.</param>
        /// <param name="tssQuote">The text in the quote.</param>
        /// <param name="sel">selection in main window</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        private IScrScriptureNote CreateAndCheckAnnotation(ICmObject topObj, ICmObject bottomObj,
                                                           int startRef, int endRef, int startOffset, int endOffset, string strQuote)
        {
            ILangProject      lp = Cache.LangProject;
            ICmAnnotationDefn transNoteAnnDefn =
                Cache.ServiceLocator.GetInstance <ICmAnnotationDefnRepository>().TranslatorAnnotationDefn;

            // Get information from the selection about the location of the annotation.
            ITsStrBldr tssBldrQuote = TsStrBldrClass.Create();

            tssBldrQuote.Replace(0, 0, strQuote, StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));

            IScrScriptureNote ann =
                m_notesEditingHelper.InsertNote(transNoteAnnDefn, startRef, endRef,
                                                topObj, bottomObj, startOffset, endOffset, tssBldrQuote.GetString());

            Assert.IsNotNull(ann);
            Assert.AreEqual(transNoteAnnDefn, ann.AnnotationTypeRA, "Wrong type of note created");
            Assert.AreEqual(topObj, ann.BeginObjectRA, "Wrong paragraph annotated");
            Assert.AreEqual(bottomObj, ann.EndObjectRA, "Wrong paragraph annotated");
            Assert.AreEqual(startRef, ann.BeginRef, "Should have the correct start para reference");
            Assert.AreEqual(endRef, ann.EndRef, "Should have the correct end para reference");
            Assert.AreEqual(startOffset, ann.BeginOffset, "Should have the correct starting char offset");
            Assert.AreEqual(endOffset, ann.EndOffset, "Should have the correct ending char offset");
            Assert.AreEqual(lp.DefaultUserAgent, ann.SourceRA, "Wrong agent");
            VerifyInitializedText(ann.DiscussionOA, "Discussion");
            Assert.AreEqual(tssBldrQuote.Text, ((IStTxtPara)ann.QuoteOA.ParagraphsOS[0]).Contents.Text);
            VerifyInitializedText(ann.RecommendationOA, "Recommendation");
            VerifyInitializedText(ann.ResolutionOA, "Resolution");
            return(ann);
        }
Esempio n. 8
0
        /// -------------------------------------------------------------------------------------
        /// <summary>
        /// Perform one-time initialization of a new Scripture project
        /// </summary>
        /// <returns>true if data loaded successfully; false, otherwise</returns>
        /// -------------------------------------------------------------------------------------
        protected bool Initialize(IThreadedProgress progressDlg)
        {
            if (m_scr != null)
            {
                // Preload all book, section and paragraphs if we already have Scripture
                m_cache.ServiceLocator.DataSetup.LoadDomainAsync(BackendBulkLoadDomain.Scripture);

                ILangProject lp = m_cache.LanguageProject;
                if (m_scr.BookAnnotationsOS.Count != 0 &&
                    m_scr.PublicationsOC.Count != 0 &&
                    lp.KeyTermsList.PossibilitiesOS.Count >= 1 &&
                    m_scr.NoteCategoriesOA != null && m_scr.NoteCategoriesOA.PossibilitiesOS.Count > 0)
                {
                    return(true);
                }
            }

            try
            {
                progressDlg.RunTask(InitializeScriptureProject);
            }
            catch (WorkerThreadException e)
            {
                while (m_cache.DomainDataByFlid.GetActionHandler().CanUndo())
                {
                    UndoResult ures = m_cache.DomainDataByFlid.GetActionHandler().Undo();
                    // Enhance JohnT: make use of ures?
                }
                MessageBox.Show(Form.ActiveForm, e.InnerException.Message, FwUtils.ksTeAppName,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            return(true);
        }
Esempio n. 9
0
        public static new InterlinLineChoices DefaultChoices(int vern, int analysis, ILangProject proj)
        {
            InterlinLineChoices result = new EditableInterlinLineChoices(vern, analysis, proj);

            result.SetStandardState();
            return(result);
        }
Esempio n. 10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// If the current Scripture Note categories list version in the Db doesn't match that of
        /// the current XML file, update the DB.
        /// </summary>
        /// <param name="lp">The language project</param>
        /// <param name="existingProgressDlg">The existing progress dialog, if any.</param>
        /// ------------------------------------------------------------------------------------
        public static void EnsureCurrentScrNoteCategories(ILangProject lp,
                                                          IAdvInd4 existingProgressDlg)
        {
            XmlNode    scrNoteCategories = LoadScrNoteCategoriesDoc();
            IScripture scr        = lp.TranslatedScriptureOA;
            Guid       newVersion = Guid.Empty;

            try
            {
                XmlNode version = scrNoteCategories.Attributes.GetNamedItem("version");
                newVersion = new Guid(version.Value);
            }
            catch (Exception e)
            {
                ReportInvalidInstallation("List version attribute invalid in TeScrNoteCategories.xml", e);
            }
            if (scr.NoteCategoriesOA == null || newVersion != scr.NoteCategoriesOA.ListVersion)
            {
                using (ProgressDialogWithTask dlg = new ProgressDialogWithTask(Form.ActiveForm))
                {
                    dlg.RunTask(existingProgressDlg, true,
                                new BackgroundTaskInvoker(CreateScrNoteCategories), scrNoteCategories, scr);
                }
            }
        }
        public virtual void Initialize()
        {
            CheckDisposed();

            Debug.Assert(m_fdoCache == null, "m_fdoCache is not null.");
            //if (m_fdoCache != null)
            //	m_fdoCache.Dispose();

            m_fdoCache = GetCache();
            FwStyleSheet styleSheet = new FwStyleSheet();

            ILangProject lgproj    = m_fdoCache.LangProject;
            IScripture   scripture = lgproj.TranslatedScriptureOA;

            styleSheet.Init(m_fdoCache, scripture.Hvo,
                            (int)Scripture.ScriptureTags.kflidStyles);

            Debug.Assert(m_basicView == null, "m_basicView is not null.");
            //if (m_basicView != null)
            //	m_basicView.Dispose();
            m_basicView            = new DummyBasicView();
            m_basicView.Cache      = m_fdoCache;
            m_basicView.Visible    = false;
            m_basicView.StyleSheet = styleSheet;
        }
        /// <summary>
        ///
        /// </summary>
        public bool RetrieveModel()
        {
            lock (m_syncRoot)
            {
                if (m_loaded)
                {
                    return(false);
                }
                m_loaded = true;
            }

            // According to the fxt template files, GAFAWS is NFC, all others are NFD.
            using (new WorkerThreadReadHelper(m_cache.ServiceLocator.GetInstance <IWorkerThreadReadHandler>()))
            {
                ILangProject lp = m_cache.LanguageProject;
                using (var task = new TaskReport(ParserCoreStrings.ksRetrievingGrammarAndLexicon, m_taskUpdateHandler))
                {
                    // 1. Export lexicon and/or grammar.
                    m_modelDom = null;
                    M3ModelExportServices.ExportGrammarAndLexicon(m_modelPath, lp);
                }

                // 2. Export GAFAWS data.
                using (var task = new TaskReport(ParserCoreStrings.ksRetrievingTemplateInformation, m_taskUpdateHandler))
                {
// The following needs to be enabled, in order to avoid an exception bieng thrown after the export work,
// but it is such a handy way to get Flex to stop in my profiler. :-)
                    m_templateDom = null;
                    M3ModelExportServices.ExportGafaws(m_outputDirectory, m_cache.ProjectId.Name,
                                                       lp.PartsOfSpeechOA.PossibilitiesOS);
                }
            }
            return(true);
        }
Esempio n. 13
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Creates and opens a <see cref="DummyFootnoteView"/> in a form. Loads scripture
        /// footnotes from the DB.
        /// </summary>
        /// -----------------------------------------------------------------------------------
        public void CreateFootnoteView(FdoCache cache)
        {
            CheckDisposed();

            Cache = cache;
            FwStyleSheet styleSheet = new FwStyleSheet();

            ILangProject lgproj    = Cache.LangProject;
            IScripture   scripture = lgproj.TranslatedScriptureOA;

            styleSheet.Init(Cache, scripture.Hvo,
                            (int)Scripture.ScriptureTags.kflidStyles);

            m_footnoteView        = new DummyFootnoteView(Cache);
            m_footnoteView.Anchor = AnchorStyles.Top | AnchorStyles.Left |
                                    AnchorStyles.Right | AnchorStyles.Bottom;
            m_footnoteView.Dock = DockStyle.Fill;
            m_footnoteView.Name = "footnoteView";
            // make sure book filter is created before view constructor is created.
            int nbook = m_footnoteView.BookFilter.BookCount;

            m_footnoteView.MakeRoot();
            m_footnoteView.Visible    = true;
            m_footnoteView.StyleSheet = styleSheet;
            Controls.Add(m_footnoteView);
            m_footnoteView.ActivateView();
        }
Esempio n. 14
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                // Dispose managed resources here.
                if (m_mock != null)
                {
                    m_mock.Dispose();
                }
                string langFilesPath = Path.Combine(DirectoryFinder.FWDataDirectory, "Languages");
                // Delete any language files created by these tests.
                foreach (string filename in Directory.GetFiles(langFilesPath, "*.xml"))
                {
                    File.Delete(filename);
                }
                // Restore any backed up XML files in the Languages folder to their original names
                foreach (string filename in Directory.GetFiles(langFilesPath, "*.xml.BAK"))
                {
                    File.Move(filename, filename.Replace(".xml.BAK", ".xml"));
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_mock = null;
            m_lp   = null;

            base.Dispose(disposing);
        }
Esempio n. 15
0
 public void Teardown()
 {
     CheckDisposed();
     m_mock.Dispose();
     m_mock = null;
     m_lp   = null;
 }
Esempio n. 16
0
        public void CountPropertyTests()
        {
            IFdoServiceLocator servLoc = Cache.ServiceLocator;
            ILangProject       lp      = Cache.LanguageProject;
            ILexDb             lexDb   = lp.LexDbOA;
            ILexEntry          le      = servLoc.GetInstance <ILexEntryFactory>().Create();
            ILexSense          sense   = servLoc.GetInstance <ILexSenseFactory>().Create();

            le.SensesOS.Add(sense);

            // FdoReferenceCollection
            int originalCount = lexDb.LexicalFormIndexRC.Count;

            lexDb.LexicalFormIndexRC.Add(le);
            Assert.AreEqual(originalCount + 1, lexDb.LexicalFormIndexRC.Count);
            lexDb.LexicalFormIndexRC.Remove(le);
            Assert.AreEqual(originalCount, lexDb.LexicalFormIndexRC.Count);

            // FdoReferenceSequence
            originalCount = le.MainEntriesOrSensesRS.Count;
            le.MainEntriesOrSensesRS.Add(sense);
            Assert.AreEqual(originalCount + 1, le.MainEntriesOrSensesRS.Count);
            le.MainEntriesOrSensesRS.RemoveAt(le.MainEntriesOrSensesRS.Count - 1);
            Assert.AreEqual(originalCount, le.MainEntriesOrSensesRS.Count);
        }
Esempio n. 17
0
        /// <summary>
        /// Add the item to the language database
        /// </summary>
        /// <param name="cache">FDO cache to use</param>
        public void AddToDataBase(FdoCache cache)
        {
            ILangProject   lp = cache.LangProject;
            IMoMorphData   md = lp.MorphologicalDataOA;
            IMoGlossSystem gs = md.GlossSystemOA;

            XmlNode parent = m_xmlNode.ParentNode;

            if (parent.Name != "item")
            {             // is a top level item; find it or add it
                IMoGlossItem giFound = gs.FindEmbeddedItem(Term, Abbrev, false);
                if (giFound == null)
                {                 // not found, so add it
                    gs.GlossesOC.Add(m_glossItem);
                }
            }
            else
            {             // not at top level; get parent and add it to parent;
                // also create any missing items between this node and the top
                IMoGlossItem giParent = GetMyParentGlossItem(cache, parent);
                giParent.GlossItemsOS.Append(m_glossItem);
            }
            FillInGlossItemBasedOnXmlNode(m_glossItem, m_xmlNode, this);
            CreateFeatStructFrag();
        }
Esempio n. 18
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create and Check an Annotation
        /// </summary>
        /// <param name="hvoParaStart">The hvo para start.</param>
        /// <param name="hvoParaEnd">The hvo para end.</param>
        /// <param name="startRef">The start ref.</param>
        /// <param name="endRef">The end ref.</param>
        /// <param name="startOffset">The start offset.</param>
        /// <param name="endOffset">The end offset.</param>
        /// <param name="tssQuote">The text in the quote.</param>
        /// <param name="sel">selection in main window</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        private IScrScriptureNote CreateAndCheckAnnotation(int hvoObjStart, int hvoObjEnd,
                                                           int startRef, int endRef, int startOffset, int endOffset, string strQuote)
        {
            ILangProject     lp = Cache.LangProject;
            CmAnnotationDefn transNoteAnnDefn = new CmAnnotationDefn(Cache,
                                                                     LangProject.kguidAnnTranslatorNote);

            // Get information from the selection about the location of the annotation.
            CmObject   topObj       = (CmObject)CmObject.CreateFromDBObject(m_inMemoryCache.Cache, hvoObjStart);
            CmObject   bottomObj    = (CmObject)CmObject.CreateFromDBObject(m_inMemoryCache.Cache, hvoObjEnd);
            int        wsSelector   = -1;
            ITsStrBldr tssBldrQuote = TsStrBldrClass.Create();

            tssBldrQuote.Replace(0, 0, strQuote, StyleUtils.ParaStyleTextProps(ScrStyleNames.Remark));

            IScrScriptureNote ann =
                m_notesEditingHelper.InsertNote(transNoteAnnDefn, startRef, endRef,
                                                topObj, bottomObj, wsSelector, startOffset, endOffset, tssBldrQuote.GetString());

            Assert.IsNotNull(ann);
            Assert.AreEqual(transNoteAnnDefn.Hvo, ann.AnnotationTypeRAHvo, "Wrong type of note created");
            Assert.AreEqual(hvoObjStart, ann.BeginObjectRAHvo, "Wrong paragraph annotated");
            Assert.AreEqual(hvoObjEnd, ann.EndObjectRAHvo, "Wrong paragraph annotated");
            Assert.AreEqual(startRef, ann.BeginRef, "Should have the correct start para reference");
            Assert.AreEqual(endRef, ann.EndRef, "Should have the correct end para reference");
            Assert.AreEqual(startOffset, ann.BeginOffset, "Should have the correct starting char offset");
            Assert.AreEqual(endOffset, ann.EndOffset, "Should have the correct ending char offset");
            Assert.AreEqual(lp.DefaultUserAgent.Hvo, ann.SourceRAHvo, "Wrong agent");
            VerifyInitializedText(ann.DiscussionOA, "Discussion");
            Assert.AreEqual(tssBldrQuote.Text, ((StTxtPara)ann.QuoteOA.ParagraphsOS[0]).Contents.Text);
            VerifyInitializedText(ann.RecommendationOA, "Recommendation");
            VerifyInitializedText(ann.ResolutionOA, "Resolution");
            return(ann);
        }
Esempio n. 19
0
        public void AddTo_RefColToRefCol()
        {
            IFdoServiceLocator servLoc = Cache.ServiceLocator;
            ILangProject       lp      = Cache.LanguageProject;
            ILexDb             lexDb   = lp.LexDbOA;
            ILexAppendix       app1    = servLoc.GetInstance <ILexAppendixFactory>().Create();

            lexDb.AppendixesOC.Add(app1);
            ILexAppendix app2 = servLoc.GetInstance <ILexAppendixFactory>().Create();

            lexDb.AppendixesOC.Add(app2);
            ILexEntry le1    = servLoc.GetInstance <ILexEntryFactory>().Create();
            ILexSense sense1 = servLoc.GetInstance <ILexSenseFactory>().Create();

            le1.SensesOS.Add(sense1);
            ILexSense sense2 = servLoc.GetInstance <ILexSenseFactory>().Create();

            le1.SensesOS.Add(sense2);

            sense1.AppendixesRC.Add(app1);
            sense1.AppendixesRC.Add(app2);

            sense1.AppendixesRC.AddTo(sense2.AppendixesRC);

            Assert.AreEqual(2, sense2.AppendixesRC.Count);
            Assert.IsTrue(sense2.AppendixesRC.Contains(app1));
            Assert.IsTrue(sense2.AppendixesRC.Contains(app2));
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the current version of the key terms list used in this project.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private Guid GetLangProjKtListVersion(ILangProject lp)
        {
            ICmResource resource = (from res in lp.TranslatedScriptureOA.ResourcesOC.ToArray()
                                    where res.Name.Equals(TeResourceHelper.BiblicalTermsResourceName)
                                    select res).FirstOrDefault();

            return((resource != null) ? resource.Version : Guid.Empty);
        }
		public override void FixtureSetup()
		{
			base.FixtureSetup();

			kwsVernInPara = WritingSystemServices.kwsVernInParagraph;
			kwsAnalysis = WritingSystemServices.kwsAnal;
			m_lp = Cache.LangProject;
		}
Esempio n. 22
0
        /// -------------------------------------------------------------------------------------
        /// <summary>
        /// If the current stylesheet version in the Db doesn't match that of the current XML
        /// file, update the DB.
        /// </summary>
        /// <param name="lp">The language project</param>
        /// -------------------------------------------------------------------------------------
        public static void EnsureCurrentStylesheet(ILangProject lp)
        {
            FlexStylesXmlAccessor acc = new FlexStylesXmlAccessor(lp.LexDbOA);

            // TODO: consider passing progress dialog from SplashScreen if splash screen
            // is showing.
            acc.EnsureCurrentResource(null);
        }
Esempio n. 23
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Tests adding a word
        /// </summary>
        /// <param name="cache">the FdoCache</param>
        /// ------------------------------------------------------------------------------------
        protected void AddWord(FdoCache cache)
        {
            const string kWordForm = "FDOCompetingTransactions";
            ILangProject lp        = cache.LangProject;
            IWfiWordform word      = WfiWordform.FindOrCreateWordform(m_fdoCache, kWordForm, lp.DefaultVernacularWritingSystem);

            word.AnalysesOC.Add(new WfiAnalysis());
        }
Esempio n. 24
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// If the current stylesheet version in the Db doesn't match that of the current XML
        /// file, update the DB.
        /// </summary>
        /// <param name="lp">The language project</param>
        /// <param name="progressDlg">The progress dialog.</param>
        /// ------------------------------------------------------------------------------------
        public static void EnsureCurrentStylesheet(ILangProject lp, IThreadedProgress progressDlg)
        {
            // We don't need to establish a NonUndoableUnitOfWork here because caller has already
            // done it and if not, the internal code of StylesXmlAccessor will do it for us.
            var acc = new FlexStylesXmlAccessor(lp.LexDbOA);

            acc.EnsureCurrentResource(progressDlg);
        }
Esempio n. 25
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            kwsVernInPara = WritingSystemServices.kwsVernInParagraph;
            kwsAnalysis   = WritingSystemServices.kwsAnal;
            m_lp          = Cache.LangProject;
        }
Esempio n. 26
0
        /// <summary>
        /// Get parent MoGlossItem and fill in any missing items between the parent and the top level.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="node"></param>
        /// <returns>The MoGlossItem object which is or is to be the parent of this item.</returns>
        private IMoGlossItem GetMyParentGlossItem(FdoCache cache, XmlNode node)
        {
            ILangProject   lp = cache.LangProject;
            IMoMorphData   md = lp.MorphologicalDataOA;
            IMoGlossSystem gs = md.GlossSystemOA;

            System.Xml.XmlNode parent = node.ParentNode;
#if NUnitDebug
            Console.WriteLine("gmpgi: working on " + XmlUtils.GetAttributeValue(node, "id"));
#endif
            if (parent.Name != "item")
            {             // is a top level item; find it or add it
#if NUnitDebug
                Console.WriteLine("gmpgi: found top");
#endif
                MIoGlossItem giFound = gs.FindEmbeddedItem(XmlUtils.GetAttributeValue(node, "term"),
                                                           XmlUtils.GetAttributeValue(node, "abbrev"), false);
                if (giFound == null)
                {                 // not found; so add it
                    IMoGlossItem gi = new MoGlossItem();
                    gs.GlossesOC.Add(gi);
                    FillInGlossItemBasedOnXmlNode(gi, node, this);
#if NUnitDebug
                    Console.WriteLine("gmpgi, found top, made new, returning ", gi.Name.AnalysisDefaultWritingSystem);
#endif
                    return(gi);
                }
                else
                {                 //found, so return it
#if NUnitDebug
                    Console.WriteLine("gmpgi, found top, exists, returning ", giFound.Name.AnalysisDefaultWritingSystem);
#endif
                    return(giFound);
                }
            }
            else
            {              // not a top level item; get its parent and add it, if need be
#if NUnitDebug
                Console.WriteLine("gmpgi: calling parent of " + XmlUtils.GetAttributeValue(node, "id"));
#endif
                IMoGlossItem giParent = GetMyParentGlossItem(cache, parent);
                IMoGlossItem giFound  = giParent.FindEmbeddedItem(XmlUtils.GetAttributeValue(node, "term"),
                                                                  XmlUtils.GetAttributeValue(node, "abbrev"), false);
                if (giFound == null)
                {                 // not there, add it
#if NUnitDebug
                    Console.WriteLine("gmpgi: adding a node");
#endif
                    giFound = new MoGlossItem();
                    giParent.GlossItemsOS.Append(giFound);
                    FillInGlossItemBasedOnXmlNode(giFound, node, this);
                }
#if NUnitDebug
                Console.WriteLine("gmpgi, in middle, returning " + giFound.Name.AnalysisDefaultWritingSystem + " for node " + XmlUtils.GetAttributeValue(node, "id"));
#endif
                return(giFound);
            }
        }
Esempio n. 27
0
        //#region Public methods
        ///// ------------------------------------------------------------------------------------
        ///// <summary>
        ///// Adds the specified renderings.
        ///// </summary>
        ///// <param name="termRenderings">The collection of references that correspond to the
        ///// biblical terms that have vernacular renderings.</param>
        ///// ------------------------------------------------------------------------------------
        //public void Add(IEnumerable<IChkRef> termRenderings)
        //{
        //    foreach (IChkRef rendering in termRenderings)
        //        Renderings.Add(new XmlTermRendering(rendering));
        //}
        //#endregion

        #region Methods to write annotations to cache
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Writes the list of renderings to the specified cache.
        /// </summary>
        /// <param name="lp">The language project.</param>
        /// <param name="termsListVersionsMatch">flag indicating whether the term list versions
        /// in the project is the same as the term list version used by the XML data that was
        /// read.</param>
        /// <param name="ResolveConflict">The delegate to call to resolve a conflict when a
        /// different rendering already exists.</param>
        /// ------------------------------------------------------------------------------------
        internal void WriteToCache(ILangProject lp, bool termsListVersionsMatch,
                                   Func <IChkRef, string, string, bool> ResolveConflict)
        {
            m_term = FindTerm(lp, termsListVersionsMatch);
            foreach (XmlTermRendering rendering in Renderings)
            {
                rendering.WriteToCache(m_term, ResolveConflict);
            }
        }
Esempio n. 28
0
		private static XElement ExportLanguageProject(ILangProject languageProject, Icu.UNormalizationMode mode)
		{
			return new XElement("LangProject",
				new XElement("Name", languageProject.ShortName),
				ExportBestAnalysis(languageProject.Description, "Description", mode),
				ExportBestAnalysis(languageProject.MainCountry, "MainCountry", mode),
				ExportWritingSystems(languageProject.CurrentVernacularWritingSystems, "VernWss"),
				ExportWritingSystems(languageProject.CurrentAnalysisWritingSystems, "AnalysisWss"));
		}
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Writes the list of renderings to the specified cache.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="ResolveConflict">The delegate to call to resolve a conflict when a
        /// different rendering already exists.</param>
        /// ------------------------------------------------------------------------------------
        protected void WriteToCache(FdoCache cache, Func <IChkRef, string, string, bool> ResolveConflict)
        {
            ILangProject lp            = cache.LangProject;
            bool         matchOnTermId = (TermsListVersion == GetLangProjKtListVersion(lp));

            foreach (XmlTerm term in Terms)
            {
                term.WriteToCache(lp, matchOnTermId, ResolveConflict);
            }
        }
Esempio n. 30
0
        public override void Exit()
        {
            CheckDisposed();
            base.Exit();

            m_lp         = null;
            m_styleSheet = null;
            m_stylesComboBox.Dispose();
            m_stylesComboBox = null;
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="XmlTermRenderingsList"/> class based on
        /// the given collection of Scripture notes.
        /// </summary>
        /// <param name="lp">The langauge project.</param>
        /// ------------------------------------------------------------------------------------
        public XmlTermRenderingsList(ILangProject lp)
        {
            DefaultVernIcuLocale = lp.Services.WritingSystems.DefaultVernacularWritingSystem.IcuLocale;
            DateTimeExported     = DateTime.Now;
            ProjectName          = lp.Cache.ProjectId.Name;
            using (WindowsIdentity whoami = WindowsIdentity.GetCurrent())
                ExportedBy = whoami != null?whoami.Name.Normalize() : null;
            TermsListVersion = GetLangProjKtListVersion(lp);

            AddTerms(lp.KeyTermsList.PossibilitiesOS);
        }
Esempio n. 32
0
        /// <summary>
        ///
        /// </summary>
        public override void TestTearDown()
        {
            m_lp         = null;
            m_styleSheet = null;
            m_stylesComboBox.Dispose();
            m_stylesComboBox = null;
            m_styleListHelper.Dispose();
            m_styleListHelper = null;

            base.TestTearDown();
        }
Esempio n. 33
0
		public void SetUp()
		{
			CheckDisposed();
			if (m_mock != null)
				m_mock.Dispose();

			m_mock = InMemoryFdoCache.CreateInMemoryFdoCache();
			m_mock.InitializeWritingSystemEncodings();
			m_mock.InitializeLangProject();
			m_lp = m_mock.Cache.LangProject;
		}
Esempio n. 34
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="XmlTermRenderingsList"/> class based on
		/// the given collection of Scripture notes.
		/// </summary>
		/// <param name="lp">The langauge project.</param>
		/// ------------------------------------------------------------------------------------
		public XmlTermRenderingsList(ILangProject lp)
		{
			DefaultVernIcuLocale = lp.Services.WritingSystems.DefaultVernacularWritingSystem.IcuLocale;
			DateTimeExported = DateTime.Now;
			ProjectName = lp.Cache.ProjectId.Name;
			using (WindowsIdentity whoami = WindowsIdentity.GetCurrent())
				ExportedBy = whoami != null ? whoami.Name.Normalize() : null;
			TermsListVersion = GetLangProjKtListVersion(lp);

			AddTerms(lp.KeyTermsList.PossibilitiesOS);
		}
Esempio n. 35
0
        public void InsertIntoRefSequence_Uninitialized()
        {
            IFdoServiceLocator servLoc = Cache.ServiceLocator;
            ILangProject       lp      = Cache.LanguageProject;
            ILexEntry          le      = servLoc.GetInstance <ILexEntryFactory>().Create();

            var senseUninitialized = MockRepository.GenerateStub <ILexSense>();

            senseUninitialized.Stub(x => x.Hvo).Return((int)SpecialHVOValues.kHvoUninitializedObject);
            le.MainEntriesOrSensesRS.Insert(0, senseUninitialized);
        }
Esempio n. 36
0
		public InterlinLineChoices(int defaultVernacularWs, int defaultAnalysisWs, ILangProject proj, InterlinMode mode)
		{
			this.Mode = mode;
			InitFieldNames(mode);
			if (defaultVernacularWs == 0)
				m_wsDefVern = LangProject.kwsVernInParagraph;
			else
				m_wsDefVern = defaultVernacularWs;
			m_wsDefAnal = defaultAnalysisWs;
			m_proj = proj;
		}
Esempio n. 37
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Finds the term in the project's list of key terms corresponding to this XML term.
        /// </summary>
        /// <param name="lp">The language project.</param>
        /// <param name="matchOnTermId">if set to <c>true</c> the matching logic can on term id].</param>
        /// ------------------------------------------------------------------------------------
        private IChkTerm FindTerm(ILangProject lp, bool matchOnTermId)
        {
            IEnumerable <IChkTerm> allTerms = lp.Services.GetInstance <IChkTermRepository>().AllInstances().Where(t => t.OccurrencesOS.Any());

            if (matchOnTermId)
            {
                return(allTerms.FirstOrDefault(term => term.TermId == TermIdNum));
            }

            return(allTerms.FirstOrDefault(term => term.OccurrencesOS.First().KeyWord.Text == KeyWord.Text &&
                                           term.OccurrencesOS.Select(o => o.Ref).SequenceEqual(Renderings.Select(r => r.Reference))));
        }
		/// <summary>
		/// Create various possibility lists and add them to the language project.
		/// </summary>
		/// <param name="lp"></param>
		private static void SetupVariousPossibilityLists(ILangProject lp)
		{
			var possListFactory = lp.Cache.ServiceLocator.GetInstance<ICmPossibilityListFactory>();

			lp.AnnotationDefsOA = possListFactory.Create();
			lp.AnnotationDefsOA.ItemClsid = CmAnnotationDefnTags.kClassId;
			lp.AnthroListOA = possListFactory.Create();
			lp.AnthroListOA.ItemClsid = CmAnthroItemTags.kClassId;
			lp.PartsOfSpeechOA = possListFactory.Create();
			lp.PartsOfSpeechOA.ItemClsid = PartOfSpeechTags.kClassId;
			lp.ConfidenceLevelsOA = possListFactory.Create();
			lp.ConfidenceLevelsOA.ItemClsid = CmPossibilityTags.kClassId;
			lp.LocationsOA = possListFactory.Create();
			lp.LocationsOA.ItemClsid = CmLocationTags.kClassId;
			lp.SemanticDomainListOA = possListFactory.Create();
			lp.SemanticDomainListOA.ItemClsid = CmSemanticDomainTags.kClassId;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// If the current Scripture Note categories list version in the Db doesn't match that of
		/// the current XML file, update the DB.
		/// </summary>
		/// <param name="lp">The language project</param>
		/// <param name="existingProgressDlg">The existing progress dialog, if any.</param>
		/// ------------------------------------------------------------------------------------
		public static void EnsureCurrentScrNoteCategories(ILangProject lp,
			IThreadedProgress existingProgressDlg)
		{
			XmlNode scrNoteCategories = LoadScrNoteCategoriesDoc();
			IScripture scr = lp.TranslatedScriptureOA;
			Guid newVersion = Guid.Empty;
			try
			{
				XmlNode version = scrNoteCategories.Attributes.GetNamedItem("version");
				newVersion = new Guid(version.Value);
			}
			catch (Exception e)
			{
				ReportInvalidInstallation("List version attribute invalid in TeScrNoteCategories.xml", e);
			}
			if (scr.NoteCategoriesOA == null || newVersion != scr.NoteCategoriesOA.ListVersion)
			{
				existingProgressDlg.RunTask(CreateScrNoteCategories, scrNoteCategories, scr);
			}
		}
Esempio n. 40
0
		protected override void CreateTestData()
		{
			m_lp = Cache.LanguageProject;

			AddTestStyle("Normal", ContextValues.Internal, StructureValues.Undefined,
				FunctionValues.Prose, false, m_lp.StylesOC);
			AddTestStyle("Paragraph", ContextValues.Text, StructureValues.Body,
				FunctionValues.Prose, false, m_lp.StylesOC);
			AddTestStyle("Section Head", ContextValues.Text, StructureValues.Heading,
				FunctionValues.Prose, false, m_lp.StylesOC);
			AddTestStyle("Verse Number", ContextValues.Text, StructureValues.Body,
				FunctionValues.Verse, true, m_lp.StylesOC);
			AddTestStyle("Title Main", ContextValues.Title, StructureValues.Body,
				FunctionValues.Prose, false, m_lp.StylesOC);
			AddTestStyle("Note General Paragraph", ContextValues.Note, StructureValues.Undefined,
				FunctionValues.Prose, false, m_lp.StylesOC);
			AddTestStyle("Note Marker", ContextValues.Internal, StructureValues.Undefined,
				FunctionValues.Prose, true, m_lp.StylesOC);
			AddTestStyle(kStyleName, ContextValues.Text, StructureValues.Body,
				FunctionValues.Prose, true, 2, m_lp.StylesOC);

			// Setup the stylesheet.
			var captionStyle = AddTestStyle("Caption", ContextValues.Internal,
				StructureValues.Body, FunctionValues.Prose, false,
				m_lp.StylesOC);
			m_styleSheet = new FwStyleSheet();
			m_styleSheet.Init(Cache, m_lp.Hvo,
				LangProjectTags.kflidStyles);

			Debug.Assert(m_stylesComboBox == null, "m_stylesComboBox is not null.");
			//if (m_stylesComboBox != null)
			//	m_stylesComboBox.Dispose();
			m_stylesComboBox = new ComboBox();
			m_styleListHelper = new StyleComboListHelper(m_stylesComboBox);

			// Set the options to display all of the styles
			m_styleListHelper.MaxStyleLevel = int.MaxValue;
		}
Esempio n. 41
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes Scripture for testing.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override void FixtureSetup()
		{
			base.FixtureSetup();

			ScrReferenceTests.InitializeScrReferenceForTests();
			m_lp = Cache.LanguageProject;
			m_repoScrBook = Cache.ServiceLocator.GetInstance<IScrBookRepository>();
			m_repoScrSection = Cache.ServiceLocator.GetInstance<IScrSectionRepository>();
			m_repoStTxtPara = Cache.ServiceLocator.GetInstance<IScrTxtParaRepository>();
			IWritingSystem temp;
			Cache.ServiceLocator.WritingSystemManager.GetOrSet("en", out temp);
			m_wsEn = temp.Handle;
			Cache.ServiceLocator.WritingSystemManager.GetOrSet("de", out temp);
			m_wsDe = temp.Handle;

			NonUndoableUnitOfWorkHelper.Do(m_actionHandler, () =>
			{
				// The following has the side-effect of creating and initializing the ScrRefSystem
				m_scr = m_lp.TranslatedScriptureOA = Cache.ServiceLocator.GetInstance<IScriptureFactory>().Create();
				CreateStandardScriptureStyles();
				InitializeScrAnnotationCategories();
			});
		}
Esempio n. 42
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// If the current Scripture Note categories list version in the Db doesn't match that of
		/// the current XML file, update the DB.
		/// </summary>
		/// <param name="lp">The language project</param>
		/// <param name="existingProgressDlg">The existing progress dialog, if any.</param>
		/// ------------------------------------------------------------------------------------
		public static void EnsureCurrentScrNoteCategories(ILangProject lp,
			IAdvInd4 existingProgressDlg)
		{
			XmlNode scrNoteCategories = LoadScrNoteCategoriesDoc();
			IScripture scr = lp.TranslatedScriptureOA;
			Guid newVersion = Guid.Empty;
			try
			{
				XmlNode version = scrNoteCategories.Attributes.GetNamedItem("version");
				newVersion = new Guid(version.Value);
			}
			catch (Exception e)
			{
				ReportInvalidInstallation("List version attribute invalid in TeScrNoteCategories.xml", e);
			}
			if (scr.NoteCategoriesOA == null || newVersion != scr.NoteCategoriesOA.ListVersion)
			{
				using (ProgressDialogWithTask dlg = new ProgressDialogWithTask(Form.ActiveForm))
				{
					dlg.RunTask(existingProgressDlg, true,
						new BackgroundTaskInvoker(CreateScrNoteCategories), scrNoteCategories, scr);
				}
			}
		}
Esempio n. 43
0
		public override void Exit()
		{
			CheckDisposed();
			base.Exit();

			m_lp = null;
			m_styleSheet = null;
			m_stylesComboBox.Dispose();
			m_stylesComboBox = null;
		}
Esempio n. 44
0
		/// <summary>
		/// Create one starting from a language project.
		/// </summary>
		/// <param name="lp"></param>
		public WsListManager(ILangProject lp)
		{
			m_lp = lp;
		}
Esempio n. 45
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected virtual void Dispose(bool disposing)
		{
			Debug.WriteLineIf(!disposing, "****************** Missing Dispose() call for " + GetType().Name + ". ******************");
			// Must not be run more than once.
			if (m_isDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_lp = null;
			m_labels = null;
			m_labelBasis = null;
			m_tssColon = null;
			m_ttpLabelStyle = null;
			m_isDisposed = true;
		}
Esempio n. 46
0
		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// If the current stylesheet version in the Db doesn't match that of the current XML
		/// file, update the DB.
		/// </summary>
		/// <param name="lp">The language project</param>
		/// <param name="progressDlg">The progress dialog from the splash screen</param>
		/// -------------------------------------------------------------------------------------
		public static void EnsureCurrentStylesheet(ILangProject lp, IAdvInd4 progressDlg)
		{
			TeStylesXmlAccessor acc = new TeStylesXmlAccessor(lp.TranslatedScriptureOA);
			acc.EnsureCurrentResource(progressDlg);

			if (acc.UserModifiedStyles.Count > 0)
			{
				using (FwStylesModifiedDlg dlg = new FwStylesModifiedDlg(acc.UserModifiedStyles,
					lp.Cache.ProjectName(), FwApp.App))
				{
					dlg.ShowDialog();
				}
			}
		}
Esempio n. 47
0
		private static XElement ExportPartsOfSpeech(ILangProject languageProject, Icu.UNormalizationMode mode)
		{
			return new XElement("PartsOfSpeech",
								ExportPartsOfSpeechList(languageProject.PartsOfSpeechOA.PossibilitiesOS, mode));
		}
Esempio n. 48
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates and initializes a new instance of the FwProjProperties class. Accepts an
		/// FdoCache that encapsulates a DB connection.
		/// </summary>
		/// <param name="cache">Accessor for data cache and DB connection</param>
		/// <param name="app">The application (can be <c>null</c>)</param>
		/// <param name="helpTopicProvider">IHelpTopicProvider object used to get help
		/// information</param>
		/// <param name="stylesheet">this is used for the FwTextBox</param>
		/// ------------------------------------------------------------------------------------
		public FwProjPropertiesDlg(FdoCache cache, IApp app, IHelpTopicProvider helpTopicProvider,
			IVwStylesheet stylesheet): this()
		{
			if (cache == null)
				throw new ArgumentNullException("cache", "Null Cache passed to FwProjProperties");

			m_cache = cache;
			m_txtProjName.Enabled = m_cache.ProjectId.IsLocal;

			m_helpTopicProvider = helpTopicProvider;
			m_app = app;
			m_stylesheet = stylesheet;

			m_langProj = m_cache.LanguageProject;
			InitializeWsTab();
			InitializeGeneralTab();
			m_fLinkedFilesChanged = false;
			txtExtLnkEdit.Text = m_langProj.LinkedFilesRootDir;
			if (!cache.ProjectId.IsLocal)
			{
				int deltaX = btnLinkedFilesBrowse.Width + btnLinkedFilesBrowse.Location.X - (txtExtLnkEdit.Location.X + txtExtLnkEdit.Width);
				btnLinkedFilesBrowse.Enabled = false;
				btnLinkedFilesBrowse.Visible = false;
				txtExtLnkEdit.Width = txtExtLnkEdit.Width + deltaX;
				txtExtLnkEdit.Enabled = false;
			}

			m_defaultLinkedFilesFolder = FdoFileHelper.GetDefaultLinkedFilesDir(m_cache.ServiceLocator.DataSetup.ProjectId.ProjectFolder);
		}
Esempio n. 49
0
 public void Retrieve(string outputPath, ILangProject langProject)
 {
     M3ModelExportServices.ExportGrammarSketch(outputPath, langProject);
 }
Esempio n. 50
0
		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// If the current stylesheet version in the Db doesn't match that of the current XML
		/// file, update the DB.
		/// </summary>
		/// <param name="lp">The language project</param>
		/// -------------------------------------------------------------------------------------
		public static void EnsureCurrentStylesheet(ILangProject lp)
		{
			FlexStylesXmlAccessor acc = new FlexStylesXmlAccessor(lp.LexDbOA);
			// TODO: consider passing progress dialog from SplashScreen if splash screen
			// is showing.
			acc.EnsureCurrentResource(null);
		}
Esempio n. 51
0
		/// <summary>
		///
		/// </summary>
		public override void TestTearDown()
		{
			m_lp = null;
			m_styleSheet = null;
			m_stylesComboBox.Dispose();
			m_stylesComboBox = null;
			m_styleListHelper.Dispose();
			m_styleListHelper = null;

			base.TestTearDown();
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initialize lexical database and morph types
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private static void InitializeLexDb(ILangProject lp)
		{
			var cache = lp.Cache;
			var servLoc = cache.ServiceLocator;
			var dataReader = (IDataReader)servLoc.GetInstance<IDataSetup>();

			var lexDb = servLoc.GetInstance<ILexDbFactory>().Create();
			lp.LexDbOA = lexDb;
			var listFactory = servLoc.GetInstance<ICmPossibilityListFactory>();
			lexDb.UsageTypesOA = listFactory.Create();
			lexDb.UsageTypesOA.ItemClsid = CmPossibilityTags.kClassId;
			lexDb.DomainTypesOA = listFactory.Create();
			lexDb.DomainTypesOA.ItemClsid = CmPossibilityTags.kClassId;
			//LangProject.StatusOA = listFactory.Create();
			//LangProject.StatusOA.ItemClsid = CmPossibilityTags.kClassId;
			lexDb.SenseTypesOA = listFactory.Create();
			lexDb.SenseTypesOA.ItemClsid = CmPossibilityTags.kClassId;

			AddMorphTypes(lexDb);

			var mdcManaged = servLoc.GetInstance<IFwMetaDataCacheManaged>();
			var listFactoryInternal = listFactory as ICmPossibilityListFactoryInternal;
			lexDb.ComplexEntryTypesOA = listFactoryInternal.Create(
				new Guid("1ee09905-63dd-4c7a-a9bd-1d496743ccd6"),
				dataReader.GetNextRealHvo());
			lexDb.ComplexEntryTypesOA.ItemClsid = LexEntryTypeTags.kClassId;
			lexDb.VariantEntryTypesOA = listFactoryInternal.Create(
				new Guid("bb372467-5230-43ef-9cc7-4d40b053fb94"),
				dataReader.GetNextRealHvo());
			lexDb.VariantEntryTypesOA.ItemClsid = LexEntryTypeTags.kClassId;
			AddEntryTypes(lexDb);

			// TODO: add lexDb.Introduction, lexDb.Domain/Subentry/Sense,
			// lexDb.AllomorphConditions, lexDb.Status
		}
		/// <summary>
		/// Create the most basic parts of the LgWritingSystem objects.
		/// This can be everything except ITsStrings,
		/// which may depend on non-existing WS definitions.
		/// A second pass will add the ITsStrings.
		/// </summary>
		private static void BootstrapWritingSystems(ILangProject lp)
		{
			IWritingSystemManager wsManager = lp.Services.WritingSystemManager;
			// English WS.
			IWritingSystem ws;
			wsManager.GetOrSet("en", out ws);
			lp.AddToCurrentAnalysisWritingSystems(ws);

			// Spanish WS.
			wsManager.GetOrSet("es", out ws);
			// German WS.
			wsManager.GetOrSet("de", out ws);
			// French WS.
			wsManager.GetOrSet("fr", out ws);

			wsManager.Save();
		}
		/// <summary>
		/// Add the annotation types with their guids to the propery possibility or list.
		/// TODO: these lists have other properties that need to be set at some point. Hopefully we'll
		/// just load that from NewLangProj or some other xml file.
		/// </summary>
		/// <param name="lp"></param>
		private static void SetupAnnotationDefns(ILangProject lp)
		{
			ICmPossibilityList posList = lp.AnnotationDefsOA;

			// Text Annotations
			ICmAnnotationDefn txtAnnDef = AddAnnotationDefn(posList, CmAnnotationDefnTags.kguidAnnText);

			// Notes
			ICmAnnotationDefn noteAnnDef = AddAnnotationDefn(posList, CmAnnotationDefnTags.kguidAnnNote);
			ICmAnnotationDefn noteSubDef = AddAnnotationDefn(noteAnnDef, CmAnnotationDefnTags.kguidAnnConsultantNote);
			noteSubDef.UserCanCreate = true;
			noteSubDef.Name.UserDefaultWritingSystem = TsStringUtils.MakeTss("Consultant", lp.Cache.DefaultUserWs);
			noteSubDef = AddAnnotationDefn(noteAnnDef, CmAnnotationDefnTags.kguidAnnTranslatorNote);
			noteSubDef.UserCanCreate = true;
			noteSubDef.Name.UserDefaultWritingSystem = TsStringUtils.MakeTss("Translator", lp.Cache.DefaultUserWs);

			// Others
			AddAnnotationDefn(posList, CmAnnotationDefnTags.kguidAnnComment);
			AddAnnotationDefn(posList, CmAnnotationDefnTags.kguidAnnCheckingError);
		}
		/// <summary>
		/// Add the agent types with their guids to the proper list.
		/// </summary>
		/// <param name="lp"></param>
		private static void SetupAgents(ILangProject lp)
		{
			var servLoc = lp.Cache.ServiceLocator;
			var dataReader = (IDataReader)servLoc.GetInstance<IDataSetup>();
			var agentFactory = servLoc.GetInstance<ICmAgentFactory>() as ICmAgentFactoryInternal;
			Debug.Assert(agentFactory != null, "ServiceLocator has no instance of ICmAgentFactory.");
			var agent = agentFactory.Create(
				CmAgentTags.kguidAgentDefUser,
				dataReader.GetNextRealHvo(),
				true,
				null);
			lp.AnalyzingAgentsOC.Add(agent);

			agent = agentFactory.Create(
				CmAgentTags.kguidAgentXAmpleParser,
				dataReader.GetNextRealHvo(),
				false,
				"Normal");
			lp.AnalyzingAgentsOC.Add(agent);

			agent = agentFactory.Create(
				CmAgentTags.kguidAgentComputer,
				dataReader.GetNextRealHvo(),
				false,
				null);
			lp.AnalyzingAgentsOC.Add(agent);
		}
Esempio n. 56
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Called to make the test data for the tests
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			base.CreateTestData();

			m_lp = Cache.LangProject;

			AddTestStyle("Normal", ContextValues.Internal, StructureValues.Undefined,
				FunctionValues.Prose, false, m_lp.StylesOC);
			AddTestStyle("Paragraph", ContextValues.Text, StructureValues.Body,
				FunctionValues.Prose, false, m_lp.StylesOC);
			AddTestStyle("Section Head", ContextValues.Text, StructureValues.Heading,
				FunctionValues.Prose, false, m_lp.StylesOC);
			AddTestStyle("Verse Number", ContextValues.Text, StructureValues.Body,
				FunctionValues.Verse, true, m_lp.StylesOC);
			AddTestStyle("Title Main", ContextValues.Title, StructureValues.Body,
				FunctionValues.Prose, false, m_lp.StylesOC);
			AddTestStyle("Note General Paragraph", ContextValues.Note, StructureValues.Undefined,
				FunctionValues.Prose, false, m_lp.StylesOC);
			AddTestStyle("Note Marker", ContextValues.Internal, StructureValues.Undefined,
				FunctionValues.Prose, true, m_lp.StylesOC);
			AddTestStyle(kStyleName, ContextValues.Text, StructureValues.Body,
				FunctionValues.Prose, true, 2, m_lp.StylesOC);
		}
		/// <summary>
		/// Add the translation types with their guids to the proper list
		/// and create the KeyTerms list.
		/// </summary>
		/// <param name="lp"></param>
		private static void SetupTranslationTypesAndKeyTermsList(ILangProject lp)
		{
			var servLoc = lp.Cache.ServiceLocator;
			var dataReader = (IDataReader)servLoc.GetInstance<IDataSetup>();
			var mdcManaged = servLoc.GetInstance<IFwMetaDataCacheManaged>();
			var listFactory = servLoc.GetInstance<ICmPossibilityListFactory>() as ICmPossibilityListFactoryInternal;
			Debug.Assert(listFactory != null, "ServiceLocator has no instance of ICmPossibilityListFactory.");

			int flidTranslationTags = mdcManaged.GetFieldId("LangProject", "TranslationTags", false);

			var list = listFactory.Create(
				CmPossibilityListTags.kguidTranslationTypes,
				dataReader.GetNextRealHvo());
			lp.TranslationTagsOA = list;
			lp.TranslationTagsOA.ItemClsid = CmPossibilityTags.kClassId;

			var possFactory = servLoc.GetInstance<ICmPossibilityFactory>() as ICmPossibilityFactoryInternal;
			Debug.Assert(possFactory != null, "ServiceLocator has no instance of ICmPossibilityFactory.");

			// Back trans item.
			possFactory.Create(
				CmPossibilityTags.kguidTranBackTranslation,
				dataReader.GetNextRealHvo(),
				list,
				0);

			// Back trans item.
			possFactory.Create(
				CmPossibilityTags.kguidTranFreeTranslation,
				dataReader.GetNextRealHvo(),
				list,
				1);

			// Literal trans item.
			possFactory.Create(
				CmPossibilityTags.kguidTranLiteralTranslation,
				dataReader.GetNextRealHvo(),
				list,
				2);

			// Key terms list.
			int flidCheckLists = mdcManaged.GetFieldId("LangProject", "CheckLists", false);

			list = listFactory.Create(
				CmPossibilityListTags.kguidChkKeyTermsList,
				dataReader.GetNextRealHvo());
			list.ItemClsid = 0;		// it's not clear what this value should be -- it's 0 in Sena 3 for version 6.0 of FieldWorks
			lp.CheckListsOC.Add(list);
		}
Esempio n. 58
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
				if (m_stylesComboBox != null)
					m_stylesComboBox.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_stylesComboBox = null;
			m_styleListHelper = null;
			m_styleSheet = null;
			m_lp = null;

			base.Dispose(disposing);
		}
Esempio n. 59
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// If the current stylesheet version in the Db doesn't match that of the current XML
		/// file, update the DB.
		/// </summary>
		/// <param name="lp">The language project</param>
		/// <param name="progressDlg">The progress dialog.</param>
		/// ------------------------------------------------------------------------------------
		public static void EnsureCurrentStylesheet(ILangProject lp, IThreadedProgress progressDlg)
		{
			// We don't need to establish a NonUndoableUnitOfWork here because caller has already
			// done it and if not, the internal code of StylesXmlAccessor will do it for us.
			var acc = new FlexStylesXmlAccessor(lp.LexDbOA);
			acc.EnsureCurrentResource(progressDlg);
		}
Esempio n. 60
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// This version is implemented for easier testing.
		/// TODO: Make this a member method.
		/// </summary>
		/// <param name="lp"></param>
		/// <param name="displayLocale"></param>
		/// <param name="fileList"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public static Set<NamedWritingSystem> GetAllNamedWritingSystems(ILangProject lp,
			string displayLocale, string[] fileList)
		{
			Set<NamedWritingSystem> namedWritingSystems = (lp as LangProject).GetNamedWritingSystemsFromDb(displayLocale);
			GetNamedWritingSystemsFromLDFs(lp.Cache.LanguageWritingSystemFactoryAccessor, fileList, namedWritingSystems);
			return namedWritingSystems;
		}