コード例 #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Perform one-time initialization of a new Scripture project
		/// </summary>
		/// <param name="cache">The database cache</param>
		/// <param name="app">The TE application.</param>
		/// <param name="progressDlg">The progress dialog (can be null).</param>
		/// <returns>
		/// true if data loaded successfully; false, otherwise
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static bool Initialize(FdoCache cache, FwApp app,
			IThreadedProgress progressDlg)
		{
			TeScrInitializer scrInitializer = new TeScrInitializer(cache);
			scrInitializer.m_app = app;
			return scrInitializer.Initialize(progressDlg);
		}
コード例 #2
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Preloads all the data needed by TE and checks to make sure that the information
        /// that TE needs to run (styles, Key terms, etc.) is up to date.
        /// </summary>
        /// <param name="cache">FDO cache for accessing DB</param>
        /// <param name="fOpeningNewProject"><c>true</c> if opening a brand spankin' new
        /// project</param>
        /// <returns>true if data loaded successfully; false, otherwise</returns>
        /// -----------------------------------------------------------------------------------
        protected bool LoadData(FdoCache cache, bool fOpeningNewProject)
        {
            // Load the Scripture Books
            //LangProject lp = cache.LangProject;

            // Temporary code.... Uncomment this line if the only thing you need to do is
            // reload the styles list.
            //			TeStylesXmlAccessor.CreateFactoryScrStyles(lp.TranslatedScriptureOA, null);

            // temporary code to blow away the user views for TE
            //			foreach (UserView view in cache.UserViewSpecs.GetUserViews(TeApp.AppGuid))
            //			{
            //				cache.DeleteObject(view.Hvo);
            //			}

            // Temporary code.... Remove after PHM, JAS, and JUD are imported into TestLangProj
            //			lp.TranslatedScriptureOA.DefaultImportSettings = null;

            // Temporary code.... Remove after New Styles are created
            //			lp.TranslatedScriptureOA = null;

            if (!TeScrInitializer.Initialize(cache, m_SplashScreenWnd))
            {
                return(false);
            }

            ScriptureChangeWatcher.Create(cache);
            return(true);
        }
コード例 #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Perform one-time initialization of a new Scripture project
        /// </summary>
        /// <param name="cache">The database cache</param>
        /// <param name="app">The TE application.</param>
        /// <param name="progressDlg">The progress dialog (can be null).</param>
        /// <returns>
        /// true if data loaded successfully; false, otherwise
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public static bool Initialize(FdoCache cache, FwApp app,
                                      IThreadedProgress progressDlg)
        {
            TeScrInitializer scrInitializer = new TeScrInitializer(cache);

            scrInitializer.m_app = app;
            return(scrInitializer.Initialize(progressDlg));
        }
