protected override void Execute() { try { _projectsController = SdlTradosStudio.Application?.GetController <ProjectsController>(); _projectControllerService = new ProjectsControllerService(_projectsController); var fileDialog = new OpenFileDialog { Filter = @"Transit Project Package Files (*.ppf)|*.ppf;" }; var dialogResult = fileDialog.ShowDialog(); if (dialogResult != DialogResult.OK) { return; } var pathToTempFolder = CreateTempPackageFolder(); var wizardModel = new WizardModel { TransitFilePathLocation = fileDialog.FileName, PathToTempFolder = pathToTempFolder }; var pages = CreatePages(wizardModel); using (var wizard = new ImportWizard(pages, _eventAggregatorService, _projectControllerService)) { wizard.ShowDialog(); } } catch (Exception ex) { _logger.Error($"{ex.Message}\n {ex.StackTrace}"); } }
private void btnWizard_Click(object sender, EventArgs e) { ImportWizard wizard = new ImportWizard(); if (wizard.ShowDialog(this) == DialogResult.OK) { tableSource.Import(wizard.GetTable(), wizard.GetColumns()); } }
///------------------------------------------------------------------------------- /// <summary> /// When the Source button is clicked, display the import wizard. /// </summary> ///------------------------------------------------------------------------------- private void btnSource_Click(object sender, System.EventArgs e) { using (ImportWizard importWizard = new ImportWizard(m_scr.Cache.ProjectId.Name, m_scr, m_StyleSheet, m_helpTopicProvider, m_app)) { using (NonUndoableUnitOfWorkHelper undoHelper = new NonUndoableUnitOfWorkHelper(ActionHandler)) { if (importWizard.ShowDialog() == DialogResult.Cancel) { // Ditch any in-memory changes made to the settings. Reload from the DB. m_importSettings.RevertToSaved(); } else { undoHelper.RollBack = false; } } // If there are no files after showing the wizard, close the import dialog if (InitBookNameList() == 0) { MessageBox.Show(this, DlgResources.ResourceString("kstidImportFilesUnavailable"), m_app.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); return; } // The default set of settings may have changed. m_importSettings = m_scr.DefaultImportSettings; // Update the file ranges for import because they may have changed. InitializeStartAndEndRefControls(); // Update the passage controls to reflect the new range of files available // Only make changes that do not expand the available range of books since a // range may have been specified before the wizard was run that we do not // want to overwrite if (!scrPsgFrom.IsReferenceValid(scrPsgFrom.ScReference)) { SetStartRefToFirstImportableBook(); } if (!scrPsgTo.IsReferenceValid(scrPsgTo.ScReference)) { SetEndRefToLastImportableBook(); } } btnOK.Focus(); }
///------------------------------------------------------------------------------- /// <summary> /// When the Source button is clicked, display the import wizard. /// </summary> ///------------------------------------------------------------------------------- private void btnSource_Click(object sender, System.EventArgs e) { ILangProject lp = m_cache.LangProject; Scripture scr = (Scripture)lp.TranslatedScriptureOA; using (ImportWizard importWizard = new ImportWizard(lp.Name.AnalysisDefaultWritingSystem, scr, m_StyleSheet, m_cache, m_helpFile)) { if (importWizard.ShowDialog() == DialogResult.Cancel) { // Ditch any in-memory changes made to the settings. Reload from the DB. m_importSettings.RevertToSaved(); } // If there are no files after showing the wizard, close the import dialog if (InitBookNameList() == 0) { MessageBox.Show(this, DlgResources.ResourceString("kstidImportFilesUnavailable"), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); return; } // Update the file ranges for import because they may have changed. The default // set of settings may also have changed, so we re-retrieve them from the DB. m_importSettings = (ScrImportSet)scr.DefaultImportSettings; scrPsgFrom.Initialize(new ScrReference(StartRef, scr.Versification), scr, m_importSettings.BooksForProject.ToArray()); scrPsgTo.Initialize(new ScrReference(EndRef, scr.Versification), scr, m_importSettings.BooksForProject.ToArray()); // Update the passage controls to reflect the new range of files available // Only make changes that do not expand the available range of books since a // range may have been specified before the wizard was run that we do not // want to overwrite if (!scrPsgFrom.IsReferenceValid(scrPsgFrom.ScReference)) { SetStartRefToFirstImportableBook(); } if (!scrPsgTo.IsReferenceValid(scrPsgTo.ScReference)) { SetEndRefToLastImportableBook(); } } btnOK.Focus(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Get the settings for Import, either from database or from wizard /// </summary> /// <returns>Import settings, or <c>null</c> if user canceled dialog.</returns> /// ------------------------------------------------------------------------------------ protected ScrImportSet GetImportSettings() { ILangProject proj = m_cache.LangProject; Scripture scr = (Scripture)proj.TranslatedScriptureOA; ScrImportSet importSettings = new ScrImportSet(m_cache, scr.DefaultImportSettingsHvo, m_styleSheet, FwApp.App.HelpFile); importSettings.OverlappingFileResolver = new ConfirmOverlappingFileReplaceDialog(); if (!importSettings.BasicSettingsExist) { // REVIEW DavidO: Should I use AnalysisDefaultWritingSystem or // VernacularDefaultWritingSystem or something else. using (ImportWizard importWizard = new ImportWizard(proj.Name.UserDefaultWritingSystem, scr, m_styleSheet, m_cache, FwApp.App.HelpFile)) { if (importWizard.ShowDialog() == DialogResult.Cancel) { return(null); } // Scripture reference range may have changed ImportDialog.ClearDialogReferences(m_cache); importSettings = (ScrImportSet)scr.DefaultImportSettings; } } else { StringCollection sInvalidFiles; bool fCompletedWizard = false; while (!importSettings.ImportProjectIsAccessible(out sInvalidFiles)) { // Display the "Project Not Found" message box using (ScrImportSetMessage dlg = new ScrImportSetMessage()) { string[] files = new string[sInvalidFiles.Count]; sInvalidFiles.CopyTo(files, 0); dlg.InvalidFiles = files; dlg.HelpURL = FwApp.App.HelpFile; dlg.HelpTopic = "/Beginning_Tasks/Import_Standard_Format/Project_Files_Unavailable.htm"; dlg.DisplaySetupOption = true; switch (dlg.ShowDialog()) { case DialogResult.OK: // Setup... { using (ImportWizard importWizard = new ImportWizard( proj.Name.UserDefaultWritingSystem, scr, m_styleSheet, m_cache, FwApp.App.HelpFile)) { if (importWizard.ShowDialog() == DialogResult.Cancel) { return(null); } // Scripture reference range may have changed ImportDialog.ClearDialogReferences(m_cache); importSettings = (ScrImportSet)scr.DefaultImportSettings; fCompletedWizard = true; } break; } case DialogResult.Cancel: return(null); case DialogResult.Retry: // Loop around until user gets tired. break; } } } if (!fCompletedWizard) { if (ParatextProjHasUnmappedMarkers(importSettings)) { // TODO: Show message box and then bring up import wizard } } } return(importSettings); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Get the settings for Import, either from database or from wizard /// </summary> /// <returns>Import settings, or <c>null</c> if user canceled dialog.</returns> /// ------------------------------------------------------------------------------------ protected IScrImportSet GetImportSettings() { ILangProject proj = m_cache.LangProject; IScripture scr = proj.TranslatedScriptureOA; IScrImportSet importSettings = null; NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor, () => { importSettings = scr.FindOrCreateDefaultImportSettings(TypeOfImport.Unknown); }); importSettings.StyleSheet = m_styleSheet; importSettings.OverlappingFileResolver = new ConfirmOverlappingFileReplaceDialog(m_helpTopicProvider); if (!importSettings.BasicSettingsExist) { using (NonUndoableUnitOfWorkHelper undoHelper = new NonUndoableUnitOfWorkHelper( m_cache.ServiceLocator.GetInstance <IActionHandler>())) { using (ImportWizard importWizard = new ImportWizard(m_cache.ProjectId.Name, scr, m_styleSheet, m_helpTopicProvider, m_app)) { if (importWizard.ShowDialog() == DialogResult.Cancel) { return(null); } // Scripture reference range may have changed ImportDialog.ClearDialogReferences(); importSettings = scr.DefaultImportSettings; } undoHelper.RollBack = false; } } else { StringCollection sInvalidFiles; bool fCompletedWizard = false; while (!importSettings.ImportProjectIsAccessible(out sInvalidFiles)) { // Display the "Project Not Found" message box using (ScrImportSetMessage dlg = new ScrImportSetMessage()) { string[] files = new string[sInvalidFiles.Count]; sInvalidFiles.CopyTo(files, 0); dlg.InvalidFiles = files; dlg.HelpURL = m_helpTopicProvider.HelpFile; dlg.HelpTopic = "/Beginning_Tasks/Import_Standard_Format/Project_Files_Unavailable.htm"; dlg.DisplaySetupOption = true; switch (dlg.ShowDialog()) { case DialogResult.OK: // Setup... { using (NonUndoableUnitOfWorkHelper undoHelper = new NonUndoableUnitOfWorkHelper( m_cache.ServiceLocator.GetInstance <IActionHandler>())) { using (ImportWizard importWizard = new ImportWizard( m_cache.ProjectId.Name, scr, m_styleSheet, m_helpTopicProvider, m_app)) { if (importWizard.ShowDialog() == DialogResult.Cancel) { return(null); } // Scripture reference range may have changed ImportDialog.ClearDialogReferences(); importSettings = scr.DefaultImportSettings; fCompletedWizard = true; } undoHelper.RollBack = false; } break; } case DialogResult.Cancel: return(null); case DialogResult.Retry: // Loop around until user gets tired. break; } } } if (!fCompletedWizard) { if (ParatextProjHasUnmappedMarkers(importSettings)) { // TODO: Show message box and then bring up import wizard } } } return(importSettings); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Get the settings for Import, either from database or from wizard /// </summary> /// <returns>Import settings, or <c>null</c> if user canceled dialog.</returns> /// ------------------------------------------------------------------------------------ protected ScrImportSet GetImportSettings() { ILangProject proj = m_cache.LangProject; Scripture scr = (Scripture)proj.TranslatedScriptureOA; ScrImportSet importSettings = new ScrImportSet(m_cache, scr.DefaultImportSettingsHvo, m_styleSheet, FwApp.App.HelpFile); importSettings.OverlappingFileResolver = new ConfirmOverlappingFileReplaceDialog(); if (!importSettings.BasicSettingsExist) { // REVIEW DavidO: Should I use AnalysisDefaultWritingSystem or // VernacularDefaultWritingSystem or something else. using (ImportWizard importWizard = new ImportWizard(proj.Name.UserDefaultWritingSystem, scr, m_styleSheet, m_cache, FwApp.App.HelpFile)) { if (importWizard.ShowDialog() == DialogResult.Cancel) return null; // Scripture reference range may have changed ImportDialog.ClearDialogReferences(m_cache); importSettings = (ScrImportSet)scr.DefaultImportSettings; } } else { StringCollection sInvalidFiles; bool fCompletedWizard = false; while (!importSettings.ImportProjectIsAccessible(out sInvalidFiles)) { // Display the "Project Not Found" message box using (ScrImportSetMessage dlg = new ScrImportSetMessage()) { string[] files = new string[sInvalidFiles.Count]; sInvalidFiles.CopyTo(files, 0); dlg.InvalidFiles = files; dlg.HelpURL = FwApp.App.HelpFile; dlg.HelpTopic = "/Beginning_Tasks/Import_Standard_Format/Project_Files_Unavailable.htm"; dlg.DisplaySetupOption = true; switch(dlg.ShowDialog()) { case DialogResult.OK: // Setup... { using (ImportWizard importWizard = new ImportWizard( proj.Name.UserDefaultWritingSystem, scr, m_styleSheet, m_cache, FwApp.App.HelpFile)) { if (importWizard.ShowDialog()== DialogResult.Cancel) return null; // Scripture reference range may have changed ImportDialog.ClearDialogReferences(m_cache); importSettings = (ScrImportSet)scr.DefaultImportSettings; fCompletedWizard = true; } break; } case DialogResult.Cancel: return null; case DialogResult.Retry: // Loop around until user gets tired. break; } } } if (!fCompletedWizard) { if (ParatextProjHasUnmappedMarkers(importSettings)) { // TODO: Show message box and then bring up import wizard } } } return importSettings; }
///------------------------------------------------------------------------------- /// <summary> /// When the Source button is clicked, display the import wizard. /// </summary> ///------------------------------------------------------------------------------- private void btnSource_Click(object sender, System.EventArgs e) { ILangProject lp = m_cache.LangProject; Scripture scr = (Scripture)lp.TranslatedScriptureOA; using (ImportWizard importWizard = new ImportWizard(lp.Name.AnalysisDefaultWritingSystem, scr, m_StyleSheet, m_cache, m_helpFile)) { if (importWizard.ShowDialog() == DialogResult.Cancel) { // Ditch any in-memory changes made to the settings. Reload from the DB. m_importSettings.RevertToSaved(); } // If there are no files after showing the wizard, close the import dialog if (InitBookNameList() == 0) { MessageBox.Show(this, DlgResources.ResourceString("kstidImportFilesUnavailable"), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); return; } // Update the file ranges for import because they may have changed. The default // set of settings may also have changed, so we re-retrieve them from the DB. m_importSettings = (ScrImportSet)scr.DefaultImportSettings; scrPsgFrom.Initialize(new ScrReference(StartRef, scr.Versification), scr, m_importSettings.BooksForProject.ToArray()); scrPsgTo.Initialize(new ScrReference(EndRef, scr.Versification), scr, m_importSettings.BooksForProject.ToArray()); // Update the passage controls to reflect the new range of files available // Only make changes that do not expand the available range of books since a // range may have been specified before the wizard was run that we do not // want to overwrite if (!scrPsgFrom.IsReferenceValid(scrPsgFrom.ScReference)) SetStartRefToFirstImportableBook(); if (!scrPsgTo.IsReferenceValid(scrPsgTo.ScReference)) SetEndRefToLastImportableBook(); } btnOK.Focus(); }