Exemplo n.º 1
0
 /// <summary>
 /// Migrates old dictionary and reversal configurations if there are not already new dictionary and reversal configurations.
 /// </summary>
 public void MigrateOldConfigurationsIfNeeded()
 {
     using (m_logger = new SimpleLogger())
     {
         try
         {
             var versionProvider = new VersionInfoProvider(Assembly.GetExecutingAssembly(), true);
             // Further migration changes (especially Label changes) may need changes in multiple migrators:
             foreach (var migrator in m_migrators)
             {
                 migrator.MigrateIfNeeded(m_logger, m_propertyTable, versionProvider.ApplicationVersion);
             }
             CreateProjectCustomCssIfNeeded(m_propertyTable);
         }
         finally
         {
             if (m_logger.HasContent)
             {
                 var configurationDir = DictionaryConfigurationListener.GetProjectConfigurationDirectory(m_propertyTable,
                                                                                                         DictionaryConfigurationListener.DictionaryConfigurationDirectoryName);
                 Directory.CreateDirectory(configurationDir);
                 File.AppendAllText(Path.Combine(configurationDir, "ConfigMigrationLog.txt"), m_logger.Content);
             }
         }
     }
     m_logger = null;
 }
Exemplo n.º 2
0
        /// <summary>Create custom CSS file in the project's folder</summary>
        private static void CreateProjectCustomCssIfNeeded(PropertyTable propertyTable)
        {
            var innerDirectories = new [] { "Dictionary", "ReversalIndex" };

            foreach (var innerDir in innerDirectories)
            {
                var configDir = DictionaryConfigurationListener.GetProjectConfigurationDirectory(propertyTable, innerDir);
                Directory.CreateDirectory(configDir);
                var customCssPath = Path.Combine(configDir, string.Format("Project{0}Overrides.css", innerDir == "ReversalIndex" ? "Reversal" : innerDir));
                if (!File.Exists(customCssPath))
                {
                    File.WriteAllText(customCssPath, "/* This file can be used to add custom css rules that will be applied to the xhtml export */");
                }
            }
        }
Exemplo n.º 3
0
        public void GetProjectConfigurationDirectory_ReportsCorrectlyForDictionaryAndReversal()
        {
            {
                string projectConfigDir;

                m_propertyTable.SetProperty("currentContentControl", "lexiconEdit", true);
                projectConfigDir = Path.Combine(LcmFileHelper.GetConfigSettingsDir(Cache.ProjectId.ProjectFolder), "Dictionary");
                Assert.That(DictionaryConfigurationListener.GetProjectConfigurationDirectory(m_propertyTable), Is.EqualTo(projectConfigDir), "did not return expected directory");

                m_propertyTable.SetProperty("currentContentControl", "reversalToolEditComplete", true);
                projectConfigDir = Path.Combine(LcmFileHelper.GetConfigSettingsDir(Cache.ProjectId.ProjectFolder), "ReversalIndex");
                Assert.That(DictionaryConfigurationListener.GetProjectConfigurationDirectory(m_propertyTable), Is.EqualTo(projectConfigDir), "did not return expected directory");

                m_propertyTable.SetProperty("currentContentControl", "somethingElse", true);
                Assert.IsNull(DictionaryConfigurationListener.GetProjectConfigurationDirectory(m_propertyTable), "Other areas should cause null return");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a DictionaryConfigurationModel with one Main and one of each neeeded Minor Entry nodes, all with enabled HeadWord children
        /// </summary>
        internal static DictionaryConfigurationModel CreateInterestingConfigurationModel(LcmCache cache, PropertyTable propertyTable        = null,
                                                                                         DictionaryConfigurationModel.ConfigType configType = DictionaryConfigurationModel.ConfigType.Root)
        {
            var mainHeadwordNode = new ConfigurableDictionaryNode
            {
                FieldDescription      = "HeadWord",
                CSSClassNameOverride  = "entry",
                DictionaryNodeOptions = GetWsOptionsForLanguages(new[] { "fr" }),
                Before = "MainEntry: ",
            };
            var subEntryNode = new ConfigurableDictionaryNode
            {
                Children = new List <ConfigurableDictionaryNode> {
                    mainHeadwordNode
                },
                FieldDescription = "Subentries"
            };
            var mainEntryNode = new ConfigurableDictionaryNode
            {
                Children = new List <ConfigurableDictionaryNode> {
                    mainHeadwordNode
                },
                FieldDescription = "LexEntry"
            };

            if (configType == DictionaryConfigurationModel.ConfigType.Hybrid || configType == DictionaryConfigurationModel.ConfigType.Root)
            {
                mainEntryNode.Children.Add(subEntryNode);
            }
            if (configType == DictionaryConfigurationModel.ConfigType.Hybrid || configType == DictionaryConfigurationModel.ConfigType.Lexeme)
            {
                mainEntryNode.DictionaryNodeOptions = GetFullyEnabledListOptions(cache, DictionaryNodeListOptions.ListIds.Complex);
            }

            CssGeneratorTests.PopulateFieldsForTesting(mainEntryNode);

            var minorEntryNode = mainEntryNode.DeepCloneUnderSameParent();

            minorEntryNode.CSSClassNameOverride = "minorentry";
            minorEntryNode.Before = "MinorEntry: ";
            minorEntryNode.DictionaryNodeOptions = GetFullyEnabledListOptions(cache, DictionaryNodeListOptions.ListIds.Complex);

            var minorSecondNode = minorEntryNode.DeepCloneUnderSameParent();

            minorSecondNode.Before = "HalfStep: ";
            minorSecondNode.DictionaryNodeOptions = GetFullyEnabledListOptions(cache, DictionaryNodeListOptions.ListIds.Variant);

            var model = new DictionaryConfigurationModel
            {
                AllPublications = true,
                Parts           = new List <ConfigurableDictionaryNode> {
                    mainEntryNode, minorEntryNode, minorSecondNode
                },
                FilePath = propertyTable == null ? null : Path.Combine(DictionaryConfigurationListener.GetProjectConfigurationDirectory(propertyTable),
                                                                       "filename" + DictionaryConfigurationModel.FileExtension),
                IsRootBased = configType == DictionaryConfigurationModel.ConfigType.Root
            };

            if (configType != DictionaryConfigurationModel.ConfigType.Root)
            {
                model.Parts.Remove(minorEntryNode);
            }

            return(model);
        }