コード例 #4
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Creates a new instance of the main Translation Editor window
        /// </summary>
        ///
        /// <param name="cache">Instance of the FW Data Objects cache that the new main window
        /// will use for accessing the database.</param>
        /// <param name="fNewCache">Flag indicating whether one-time, application-specific
        /// initialization should be done for this cache.</param>
        /// <param name="wndCopyFrom"> Must be null for creating the original app window.
        /// Otherwise, a reference to the main window whose settings we are copying.</param>
        /// <param name="fOpeningNewProject"><c>true</c> if opening a brand spankin' new
        /// project</param>
        /// <returns>New instance of TeMainWnd if Scripture data has been successfully loaded;
        /// null, otherwise</returns>
        /// -----------------------------------------------------------------------------------
        protected override Form NewMainAppWnd(FdoCache cache, bool fNewCache, Form wndCopyFrom,
                                              bool fOpeningNewProject)
        {
            if (!LoadData(cache, fOpeningNewProject))
            {
                return(null);
            }

            if (fNewCache)
            {
                ILangProject lp = cache.LangProject;
                // Loop through the Vernacular WS and initialize them
                foreach (ILgWritingSystem ws in lp.VernWssRC)
                {
                    cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(ws.Hvo);
                }

                // Loop through the Analysis WS and initialize them
                foreach (ILgWritingSystem ws in lp.AnalysisWssRC)
                {
                    cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(ws.Hvo);
                }

                // Since getting the engine for a WS can actually cause it to get updated from
                // the local XML file, we now need to clear the info about them, so we won't be
                // using stale data from the cache.
                cache.VwCacheDaAccessor.ClearInfoAboutAll(lp.VernWssRC.HvoArray, lp.VernWssRC.Count,
                                                          VwClearInfoAction.kciaRemoveObjectAndOwnedInfo);
                cache.VwCacheDaAccessor.ClearInfoAboutAll(lp.AnalysisWssRC.HvoArray, lp.AnalysisWssRC.Count,
                                                          VwClearInfoAction.kciaRemoveObjectAndOwnedInfo);

                // Make sure this DB uses the current stylesheet version, note categories & and key terms list
                if (!fOpeningNewProject)
                {
                    IAdvInd4 progressDlg = m_SplashScreenWnd != null ? m_SplashScreenWnd.ProgressBar as IAdvInd4 : null;
                    TeScrInitializer.EnsureProjectComponentsValid(cache, progressDlg);
                }
                // Do any other needed initialization here.
            }

            // TE-1913: Prevent user from accessing windows that are open to the same project.
            // Originally this was used for importing.
            foreach (Form wnd in MainWindows)
            {
                if (!wnd.Enabled && (wnd is FwMainWnd && ((FwMainWnd)wnd).Cache == cache))
                {
                    MessageBox.Show("This project is locked by another window. Please try again later.",
                                    "Project Locked", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(null);
                }
            }
            return(NewTeMainWnd(cache, wndCopyFrom));
        }
コード例 #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Performs any needed tasks to ensure that the project is valid and has any objects
		/// required by this version of the application.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="helpTopicProvider">The Help topic provider.</param>
		/// <param name="existingProgressDlg">The existing progress dialog, if any.</param>
		/// ------------------------------------------------------------------------------------
		public static void EnsureProjectValid(FdoCache cache, IHelpTopicProvider helpTopicProvider,
			IProgress existingProgressDlg)
		{
			TeScrInitializer scrInitializer = new TeScrInitializer(cache);
			scrInitializer.RemoveRtlMarksFromScrProperties();
			scrInitializer.EnsureScriptureTextsValid();
			List<string> issuesToReport = scrInitializer.FixOrcsWithoutProps();
			if (issuesToReport != null)
			{
				using (FixedOrphanFootnoteReportDlg dlg = new FixedOrphanFootnoteReportDlg(
					issuesToReport, cache.ProjectId.UiName, helpTopicProvider))
				{
					dlg.ShowDialog();
				}
			}
		}
コード例 #6
0
ファイル: TeApp.cs プロジェクト: vkarthim/FieldWorks
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///	App-specific initialization of the cache.
        /// </summary>
        /// <param name="progressDlg">The progress dialog.</param>
        /// <returns>True if the initialize was successful, false otherwise</returns>
        /// ------------------------------------------------------------------------------------
        public override bool InitCacheForApp(IThreadedProgress progressDlg)
        {
            if (!TeScrInitializer.Initialize(Cache, this, progressDlg))
            {
                return(false);
            }

            // Make sure this DB uses the current stylesheet version, note categories & and key terms list
            IActionHandler actionHandler = Cache.ServiceLocator.GetInstance <IActionHandler>();

            NonUndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(actionHandler,
                                                               () => TeScrInitializer.EnsureProjectComponentsValid(Cache, this, progressDlg));

            Cache.ServiceLocator.GetInstance <IParagraphCounterRepository>().RegisterViewTypeId <TeParaCounter>((int)TeViewGroup.Scripture);
            Cache.ServiceLocator.GetInstance <IParagraphCounterRepository>().RegisterViewTypeId <TeParaCounter>((int)TeViewGroup.Footnote);
            return(true);
        }
コード例 #7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Performs any needed tasks to ensure that the project is valid and has any objects
        /// required by this version of the application.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="existingProgressDlg">The existing progress dialog, if any.</param>
        /// ------------------------------------------------------------------------------------
        public static void EnsureProjectValid(FdoCache cache, IAdvInd4 existingProgressDlg)
        {
            TeScrInitializer scrInitializer = new TeScrInitializer(cache);

            scrInitializer.RemoveRtlMarksFromScrProperties();
            scrInitializer.EnsureScriptureTextsValid();
            List <string> issuesToReport = scrInitializer.FixOrcsWithoutProps();

            if (issuesToReport != null)
            {
                using (FixedOrphanFootnoteReportDlg dlg = new FixedOrphanFootnoteReportDlg(
                           issuesToReport, cache.ProjectName(), FwApp.App))
                {
                    dlg.ShowDialog();
                }
            }
        }
コード例 #8
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Performs minimal initialization of Scripture needed by FLEx for importing from
        /// Paratext.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public static void EnsureMinimalScriptureInitialization(FdoCache cache, IThreadedProgress progressDlg,
                                                                IHelpTopicProvider helpTopicProvider)
        {
            TeScrInitializer scrInitializer = new TeScrInitializer(cache);

            if (scrInitializer.m_scr == null)
            {
                progressDlg.RunTask((progDlg, args) =>
                {
                    scrInitializer.InitializeScriptureAndStyles(progDlg);
                    return(null);
                });
            }
            else
            {
                TeStylesXmlAccessor.EnsureCurrentStylesheet(cache, progressDlg, helpTopicProvider);
            }
        }
コード例 #9
0
ファイル: TeScrInitializer.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Perform one-time initialization of a new Scripture project
		/// </summary>
		/// <param name="cache">The database cache</param>
		/// <param name="splashScreen">The splash screen (can be null).</param>
		/// <returns>
		/// true if data loaded successfully; false, otherwise
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static bool Initialize(FdoCache cache, IFwSplashScreen splashScreen)
		{
			TeScrInitializer scrInitializer = new TeScrInitializer(cache);
			return scrInitializer.Initialize(splashScreen);
		}
コード例 #10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Performs minimal initialization of Scripture needed by FLEx for importing from
		/// Paratext.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public static void EnsureMinimalScriptureInitialization(FdoCache cache, IThreadedProgress progressDlg,
			IHelpTopicProvider helpTopicProvider)
		{
			TeScrInitializer scrInitializer = new TeScrInitializer(cache);
			if (scrInitializer.m_scr == null)
			{
				progressDlg.RunTask((progDlg, args) =>
				{
					scrInitializer.InitializeScriptureAndStyles(progDlg);
					return null;
				});
			}
			else
				TeStylesXmlAccessor.EnsureCurrentStylesheet(cache, progressDlg, helpTopicProvider);
		}
コード例 #11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Perform one-time initialization of a new Scripture project
        /// </summary>
        /// <param name="cache">The database cache</param>
        /// <param name="splashScreen">The splash screen (can be null).</param>
        /// <returns>
        /// true if data loaded successfully; false, otherwise
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public static bool Initialize(FdoCache cache, IFwSplashScreen splashScreen)
        {
            TeScrInitializer scrInitializer = new TeScrInitializer(cache);

            return(scrInitializer.Initialize(splashScreen));
        }