Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event
        /// data.</param>
        /// ------------------------------------------------------------------------------------
        private void btnSave_Click(object sender, EventArgs e)
        {
            IScrDraft savedVersion;

            using (SaveVersionDialog dlg = new SaveVersionDialog(m_cache, m_helpTopicProvider))
            {
                dlg.ShowDialog();
                savedVersion = dlg.SavedVersion;
            }

            if (savedVersion == null)
            {
                return;
            }

            // Add the archive as a new root node in the tree
            TreeNode versionNode = new TreeNode(GetSavedVersionLabel(savedVersion));

            versionNode.Tag = savedVersion;
            // Add all of the books in the archive as child nodes.
            foreach (IScrBook book in savedVersion.BooksOS)
            {
                TreeNode bookNode = new TreeNode(((IScrBook)book).BestUIName + " " +
                                                 ImportedBooks.GetBookInfo(book));
                bookNode.Tag = book;
                versionNode.Nodes.Add(bookNode);
            }
            m_treeArchives.Nodes.Insert(0, versionNode);
        }
Exemplo n.º 2
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Displays the imported books dialog box (virtual to allow tests to supress display
 /// of dialog box).
 /// </summary>
 /// <param name="backupSavedVersion">The saved version for backups of any overwritten
 /// books.</param>
 /// ------------------------------------------------------------------------------------
 protected virtual void DisplayImportedBooksDlg(IScrDraft backupSavedVersion)
 {
     using (ImportedBooks dlg = new ImportedBooks(m_cache, m_styleSheet,
                                                  m_importedSavedVersion, m_importCallbacks.DraftViewZoomPercent,
                                                  m_importCallbacks.FootnoteZoomPercent, backupSavedVersion, m_bookFilter))
     {
         dlg.ShowOrSave(m_mainWnd);
     }
 }
Exemplo n.º 3
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Displays the imported books dialog box (virtual to allow tests to suppress display
 /// of dialog box).
 /// </summary>
 /// <param name="backupSavedVersion">The saved version for backups of any overwritten
 /// books.</param>
 /// ------------------------------------------------------------------------------------
 protected virtual void DisplayImportedBooksDlg(IScrDraft backupSavedVersion)
 {
     using (ImportedBooks dlg = new ImportedBooks(m_cache, m_styleSheet,
                                                  ImportedVersion, m_importCallbacks.DraftViewZoomPercent,
                                                  m_importCallbacks.FootnoteZoomPercent, backupSavedVersion, m_importCallbacks.BookFilter,
                                                  UndoManager.ImportedBooks.Keys, m_helpTopicProvider, m_app))
     {
         dlg.ShowOrSave(m_mainWnd, m_fParatextStreamlinedImport);
     }
 }
Exemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:SavedVersionsDialog"/> class.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="styleSheet">The style sheet.</param>
        /// <param name="zoomFactorDraft">The zoom percentage to be used for the "draft" (i.e.,
        /// main Scripture) view</param>
        /// <param name="zoomFactorFootnote">The zoom percentage to be used for the "footnote"
        /// view</param>
        /// <param name="helpTopicProvider">The help topic provider.</param>
        /// <param name="app">The app.</param>
        /// ------------------------------------------------------------------------------------
        public SavedVersionsDialog(FdoCache cache, IVwStylesheet styleSheet,
                                   float zoomFactorDraft, float zoomFactorFootnote, IHelpTopicProvider helpTopicProvider,
                                   FwApp app)
        {
            InitializeComponent();

            m_cache             = cache;
            m_helpTopicProvider = helpTopicProvider;
            m_app          = app;
            m_styleSheet   = styleSheet;
            m_zoomDraft    = zoomFactorDraft;
            m_zoomFootnote = zoomFactorFootnote;
            m_scr          = cache.LangProject.TranslatedScriptureOA;

            // Create a list of all of the nodes to add.  The list will be sorted by date
            // before adding them to the tree.
            List <TreeNode> list = new List <TreeNode>();

            // Add all of the saved version as root nodes in the tree
            foreach (IScrDraft savedVersion in m_scr.ArchivedDraftsOC)
            {
                TreeNode versionNode = new TreeNode(GetSavedVersionLabel(savedVersion));
                versionNode.Tag = savedVersion;
                list.Add(versionNode);

                // Add all of the books in the saved version as child nodes.
                foreach (IScrBook book in savedVersion.BooksOS)
                {
                    TreeNode bookNode = new TreeNode(((IScrBook)book).BestUIName + " " +
                                                     ImportedBooks.GetBookInfo(book));
                    bookNode.Tag = book;
                    versionNode.Nodes.Add(bookNode);
                }
            }

            // Sort the list of root nodes by date in decending order.
            list.Sort(new ArchiveDateComparer(false));

            // Add all of the nodes in the list to the tree view.
            foreach (TreeNode node in list)
            {
                m_treeArchives.Nodes.Add(node);
            }

            // If the list is empty then disable the action buttons.
            if (list.Count == 0)
            {
                m_btnDiff.Enabled       = false;
                m_btnCopyToCurr.Enabled = false;
                m_btnDelete.Enabled     = false;
            }
        }
Exemplo n.º 5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Displays the imported books dialog box (virtual to allow tests to suppress display
		/// of dialog box).
		/// </summary>
		/// <param name="backupSavedVersion">The saved version for backups of any overwritten
		/// books.</param>
		/// ------------------------------------------------------------------------------------
		protected virtual void DisplayImportedBooksDlg(IScrDraft backupSavedVersion)
		{
			using (ImportedBooks dlg = new ImportedBooks(m_cache, m_styleSheet,
				ImportedVersion, m_importCallbacks.DraftViewZoomPercent,
				m_importCallbacks.FootnoteZoomPercent, backupSavedVersion, m_importCallbacks.BookFilter,
				UndoManager.ImportedBooks.Keys, m_helpTopicProvider, m_app))
			{
				dlg.ShowOrSave(m_mainWnd, m_fParatextStreamlinedImport);
			}
		}
Exemplo n.º 6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the Click event of the m_btnCopyToCurr control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event
        /// data.</param>
        /// ------------------------------------------------------------------------------------
        private void m_btnCopyToCurr_Click(object sender, EventArgs e)
        {
            // If nothing or a complete archive is selected, do nothing.
            TreeNode node = m_treeArchives.SelectedNode;

            if (node == null || !(node.Tag is IScrBook))
            {
                return;
            }

            IScrBook           savedBook        = (IScrBook)node.Tag;
            IScrBook           originalBook     = (IScrBook)m_scr.FindBook(savedBook.CanonicalNum);
            TreeNode           parentNode       = node.Parent;
            IScrDraft          archive          = (IScrDraft)parentNode.Tag;
            OverwriteType      typeOfOverwrite  = OverwriteType.FullNoDataLoss;
            List <IScrSection> sectionsToRemove = null;

            if (originalBook != null)
            {
                string        sDetails;
                HashSet <int> missingBtWs;
                typeOfOverwrite = originalBook.DetermineOverwritability(savedBook, out sDetails,
                                                                        out sectionsToRemove, out missingBtWs);
                if (typeOfOverwrite == OverwriteType.DataLoss)
                {
                    // There will be data loss if the user overwrites so we don't allow them
                    // to continue.
                    ImportedBooks.ReportDataLoss(originalBook, ScrDraftType.SavedVersion, this, sDetails);
                    return;
                }

                if (missingBtWs != null && !ImportedBooks.ConfirmBtOverwrite(originalBook,
                                                                             ScrDraftType.SavedVersion, sectionsToRemove, missingBtWs, this))
                {
                    // The user might lose back translation(s) if they proceed and they decided
                    // against it.
                    return;
                }
            }

            string stUndo;
            string stRedo;

            TeResourceHelper.MakeUndoRedoLabels("kstidOverwriteCurrentWithSaved", out stUndo, out stRedo);
            using (new WaitCursor(this))
                using (UndoTaskHelper undoHelper = new UndoTaskHelper(m_cache.ActionHandlerAccessor,
                                                                      null, stUndo, stRedo))
                {
                    if (typeOfOverwrite == OverwriteType.Partial)
                    {
                        // Perform an automerge of the original book and the saved version.
                        using (BookMerger merger = new BookMerger(m_cache, m_styleSheet, savedBook))
                        {
                            using (ProgressDialogWithTask progress = new ProgressDialogWithTask(this, m_cache.ThreadHelper))
                            {
                                progress.Title = DlgResources.ResourceString("kstidOverwriteCaption");
                                progress.RunTask(merger.DoPartialOverwrite, sectionsToRemove);
                            }
                            if (!merger.AutoMerged)
                            {
                                throw new ContinuableErrorException("Partial Overwrite was not successful.");
                            }
                        }
                    }
                    else
                    {
                        // FWNX-677 - caused by mono-calgary patch bug-614850_Modal_614850_v6.patch
                        List <Form> disabled_forms = new List <Form>();
                        if (MiscUtils.IsUnix)
                        {
                            lock (Application.OpenForms)
                            {
                                foreach (Form form in Application.OpenForms)
                                {
                                    if (form.Enabled == false)
                                    {
                                        disabled_forms.Add(form);
                                    }
                                }
                            }
                            foreach (Form form in disabled_forms)
                            {
                                form.Enabled = true;
                            }
                        }

                        if (originalBook != null)
                        {
                            if (m_cache.ActionHandlerAccessor != null)
                            {
                                // When Undoing, we need to first resurrect the deleted book, then
                                // put it back in the book filter...so we need a RIFF in the sequence
                                // BEFORE the delete.
                                ReplaceInFilterFixer fixer1 = new ReplaceInFilterFixer(originalBook, null, m_app);
                                m_cache.ActionHandlerAccessor.AddAction(fixer1);
                            }
                            m_scr.ScriptureBooksOS.Remove(originalBook);
                        }
                        IScrBook             newBook = m_scr.CopyBookToCurrent(savedBook);
                        ReplaceInFilterFixer fixer   = new ReplaceInFilterFixer(null, newBook, m_app);

                        fixer.Redo();
                        if (m_cache.ActionHandlerAccessor != null)
                        {
                            m_cache.ActionHandlerAccessor.AddAction(fixer);
                        }

                        // FWNX-677 - caused by mono-calgary patch bug-614850_Modal_614850_v6.patch
                        if (MiscUtils.IsUnix)
                        {
                            foreach (Form form in disabled_forms)
                            {
                                form.Enabled = false;
                            }
                            disabled_forms.Clear();
                        }
                    }
                    undoHelper.RollBack = false;
                }
        }
Exemplo n.º 7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the Click event of the m_btnCopyToCurr control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event
        /// data.</param>
        /// ------------------------------------------------------------------------------------
        private void m_btnCopyToCurr_Click(object sender, EventArgs e)
        {
            // If nothing or a complete archive is selected, do nothing.
            TreeNode node = m_treeArchives.SelectedNode;

            if (node == null || !(node.Tag is ScrBook))
            {
                return;
            }

            ScrBook            savedBook        = node.Tag as ScrBook;
            ScrBook            originalBook     = (ScrBook)m_scr.FindBook(savedBook.CanonicalNum);
            TreeNode           parentNode       = node.Parent;
            ScrDraft           archive          = parentNode.Tag as ScrDraft;
            OverwriteType      typeOfOverwrite  = OverwriteType.FullNoDataLoss;
            List <IScrSection> sectionsToRemove = null;

            if (originalBook != null)
            {
                string     sDetails;
                List <int> missingBtWs;
                typeOfOverwrite = originalBook.DetermineOverwritability(savedBook, out sDetails,
                                                                        out sectionsToRemove, out missingBtWs);
                if (typeOfOverwrite == OverwriteType.DataLoss)
                {
                    // There will be data loss if the user overwrites so we don't allow them
                    // to continue.
                    ImportedBooks.ReportDataLoss(originalBook, ScrDraftType.SavedVersion, this, sDetails);
                    return;
                }

                if (missingBtWs != null && !ImportedBooks.ConfirmBtOverwrite(originalBook,
                                                                             ScrDraftType.SavedVersion, sectionsToRemove, missingBtWs, this))
                {
                    // The user might lose back translation(s) if they proceed and they decided
                    // against it.
                    return;
                }
            }

            string stUndo;
            string stRedo;

            TeResourceHelper.MakeUndoRedoLabels("kstidOverwriteCurrentWithSaved", out stUndo, out stRedo);
            using (new WaitCursor(this))
                using (UndoTaskHelper helper = new UndoTaskHelper(m_cache.MainCacheAccessor, null, stUndo, stRedo, true))
                {
                    try
                    {
                        if (typeOfOverwrite == OverwriteType.Partial)
                        {
                            // Perform an automerge of the original book and the saved version.
                            using (BookMerger merger = new BookMerger(m_cache, m_styleSheet, savedBook))
                            {
                                using (ProgressDialogWithTask progress = new ProgressDialogWithTask(this))
                                {
                                    progress.Title = DlgResources.ResourceString("kstidOverwriteCaption");
                                    progress.RunTask(true, new BackgroundTaskInvoker(merger.DoPartialOverwrite), sectionsToRemove);
                                }
                                if (!merger.AutoMerged)
                                {
                                    throw new Exception("Partial Overwrite was not successful.");
                                }
                            }
                        }
                        else
                        {
                            if (originalBook != null)
                            {
                                if (m_cache.ActionHandlerAccessor != null)
                                {
                                    // When Undoing, we need to first resurrect the deleted book, then
                                    // put it back in the book filter...so we need a RIFF in the sequence
                                    // BEFORE the delete.
                                    ReplaceInFilterFixer fixer1 = new ReplaceInFilterFixer(originalBook.Hvo, 0, m_cache);
                                    m_cache.ActionHandlerAccessor.AddAction(fixer1);
                                }
                                originalBook.DeleteUnderlyingObject();
                            }
                            int hvoNew = (m_scr as Scripture).CopyBookToCurrent(savedBook);
                            ReplaceInFilterFixer fixer = new ReplaceInFilterFixer(0, hvoNew, m_cache);
                            fixer.Redo(false);
                            if (m_cache.ActionHandlerAccessor != null)
                            {
                                m_cache.ActionHandlerAccessor.AddAction(fixer);
                            }
                        }
                    }
                    catch
                    {
                        helper.EndUndoTask = false;
                        throw;
                    }
                }
        }
Exemplo n.º 8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Displays the imported books dialog box (virtual to allow tests to supress display
		/// of dialog box).
		/// </summary>
		/// <param name="backupSavedVersion">The saved version for backups of any overwritten
		/// books.</param>
		/// ------------------------------------------------------------------------------------
		protected virtual void DisplayImportedBooksDlg(IScrDraft backupSavedVersion)
		{
			using (ImportedBooks dlg = new ImportedBooks(m_cache, m_styleSheet,
				m_importedSavedVersion, m_importCallbacks.DraftViewZoomPercent,
				m_importCallbacks.FootnoteZoomPercent, backupSavedVersion, m_bookFilter))
			{
				dlg.ShowOrSave(m_mainWnd);
			}
		}