public BookServer CreateBookServer() { _collectionSettings = CreateDefaultCollectionsSettings(); var xmatterFinder = new XMatterPackFinder(new[] { BloomFileLocator.GetInstalledXMatterDirectory() }); var fileLocator = new BloomFileLocator(_collectionSettings, xmatterFinder, ProjectContext.GetFactoryFileLocations(), ProjectContext.GetFoundFileLocations(), ProjectContext.GetAfterXMatterFileLocations()); var starter = new BookStarter(fileLocator, (dir, forSelectedBook) => new BookStorage(dir, fileLocator, new BookRenamedEvent(), _collectionSettings), _collectionSettings); return(new BookServer( //book factory (bookInfo, storage) => { return new Bloom.Book.Book(bookInfo, storage, null, _collectionSettings, new PageSelection(), new PageListChangedEvent(), new BookRefreshEvent()); }, // storage factory (path, forSelectedBook) => { var storage = new BookStorage(path, fileLocator, new BookRenamedEvent(), _collectionSettings); storage.BookInfo = new BookInfo(path, true); return storage; }, // book starter factory () => starter, // configurator factory null)); }
public BloomFileLocator(CollectionSettings collectionSettings, XMatterPackFinder xMatterPackFinder, IEnumerable <string> factorySearchPaths, IEnumerable <string> userInstalledSearchPaths) : base(factorySearchPaths.Concat(userInstalledSearchPaths)) //review: is this even used, since we override GetSearchPaths()? { _bookSpecificSearchPaths = new List <string>(); _collectionSettings = collectionSettings; _xMatterPackFinder = xMatterPackFinder; _factorySearchPaths = factorySearchPaths; _userInstalledSearchPaths = userInstalledSearchPaths;; }
public CollectionSettingsDialog(CollectionSettings collectionSettings, XMatterPackFinder xmatterPackFinder, QueueRenameOfCollection queueRenameOfCollection, PageRefreshEvent pageRefreshEvent) { _collectionSettings = collectionSettings; _xmatterPackFinder = xmatterPackFinder; _queueRenameOfCollection = queueRenameOfCollection; _pageRefreshEvent = pageRefreshEvent; InitializeComponent(); // moved from the Designer where it was deleted if the Designer was touched _xmatterList.Columns.AddRange(new[] { new ColumnHeader() { Width = 250 } }); if (_collectionSettings.IsSourceCollection) { _language1Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language1InSourceCollection", "Language 1", "In a local language collection, we say 'Local Language', but in a source collection, Local Language has no relevance, so we use this different label"); _language2Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language2InSourceCollection", "Language 2", "In a local language collection, we say 'Language 2 (e.g. National Language)', but in a source collection, National Language has no relevance, so we use this different label"); _language3Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language3InSourceCollection", "Language 3", "In a local language collection, we say 'Language 3 (e.g. Regional Language)', but in a source collection, National Language has no relevance, so we use this different label"); } _showExperimentalFeatures.Checked = Settings.Default.ShowExperimentalFeatures; // AutoUpdate applies only to Windows: see https://silbloom.myjetbrains.com/youtrack/issue/BL-2317. if (SIL.PlatformUtilities.Platform.IsWindows) { _automaticallyUpdate.Checked = Settings.Default.AutoUpdate; } else { _automaticallyUpdate.Hide(); } // _showSendReceive.CheckStateChanged += (sender, args) => // { // Settings.Default.ShowSendReceive = _showSendReceive.CheckState == // CheckState.Checked; // // _restartRequired = true; // UpdateDisplay(); // }; CollectionSettingsApi.BrandingChangeHandler = ChangeBranding; SetupEnterpriseBrowser(); UpdateDisplay(); if (CollectionSettingsApi.FixEnterpriseSubscriptionCodeMode) { _tab.SelectedTab = _enterpriseTab; } }
public static int Handle(HydrateParameters options) { if (!Directory.Exists(options.Path)) { if (options.Path.Contains(".htm")) { Debug.WriteLine("Supply only the directory, not the path to the file."); Console.Error.WriteLine("Supply only the directory, not the path to the file."); } else { Debug.WriteLine("Could not find " + options.Path); Console.Error.WriteLine("Could not find " + options.Path); } return(1); } Console.WriteLine("Starting Hydrating."); var layout = new Layout { SizeAndOrientation = SizeAndOrientation.FromString(options.SizeAndOrientation) }; var collectionSettings = new CollectionSettings { XMatterPackName = options.XMatter, Language1Iso639Code = options.VernacularIsoCode, Language2Iso639Code = string.IsNullOrWhiteSpace(options.NationalLanguage1IsoCode) ? options.VernacularIsoCode : options.NationalLanguage1IsoCode, Language3Iso639Code = options.NationalLanguage2IsoCode }; XMatterPackFinder xmatterFinder = new XMatterPackFinder(new[] { BloomFileLocator.GetInstalledXMatterDirectory() }); var locator = new BloomFileLocator(collectionSettings, xmatterFinder, ProjectContext.GetFactoryFileLocations(), ProjectContext.GetFoundFileLocations(), ProjectContext.GetAfterXMatterFileLocations()); var bookInfo = new BookInfo(options.Path, true); var book = new Book.Book(bookInfo, new BookStorage(options.Path, locator, new BookRenamedEvent(), collectionSettings), null, collectionSettings, null, null, new BookRefreshEvent(), new BookSavedEvent()); //we might change this later, or make it optional, but for now, this will prevent surprises to processes //running this CLI... the folder name won't change out from under it. book.LockDownTheFileAndFolderName = true; book.SetLayout(layout); book.BringBookUpToDate(new NullProgress()); Console.WriteLine("Finished Hydrating."); Debug.WriteLine("Finished Hydrating."); return(0); }
public CollectionSettingsDialog(CollectionSettings collectionSettings, XMatterPackFinder xmatterPackFinder, QueueRenameOfCollection queueRenameOfCollection) { _collectionSettings = collectionSettings; _xmatterPackFinder = xmatterPackFinder; _queueRenameOfCollection = queueRenameOfCollection; InitializeComponent(); if (_collectionSettings.IsSourceCollection) { _language1Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language1InSourceCollection", "Language 1", "In a vernacular collection, we say 'Vernacular Language', but in a souce collection, Vernacular has no relevance, so we use this different label"); _language2Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language2InSourceCollection", "Language 2", "In a vernacular collection, we say 'Language 2 (e.g. National Language)', but in a souce collection, National Language has no relevance, so we use this different label"); _language3Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language3InSourceCollection", "Language 3", "In a vernacular collection, we say 'Language 3 (e.g. Regional Language)', but in a souce collection, National Language has no relevance, so we use this different label"); } #if !DEBUG _showSendReceive.Enabled = false; #endif _showSendReceive.Checked = Settings.Default.ShowSendReceive; _showExperimentalTemplates.Checked = Settings.Default.ShowExperimentalBooks; _showExperimentCommands.Checked = Settings.Default.ShowExperimentalCommands; // _showSendReceive.CheckStateChanged += (sender, args) => // { // Settings.Default.ShowSendReceive = _showSendReceive.CheckState == // CheckState.Checked; // // _restartRequired = true; // UpdateDisplay(); // }; switch (Settings.Default.ImageHandler) { case "": _useImageServer.CheckState = CheckState.Checked; break; case "off": _useImageServer.CheckState = CheckState.Unchecked; break; case "http": _useImageServer.CheckState = CheckState.Checked; break; } // this._useImageServer.CheckedChanged += new System.EventHandler(this._useImageServer_CheckedChanged); _useImageServer.CheckStateChanged += new EventHandler(_useImageServer_CheckedChanged); UpdateDisplay(); }
public BloomFileLocator(CollectionSettings collectionSettings, XMatterPackFinder xMatterPackFinder, IEnumerable <string> factorySearchPaths, IEnumerable <string> userInstalledSearchPaths, IEnumerable <string> afterXMatterSearchPaths = null) { if (afterXMatterSearchPaths == null) { afterXMatterSearchPaths = new string[] {}; } _bookSpecificSearchPaths = new List <string>(); _collectionSettings = collectionSettings; _xMatterPackFinder = xMatterPackFinder; _factorySearchPaths = factorySearchPaths; _userInstalledSearchPaths = userInstalledSearchPaths; _afterXMatterSearchPaths = afterXMatterSearchPaths; sTheMostRecentBloomFileLocator = this; }
public BloomFileLocator(CollectionSettings collectionSettings, XMatterPackFinder xMatterPackFinder, IEnumerable <string> factorySearchPaths, IEnumerable <string> userInstalledSearchPaths, IEnumerable <string> afterXMatterSearchPaths = null) : base(factorySearchPaths.Concat(userInstalledSearchPaths)) //review: is this even used, since we override GetSearchPaths()? { if (afterXMatterSearchPaths == null) { afterXMatterSearchPaths = new string[] {}; } _bookSpecificSearchPaths = new List <string>(); _collectionSettings = collectionSettings; _xMatterPackFinder = xMatterPackFinder; _factorySearchPaths = factorySearchPaths; _userInstalledSearchPaths = userInstalledSearchPaths; _afterXMatterSearchPaths = afterXMatterSearchPaths; sTheMostRecentBloomFileLocator = this; }
public void Setup() { _librarySettings = new Moq.Mock <CollectionSettings>(); _librarySettings.SetupGet(x => x.IsSourceCollection).Returns(false); _librarySettings.SetupGet(x => x.Language1Iso639Code).Returns("xyz"); _librarySettings.SetupGet(x => x.Language2Iso639Code).Returns("fr"); _librarySettings.SetupGet(x => x.Language3Iso639Code).Returns("es"); _librarySettings.SetupGet(x => x.XMatterPackName).Returns("Factory"); ErrorReport.IsOkToInteractWithUser = false; _projectFolder = new TemporaryFolder("BookStarterTests_ProjectCollection"); var collectionSettings = new CollectionSettings(Path.Combine(_projectFolder.Path, "test.bloomCollection")); var xmatterFinder = new XMatterPackFinder(new [] { FileLocator.GetDirectoryDistributedWithApplication("xMatter") }); _fileLocator = new BloomFileLocator(collectionSettings, xmatterFinder, ProjectContext.GetFactoryFileLocations(), ProjectContext.GetFoundFileLocations()); _starter = new BookStarter(_fileLocator, dir => new BookStorage(dir, _fileLocator, new BookRenamedEvent(), collectionSettings), _librarySettings.Object); _shellCollectionFolder = new TemporaryFolder("BookStarterTests_ShellCollection"); }
public void Setup() { var locations = new List <string>(); locations.Add(BloomFileLocator.GetFactoryXMatterDirectory()); _xMatterParentFolder = new TemporaryFolder("UserCollection"); _xMatterFolder = new TemporaryFolder(_xMatterParentFolder, "User-XMatter"); locations.Add(_xMatterParentFolder.Path); RobustFile.WriteAllText(Path.Combine(_xMatterFolder.Path, "SomeRandomXYZABCStyles.css"), "Some arbitrary test data"); RobustFile.WriteAllText(Path.Combine(_xMatterFolder.Path, "Decodable Reader.css"), "Fake DR test data"); //locations.Add(XMatterAppDataFolder); //locations.Add(XMatterCommonDataFolder); _xMatterFinder = new XMatterPackFinder(locations); _otherFilesForTestingFolder = new TemporaryFolder("BloomFileLocatorTests"); var userInstalledSearchPaths = new List <string>(ProjectContext.GetFoundFileLocations()); userInstalledSearchPaths.Add(_otherFilesForTestingFolder.Path); _fileLocator = new BloomFileLocator(new CollectionSettings(), _xMatterFinder, ProjectContext.GetFactoryFileLocations(), userInstalledSearchPaths, ProjectContext.GetAfterXMatterFileLocations()); //Without this, tests can interact with one another, leaving the language set as something unexpected. LocalizationManager.SetUILanguage("en", false); }
public static int Handle(HydrateParameters options) { if (!Directory.Exists(options.Path)) { if (options.Path.Contains(".htm")) { Debug.WriteLine("Supply only the directory, not the path to the file."); Console.Error.WriteLine("Supply only the directory, not the path to the file."); } else { Debug.WriteLine("Could not find " + options.Path); Console.Error.WriteLine("Could not find " + options.Path); } return(1); } Console.WriteLine("Starting Hydrating."); var layout = new Layout { SizeAndOrientation = SizeAndOrientation.FromString(options.SizeAndOrientation) }; var collectionSettings = new CollectionSettings { XMatterPackName = options.XMatter, Language1Iso639Code = options.VernacularIsoCode, Language2Iso639Code = options.NationalLanguage1IsoCode, Language3Iso639Code = options.NationalLanguage2IsoCode }; XMatterPackFinder xmatterFinder = new XMatterPackFinder(new[] { BloomFileLocator.GetInstalledXMatterDirectory() }); var locator = new BloomFileLocator(collectionSettings, xmatterFinder, ProjectContext.GetFactoryFileLocations(), ProjectContext.GetFoundFileLocations(), ProjectContext.GetAfterXMatterFileLocations()); var bookInfo = new BookInfo(options.Path, true); var book = new Book.Book(bookInfo, new BookStorage(options.Path, locator, new BookRenamedEvent(), collectionSettings), null, collectionSettings, null, null, new BookRefreshEvent()); if (collectionSettings.XMatterPackName == "Video") { if (null == book.OurHtmlDom.SelectSingleNodeHonoringDefaultNS("//script[contains(text(),'bloomPlayer.js')]")) { var element = book.OurHtmlDom.Head.AppendChild(book.OurHtmlDom.RawDom.CreateElement("script")) as XmlElement; element.IsEmpty = false; element.SetAttribute("type", "text/javascript"); element.SetAttribute("src", "bloomPlayer.js"); } AddRequisiteJsFiles(options.Path); } //we might change this later, or make it optional, but for now, this will prevent surprises to processes //running this CLI... the folder name won't change out from under it. book.LockDownTheFileAndFolderName = true; book.SetLayout(layout); book.BringBookUpToDate(new NullProgress()); Console.WriteLine("Finished Hydrating."); Debug.WriteLine("Finished Hydrating."); return(0); }
public static void ChangeLayoutForAllContentPagesInAllBooks(IProgress progress, string collectionPath, string bookPath, string pageGuid) { if (!File.Exists(bookPath)) { MessageBox.Show("Could not find template book " + bookPath); return; } if (!File.Exists(collectionPath)) { MessageBox.Show("Could not find collection file " + collectionPath); return; } var problems = new StringBuilder(); var collectionFolder = Path.GetDirectoryName(collectionPath); var collection = new BookCollection(collectionFolder, BookCollection.CollectionType.TheOneEditableCollection, new BookSelection()); var collectionSettings = new CollectionSettings(collectionPath); XMatterPackFinder xmatterFinder = new XMatterPackFinder(new[] { BloomFileLocator.GetInstalledXMatterDirectory() }); var locator = new BloomFileLocator(collectionSettings, xmatterFinder, ProjectContext.GetFactoryFileLocations(), ProjectContext.GetFoundFileLocations(), ProjectContext.GetAfterXMatterFileLocations()); var templateBookInfo = new BookInfo(Path.GetDirectoryName(bookPath), true); var templateBook = new Book.Book(templateBookInfo, new BookStorage(templateBookInfo.FolderPath, locator, new BookRenamedEvent(), collectionSettings), null, collectionSettings, null, null, new BookRefreshEvent()); var pageDictionary = templateBook.GetTemplatePagesIdDictionary(); IPage page = null; if (!pageDictionary.TryGetValue(pageGuid, out page)) { MessageBox.Show("Could not find template page " + pageGuid); return; } int i = 0; foreach (var bookInfo in collection.GetBookInfos()) { i++; try { var book = new Book.Book(bookInfo, new BookStorage(bookInfo.FolderPath, locator, new BookRenamedEvent(), collectionSettings), null, collectionSettings, null, null, new BookRefreshEvent()); //progress.WriteMessage("Processing " + book.TitleBestForUserDisplay + " " + i + "/" + collection.GetBookInfos().Count()); progress.ProgressIndicator.PercentCompleted = i * 100 / collection.GetBookInfos().Count(); book.ChangeLayoutForAllContentPages(page); } catch (Exception ex) { Debug.WriteLine(ex.Message); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); problems.AppendLine(Path.GetFileName(bookInfo.FolderPath)); } } if (problems.Length == 0) { MessageBox.Show("All books converted successfully"); } else { MessageBox.Show("Bloom had problems converting the following books; please check them:\n" + problems); } }
public BloomFileLocator(CollectionSettings collectionSettings, XMatterPackFinder xMatterPackFinder, IEnumerable <string> searchPaths) : base(searchPaths) { _collectionSettings = collectionSettings; _xMatterPackFinder = xMatterPackFinder; }
public CollectionSettingsApi(CollectionSettings collectionSettings, XMatterPackFinder xmatterPackFinder) { _collectionSettings = collectionSettings; _xmatterPackFinder = xmatterPackFinder; }
public CollectionSettingsDialog(CollectionSettings collectionSettings, XMatterPackFinder xmatterPackFinder, QueueRenameOfCollection queueRenameOfCollection, PageRefreshEvent pageRefreshEvent, TeamCollectionManager tcManager) { _collectionSettings = collectionSettings; _xmatterPackFinder = xmatterPackFinder; _queueRenameOfCollection = queueRenameOfCollection; _pageRefreshEvent = pageRefreshEvent; InitializeComponent(); // moved from the Designer where it was deleted if the Designer was touched _xmatterList.Columns.AddRange(new[] { new ColumnHeader() { Width = 250 } }); _language1Name.UseMnemonic = false; // Allow & to be part of the language display names. _language2Name.UseMnemonic = false; // This may be unlikely, but can't be ruled out. _language3Name.UseMnemonic = false; // See https://issues.bloomlibrary.org/youtrack/issue/BL-9919. _language1FontLabel.UseMnemonic = false; _language2FontLabel.UseMnemonic = false; _language3FontLabel.UseMnemonic = false; CollectionSettingsApi.DialogBeingEdited = this; if (_collectionSettings.IsSourceCollection) { _language1Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language1InSourceCollection", "Language 1", "In a local language collection, we say 'Local Language', but in a source collection, Local Language has no relevance, so we use this different label"); _language2Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language2InSourceCollection", "Language 2", "In a local language collection, we say 'Language 2 (e.g. National Language)', but in a source collection, National Language has no relevance, so we use this different label"); _language3Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language3InSourceCollection", "Language 3", "In a local language collection, we say 'Language 3 (e.g. Regional Language)', but in a source collection, National Language has no relevance, so we use this different label"); } _showExperimentalBookSources.Checked = ExperimentalFeatures.IsFeatureEnabled(ExperimentalFeatures.kExperimentalSourceBooks); _allowTeamCollection.Checked = ExperimentalFeatures.IsFeatureEnabled(ExperimentalFeatures.kTeamCollections); if (!ExperimentalFeatures.IsFeatureEnabled(ExperimentalFeatures.kTeamCollections) && tcManager.CurrentCollectionEvenIfDisconnected == null) { this._tab.Controls.Remove(this._teamCollectionTab); } // Don't allow the user to disable the Team Collection feature if we're currently in a Team Collection. _allowTeamCollection.Enabled = !(_allowTeamCollection.Checked && tcManager.CurrentCollectionEvenIfDisconnected != null); // AutoUpdate applies only to Windows: see https://silbloom.myjetbrains.com/youtrack/issue/BL-2317. if (SIL.PlatformUtilities.Platform.IsWindows) { _automaticallyUpdate.Checked = Settings.Default.AutoUpdate; } else { _automaticallyUpdate.Hide(); } // Without this, PendingDefaultBookshelf stays null unless the user changes it. // The result is the bookshelf selection gets cleared when other collection settings are saved. See BL-10093. PendingDefaultBookshelf = _collectionSettings.DefaultBookshelf; // _showSendReceive.CheckStateChanged += (sender, args) => // { // Settings.Default.ShowSendReceive = _showSendReceive.CheckState == // CheckState.Checked; // // _restartRequired = true; // UpdateDisplay(); // }; CollectionSettingsApi.BrandingChangeHandler = ChangeBranding; SetupEnterpriseBrowser(); TeamCollectionApi.TheOneInstance.SetCallbackToReopenCollection(() => { _restartRequired = true; ReactDialog.CloseCurrentModal(); // close the top Create dialog _okButton_Click(null, null); // close this dialog }); UpdateDisplay(); if (CollectionSettingsApi.FixEnterpriseSubscriptionCodeMode) { _tab.SelectedTab = _enterpriseTab; } if (tcManager.CurrentCollectionEvenIfDisconnected == null) { _noRenameTeamCollectionLabel.Visible = false; } else { _bloomCollectionName.Enabled = false; } // This code would mostly more naturally go in Designer. Unfortunately we can't run designer // until we get back in a state where all our dependencies are sufficiently consistent. _defaultBookshelfControl = ReactControl.Create("defaultBookshelfControlBundle"); tabPage2.Controls.Add(_defaultBookshelfControl); _defaultBookshelfControl.Location = new Point(_xmatterDescription.Left, _xmatterDescription.Bottom + 30); // We'd like it to be as big as possible, not just big enough for the immediate content. // Until React takes over at least the whole tab, the pull-down part of the combo can't // stretch outside the Gecko control. _defaultBookshelfControl.Size = new Size(_xmatterList.Width, 200); }
public static int Handle(HydrateParameters options) { if (!Directory.Exists(options.Path)) { if (options.Path.Contains(".htm")) { Debug.WriteLine("Supply only the directory, not the path to the file."); Console.Error.WriteLine("Supply only the directory, not the path to the file."); } else { Debug.WriteLine("Could not find " + options.Path); Console.Error.WriteLine("Could not find " + options.Path); } return(1); } Console.WriteLine("Starting Hydrating."); var layout = new Layout { SizeAndOrientation = SizeAndOrientation.FromString(options.SizeAndOrientation) }; if (File.Exists(TeamCollectionManager.GetTcLinkPathFromLcPath(Path.GetDirectoryName(options.Path)))) { throw new ApplicationException("Hydrate command cannot currently be used in Team Collections"); // To make this possible, we'd need to spin up a TeamCollectionManager and TeamCollection and pass the latter // to the Book as its SaveContext and still changes would be forbidden unless the book was checked out. } var collectionSettings = new CollectionSettings { XMatterPackName = options.XMatter, Language1Iso639Code = options.VernacularIsoCode, Language2Iso639Code = string.IsNullOrWhiteSpace(options.NationalLanguage1IsoCode) ? options.VernacularIsoCode : options.NationalLanguage1IsoCode, Language3Iso639Code = options.NationalLanguage2IsoCode }; XMatterPackFinder xmatterFinder = new XMatterPackFinder(new[] { BloomFileLocator.GetFactoryXMatterDirectory(), }); var locator = new BloomFileLocator(collectionSettings, xmatterFinder, ProjectContext.GetFactoryFileLocations(), ProjectContext.GetFoundFileLocations(), ProjectContext.GetAfterXMatterFileLocations()); // alwaysSaveable is fine here, as we already checked it's not a TC. var bookInfo = new BookInfo(options.Path, true, new AlwaysEditSaveContext()); var book = new Book.Book(bookInfo, new BookStorage(options.Path, locator, new BookRenamedEvent(), collectionSettings), null, collectionSettings, null, null, new BookRefreshEvent(), new BookSavedEvent()); // This was added as part of the phase 1 changes towards the new language system, where book languages // are more clearly distinct from collection languages, and there's no sense (except underlying storage) in which // a book has languages that are not selected for display. This made it necessary to decide explicitly // whether passing the national language options implies that a book is bi- or tri-lingual. Andrew and I (JohnT) // could not think of any reason to pass the arguments at all except to achieve that, so I made it so. var langs = new List <string>(); langs.Add(options.VernacularIsoCode); if (!string.IsNullOrEmpty(options.NationalLanguage1IsoCode) && options.NationalLanguage1IsoCode != options.VernacularIsoCode) { langs.Add(options.NationalLanguage1IsoCode); } if (!string.IsNullOrEmpty(options.NationalLanguage2IsoCode)) { langs.Add(options.NationalLanguage2IsoCode); } book.SetMultilingualContentLanguages(langs.ToArray()); //we might change this later, or make it optional, but for now, this will prevent surprises to processes //running this CLI... the folder name won't change out from under it. book.LockDownTheFileAndFolderName = true; book.SetLayout(layout); book.BringBookUpToDate(new NullProgress()); Console.WriteLine("Finished Hydrating."); Debug.WriteLine("Finished Hydrating."); return(0); }
public CollectionSettingsDialog(CollectionSettings collectionSettings, QueueRenameOfCollection queueRenameOfCollection, PageRefreshEvent pageRefreshEvent, TeamCollectionManager tcManager, XMatterPackFinder xmatterPackFinder) { _collectionSettings = collectionSettings; _queueRenameOfCollection = queueRenameOfCollection; _pageRefreshEvent = pageRefreshEvent; _xmatterPackFinder = xmatterPackFinder; InitializeComponent(); _language1Name.UseMnemonic = false; // Allow & to be part of the language display names. _language2Name.UseMnemonic = false; // This may be unlikely, but can't be ruled out. _language3Name.UseMnemonic = false; // See https://issues.bloomlibrary.org/youtrack/issue/BL-9919. PendingFontSelections[0] = _collectionSettings.LanguagesZeroBased[0].FontName; PendingFontSelections[1] = _collectionSettings.LanguagesZeroBased[1].FontName; var have3rdLanguage = _collectionSettings.LanguagesZeroBased[2] != null; PendingFontSelections[2] = have3rdLanguage ? _collectionSettings.LanguagesZeroBased[2].FontName : ""; PendingNumberingStyle = _collectionSettings.PageNumberStyle; PendingXmatter = _collectionSettings.XMatterPackName; CollectionSettingsApi.DialogBeingEdited = this; if (_collectionSettings.IsSourceCollection) { _language1Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language1InSourceCollection", "Language 1", "In a local language collection, we say 'Local Language', but in a source collection, Local Language has no relevance, so we use this different label"); _language2Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language2InSourceCollection", "Language 2", "In a local language collection, we say 'Language 2 (e.g. National Language)', but in a source collection, National Language has no relevance, so we use this different label"); _language3Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language3InSourceCollection", "Language 3", "In a local language collection, we say 'Language 3 (e.g. Regional Language)', but in a source collection, National Language has no relevance, so we use this different label"); } _showExperimentalBookSources.Checked = ExperimentalFeatures.IsFeatureEnabled(ExperimentalFeatures.kExperimentalSourceBooks); _allowTeamCollection.Checked = ExperimentalFeatures.IsFeatureEnabled(ExperimentalFeatures.kTeamCollections); _allowSpreadsheetImportExport.Checked = ExperimentalFeatures.IsFeatureEnabled(ExperimentalFeatures.kSpreadsheetImportExport); if (!ExperimentalFeatures.IsFeatureEnabled(ExperimentalFeatures.kTeamCollections) && tcManager.CurrentCollectionEvenIfDisconnected == null) { this._tab.Controls.Remove(this._teamCollectionTab); } // Don't allow the user to disable the Team Collection feature if we're currently in a Team Collection. _allowTeamCollection.Enabled = !(_allowTeamCollection.Checked && tcManager.CurrentCollectionEvenIfDisconnected != null); // AutoUpdate applies only to Windows: see https://silbloom.myjetbrains.com/youtrack/issue/BL-2317. if (SIL.PlatformUtilities.Platform.IsWindows) { _automaticallyUpdate.Checked = Settings.Default.AutoUpdate; } else { _automaticallyUpdate.Hide(); } // Without this, PendingDefaultBookshelf stays null unless the user changes it. // The result is the bookshelf selection gets cleared when other collection settings are saved. See BL-10093. PendingDefaultBookshelf = _collectionSettings.DefaultBookshelf; CollectionSettingsApi.BrandingChangeHandler = ChangeBranding; TeamCollectionApi.TheOneInstance.SetCallbackToReopenCollection(() => { _restartRequired = true; ReactDialog.CloseCurrentModal(); // close the top Create dialog _okButton_Click(null, null); // close this dialog }); UpdateDisplay(); if (CollectionSettingsApi.FixEnterpriseSubscriptionCodeMode) { _tab.SelectedTab = _enterpriseTab; } if (tcManager.CurrentCollectionEvenIfDisconnected == null) { _noRenameTeamCollectionLabel.Visible = false; } else { _bloomCollectionName.Enabled = false; } }
public static void ChangeLayoutForAllContentPagesInAllBooks(IProgress progress, string collectionPath, string bookPath, string pageGuid) { if (!File.Exists(bookPath)) { MessageBox.Show("Could not find template book " + bookPath); return; } if (!File.Exists(collectionPath)) { MessageBox.Show("Could not find collection file " + collectionPath); return; } var collectionFolder = Path.GetDirectoryName(collectionPath); if (File.Exists(TeamCollectionManager.GetTcLinkPathFromLcPath(collectionFolder))) { MessageBox.Show("Change Layout command cannot currently be used in Team Collections"); return; // To make this possible, we'd need to spin up a TeamCollectionManager and TeamCollection and pass the latter // to the Book as its SaveContext and still changes would be forbidden unless every book was checked out. } var problems = new StringBuilder(); var collection = new BookCollection(collectionFolder, BookCollection.CollectionType.TheOneEditableCollection, new BookSelection(), null); var collectionSettings = new CollectionSettings(collectionPath); XMatterPackFinder xmatterFinder = new XMatterPackFinder(new[] { BloomFileLocator.GetFactoryXMatterDirectory() }); var locator = new BloomFileLocator(collectionSettings, xmatterFinder, ProjectContext.GetFactoryFileLocations(), ProjectContext.GetFoundFileLocations(), ProjectContext.GetAfterXMatterFileLocations()); // AlwaysSaveable is fine here, as we checked above that it's not a TC. var templateBookInfo = new BookInfo(Path.GetDirectoryName(bookPath), true, new AlwaysEditSaveContext()); var templateBook = new Book.Book(templateBookInfo, new BookStorage(templateBookInfo.FolderPath, locator, new BookRenamedEvent(), collectionSettings), null, collectionSettings, null, null, new BookRefreshEvent(), new BookSavedEvent(), new NoEditSaveContext()); var pageDictionary = templateBook.GetTemplatePagesIdDictionary(); IPage page = null; if (!pageDictionary.TryGetValue(pageGuid, out page)) { MessageBox.Show("Could not find template page " + pageGuid); return; } int i = 0; foreach (var bookInfo in collection.GetBookInfos()) { i++; try { var book = new Book.Book(bookInfo, new BookStorage(bookInfo.FolderPath, locator, new BookRenamedEvent(), collectionSettings), null, collectionSettings, null, null, new BookRefreshEvent(), new BookSavedEvent()); //progress.WriteMessage("Processing " + book.TitleBestForUserDisplay + " " + i + "/" + collection.GetBookInfos().Count()); progress.ProgressIndicator.PercentCompleted = i * 100 / collection.GetBookInfos().Count(); book.ChangeLayoutForAllContentPages(page); } catch (Exception ex) { Debug.WriteLine(ex.Message); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); problems.AppendLine(Path.GetFileName(bookInfo.FolderPath)); } } if (problems.Length == 0) { MessageBox.Show("All books converted successfully"); } else { MessageBox.Show("Bloom had problems converting the following books; please check them:\n" + problems); } }